/* Shared calm theme. Modules use these tokens so new screens stay consistent. */
:root {
  --ink: #263b3e;
  --muted: #5f7373;
  --line: #dfe7e3;
  --surface: #ffffff;
  --canvas: #f3f6f3;
  --sidebar: #f8faf7;
  --accent: #356c62;
  --accent-hover: #2b594f;
  --accent-soft: #e7f1ec;
  --blue: #4c6c8a;
  --blue-soft: #edf2f7;
  --success: #39694f;
  --success-soft: #eaf3ed;
  --warning: #826329;
  --warning-soft: #fbf4e5;
  --danger: #a0443e;
  --danger-soft: #faeeeb;
  --red: var(--accent);
  --red-dark: var(--accent-hover);
  --radius: 14px;
  --shadow: 0 8px 30px #263b3e10;
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.45;
  color-scheme: light;
}

body { color: var(--ink); }
button { transition: background .15s, border-color .15s, box-shadow .15s; }
button:disabled { opacity: .55; }
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
input::placeholder, textarea::placeholder { color: #748587; opacity: 1; }

/* A light navigation rail keeps the workspace visually open. */
.sidebar {
  width: 236px;
  padding: 26px 16px 18px;
  background: var(--sidebar);
  color: var(--ink);
  border-right: 1px solid var(--line);
}
.app-shell { margin-left: 236px; }
.brand img { width: 158px; border-radius: 7px; }
.brand > span { color: #536e66; font-size: 11px; letter-spacing: 2px; margin-top: 10px; }
.workspace-label { color: var(--muted); font-size: 10px; margin: 15px 0 25px; letter-spacing: 1.6px; }
.nav-section { color: var(--muted); letter-spacing: .2px; font-size: 11px; margin: 20px 0 8px; }
.nav-item { color: #4f6465; border-radius: 9px; min-height: 46px; padding: 11px 10px; gap: 9px; font-size: 13px; }
.nav-item:hover { background: #edf2ed; color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-hover); box-shadow: inset 3px 0 0 var(--accent); }
.nav-count, .nav-item.active .nav-count { background: #d9e7df; color: #365d50; font-weight: 600; }
.nav-count.red { color: var(--warning); background: #f4e9ce; }
.nav-divider { background: var(--line); margin: 22px 12px 16px; }
.future-nav { color: var(--muted); font-size: 12px; }
.future-nav > summary { cursor: pointer; padding: 11px 12px; border-radius: 8px; }
.future-nav > summary:hover { background: #edf2ed; }
.future-nav[open] > summary { margin-bottom: 5px; }
.nav-item.future { color: var(--muted); min-height: 42px; font-size: 13px; }
.future .planned { border-color: var(--line); background: #f0f4ef; color: #5f746d; }
.sidebar-bottom { border-top-color: var(--line); padding: 18px 10px 0; margin-top: auto; }
.sidebar-bottom strong { color: #47625a; }
.sidebar-bottom div > span { color: var(--muted); }
.local-mark { color: var(--accent); background: var(--accent-soft); }

/* Page hierarchy and primary actions. */
.topbar { height: 70px; padding: 0 32px; background: #fcfdfb; }
.topbar-right { gap: 13px; }
.fy-label { color: var(--muted); background: #f0f4ef; padding: 5px 9px; border-radius: 6px; }
.crumb-separator { color: #a2b0ab; }
.company-avatar { color: var(--accent); background: var(--accent-soft); border-color: #d5e4db; }
#main { padding: 30px 32px 22px; }
.page-heading { margin-bottom: 24px; }
.page-heading h1 { font-size: 28px; font-weight: 650; letter-spacing: -.6px; }
.eyebrow { color: #5d786d; font-size: 10px; letter-spacing: 1.4px; }
.page-heading p { color: var(--muted); max-width: 580px; line-height: 1.6; }
.button { min-height: 44px; border-radius: 9px; padding: 10px 17px; }
.primary { background: var(--accent); box-shadow: 0 2px 5px #356c6212; }
.primary:hover { background: var(--accent-hover); }
.secondary { color: #4c6460; background: var(--surface); border-color: #d6e0da; }
.secondary:hover { background: #edf3ef; border-color: #b5cdc0; }
.icon-button { color: #5b726b; background: var(--surface); border-radius: 8px; }
.icon-button:hover { background: var(--accent-soft); }
.text-button { color: var(--accent-hover); border-radius: 6px; }
.text-button:hover { background: var(--accent-soft); }
.stats-grid { gap: 14px; margin-bottom: 24px; }
.stat-card { padding: 17px 19px; border-radius: 12px; box-shadow: 0 2px 8px #263b3e03; }
.stat-card:hover { background: #fcfdfb; border-color: #aac6b6; box-shadow: 0 4px 16px #263b3e08; }
.stat-label { color: #526b66; font-size: 13px; }
.stat-value { font-size: 30px; margin-top: 7px; }
.stat-note { color: var(--muted); line-height: 1.5; margin-top: 6px; }
.stat-note b { color: var(--warning); }
.stat-icon.red { color: var(--accent); background: var(--accent-soft); }
.stat-icon.blue { color: var(--blue); background: var(--blue-soft); }
.stat-icon.green { color: var(--success); background: var(--success-soft); }
.stat-icon.orange { color: var(--warning); background: var(--warning-soft); }

/* Register tools remain directly above their columns. */
.register-panel { box-shadow: 0 3px 16px #263b3e04; }
.panel-heading { padding: 21px 24px 17px; }
.panel-caption { color: var(--muted); font-size: 13px; line-height: 1.5; }
.record-pill { background: #f0f5f1; color: #516c5d; border-color: #e0e9e2; }
.scope-tabs { gap: 8px; padding: 0 24px 13px; }
.scope-tab { padding: 8px 12px; border: 1px solid transparent; border-radius: 8px; color: #5c716b; font-size: 13px; }
.scope-tab:hover { background: #f2f6f2; }
.scope-tab.active { color: var(--accent-hover); border-color: #cbded2; background: var(--accent-soft); }
.scope-tab .tab-count { color: #526b60; background: #edf2ee; }
.scope-tab.active .tab-count { color: var(--accent-hover); background: #d4e5da; }
.filter-toolbar { padding: 16px 24px; gap: 12px; }
.filter-hint { color: var(--muted); font-size: 11px; }
.search-box { min-height: 44px; border-color: #d5e1d9; border-radius: 9px; color: var(--muted); background: #fcfdfb; }
.search-box input { font-size: 14px; padding: 11px 0; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px #356c6212; }
.search-box kbd { color: #61766a; background: #f0f4ef; border-color: var(--line); }
#table-wrap { max-height: 65vh; scrollbar-color: #c4d4cb #f2f6f3; scrollbar-width: thin; }
#register-table thead { background: #f2f6f3; }
#register-table th { color: #4f6960; font-size: 12px; text-transform: none; letter-spacing: 0; padding: 13px 14px 12px; }
#register-table td { padding: 15px 14px; font-size: 13px; color: #516766; border-bottom-color: #e8eeea; }
#register-table th:first-child, #register-table td:first-child { padding-left: 22px; }
#register-table tbody tr:nth-child(even) td { background: #fafcfb; }
#register-table tbody tr:hover td, #register-table tbody tr:focus-visible td { background: #edf4ef; }
#register-table tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#register-table th:first-child, #register-table td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; box-shadow: 1px 0 0 var(--line); }
#register-table th:first-child { background: #f2f6f3; z-index: 3; }
.client-cell { min-width: 200px; max-width: 255px; }
.client-name { color: var(--ink); font-size: 14px; font-weight: 600; }
.secondary-line { color: var(--muted); }
.enq-id { color: #456762; }
.column-filters { margin-top: 9px; gap: 5px; min-width: 118px; }
.column-filters input, .column-filters select { min-width: 118px; min-height: 32px; border-radius: 6px; border-color: #d3dfd6; color: #4f6762; }
.column-filters input::placeholder { color: #74857e; }
.column-filters input:focus, .column-filters select:focus { border-color: var(--accent); outline: 2px solid #356c621c; }
.column-filters input[type=date] { color: #526c63; }
.column-date { color: var(--muted); }
.column-date input { min-width: 118px; }
.project-cell { min-width: 165px; max-width: 240px; }
.requirement-cell { min-width: 125px; }
.owner-cell { min-width: 126px; }
.avatar { color: #4f6c63; background: #e7efea; }
.badge { border-radius: 6px; color: #5f746f; background: #eff3f0; }
.badge.open { color: var(--success); background: var(--success-soft); }
.badge.received { color: var(--blue); background: var(--blue-soft); }
.badge.hold { color: var(--warning); background: var(--warning-soft); }
.badge.lost, .badge.canceled, .badge.wrong { color: var(--danger); background: var(--danger-soft); }
.badge.unspecified { color: #657570; background: #eef2ef; }
.priority-inline { color: var(--muted); }
.priority-dot.high { background: #b27358; }
.priority-dot.med { background: #ac945b; }
.priority-dot.low { background: #8aab97; }
.date-cell.overdue { color: #936046; }
.row-open { color: var(--accent); border-radius: 7px; min-width: 32px; min-height: 32px; }
.row-open:hover { background: #dcebe2; }
.table-footer { background: #fcfdfb; color: var(--muted); }
.rows-label select { color: var(--ink); border-color: var(--line); border-radius: 6px; }
.workspace-footer { color: var(--muted); }
.empty-state p, .loading-row { color: var(--muted); }
.empty-state strong { color: #4d6960; }
.filter-count { color: var(--accent-hover); background: var(--accent-soft); }

/* Continuous forms use calm sections and clear, comfortably sized fields. */
dialog { border-color: var(--line); background: var(--surface); box-shadow: 0 16px 80px #263b3e29; }
dialog::backdrop { background: #253d3a54; backdrop-filter: blur(2px); }
.editor-dialog { width: min(900px, 95vw); border-radius: 18px 0 0 18px; }
.dialog-header { padding: 24px 28px 20px; background: #fcfdfb; }
.dialog-header h2 { color: var(--ink); }
.dialog-header .icon-button { background: #eef3ef; }
.editor-body { background: var(--canvas); padding: 24px 28px 28px; }
.continuous-form-note { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.form-section { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 21px; margin-bottom: 20px; }
.form-section-heading { color: #3d5e53; font-size: 15px; margin-bottom: 20px; }
.section-number { color: var(--accent); background: var(--accent-soft); padding: 5px 7px; border-radius: 6px; }
.form-grid { gap: 18px 20px; }
.form-field { color: #4e6660; font-size: 13px; gap: 8px; }
.form-field input, .form-field select, .form-field textarea { min-height: 44px; border-radius: 8px; color: var(--ink); border-color: #d3dfd7; padding: 11px 12px; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--accent); outline: 3px solid #356c6214; }
.form-field input:read-only { color: #61776b; background: #f0f5f1; }
.required, .field-error { color: var(--danger); }
.field-help { color: var(--muted); line-height: 1.55; font-size: 12px; }
.form-alert { color: var(--danger); background: var(--danger-soft); border-color: #ecd5ce; }
.form-field.invalid input, .form-field.invalid select, .form-field.invalid textarea { border-color: #bc7c71; }
.identity-strip { background: #eaf2ed; border-color: #d5e4da; border-radius: 11px; padding: 17px 20px; margin-bottom: 20px; }
.identity-strip small { color: #536f63; letter-spacing: .4px; }
.identity-strip strong { color: #315b4f; font-size: 15px; }
.identity-strip .auto-tag { color: #456b5b; background: #d8e8de; }
.editor-pane + .editor-pane { border-top: 0; padding-top: 0; margin-top: 0; }
.dialog-footer { background: #fcfdfb; padding: 17px 28px; }
.dialog-footer > span { color: var(--muted); font-size: 12px; }
.master-form-help { padding: 0 5px; margin: -7px 0 22px; }
.suggestions { border-color: var(--line); border-radius: 9px; top: 80px; }
.suggestion { color: var(--ink); border-bottom-color: var(--line); background: var(--surface); }
.suggestion small { color: var(--muted); }
.suggestion:hover, .suggestion:focus { background: var(--accent-soft); }
.suggestions .suggestion[role=option]:focus { outline-color: var(--accent); }
.customer-selected { color: var(--success); background: var(--success-soft); border-color: #cfe0d4; }
.customer-selected button { color: var(--accent); }
.quote-summary { color: #5d776c; background: var(--accent-soft); }
.quote-summary strong { color: var(--accent-hover); }
.import-warning { color: var(--warning); background: var(--warning-soft); border-color: #e9dfc7; }
.activity-card { background: var(--surface); }
.activity-card header, .activity-card small { color: var(--muted); }
.source-details, .import-flags, .source-table td:first-child { color: var(--muted); }
.source-details summary, .history-section > summary { color: var(--accent-hover); }
.detail-field { border-bottom-color: var(--line); }
.detail-field small { color: var(--muted); }
.toast { color: #36594a; border-color: #cfdfd5; border-left-color: var(--accent); }
.toast.error { color: var(--danger); border-left-color: var(--danger); }
.report-card { background: var(--surface); }
.report-card p, .bar-row, .bar-number { color: var(--muted); }
.bar-track { background: #edf2ee; }

/* Download the same filtered selection in either file format. */
.register-downloads { display:flex; justify-content:space-between; align-items:center; gap:18px; padding:12px 24px; border-top:1px solid var(--line); background:#f7faf7; }
.register-downloads strong { display:block; color:#49695c; font-size:12px; font-weight:600; }
.register-downloads #download-status { display:block; color:var(--muted); font-size:11px; line-height:1.5; margin-top:3px; }
.download-actions { display:flex; gap:8px; flex-shrink:0; }
.download-link { min-height:38px; padding:8px 12px; font-size:12px; }
.download-link[aria-disabled=true] { opacity:.55; pointer-events:none; cursor:wait; }

@media (min-width: 1600px) {
  #main { padding: 34px 42px 24px; }
  .topbar { padding: 0 42px; }
}
@media (max-width: 1250px) and (min-width: 961px) {
  .sidebar { width: 218px; padding-left: 14px; padding-right: 14px; }
  .app-shell { margin-left: 218px; }
  #main { padding: 26px 24px 20px; }
  .topbar { padding: 0 24px; }
}
@media (max-width: 960px) {
  .sidebar { width: 236px; }
  .app-shell { margin-left: 0; }
  .topbar { height: 66px; }
  #main { padding: 26px 24px 20px; }
  .filter-hint { flex: 1; }
}
@media (max-width: 650px) {
  #main { padding: 22px 16px 18px; }
  .topbar { padding: 0 16px; }
  .topbar-right { gap: 7px; }
  .fy-label { background: transparent; padding: 0; }
  .page-heading h1 { font-size: 25px; }
  .heading-actions { justify-content: stretch; }
  .stats-grid { gap: 10px; margin-bottom: 20px; }
  .stat-card { padding: 14px; }
  .stat-label { font-size: 12px; }
  .stat-value { font-size: 27px; }
  .stat-note { font-size: 11px; }
  .panel-heading { padding: 18px 16px 15px; }
  .panel-caption { max-width: none; font-size: 12px; }
  .scope-tabs { padding: 0 16px 11px; gap: 5px; }
  .scope-tab { padding: 8px 10px; font-size: 12px; }
  .filter-toolbar { padding: 14px 16px; gap: 8px; }
  .register-downloads { padding:12px 16px; flex-direction:column; align-items:stretch; gap:10px; }
  .download-actions { width:100%; }
  .download-link { flex:1; min-height:44px; }
  .filter-hint { font-size: 10px; }
  .search-box kbd { display: none; }
  #register-table td:first-child, #register-table th:first-child { padding-left: 16px; }
  .client-cell { min-width: 180px; max-width: 210px; }
  .column-filters input, .column-filters select { font-size: 13px; }
  .editor-dialog { width: 100vw; max-width: 100vw; border-radius: 0; }
  .dialog-header { padding: 20px; }
  .editor-body { padding: 18px 16px; }
  .form-section { padding: 18px 16px; }
  .identity-strip { padding: 14px; gap: 12px; }
  .identity-strip strong { font-size: 12px; }
  .dialog-footer { padding: 14px 16px; }
  .dialog-footer > span { display: none; }
  .dialog-footer > div { width: 100%; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
  .dialog-footer .button { min-height: 44px; padding: 10px 12px; }
}

/* Mandatory fields: a star on the label; a missing one is outlined in red until it is filled. */
.required-star { color: var(--danger, #b4473a); font-weight: 600; }
.is-missing input, .is-missing select, .is-missing textarea, .is-missing button,
input.is-missing, select.is-missing, textarea.is-missing, button.is-missing,
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"], button[aria-invalid="true"] { border-color: #c0392b !important; box-shadow: 0 0 0 2px #f4cbc4 !important; }
.is-missing > label, .is-missing > span:first-child { color: #a5372a; }
.missing-note { display: block; margin-top: 2px; color: #a5372a; font-size: 11px; line-height: 1.3; }
.is-missing .ow-unit-select { border-color: #b0b6c0 !important; box-shadow: none !important; }
