/* Kazakh DMC supplier database. Brand colours come from settings via --brand / --accent. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dde3ea;
  --border-strong: #c9d2dc;
  --text: #1c2733;
  --muted: #5f6b7a;
  --head-bg: #eef3f9;
  --row-alt: #fafbfd;
  --warn-bg: #fff2d6; --warn-fg: #7a4f00;
  --ok-bg: #e3f5ea; --ok-fg: #1d6b3a;
  --info-bg: #e2ecf8; --info-fg: #1e4f8a;
  --restricted-bg: #fde8e8; --restricted-fg: #9b1c1c;
  --internal-bg: #efe9fb; --internal-fg: #5b3a9c;
  --radius: 8px;
  --label-w: 150px;
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; line-height: 1.45; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; }
abbr[title] { text-decoration: none; cursor: help; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; letter-spacing: .02em; }
.sub { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.warn-text { color: var(--warn-fg); }
[hidden] { display: none !important; }

/* top */
.env-banner { background: #fff1c2; color: #5c4300; text-align: center; font-size: 13px; padding: 4px 12px; border-bottom: 1px solid #ecd78a; }
.topbar { background: var(--brand); color: #fff; display: flex; align-items: center; gap: 28px; padding: 0 20px; height: 50px; }
.brand { color: #fff; text-decoration: none; font-size: 19px; font-weight: 700; white-space: nowrap; }
.brand-sep { opacity: .5; margin: 0 10px; font-weight: 300; }
.brand-product { font-weight: 400; font-size: 15px; }
.mainnav a { color: #dbe6f3; text-decoration: none; padding: 14px 4px; border-bottom: 3px solid transparent; }
.mainnav a.active { color: #fff; border-bottom-color: #fff; font-weight: 600; }
.user-chip { margin-left: auto; font-size: 12.5px; color: #c7d5e6; border: 1px solid rgba(255,255,255,.3); padding: 3px 10px; border-radius: 99px; white-space: nowrap; }

/* layout */
.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100vh - 100px); }
.layout.dir-hidden { grid-template-columns: minmax(0, 1fr); }
.layout.dir-hidden .directory { display: none; }
.profile .show-directory { display: none; margin-bottom: 10px; }
.layout.dir-hidden .profile .show-directory { display: inline-flex; }
.directory { background: var(--surface); border-right: 1px solid var(--border); padding: 14px 14px; position: sticky; align-self: start; top: 0; height: calc(100vh - 50px); overflow-y: auto; }
.profile { padding: 16px 24px 28px; min-width: 0; }

/* directory */
.dir-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dir-title { font-size: 17px; }
.icon-btn { border: 1px solid var(--border); background: #fff; border-radius: 6px; width: 28px; height: 28px; cursor: pointer; color: var(--muted); font-size: 15px; line-height: 1; }
.dir-filters input[type=search], .dir-filters select { width: 100%; padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: 6px; font: inherit; background: #fff; }
.dir-filters label { display: block; font-size: 12.5px; color: var(--muted); margin: 7px 0 2px; }
.filter-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; }
.more-filters { margin-top: 6px; font-size: 13px; }
.more-filters summary { cursor: pointer; color: var(--accent); }
.dir-actions { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 6px; }
.dir-count { font-size: 13px; color: var(--muted); }
.dir-list { list-style: none; margin: 0; padding: 0; }
.dir-item { display: block; padding: 7px 9px; border-radius: 6px; text-decoration: none; color: var(--text); border-left: 3px solid transparent; }
.dir-item:hover { background: var(--head-bg); }
.dir-item.selected { background: #dfe9f7; border-left-color: var(--accent); }
.dir-name { display: block; font-weight: 600; font-size: 14.5px; }
.dir-meta { display: block; font-size: 12.5px; color: var(--muted); }
.dir-empty { padding: 10px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13.5px; padding: 6px 13px; border-radius: 6px; border: 1px solid var(--border-strong); background: #fff; color: var(--text); cursor: pointer; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-xs { padding: 2px 8px; font-size: 12.5px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* profile head */
.profile-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.profile-head h1 { font-size: 24px; line-height: 1.2; }
.facts { margin: 4px 0 0; color: var(--text); font-size: 14px; }
.facts span + span::before { content: "·"; color: var(--muted); margin: 0 7px; }
.snapshot { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: 13.5px; }
.snapshot > div { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.snapshot dt { color: var(--muted); }
.snapshot dd { margin: 0; display: flex; gap: 4px; flex-wrap: wrap; align-items: baseline; }
.more-tags { display: inline-block; position: relative; }
.more-tags summary { list-style: none; cursor: pointer; }
.more-tags summary::-webkit-details-marker { display: none; }
.popover { position: absolute; z-index: 5; top: 24px; left: 0; min-width: 260px; margin: 0; padding: 8px 12px; list-style: none; background: #fff; border: 1px solid var(--border-strong); border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.popover li { padding: 2px 0; }
.head-actions { display: flex; gap: 8px; flex-shrink: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 12px 0 14px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; font-size: 14px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2 { font-size: 15px; font-weight: 650; }
.card-head .btn { margin-left: auto; }
.unit { font-size: 13px; color: var(--muted); font-weight: 400; }
.section-title { font-size: 16px; margin: 18px 0 10px; }
.sub-head { font-size: 14px; margin: 14px 0 6px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + .grid-2, .card + .grid-2 { margin-top: 14px; }
.grid-2.align-start { align-items: start; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.legend b { color: var(--text); font-weight: 600; }
.preview-note { background: var(--info-bg); color: var(--info-fg); border-radius: 6px; padding: 7px 12px; font-size: 13.5px; margin-bottom: 12px; }

/* tags & badges */
.tag, .badge, .chip, .status, .applies { display: inline-block; font-size: 12.5px; padding: 1px 8px; border-radius: 99px; white-space: nowrap; background: #edf1f5; color: #344456; }
.tag-more { background: var(--info-bg); color: var(--info-fg); font-weight: 600; }
.tag-restricted, .status-restricted { background: var(--restricted-bg); color: var(--restricted-fg); }
.status-shared { background: var(--ok-bg); color: var(--ok-fg); }
.tag-internal { background: var(--internal-bg); color: var(--internal-fg); }
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); white-space: normal; font-weight: 600; }
.badge-info { background: var(--info-bg); color: var(--info-fg); }
.badge-muted { background: #edf1f5; color: var(--muted); }
.chip { background: var(--info-bg); color: var(--info-fg); }
.chip-weekend { background: #e6f4f1; color: #1d6458; }
.chip-blackout { background: #fbe9e3; color: #92351b; }
.chip-seasonal { background: #f3eedd; color: #6e5714; }
.applies { background: var(--info-bg); color: var(--info-fg); font-weight: 600; }
.applies-both { background: #e6f4f1; color: #1d6458; }
.wa { font-size: 11px; font-weight: 700; color: #1d7a45; background: #e3f5ea; border-radius: 4px; padding: 0 4px; }

/* key/value: labels sit next to values */
.kv { margin: 0; }
.kv > div { display: grid; grid-template-columns: var(--label-w) minmax(0, 1fr); gap: 10px; padding: 5px 0; border-bottom: 1px solid #eef1f5; }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.kv-tight > div { padding: 3px 0; }
.bank { margin-top: 10px; padding-top: 6px; border-top: 1px solid var(--border); }

/* tables */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; }
.data th, .data td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 13.5px; }
.data thead th { background: var(--head-bg); font-size: 13px; font-weight: 600; color: #344456; white-space: nowrap; }
.data tbody th { font-weight: 600; }
.data tbody tr:nth-child(even) { background: var(--row-alt); }
.data tbody tr:last-child th, .data tbody tr:last-child td { border-bottom: 0; }
.data tfoot th, .data tfoot td { border-top: 1px solid var(--border-strong); border-bottom: 0; background: var(--head-bg); }
.data.compact th, .data.compact td { padding: 5px 9px; }
.card > table.data, .policy > table.data, .grid-2 .card > table.data { border: 1px solid var(--border); }
.r { text-align: right !important; }
.num { font-variant-numeric: tabular-nums; }
.blank { color: #a6b0bc; }
.st { white-space: nowrap; }
.st-free, .st-included { color: var(--ok-fg); font-weight: 600; }
.st-not_permitted, .st-not_available { color: #8b3d3d; }
.st-to_confirm { color: var(--warn-fg); font-style: italic; }
a.st-per_child_policy { color: var(--info-fg); }
.row-exception th, .row-exception td { background: #fffaf0 !important; }
.row-muted th, .row-muted td { color: var(--muted); }
.row-detail td { background: #f7f9fc !important; color: var(--muted); font-size: 13px; padding-left: 24px; }
.note-toggle { font: inherit; font-size: 11.5px; font-weight: 600; color: var(--info-fg); background: var(--info-bg); border: 0; border-radius: 4px; padding: 0 5px; margin-left: 4px; cursor: pointer; }
@keyframes flash { from { background: #ffe9a8; } to { background: #fffaf0; } }
tr.flash th, tr.flash td { animation: flash 1.6s ease-out; }
/* keep the room name visible while scrolling wide tables */
.sticky-first tbody th:first-child, .sticky-first thead th:first-child, .sticky-first tfoot th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--border); min-width: 170px; }
.sticky-first thead th:first-child, .sticky-first tfoot th:first-child { background: var(--head-bg); }
.sticky-first tbody tr:nth-child(even) th:first-child { background: var(--row-alt); }
.sticky-first .row-detail td { position: static; }

/* rate tables */
.rate-table { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; }
.rate-table.has-conflict { border-color: #e7c27a; }
.rate-table > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; background: var(--row-alt); border-radius: 6px; }
.rate-table > summary::-webkit-details-marker { display: none; }
.rate-table > summary::before { content: "▸"; color: var(--muted); width: 10px; }
.rate-table[open] > summary::before { content: "▾"; }
.rate-table[open] > summary { border-bottom: 1px solid var(--border); border-radius: 6px 6px 0 0; }
.rt-name { font-weight: 650; }
.rt-meta { color: var(--muted); font-size: 13.5px; }
.rt-body { padding: 10px 12px; }
.periods { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px; }
.periods-table { width: auto; border: 1px solid var(--border); }
.period-side { flex: 1; min-width: 240px; }
.period-side p { margin: 0 0 4px; }
.pad { padding: 10px 0; margin: 0; }
.foot-note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

/* edit previews */
.edit-preview { display: inline-block; margin-left: 8px; font-size: 13px; vertical-align: baseline; }
.edit-preview > summary { cursor: pointer; color: var(--accent); }
.edit-preview[open] { display: block; margin: 4px 0 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-top: 6px; padding: 8px; background: #f7f9fc; border: 1px dashed var(--border-strong); border-radius: 6px; }
.inline-form select, .inline-form input { font: inherit; padding: 3px 6px; border: 1px solid var(--border-strong); border-radius: 5px; }
.inline-form input[type=number] { width: 110px; }
.period-editor { margin-top: 6px; padding: 8px; background: #f7f9fc; border: 1px dashed var(--border-strong); border-radius: 6px; }
.period-form { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 4px 0; border-bottom: 1px solid #e6ebf1; }
.period-form input[type=date] { font: inherit; padding: 2px 5px; border: 1px solid var(--border-strong); border-radius: 5px; }
.days { border: 0; margin: 0; padding: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.day { font-size: 12.5px; display: inline-flex; gap: 2px; align-items: center; }
.days ul, .days li { list-style: none; margin: 0; padding: 0; display: inline; }

/* group / policies */
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-row > div { border-left: 3px solid var(--border); padding-left: 12px; display: flex; flex-direction: column; gap: 1px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-weight: 600; font-size: 15px; }
.policy + .policy { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border-strong); }
.policy-scope { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; margin-bottom: 6px; }
.note-text { margin: 0 0 8px; }
.followups { margin: 0; padding-left: 18px; }
.followups .done { text-decoration: line-through; color: var(--muted); }

/* files */
.files-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.ftab { font: inherit; font-size: 13px; border: 1px solid var(--border-strong); background: #fff; border-radius: 99px; padding: 3px 12px; cursor: pointer; }
.ftab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.media-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.media-tile { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #fff; }
.thumb { height: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #8aa0b8; background: repeating-linear-gradient(45deg, #eef2f7, #eef2f7 10px, #e6ecf3 10px, #e6ecf3 20px); }
.ph-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.media-meta { padding: 7px 9px; display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.media-title { font-weight: 600; font-size: 13.5px; }
.grant-actions { display: flex; gap: 8px; margin-top: 10px; }

/* supplier forms */
.sf-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 14px; align-items: start; }
.sf-grid > .card { margin-bottom: 0; }
.sf-step { border: 0; padding: 0 0 10px; margin: 0 0 10px; border-bottom: 1px solid #eef1f5; }
.sf-step legend { font-weight: 650; font-size: 14px; padding: 0; margin-bottom: 4px; }
.inline-radios { display: flex; gap: 16px; flex-wrap: wrap; }
.radio, .check { display: flex; gap: 6px; align-items: center; padding: 2px 0; }
.sf-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; }
.sf-actions { display: flex; gap: 8px; margin-top: 12px; }
.sf-output ol { margin: 6px 0; padding-left: 20px; }

.empty-state { padding: 40px 0; }
.footer { text-align: right; font-size: 12.5px; color: var(--muted); padding: 8px 20px; border-top: 1px solid var(--border); background: var(--surface); }

/* tablet / phone */
@media (max-width: 1200px) { .grid-2, .sf-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .directory { position: static; height: auto; max-height: 46vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .profile { padding: 14px 16px; }
  .profile-head { flex-direction: column; }
  .topbar { gap: 14px; padding: 0 16px; }
  .brand-product, .brand-sep, .user-chip { display: none; }
  .stat-row { grid-template-columns: minmax(0, 1fr); }
  :root { --label-w: 120px; }
}

/* M1-R2 additions */
.env-pill { margin-left: auto; background: #ffd966; color: #3d2e00; font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.env-pill + .user-chip { margin-left: 8px; }
.tab-tools { display: flex; justify-content: flex-end; margin: -4px 0 8px; }
.legend-ctl { position: relative; font-size: 13px; }
.legend-ctl > summary { cursor: pointer; list-style: none; color: var(--accent); border: 1px solid var(--border-strong); border-radius: 99px; padding: 2px 12px; background: #fff; }
.legend-ctl > summary::-webkit-details-marker { display: none; }
.legend-ctl .popover { right: 0; left: auto; top: 30px; min-width: 360px; }
.legend-list { margin: 0; }
.legend-list > div { display: grid; grid-template-columns: 110px 1fr; gap: 8px; padding: 2px 0; }
.legend-list dt { font-weight: 600; }
.legend-list dd { margin: 0; color: var(--muted); }
.policy-status { width: auto; min-width: 420px; margin-top: 14px; border: 1px solid var(--border); }
.day-all { font-weight: 600; margin-right: 6px; }
.period-draft { background: #fffaf0; }
.draft-flag { font-size: 11.5px; }
.preview-chip { background: var(--info-bg); color: var(--info-fg); border-radius: 99px; padding: 2px 10px; font-size: 12.5px; margin-left: auto; }
.files-toolbar .preview-chip + .btn { margin-left: 0; }
.files-layout { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: start; }
.files-main > .card:last-child { margin-bottom: 0; }
.drawer { width: 320px; position: sticky; top: 12px; margin: 0; box-shadow: 0 6px 20px rgba(16, 37, 66, .12); }
.drawer-file { margin: 0 0 8px; }
.drawer-controls { border: 1px dashed var(--border-strong); border-radius: 6px; margin: 10px 0 8px; padding: 8px; }
.tile-btn { all: unset; display: block; width: 100%; cursor: pointer; }
.tile-btn:focus-visible { outline: 2px solid var(--accent); }
.media-tile.is-selected { outline: 2px solid var(--accent); outline-offset: -2px; }
tr.is-selected th, tr.is-selected td { background: #e3edfa !important; }
.date-echo { font-size: 12.5px; color: var(--info-fg); min-width: 82px; display: inline-block; }
.access { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; white-space: nowrap; }
.access-restricted { background: var(--restricted-bg); color: var(--restricted-fg); }
.access-team_view { background: var(--info-bg); color: var(--info-fg); }
.access-team_download { background: var(--ok-bg); color: var(--ok-fg); }
.sf-doc { border: 1px solid var(--border-strong); border-radius: 4px; padding: 12px 14px; background: #fff; }
.sf-pdf { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.sf-doc-head { display: flex; flex-direction: column; border-bottom: 2px solid var(--brand); padding-bottom: 6px; margin-bottom: 8px; }
.sf-sheets { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 8px; }
.sf-sheet { font-size: 12px; background: #e3f5ea; color: #1d6b3a; border: 1px solid #b9e2c8; border-radius: 4px 4px 0 0; padding: 1px 8px; }
.sf-block { padding: 5px 0; border-bottom: 1px dashed #e1e6ec; }
.sf-block-title { font-weight: 600; font-size: 13.5px; }
.sf-answer { display: flex; gap: 8px; align-items: center; }
.sf-blank { flex: 1; display: inline-block; min-width: 120px; height: 16px; border-bottom: 1px solid #9aa7b5; }
.sf-facts { font-size: 13px; color: var(--ok-fg); }
.sf-sign { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; margin-top: 10px; padding-top: 8px; border-top: 2px solid var(--brand); }
.sf-sign-cell { display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 1200px) { .files-layout { grid-template-columns: minmax(0, 1fr); } .drawer { width: auto; position: static; } }

/* M1-R3 */
.scope-list { list-style: none; margin: 0 0 10px; padding: 0; font-size: 13px; }
.scope-list li { padding: 3px 8px; border-left: 3px solid var(--border); margin-bottom: 3px; }
.scope-list .scope-conflict { border-left-color: #e0a829; background: var(--warn-bg); }
.scope-list .scope-overrides, .scope-list .scope-overridden { border-left-color: #7aa7dd; }
tr.cp-hit th, tr.cp-hit td { background: #fff1c7 !important; }
.contacts-table td.email { overflow-wrap: break-word; min-width: 140px; }
.contacts-table th:first-child { white-space: nowrap; }

/* M2: auth, forms, messages */
.user-menu { display: flex; align-items: center; gap: 10px; margin-left: 8px; }
.env-pill + .user-menu { margin-left: 10px; }
.top-link { color: #dbe6f3; text-decoration: none; font-size: 13px; }
.top-link:hover { color: #fff; }
.as-link { background: none; border: 0; cursor: pointer; font: inherit; font-size: 13px; padding: 0; }
form.inline { display: inline; }
.auth-page { display: flex; justify-content: center; padding: 60px 16px; }
.auth-card { width: 360px; display: flex; flex-direction: column; gap: 6px; }
.auth-card h1 { font-size: 20px; margin-bottom: 8px; }
.auth-card input { font: inherit; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 6px; }
.auth-card .btn { margin-top: 10px; }
.page-narrow { max-width: 1100px; margin: 0 auto; padding: 20px 24px 32px; }
.page-narrow h1 { font-size: 22px; margin-bottom: 12px; }
.messages { margin-bottom: 12px; }
.msg { margin: 0 0 6px; padding: 8px 12px; border-radius: 6px; background: var(--ok-bg); color: var(--ok-fg); }
.msg-error, .msg-warning { background: var(--warn-bg); color: var(--warn-fg); }
.form-error { background: var(--restricted-bg); color: var(--restricted-fg); border-radius: 6px; padding: 8px 12px; margin-bottom: 10px; }
.form-error p { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px 16px; align-items: start; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 13px; color: var(--muted); }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: 6px; background: #fff; width: 100%; }
.field textarea { min-height: 70px; }
.field-check label { color: var(--text); display: flex; gap: 6px; align-items: center; }
.field .help { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12.5px; color: var(--restricted-fg); }
.field.has-error input, .field.has-error select { border-color: var(--restricted-fg); }
.field ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.field ul label { color: var(--text); display: inline-flex; gap: 4px; }
.req { color: var(--restricted-fg); }
.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.field-wide { grid-column: 1 / -1; }

.page-wide { max-width: 1500px; margin: 0 auto; padding: 20px 24px 32px; }
.page-wide h1 { font-size: 22px; margin-bottom: 12px; }
.crumb { margin: 0 0 6px; font-size: 13px; }
.crumb a { text-decoration: none; }
.form-section { font-size: 15px; margin: 6px 0 10px; }
.form-section + .form-grid { margin-bottom: 14px; }
.inline-set { border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; margin: 14px 0; }
.inline-set > legend { font-weight: 650; padding: 0 6px; }
.inline-row { border-bottom: 1px dashed var(--border-strong); padding: 8px 0; }
.inline-row.is-new, .period-form.is-new { background: #fffaf0; }
.has-errors { background: #fff5f5; }
.rate-edit td { padding: 4px 5px; vertical-align: top; }
.rate-edit select, .rate-edit input { font: inherit; font-size: 13px; padding: 3px 4px; border: 1px solid var(--border-strong); border-radius: 4px; }
.rate-edit td:first-child select { min-width: 190px; }
.price-pair { display: flex; flex-direction: column; gap: 3px; min-width: 104px; }
.price-pair input { width: 100%; }
.rate-edit .err { display: block; font-size: 12px; color: var(--restricted-fg); }
.btn-danger { background: #b42318; border-color: #b42318; color: #fff; }
.btn-danger-outline { color: #b42318; border-color: #e6a19b; text-decoration: none; }
.spacer { flex: 1; }
.form-actions .btn-danger-outline { margin-right: auto; }
.edit-link { font-size: 12px; text-decoration: none; margin-left: 6px; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions a { font-size: 12.5px; text-decoration: none; margin-left: 8px; }
.add-link { font-size: 13px; text-decoration: none; border: 1px solid var(--border-strong); border-radius: 6px; padding: 3px 10px; background: #fff; }
.card-head .add-link { margin-left: auto; }
.del { color: #b42318; }
.upload-card > summary { cursor: pointer; }
.upload-card[open] > summary { margin-bottom: 10px; }
.thumb.has-img { background: #f1f4f8; padding: 0; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-dl { display: block; padding: 0 9px 7px; }
.drawer-section { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.drawer-section h3 { font-size: 14px; margin: 0 0 4px; }
.drawer-section .btn { align-self: flex-start; margin-top: 4px; }
.grant-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.grant-add { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.grant-add select { font: inherit; font-size: 13px; padding: 2px 4px; }
.drawer .form-grid { grid-template-columns: 1fr; }
.policy-add { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13px; margin-top: 10px; }

.inline-set { min-width: 0; }
.error-card h1 { font-size: 20px; margin-bottom: 8px; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
@media (max-width: 860px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 16px; row-gap: 6px; }
  .user-menu { margin-left: auto; }
  .env-pill { margin-left: 0; }
}
/* Settings → Manage lists */
.list-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.list-card { text-decoration: none; color: var(--text); display: block; }
.list-card:hover { border-color: var(--accent); }
.list-card h2 { font-size: 16px; margin-bottom: 6px; }
.list-switch { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.list-switch a { text-decoration: none; border: 1px solid var(--border-strong); border-radius: 99px; padding: 3px 12px; font-size: 13px; color: var(--text); background: #fff; }
.list-switch a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.rename-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rename-form input { font: inherit; font-size: 13.5px; padding: 3px 6px; border: 1px solid var(--border-strong); border-radius: 5px; }
.rename-form .order-input { width: 64px; }
.del-form { margin-left: 6px; }

/* Milestone 3: environment identification and backup warning */
.env-pill.env-test { background: #cfe2ff; color: #0b2e66; }
.env-pill.env-drill { background: #f8d7da; color: #6b0f17; }
.env-pill.env-live { background: #d1e7dd; color: #0f3d24; }
.backup-warning { background: #fff3cd; color: #5c4400; border-bottom: 1px solid #e0c36a; padding: 8px 20px; font-size: 14px; }
.history-table td { vertical-align: top; font-size: 13.5px; }
.history-table .muted { color: #667; }
.history-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin: 10px 0 16px; }

/* Milestone 4: supplier documents */
.docs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 14px; }
.doc-form fieldset { border: 0; padding: 0; margin: 0 0 10px; }
.doc-form legend { font-weight: 600; margin-bottom: 4px; }
.doc-form .check { display: inline-block; margin: 2px 10px 2px 0; }
.doc-form input[type=date] { margin-right: 10px; }
.doc-status { display: inline-block; font-size: 12.5px; padding: 1px 8px; border-radius: 99px; background: #e8eef5; color: #16324f; }
.doc-status.st-acknowledged, .doc-status.st-ret-acknowledged { background: #d1e7dd; color: #0f3d24; }
.doc-status.st-awaiting_review, .doc-status.st-ret-pending, .doc-status.st-tbc { background: #fff3cd; color: #5c4400; }
.doc-status.st-corrections, .doc-status.st-ret-corrections, .doc-status.st-ret-rejected { background: #f8d7da; color: #6b0f17; }
.doc-status.st-superseded, .doc-status.st-expired, .doc-status.st-blank { background: #eceff3; color: #555; }
.doc-version.is-superseded { opacity: .85; }
.issue-list { margin: 0; padding-left: 18px; }
.issue-list li { margin: 2px 0; }
.inline-upload { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 8px 0; }
details.frozen { margin-top: 10px; }
details.frozen h4 { margin: 10px 0 4px; }
.doc-status.st-acknowledged_review, .doc-status.st-alert { background: #fff3cd; color: #5c4400; font-weight: 600; }
.doc-status.st-acknowledged_corrections { background: #f8d7da; color: #6b0f17; font-weight: 600; }
