/* Shared sizes: new pages should reuse these tokens and existing action groups. */
:root {
  --ui-page-title-size:24px;
  --ui-body-size:12px;
  --ui-label-size:11px;
  --ui-help-size:11px;
  --ui-control-size:13px;
  --ui-compact-control-size:13px;
  --ui-field-header-height:28px;
  --ui-field-header-gap:4px;
  --ui-field-gap:8px;
  --ui-section-nav-size:12px;
  --ui-preview-title-size:20px;
  --ui-preview-label-size:10px;
  --ui-panel-title-size:14px;
  --ui-section-icon-size:16px;
  --ui-section-nav-number-size:10px;
  --ui-action-size:11px;
  --ui-report-dock-label-size:7px;
  --ui-report-dock-icon-size:22px;
}

/* Shared report action layout: Kanyon AVM's five-action review bar. */
body #view-report :is(#reportActionDock,#pendingReportActionDock,#adminWithdrawalActionDock,#adminReviewActionDock) {
  width:min(calc(var(--report-dock-count,5) * 132px + 20px),calc(100vw - 30px))!important;
  grid-template-columns:repeat(var(--report-dock-count,5),minmax(0,1fr))!important;
  gap:5px!important;
  padding:9px 12px 8px!important;
  align-items:stretch;
}
body #view-report #reportActionDock:not(.draft-edit-only) .report-dock-group,
body #view-report #reportActionDock.returned-preview-edit .report-dock-group,
body #view-report #reportActionDock .report-dock-group-buttons { display:contents!important; }
body.branch-manager-view #view-report #reportActionDock .report-dock-manager { display:none!important; }
body #view-report #reportActionDock .report-dock-group-label { display:none!important; }
body #view-report .report-action-dock .report-dock-button {
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  width:auto!important; min-width:0; height:auto!important; min-height:62px!important;
  margin:0!important; padding:5px 3px!important; gap:5px!important; border-radius:14px;
  font:700 var(--ui-report-dock-label-size)/1.12 var(--sans)!important;
}
body #view-report .report-action-dock .report-dock-button[hidden] { display:none!important; }
body #view-report .report-action-dock .report-dock-button img {
  display:block; flex:none; width:var(--ui-report-dock-icon-size)!important; height:var(--ui-report-dock-icon-size)!important;
}
body #view-report .report-action-dock .report-dock-button span {
  display:flex!important; flex-direction:column; justify-content:center; min-height:2.24em;
  font:inherit!important; line-height:1.12!important; text-align:center; white-space:pre-line; overflow-wrap:anywhere;
}
@media(max-width:700px) {
  #view-report { --ui-report-dock-icon-size:20px; }
  body #view-report :is(#reportActionDock,#pendingReportActionDock,#adminWithdrawalActionDock,#adminReviewActionDock) {
    width:auto!important; gap:1px!important; padding:8px 5px!important;
  }
  body #view-report .report-action-dock .report-dock-button { min-height:58px!important; padding-inline:1px!important; }
}

/* Approved PDFs share a heading; the individual action labels stay concise. */
body #view-report #reportActionDock.report-output-grouped {
  grid-template-columns:minmax(0,3fr) minmax(0,1fr) minmax(0,3fr)!important;
}
body #view-report #reportActionDock.report-output-grouped.without-edit { grid-template-columns:repeat(2,minmax(0,1fr))!important; }
body #view-report #reportActionDock.report-output-grouped .report-dock-group {
  display:grid!important; grid-template-rows:auto 1fr; gap:4px; min-width:0; align-items:end;
}
body #view-report #reportActionDock.report-output-grouped .report-dock-group-label {
  display:block!important; grid-row:1; font:700 8px/1.15 var(--sans); text-align:center; white-space:normal;
}
body #view-report #reportActionDock.report-output-grouped .report-dock-group-buttons {
  display:grid!important; grid-row:2; grid-template-columns:repeat(3,minmax(0,1fr));
  width:100%; min-width:0; padding:0; gap:5px; border:0; border-radius:0; background:transparent; box-shadow:none;
}
body #view-report #reportActionDock.report-output-grouped>.report-edit-button { align-self:end!important; }
body.branch-manager-view #view-report #reportActionDock.report-output-grouped .report-dock-manager { display:none!important; }
body.branch-manager-view #view-report #reportActionDock.report-output-grouped { grid-template-columns:minmax(0,1fr)!important; }
body.branch-manager-view #view-report #reportActionDock.report-output-grouped.has-branch-action .report-dock-action .report-dock-group-buttons { grid-template-columns:repeat(4,minmax(0,1fr)); }
@media(max-width:700px) {
  body #view-report #reportActionDock.report-output-grouped .report-dock-group-buttons { gap:1px; }
  body #view-report #reportActionDock.report-output-grouped .report-dock-group-label { font-size:7px; }
}

/* Audit deletion lives in the same header position for forms and reports. */
body :is(#view-form .form-header,#view-report .report-head):has(>.audit-header-menu-slot:not([hidden])) {
  display:grid!important;
  grid-template-columns:minmax(0,1fr) 36px 36px!important;
  gap:12px;
  align-items:center;
  position:relative;
  z-index:40;
  overflow:visible;
}
body :is(#view-form .form-header,#view-report .report-head)>.audit-header-menu-slot {
  display:block;
  grid-column:2!important;
  grid-row:1;
  min-width:0;
  position:relative;
}
body :is(#view-form .form-header,#view-report .report-head)>.audit-header-menu-slot[hidden] { display:none!important; }
body :is(#view-form .form-header,#view-report .report-head):has(>.audit-header-menu-slot:not([hidden]))>.ui-back-button { grid-column:3!important; }
.audit-header-menu { position:relative; width:36px; font-family:var(--sans); }
.audit-header-menu>summary {
  list-style:none;
}
.audit-header-menu>summary::-webkit-details-marker { display:none; }
.audit-header-menu>summary svg { width:22px; height:22px; }
.audit-header-menu button:focus-visible { outline:2px solid #315e9d; outline-offset:3px; }
.audit-header-menu-panel {
  position:absolute; top:calc(100% + 8px); right:0; width:252px;
  max-width:calc(100vw - 40px); box-sizing:border-box; padding:6px;
  border:1px solid #d4dfe7; border-radius:14px; background:#fff;
  box-shadow:0 12px 32px #213b4e26; z-index:20;
}
.audit-header-menu-panel>button {
  display:flex; align-items:center; gap:10px; width:100%; min-height:44px;
  border:0; border-radius:9px; padding:10px; background:transparent; color:#213b4e;
  font:600 var(--ui-compact-control-size)/1.4 var(--sans); text-align:left; cursor:pointer;
}
.audit-header-menu-panel>button:hover { background:#eef3f7; }
.audit-header-menu-panel>.audit-trash-button { color:#b4232d; border-top:1px solid #e3e9ee; border-top-left-radius:0; border-top-right-radius:0; margin-top:4px; }
.audit-header-menu-panel>.audit-trash-button:hover { background:#fff0f0; }
.audit-header-menu-panel>button svg { width:18px; height:18px; flex-shrink:0; }
@media(max-width:700px) {
  body :is(#view-form .form-header,#view-report .report-head):has(>.audit-header-menu-slot:not([hidden])) { grid-template-columns:minmax(0,1fr) 36px 36px!important; gap:8px; }
  .audit-header-menu { width:32px; }
  .audit-header-menu-panel { right:-44px; }
}
@media print { .audit-header-menu-slot { display:none!important; } }
.audit-info-dialog {
  box-sizing:border-box; width:min(560px,calc(100vw - 28px)); max-width:calc(100vw - 28px);
  max-height:calc(100dvh - 32px); margin:auto; padding:0; border:1px solid #d4dfe7;
  border-radius:22px; background:#f9fbfc; color:#213b4e; font-family:var(--sans);
  box-shadow:0 24px 80px #172f4d33; overflow:auto; overscroll-behavior:contain;
  scrollbar-width:none; -ms-overflow-style:none;
}
.audit-info-dialog::-webkit-scrollbar { display:none; width:0; height:0; }
.audit-info-dialog::backdrop { background:#18284966; }
body:has(.audit-info-dialog[open]) { overflow:hidden!important; }
.audit-info-dialog>header { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:18px 20px; border-bottom:1px solid #dce5ec; position:sticky; top:0; z-index:1; background:#f9fbfc; }
.audit-info-dialog h2 { margin:0; font-size:var(--ui-preview-title-size); line-height:1.3; }
.audit-info-close { display:flex; align-items:center; justify-content:center; flex:0 0 36px; width:36px; height:36px; border:1px solid #cedae2; border-radius:50%; background:#fff; color:#344d5d; cursor:pointer; }
.audit-info-close svg { width:18px; height:18px; }
.audit-info-close:focus-visible { outline:2px solid #315e9d; outline-offset:3px; }
.audit-info-content { padding:4px 20px 20px; }
.audit-info-content section { margin-top:18px; min-width:0; }
.audit-info-content h3 { margin:0 0 10px; font-size:var(--ui-panel-title-size); line-height:1.4; }
.audit-info-content dl { margin:0; padding:0 14px; border:1px solid #dce5ec; border-radius:14px; background:#fff; }
.audit-info-content dl>div { display:grid; grid-template-columns:minmax(0, .9fr) minmax(0,1.1fr); gap:14px; padding:11px 0; }
.audit-info-content dl>div+div { border-top:1px solid #edf1f4; }
.audit-info-content dt { color:#637684; font-size:var(--ui-label-size); line-height:1.5; overflow-wrap:anywhere; }
.audit-info-content dd { margin:0; min-width:0; font-size:var(--ui-body-size); line-height:1.5; white-space:pre-wrap; overflow-wrap:anywhere; }
@media(max-width:400px) {
  .audit-info-dialog>header { padding:14px; }
  .audit-info-content { padding:0 14px 14px; }
  .audit-info-content dl>div { grid-template-columns:minmax(0,1fr); gap:4px; }
}
@media print { .audit-info-dialog { display:none!important; } }
:is(#view-invoicing,#view-questionnaire,#view-settings,#view-settings-hub,#view-analytics,#view-actions,#view-action-report,#view-planning) :is(.module-header h2,.settings-page-header h1,.invoice-heading h1) {
  font-size:var(--ui-page-title-size); line-height:1.3; letter-spacing:-.025em; overflow-wrap:anywhere;
}
#view-invoicing { font-size:var(--ui-body-size); }
.invoice-controls label { font-size:var(--ui-label-size); }
.invoice-controls :is(input,select) { font-size:var(--ui-control-size); }
.invoice-note { font-size:var(--ui-help-size); }
.invoice-summary,.invoice-table { font-size:var(--ui-body-size); }
.invoice-table th { font-size:var(--ui-label-size); }
:is(#view-analytics,#view-invoicing) .analytics-report-actions button { font-size:var(--ui-action-size); }

/* Constrain native date/month controls and their parents, including iOS. */
body.new-design-ui .view :is(input,select,textarea) { box-sizing:border-box; min-width:0; max-width:100%; }
.view :is(input[type="month"],input[type="date"],input[type="time"]) { min-inline-size:0; max-inline-size:100%; }
.view :is(input[type="month"],input[type="date"],input[type="time"])::-webkit-date-and-time-value { min-width:0; text-align:left; }
#view-questionnaire :is(.qm-fieldset,.qm-scope,.qm-inline-editor,.qm-inline-editor label,.qm-section,.qm-section-body) { box-sizing:border-box; min-width:0; max-width:100%; }
#view-questionnaire .qm-scope { width:100%; }
#view-questionnaire .qm-scope input[type="month"] { display:block; width:100%; max-width:min(240px,100%); min-inline-size:0; -webkit-appearance:none; appearance:none; }
#view-questionnaire .qm-scope p { overflow-wrap:anywhere; }
#view-questionnaire .qm-save-bar > p { min-width:0; }
#view-questionnaire .qm-save-actions { min-width:0; }
#view-questionnaire .qm-save-actions .btn { min-width:0; white-space:normal; overflow-wrap:anywhere; }
#view-questionnaire .qm-page-header { display:grid; grid-template-columns:minmax(0,1fr) 44px; }
.settings-destination-icon .invoice-receipt-icon { color:inherit; }
.settings-destination-icon .settings-choice-icon { color:inherit; }
/* Keep the settings title, cards and return control in one centered workspace. */
#view-settings-hub .settings-destination-grid { width:100%; max-width:none; }
@media(min-width:701px) {
  body.new-design-ui.nd-authenticated > #view-settings-hub.view {
    box-sizing:border-box;
    width:calc(100% - 32px)!important;
    max-width:none!important;
    margin:16px auto!important;
    padding:0 0 34px!important;
  }
}
@media(max-width:700px) {
  :root { --ui-page-title-size:22px; --ui-control-size:16px; }
  #view-questionnaire .qm-page-header { grid-template-columns:minmax(0,1fr) 36px; }
}

@media screen {
  /* Clip the existing horizontal overflow without making body a scroll
     container: the header must stick to the document viewport. */
  html:has(body.new-design-ui.nd-authenticated),
  body.new-design-ui.nd-authenticated { overflow-x:clip; }
  html:has(body.new-design-ui.nd-authenticated) {
    scroll-padding-top:calc(var(--app-support-height,0px) + var(--app-topbar-height,86px) + var(--ui-safe-top,env(safe-area-inset-top,0px)) + 20px);
  }
  body.new-design-ui.nd-authenticated > .topbar {
    position:sticky!important;
    top:calc(var(--app-support-height,0px) + var(--ui-safe-top,env(safe-area-inset-top,0px)) + 8px);
    z-index:1400;
    background:#f7f9fa;
    box-shadow:0 3px 12px #3449560d;
    will-change:opacity;
    overflow:visible;
  }
  /* Independent backing below the bar also hides content at its rounded corners. */
  body.new-design-ui.nd-authenticated::before {
    content:"";
    position:fixed;
    top:var(--app-support-height,0px);
    left:0;
    right:0;
    height:calc(env(safe-area-inset-top,0px) + 56px);
    background:linear-gradient(to bottom,#eef2f4 0 calc(100% - 16px),rgba(238,242,244,0) 100%);
    pointer-events:none;
    z-index:899;
  }
  body.nd-view-form #view-form .section-block { scroll-margin-top:12px; }
  #supportBanner { top:env(safe-area-inset-top,0px); }
  /* Installed apps paint behind native chrome; content stays in its safe area. */
  html.standalone-edge-ui {
    --app-safe-top:env(safe-area-inset-top,0px);
    --app-safe-left:env(safe-area-inset-left,0px);
    --app-safe-right:env(safe-area-inset-right,0px);
    --app-standalone-bottom:env(safe-area-inset-bottom,0px);
    --ui-safe-top:var(--app-safe-top);
  }
  html.standalone-edge-ui:has(body.support-window) {
    --ui-safe-top:0px;
  }
  html.standalone-edge-ui body.new-design-ui {
    box-sizing:border-box;
    padding-left:var(--app-safe-left);
    padding-right:var(--app-safe-right);
  }
  html.standalone-edge-ui body.new-design-ui:not(.support-window) {
    padding-top:var(--app-safe-top);
    --ui-safe-top:var(--app-safe-top);
  }
  html.standalone-edge-ui body.new-design-ui #view-login.active {
    min-height:calc(100dvh - var(--app-safe-top) - var(--app-standalone-bottom));
  }
  html.standalone-edge-ui body.support-window {
    --ui-safe-top:0px;
  }
  html.standalone-edge-ui body.support-window #supportBanner {
    top:0;
    padding-top:calc(var(--app-safe-top) + 10px);
  }
  @media(min-width:701px) {
    html.standalone-edge-ui body.new-design-ui .nd-rail {
      left:max(16px,var(--app-safe-left));
    }
    html.standalone-edge-ui body.new-design-ui:not(.support-window) .nd-rail {
      top:calc(var(--app-safe-top) + 16px);
      bottom:calc(var(--app-standalone-bottom) + 16px);
    }
  }
}
#mobileTopBackdrop { display:none; }
/* Tablet uses the same solid backing as the phone. Keep it above page
   controls (including month pickers) and immediately below the top bar. */
@media screen and (min-width:701px) and (max-width:1180px) {
  body.new-design-ui.nd-authenticated::before { content:none; }
  body.new-design-ui.nd-authenticated > #mobileTopBackdrop {
    display:block;
    position:fixed;
    /* iOS bazen sabit katmanları görünen alana göre aşağı kaydırır; ekran dışına uzanan pay üstte boşluk açılmasını önler. */
    top:-200px;
    left:0;
    width:100%;
    height:calc(var(--app-support-height,0px) + var(--ui-safe-top,env(safe-area-inset-top,0px)) + 32px + 200px);
    background-color:#eef2f4;
    pointer-events:none;
    z-index:1399;
  }
  body.new-design-ui.nd-authenticated > #mobileTopBackdrop::after {
    content:"";
    position:absolute;
    top:100%;
    left:0;
    width:100%;
    height:16px;
    background:linear-gradient(to bottom,#eef2f4,rgba(238,242,244,0));
  }
}
@media screen and (max-width:700px) {
  :root { --ui-floating-bar-gap:8px; }
  /* Let WebKit inset native status/gesture areas; paint their opaque backdrop. */
  html:has(body.new-design-ui),
  body.new-design-ui { background-color:#eef2f4; }
  body.new-design-ui.nd-authenticated::before {
    content:none;
  }
  body.new-design-ui.nd-authenticated > .topbar {
    top:calc(var(--app-support-height,0px) + var(--ui-safe-top,env(safe-area-inset-top,0px)) + var(--ui-floating-bar-gap));
  }
  /* A real, solid edge surface lets native WebKit sample an opaque color. */
  body.new-design-ui.nd-authenticated > #mobileTopBackdrop {
    display:block;
    position:fixed;
    top:-200px;
    left:0;
    width:100%;
    height:calc(var(--app-support-height,0px) + var(--ui-safe-top,env(safe-area-inset-top,0px)) + var(--ui-floating-bar-gap) + 24px + 200px);
    background-color:#eef2f4;
    pointer-events:none;
    z-index:1399;
  }
  body.new-design-ui.nd-authenticated > #mobileTopBackdrop::after {
    content:"";
    position:absolute;
    top:100%;
    left:0;
    width:100%;
    height:16px;
    background:linear-gradient(to bottom,#eef2f4,rgba(238,242,244,0));
  }
}
@media screen and (min-width:701px) {
  body.support-window.new-design-ui .nd-rail {
    top:calc(var(--app-support-height,0px) + var(--ui-safe-top,env(safe-area-inset-top,0px)) + 16px);
  }
}
/* Tablet home: keep all action icons on the logo row, search below. */
@media screen and (min-width:701px) and (max-width:1180px) {
  body.nd-view-home.new-design-ui.nd-authenticated > #topbarRow {
    grid-template-columns:minmax(0,1fr) repeat(5,max-content)!important;
  }
  body.nd-view-home.new-design-ui.nd-authenticated > #topbarRow .nd-topbar-brand {
    grid-column:1; grid-row:1; min-width:0;
  }
  body.nd-view-home.new-design-ui.nd-authenticated > #topbarRow #topbarLogo {
    max-width:min(220px,100%); width:auto!important; height:31px!important; object-fit:contain;
  }
  body.nd-view-home.new-design-ui.nd-authenticated > #topbarRow .topbar-actions > :not(.nd-topbar-search) {
    grid-column:auto; grid-row:1;
  }
  body.nd-view-home.new-design-ui.nd-authenticated > #topbarRow #onlinePresenceWrap { grid-column:2!important; }
  body.nd-view-home.new-design-ui.nd-authenticated > #topbarRow #notificationButton { grid-column:3!important; }
  body.nd-view-home.new-design-ui.nd-authenticated > #topbarRow #settingsOpenButton { grid-column:4!important; }
  body.nd-view-home.new-design-ui.nd-authenticated > #topbarRow #topbarUserWrap { grid-column:5!important; }
  body.nd-view-home.new-design-ui.nd-authenticated > #topbarRow #topbarLogoutButton { grid-column:6!important; }
  body.nd-view-home.new-design-ui.nd-authenticated > #topbarRow .nd-topbar-search {
    grid-column:1/-1; grid-row:2; max-width:none; width:100%;
  }
}
@media screen and (max-width:700px) {
  body.new-design-ui.nd-authenticated > .topbar #notificationPopover {
    top:calc(var(--app-support-height,0px) + var(--app-topbar-height,78px) + env(safe-area-inset-top,0px) + 16px)!important;
    max-height:calc(100dvh - var(--app-support-height,0px) - var(--app-topbar-height,78px) - env(safe-area-inset-top,0px) - 32px);
    box-sizing:border-box;
    overflow-y:auto;
  }
}

/* Audit writing fields share the approved compact text size. */
@media(max-width:700px) {
  body.new-design-ui #view-form .qcard textarea { font-size:var(--ui-compact-control-size,13px); }
  body.new-design-ui #view-form :is(#mandatoryCard,#personelCard) :is(input,select,textarea) { font-size:var(--ui-compact-control-size,13px); }
}

#view-form .qcard .qnote { margin-bottom:var(--ui-field-gap); }
#view-form .qcard .obs-item-header { min-height:var(--ui-field-header-height); margin-bottom:var(--ui-field-header-gap); }
#view-form .qcard .obs-item-remove { width:var(--ui-field-header-height); height:var(--ui-field-header-height); }

/* Writing header and desktop section navigation share the page typography. */
#view-settings select,#settingsBranchDialog select,#settingsAccessDialog select,#view-questionnaire select{font-weight:400}
#view-form .form-header { display:grid!important; grid-template-columns:minmax(0,1fr) 44px; align-items:center; gap:16px; }
#view-form .form-header > div { grid-column:1; grid-row:1; min-width:0; display:flex; flex-wrap:wrap; align-items:center; gap:6px 16px; }
#view-form .form-header > .ui-back-button { grid-column:2; grid-row:1; justify-self:end; align-self:center!important; margin:0!important; }
#view-form .form-header h2 { font-size:var(--ui-page-title-size); line-height:1.3; overflow-wrap:anywhere; }
#view-form #formMeta { font-family:inherit; font-size:var(--ui-compact-control-size); line-height:1.5; overflow-wrap:anywhere; margin:0; }
@media(min-width:701px) {
  #view-form .form-header > div { align-items:center; }
  #view-form .nd-audit-steps button { font-size:var(--ui-section-nav-size); font-weight:600; min-height:48px; }
  #view-form .nd-audit-steps button b { font-weight:inherit; }
  #view-form .nd-audit-steps button span { font-family:inherit; font-size:var(--ui-section-nav-number-size); }
}
@media(max-width:700px) {
  #view-form .form-header { grid-template-columns:minmax(0,1fr) 36px; gap:12px; }
  #view-form .form-header h2 { font-size:20px; }
}

/* Matching section icons and compact accordion headings. */
#view-form :is(.nd-step-icon,.nd-panel-icon) { width:var(--ui-section-icon-size); height:var(--ui-section-icon-size); flex:0 0 var(--ui-section-icon-size); fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
#view-form .nd-form-panel > .nd-form-accordion-title { display:flex; align-items:center; gap:8px; font-size:var(--ui-panel-title-size)!important; font-weight:600; line-height:1.35; }
#view-form .nd-form-accordion-title .nd-panel-label { min-width:0; font:inherit; overflow-wrap:anywhere; }
@media(max-width:700px) { #view-form { --ui-panel-title-size:13px; } }

/* One compact header for manager, branch, invoice and KPI PDF previews. */
#view-pdf-preview .module-header { display:grid!important; grid-template-columns:minmax(0,1fr) 44px; align-items:center; gap:12px; padding:14px 16px!important; margin-bottom:14px; border-radius:18px; }
#view-pdf-preview .module-header > div { min-width:0; }
#view-pdf-preview #pdfPreviewTitle { margin:4px 0 0; color:#213b4e; font-family:var(--sans); font-size:var(--ui-preview-title-size); font-weight:600; line-height:1.35; letter-spacing:-.025em; overflow-wrap:anywhere; }
#view-pdf-preview .ui-preview-eyebrow { display:block; color:#7c8f9d; font-size:var(--ui-preview-label-size); font-weight:600; line-height:1.3; letter-spacing:.13em; }
#view-pdf-preview .module-back { align-self:center!important; margin:0!important; }
#view-pdf-preview .pdf-preview-pages { padding:14px; border-radius:18px; }
@media(max-width:700px) {
  #view-pdf-preview { --ui-preview-title-size:18px; }
  #view-pdf-preview .module-header { grid-template-columns:minmax(0,1fr) 36px!important; }
}
