/* Design system (P9b-3a), ported from design_preview/preview.css. Tokens + base + shell + home + login + inbox. */
:root {
  /* brand */
  --yellow: #FFC300;
  --yellow-press: #E6B000;
  --yellow-soft: #FFF1BF;
  --ink: #222222;
  --ink-2: #303030;
  --text: #333333;
  --muted: #5F6873;          /* darker than brand grey #69727D so it passes 4.5:1 on warm bg */
  --bg: #FFF8EF;
  --surface: #FFFFFF;
  --surface-2: #F0F0F0;
  --line: #E6DFD3;
  --line-strong: #CFC6B6;      /* decorative dividers only */
  --control-border: #857D6E;   /* input/button borders, >=3:1 (WCAG 1.4.11) */
  /* status (never the brand yellow) */
  --ok: #1B6B3A;      --ok-bg: #DDF3E4;
  --err: #B3261E;     --err-bg: #FBE3E0;
  --warn: #7A4B00;    --warn-bg: #FFE7B0;
  --info: #1F4E8C;    --info-bg: #E1ECFA;
  --review: #8A2F12;  --review-bg: #FFE0D2;
  /* space (4px base) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  /* shape */
  --r-sm: 8px; --r: 14px; --r-lg: 22px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(34,34,34,.06), 0 1px 3px rgba(34,34,34,.05);
  --shadow-2: 0 6px 20px rgba(34,34,34,.10);
  --shadow-3: 0 16px 40px rgba(34,34,34,.18);
  /* type */
  --font: "Vazirmatn", Tahoma, sans-serif;
  --fs-xs: 12px; --fs-sm: 14px; --fs: 16px; --fs-lg: 18px; --fs-xl: 22px; --fs-2xl: 28px;
  --ease: cubic-bezier(.2,.7,.2,1);
  --dur: 180ms;
  --nav-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: var(--fs); line-height: 1.75; color: var(--text); background: var(--bg); padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
a { color: inherit; }
h1, h2, h3 { color: var(--ink); line-height: 1.4; margin: 0; }
h1 { font-size: var(--fs-xl); } h2 { font-size: var(--fs-lg); } h3 { font-size: var(--fs); }
.muted { color: var(--muted); font-size: var(--fs-sm); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.ico { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 5px var(--yellow); border-radius: var(--r-sm); }
.skip { position: absolute; top: -60px; inset-inline-start: 8px; background: var(--yellow); color: var(--ink); padding: 8px 14px; border-radius: var(--r-sm); z-index: 100; }
.skip:focus { top: 8px; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--ink); color: #fff; }
.topbar-in { max-width: 1400px; margin: 0 auto; height: 60px; padding: 0 var(--s4); display: flex; align-items: center; gap: var(--s3); }
.brand { display: flex; align-items: center; gap: var(--s2); text-decoration: none; color: #fff; font-weight: 700; font-size: var(--fs-lg); }
.brand img { width: 36px; height: 36px; }
.topbar-sp { flex: 1; }
.proj { display: none; }
.proj select { background: var(--ink-2); color: #fff; border: 1px solid #4a4a4a; border-radius: var(--r-pill); padding: 6px 14px; font: inherit; font-size: var(--fs-sm); min-height: 40px; }
.icon-btn { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r-pill); border: 0; background: transparent; color: #fff; cursor: pointer; transition: background var(--dur); }
.icon-btn:hover { background: var(--ink-2); }
.bell-badge { position: absolute; top: 4px; inset-inline-start: 4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: var(--r-pill); background: var(--yellow); color: var(--ink); font-size: 12px; font-weight: 700; display: grid; place-items: center; line-height: 1; border: 2px solid var(--ink); }
.user-chip { display: none; align-items: center; gap: var(--s2); font-size: var(--fs-sm); }
.avatar { width: 36px; height: 36px; border-radius: var(--r-pill); background: var(--yellow); color: var(--ink); font-weight: 700; display: grid; place-items: center; }

/* ---------- bottom nav (mobile) ---------- */
.bottom-nav { position: fixed; inset-inline: 0; bottom: 0; z-index: 30; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); box-shadow: 0 -4px 16px rgba(34,34,34,.06); }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: var(--fs-xs); position: relative; min-height: 48px; }
.bottom-nav a[aria-current="page"] { color: var(--ink); font-weight: 700; }
.bottom-nav a[aria-current="page"]::before { content: ""; position: absolute; top: 0; width: 32px; height: 4px; border-radius: 0 0 4px 4px; background: var(--yellow); }
.bottom-nav .dot { position: absolute; top: 8px; margin-inline-start: 18px; width: 10px; height: 10px; border-radius: 50%; background: var(--yellow); border: 2px solid var(--surface); }

/* ---------- layout ---------- */
.container { max-width: 1160px; margin: 0 auto; padding: var(--s5) var(--s4); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.crumbs { font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--s1); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 48px; padding: 0 var(--s5); border: 2px solid transparent; border-radius: var(--r-pill); background: var(--yellow); color: var(--ink); font: inherit; font-weight: 700; font-size: var(--fs-sm); text-decoration: none; cursor: pointer; transition: background var(--dur), transform var(--dur) var(--ease), box-shadow var(--dur); }
.btn:hover { background: var(--yellow-press); }
.btn:active { transform: scale(.98); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.dark:hover { background: #000; }
.btn.ghost { background: transparent; border-color: var(--control-border); color: var(--ink); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--err); color: #fff; }
.btn.small { min-height: 44px; padding: 0 var(--s4); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn .spin { display: none; width: 18px; height: 18px; border: 3px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; }
.btn.loading .spin { display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- cards / badges / alerts ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s5); box-shadow: var(--shadow-1); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 12px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; background: var(--surface-2); color: var(--text); white-space: nowrap; line-height: 1.9; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.review { background: var(--review-bg); color: var(--review); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.empty { background: var(--surface-2); color: #4A4F57; }
.alert { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-sm); font-size: var(--fs-sm); border-inline-start: 5px solid currentColor; }
.alert.info { background: var(--info-bg); color: var(--info); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.err { background: var(--err-bg); color: var(--err); }
.alert b { color: inherit; }

/* ---------- home ---------- */
.hello { padding: var(--s5) 0 var(--s4); }
.hello h1 { font-size: var(--fs-2xl); }
.hello .date { color: var(--muted); font-size: var(--fs-sm); }
.home-grid { display: grid; gap: var(--s5); }
.inbox-panel { padding: 0; overflow: hidden; border-top: 5px solid var(--yellow); }
.inbox-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s4) var(--s3); }
.inbox-head h2 { display: flex; align-items: center; gap: var(--s2); }
.count { min-width: 28px; height: 28px; padding: 0 8px; border-radius: var(--r-pill); background: var(--ink); color: var(--yellow); font-size: var(--fs-sm); font-weight: 700; display: inline-grid; place-items: center; }
.notif { display: grid; grid-template-columns: 44px 1fr auto; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4); border-top: 1px solid var(--line); text-decoration: none; color: inherit; position: relative; min-height: 72px; transition: background var(--dur); }
.notif:hover { background: var(--bg); }
.notif .n-ic { width: 44px; height: 44px; border-radius: var(--r-sm); background: var(--yellow-soft); color: var(--ink); display: grid; place-items: center; }
.notif.unread::after { content: ""; position: absolute; inset-inline-start: 8px; top: 12px; width: 9px; height: 9px; background: var(--yellow); border: 2px solid var(--ink); border-radius: 50%; }
.notif .n-title { font-weight: 700; color: var(--ink); line-height: 1.5; }
.notif .n-sub { font-size: var(--fs-sm); color: var(--muted); }
.notif .n-time { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.inbox-foot { border-top: 1px solid var(--line); padding: var(--s2) var(--s4); text-align: center; }
.inbox-foot a { display: inline-flex; min-height: 44px; align-items: center; font-weight: 700; font-size: var(--fs-sm); }
.section-title { margin: 0 0 var(--s3); }
.tiles { display: grid; grid-template-columns: 1fr; gap: var(--s3); }
.tile { display: flex; align-items: center; gap: var(--s4); padding: var(--s4); min-height: 88px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; color: inherit; position: relative; overflow: hidden; box-shadow: var(--shadow-1); transition: transform var(--dur) var(--ease), box-shadow var(--dur), background var(--dur); }
.tile::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 6px; background: var(--yellow); }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.tile:active { transform: scale(.99); }
.tile .t-ic { width: 52px; height: 52px; border-radius: var(--r-sm); background: var(--ink); color: var(--yellow); display: grid; place-items: center; flex: none; }
.tile .t-ic .ico { width: 26px; height: 26px; }
.tile b { display: block; font-size: var(--fs); color: var(--ink); }
.tile span.d { font-size: var(--fs-sm); color: var(--muted); display: block; }
.tile .t-n { margin-inline-start: auto; }

/* ---------- stat cards (FM-1: storage usage on top of a list) ---------- */
.stat-cards { display: flex; flex-wrap: wrap; gap: var(--s3); margin-bottom: var(--s4); }
.stat-card { display: grid; gap: var(--s1); padding: var(--s3) var(--s4); min-width: 200px; }
.stat-card .stat-title { color: var(--muted); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--s4); background: var(--ink); background-image: radial-gradient(circle at 90% 0%, #3b3200 0, transparent 45%); }
.login .card { width: 100%; max-width: 400px; padding: var(--s6) var(--s5); text-align: center; border-top: 6px solid var(--yellow); }
.login .card img { width: 72px; height: 72px; }
.login form { text-align: start; display: grid; gap: var(--s4); margin-top: var(--s5); }

.empty-state { text-align: center; padding: var(--s7) var(--s4); border: 2px dashed var(--line-strong); border-radius: var(--r); color: var(--muted); background: var(--surface); }
.empty-state > .ico { width: 40px; height: 40px; color: var(--line-strong); }
.empty-state h3 { margin: var(--s2) 0 var(--s1); }
.toast { position: fixed; inset-inline: var(--s4); bottom: calc(var(--nav-h) + 20px); z-index: 50; background: var(--ink); color: #fff; padding: var(--s3) var(--s4); border-radius: var(--r-sm); box-shadow: var(--shadow-3); }
.messages { list-style: none; padding: 0; margin: 0 0 var(--s4); display: grid; gap: var(--s2); }
.messages li { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-sm); font-size: var(--fs-sm); border-inline-start: 5px solid currentColor; background: var(--info-bg); color: var(--info); }
.messages .msg-success { background: var(--ok-bg); color: var(--ok); }
.messages .msg-error { background: var(--err-bg); color: var(--err); }
.messages .msg-warning { background: var(--warn-bg); color: var(--warn); }
/* legacy class names still used by pages not yet restyled (P9b-3b) */
.badge.complete, .badge.st-approved, .badge.op-agree { background: var(--ok-bg); color: var(--ok); }
.badge.draft, .badge.st-filled { background: var(--warn-bg); color: var(--warn); }
.badge.st-needs_review, .badge.op-revise { background: var(--review-bg); color: var(--review); }
.badge.st-empty, .badge.inactive { background: var(--surface-2); color: #4A4F57; }
.badge.noref { background: var(--info-bg); color: var(--info); }
.btn.secondary { background: transparent; border-color: var(--control-border); color: var(--ink); }
.btn.secondary:hover { background: var(--surface-2); }
.btn-row .btn { margin-top: 0; }
/* more sheet (mobile "بیشتر") */
.more { position: relative; display: flex; }
.more > summary { list-style: none; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; color: var(--muted); font-size: var(--fs-xs); min-height: 48px; }
.more > summary::-webkit-details-marker { display: none; }
.more[open] > summary { color: var(--ink); font-weight: 700; }
.more-sheet { position: fixed; inset-inline: var(--s3); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--s2)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-3); padding: var(--s4); display: grid; gap: var(--s3); z-index: 40; }
.more-sheet .who { font-weight: 700; color: var(--ink); }
.more-sheet select { width: 100%; min-height: 48px; border: 1.5px solid var(--control-border); border-radius: var(--r-sm); padding: 0 var(--s3); font: inherit; background: var(--surface); }
.more-sheet form { margin: 0; }
.more-sheet .btn { width: 100%; }
.linkbtn { background: none; border: 0; cursor: pointer; font: inherit; padding: 0; text-decoration: underline; color: inherit; }
.logout-d { display: none; }
/* inbox page */
.inbox-card { display: grid; gap: var(--s2); padding: var(--s4); position: relative; transition: box-shadow var(--dur); }
.inbox-card:hover { box-shadow: var(--shadow-2); }
.inbox-card .ic-top { display: flex; justify-content: space-between; align-items: start; gap: var(--s3); flex-wrap: wrap; }
.inbox-card .ic-title { font-weight: 700; color: var(--ink); text-decoration: none; }
.inbox-card .ic-meta { font-size: var(--fs-sm); color: var(--muted); }
.inbox-card .ic-badges { display: flex; flex-wrap: wrap; gap: var(--s2); }
.inbox-list { display: grid; gap: var(--s3); margin-bottom: var(--s5); }
.hint { color: var(--muted); font-size: var(--fs-sm); margin: var(--s1) 0 var(--s3); }
.pg-title { display: flex; align-items: center; gap: var(--s2); margin: var(--s4) 0 var(--s2); }

@media (min-width: 700px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .toast { inset-inline: auto var(--s5); max-width: 380px; }
}
@media (min-width: 1024px) {
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }
  .proj { display: block; }
  .user-chip { display: flex; }
  .logout-d { display: block; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .toast { bottom: var(--s5); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
/* login fields (general field restyle comes with P9b-3b) */
.login .field label { display: block; margin: 0 0 var(--s1); font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.login .field input { width: 100%; min-height: 48px; padding: 10px var(--s3); border: 1.5px solid var(--control-border); border-radius: var(--r-sm); background: var(--surface); font: inherit; color: var(--text); }
.login .field input:focus-visible { outline: 0; border-color: var(--ink); box-shadow: 0 0 0 4px var(--yellow); }
.login .field.invalid input { border-color: var(--err); background: #FFFAF9; }
.login .field .req { color: var(--err); margin-inline-start: 4px; }
.login .err-msg, .field .err-msg { margin-top: var(--s1); color: var(--err); font-size: var(--fs-sm); }
.login .btn { width: 100%; }
.logout-d .linkbtn { color: #E8E8E8; font-size: var(--fs-sm); min-height: 44px; padding: 0 var(--s2); }

/* ---------- sidebar (desktop, right side in RTL) ---------- */
.layout { max-width: 1400px; margin: 0 auto; }
.sidebar { display: none; }
.sb-group { margin: var(--s4) var(--s3) var(--s1); font-size: var(--fs-xs); font-weight: 700; color: var(--muted); }
.sb-group:first-child { margin-top: 0; }
.sb-link { position: relative; display: flex; align-items: center; gap: var(--s3); min-height: 44px; padding: 6px var(--s3); border-radius: var(--r-sm); text-decoration: none; color: var(--text); font-size: var(--fs-sm); transition: background var(--dur); }
.sb-link:hover { background: var(--surface-2); }
.sb-link .ico { width: 20px; height: 20px; color: var(--muted); }
.sb-link[aria-current="page"] { background: var(--yellow-soft); color: var(--ink); font-weight: 700; }
.sb-link[aria-current="page"] .ico { color: var(--ink); }
.sb-link[aria-current="page"]::before { content: ""; position: absolute; inset-block: 8px; inset-inline-start: 0; width: 4px; border-radius: 4px; background: var(--yellow); }

/* ---------- notification panel (bell / mobile tab) ---------- */
.notif-wrap { position: relative; }
.notif-panel { position: fixed; inset-inline: var(--s3); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--s2)); max-height: 70vh; overflow-y: auto; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-top: 5px solid var(--yellow); border-radius: var(--r); box-shadow: var(--shadow-3); z-index: 45; }
.notif-panel[hidden] { display: none; }
.np-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s3) var(--s4); }
.np-head h2 { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs); }
.np-close { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; border-radius: var(--r-pill); color: var(--ink); cursor: pointer; }
.np-close:hover { background: var(--surface-2); }
.np-empty { text-align: center; padding: var(--s5) var(--s4); border-top: 1px solid var(--line); color: var(--muted); }
.np-empty .ico { width: 36px; height: 36px; color: var(--line-strong); }
.np-empty p { margin: var(--s1) 0 0; }
.np-empty b { color: var(--ink); }

@media (min-width: 1024px) {
  .layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); align-items: start; }
  .sidebar { display: block; position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; padding: var(--s4) var(--s3); margin: var(--s5) 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); }
  .container { max-width: 1100px; }
  .notif-panel { position: absolute; inset-inline: auto; inset-inline-end: 0; top: calc(100% + 6px); bottom: auto; width: 380px; max-height: min(70vh, 520px); }
}
@media (min-width: 1360px) {
  .home-grid { grid-template-columns: 5fr 7fr; align-items: start; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- error pages (404 / 500 / 400) ---------- */
.error-code { margin: var(--s2) 0 0; font-size: 3rem; font-weight: 800; line-height: 1; color: var(--ink); letter-spacing: .02em; }
.error-page h1, .error-card h1 { margin: var(--s2) 0 var(--s2); font-size: var(--fs-lg, 1.25rem); }
.error-actions { display: flex; flex-wrap: wrap; gap: var(--s3); justify-content: center; margin-top: var(--s5); }
.error-card .error-actions .btn { width: auto; }

/* ---------- print preview shell (form_print) ---------- */
.print-bar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; justify-content: space-between; margin: 0 0 var(--s3); padding: var(--s3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1, 0 1px 3px rgba(0,0,0,.08)); }
.print-select { display: flex; gap: var(--s2); align-items: center; flex: 1 1 220px; }
.print-select label { margin: 0; font-weight: 700; font-size: var(--fs-sm); white-space: nowrap; }
.print-select select { flex: 1; min-height: 44px; padding: 0 var(--s3); font: inherit; border: 1.5px solid var(--control-border); border-radius: var(--r-sm); background: var(--surface); color: var(--text); }
.print-select select:focus-visible { outline: 0; border-color: var(--ink); box-shadow: 0 0 0 4px var(--yellow); }
.pdf-viewer { display: flex; flex-direction: column; align-items: center; gap: var(--s4); padding: var(--s3); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); min-height: 60vh; }
.pdf-viewer > p { margin: auto; padding: var(--s6) var(--s4); text-align: center; }
.pdf-viewer[aria-busy="true"] > p::before { content: ""; display: block; width: 28px; height: 28px; margin: 0 auto var(--s3); border: 3px solid var(--line-strong); border-top-color: var(--ink); border-radius: 50%; animation: pdf-spin .8s linear infinite; }
.pdf-viewer .pdf-page { max-width: 100%; height: auto; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.18); }
@keyframes pdf-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pdf-viewer[aria-busy="true"] > p::before { animation: none; } }
@media (max-width: 640px) { .pdf-viewer { padding: var(--s2); border-radius: var(--r-sm); } .print-bar .btn { flex: 1 1 100%; } }

/* =====================================================================================================
   P9b-3b: list, view, multi-section form, repeating table, lookup, signature (from design_preview)
   ===================================================================================================== */
label { display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn .ico { width: 18px; height: 18px; }
.meta-line { margin: 0 0 var(--s4); }
.alert { margin-bottom: var(--s3); align-items: flex-start; }
.alert .ico { flex: none; margin-top: 2px; }

/* ---- fields ---- */
.fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
.field { min-width: 0; }
.field label, .field .lbl { display: block; margin: 0 0 var(--s1); font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.field .req { color: var(--err); margin-inline-start: 4px; }
.field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field select, .field textarea, .filters-body input, .filters-body select,
.section-actions select, .section-actions input[type=text], .rtable-grid input:not([type=checkbox]):not([type=file]), .rtable-grid select, .rtable-grid textarea {
  width: 100%; min-height: 48px; padding: 10px var(--s3); border: 1.5px solid var(--control-border); border-radius: var(--r-sm); background: var(--surface); font: inherit; font-size: var(--fs); color: var(--text); transition: border-color var(--dur), box-shadow var(--dur); }
.field textarea, .rtable-grid textarea { min-height: 96px; resize: vertical; }
.field input[type=file], .rtable-grid input[type=file] { width: 100%; padding: var(--s2); border: 1.5px dashed var(--control-border); border-radius: var(--r-sm); background: var(--surface); font: inherit; font-size: var(--fs-sm); }
.field input:hover:not([readonly]), .field select:hover, .field textarea:hover, .rtable-grid input:hover:not([readonly]), .rtable-grid select:hover { border-color: var(--ink-2); }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .filters-body input:focus-visible, .filters-body select:focus-visible,
.section-actions select:focus-visible, .section-actions input:focus-visible, .rtable-grid input:focus-visible, .rtable-grid select:focus-visible, .rtable-grid textarea:focus-visible { outline: 0; border-color: var(--ink); box-shadow: 0 0 0 4px var(--yellow); }
/* read-only / locked (lookup autofill) fields: dashed and grey */
.field input[readonly], .field input.locked, .rtable-grid input[readonly], .rtable-grid input.locked { background: var(--surface-2); color: #3A3F46; border-style: dashed; cursor: not-allowed; }
.field .help { margin-top: var(--s1); font-size: var(--fs-xs); color: var(--muted); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--err); background: #FFFAF9; }
.err-msg { display: flex; gap: 6px; align-items: flex-start; margin-top: var(--s1); color: var(--err); font-size: var(--fs-sm); }
.err-msg .ico { width: 16px; height: 16px; flex: none; margin-top: 4px; }
.field-check { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; min-height: 48px; }
.field-check input { width: 22px; height: 22px; accent-color: var(--ink); flex: none; }
.field-check label { margin: 0; }
.field-check .help, .field-check .err-msg { flex-basis: 100%; }
.chips { display: flex; gap: var(--s2); flex-wrap: wrap; }
.chip { position: relative; display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s4); border: 1.5px solid var(--control-border); border-radius: var(--r-pill); font-size: var(--fs-sm); cursor: pointer; background: var(--surface); margin: 0; }
.chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip:has(input:checked) { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip:has(input:focus-visible) { outline: 3px solid var(--ink); box-shadow: 0 0 0 5px var(--yellow); }
.approval-block { display: grid; gap: var(--s4); padding-top: var(--s4); border-top: 1px dashed var(--line-strong); }
.approval-block [hidden] { display: none; }

/* ---- list ---- */
.filters { margin-bottom: var(--s4); padding: 0; overflow: hidden; }
.filters > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); font-weight: 700; min-height: 48px; }
.filters > summary::-webkit-details-marker { display: none; }
.filters > summary:focus-visible { outline: 3px solid var(--ink); outline-offset: -3px; }
.filters[open] > summary { border-bottom: 1px solid var(--line); }
.filters-body { padding: var(--s4); display: grid; gap: var(--s3); grid-template-columns: minmax(0, 1fr); align-items: end; }
.filters-act { display: flex; gap: var(--s3); align-items: center; }
.list-table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-1); }
.list-table table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.list-table th { text-align: start; background: var(--ink); color: #fff; padding: var(--s3) var(--s4); font-weight: 700; white-space: nowrap; }
.list-table td { padding: var(--s3) var(--s4); border-top: 1px solid var(--line); vertical-align: middle; }
.list-table tbody tr:hover { background: var(--bg); }
.list-table a.row-link { font-weight: 700; color: var(--ink); text-decoration: none; }
.list-table a.row-link:hover { text-decoration: underline; }
.dots { position: relative; }
.dots > summary { list-style: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r-pill); cursor: pointer; }
.dots > summary::-webkit-details-marker { display: none; }
.dots > summary:hover, .dots[open] > summary { background: var(--surface-2); }
.dots > summary:focus-visible { outline: 3px solid var(--ink); box-shadow: 0 0 0 5px var(--yellow); }
.dots-menu { position: absolute; inset-inline-start: 0; top: 46px; z-index: 10; min-width: 160px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow-3); overflow: hidden; }
.dots-menu form { margin: 0; }
.dots-menu a, .dots-menu button { display: flex; width: 100%; min-height: 48px; align-items: center; padding: 0 var(--s4); background: none; border: 0; font: inherit; font-size: var(--fs-sm); color: var(--text); text-decoration: none; cursor: pointer; text-align: start; }
.dots-menu a:hover, .dots-menu button:hover { background: var(--surface-2); }
.dots-menu .danger { color: var(--err); }
.pager { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: var(--s4); margin-top: var(--s5); font-size: var(--fs-sm); }
.pager [aria-disabled="true"] { opacity: .4; pointer-events: none; }
.list-skeleton { display: grid; gap: var(--s3); }
.list-skeleton[hidden] { display: none; }
.list-skeleton .skeleton { height: 96px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, #F8F8F8 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r-sm); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.empty-state .btn { margin-top: var(--s2); }

/* below 1024px every list row becomes a card (same markup as the table) */
@media (max-width: 1023.98px) {
  .list-table { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .list-table table, .list-table tbody { display: block; }
  .list-table thead { display: none; }
  .list-table tr { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 2px var(--s3); position: relative; margin-bottom: var(--s3); padding: var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); }
  .list-table tbody tr:hover { background: var(--surface); }
  .list-table td { display: block; padding: 0; border: 0; grid-column: 1; font-size: var(--fs-sm); color: var(--muted); }
  .list-table td.c-title { font-size: var(--fs); }
  .list-table td.c-meta::before { content: attr(data-label) ": "; }
  .list-table td.c-status { margin-top: var(--s2); display: flex; gap: var(--s2); flex-wrap: wrap; }
  .list-table td.c-act { position: absolute; top: var(--s2); inset-inline-end: var(--s2); z-index: 2; }
  .list-table .row-title::after { content: ""; position: absolute; inset: 0; border-radius: var(--r); }
  .list-table .c-meta .muted { display: inline; }
}

/* ---- multi-section form ---- */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
.form-layout > *, .sec, .sec-body, .rtable, .fields > * { min-width: 0; }
.form-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); align-content: start; }
.rail { display: flex; gap: var(--s2); overflow-x: auto; padding: var(--s2) var(--s4); scroll-snap-type: x proximity; position: sticky; top: 60px; z-index: 20; background: var(--bg); margin-inline: calc(var(--s4) * -1); border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.rail a { display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s3); min-height: 44px; border-radius: var(--r-pill); background: var(--surface); border: 1.5px solid var(--line); text-decoration: none; font-size: var(--fs-sm); white-space: nowrap; color: var(--text); scroll-snap-align: center; flex: none; }
.rail a:hover { border-color: var(--ink-2); }
.rail a:focus-visible { outline: 3px solid var(--ink); box-shadow: 0 0 0 5px var(--yellow); }
.rail a[aria-current="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.node { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--text); flex: none; }
.node .ico { width: 14px; height: 14px; stroke-width: 3; }
.node.ok { background: var(--ok); color: #fff; }
.node.warn { background: var(--yellow); color: var(--ink); }
.node.review { background: var(--review); color: #fff; }
.rail a[aria-current="true"] .node { outline: 2px solid var(--yellow); }
.sec { padding: 0; overflow: visible; scroll-margin-top: 130px; }
.sec-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4); background: linear-gradient(to left, var(--surface), var(--bg)); border-bottom: 1px solid var(--line); flex-wrap: wrap; border-radius: var(--r) var(--r) 0 0; }
.sec-head h2 { font-size: var(--fs); flex: 1; min-width: 160px; margin: 0; }
.sec-no { color: var(--muted); margin-inline-end: 2px; }
.sec-sub { display: grid; gap: var(--s2); padding: var(--s3) var(--s4) 0; }
.sec-sub .alert { margin: 0; }
.sign-line { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; font-size: var(--fs-sm); }
.sec-body { padding: var(--s4); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
.sec.readonly .sec-head { background: var(--surface-2); }
.sec.inactive { opacity: .65; }
.ro-note { display: flex; align-items: center; gap: var(--s2); }
.ro-note .ico { width: 16px; height: 16px; }
.kv { display: grid; grid-template-columns: minmax(110px, 220px) minmax(0, 1fr); gap: var(--s2) var(--s4); font-size: var(--fs-sm); margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-height: 1.4em; overflow-wrap: anywhere; }
.kv.computed dd { font-weight: 700; color: var(--ink); }
.section-actions { display: flex; flex-wrap: wrap; gap: var(--s4); padding-top: var(--s4); border-top: 1px dashed var(--line-strong); }
.section-actions form { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; font-size: var(--fs-sm); }
.section-actions label { font-weight: 700; color: var(--ink); }
.section-actions select, .section-actions input[type=text] { width: auto; min-height: 44px; }
.delete-zone { margin-top: var(--s2); }
.savebar { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--s2)); z-index: 25; display: flex; gap: var(--s3); align-items: center; justify-content: space-between; padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-3); }
.savebar .dirty { color: var(--warn); font-weight: 700; }
.btn .spin { display: none; width: 18px; height: 18px; border: 3px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; }
.btn.loading .spin { display: inline-block; }
.btn.loading .ico { display: none; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---- repeating table: one markup, cards below 1024px, real table above ---- */
.rtable { border: 1.5px solid var(--line); border-radius: var(--r); margin: 0; padding: 0; overflow: hidden; background: var(--surface); }
.rt-title { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: var(--s2) var(--s4); background: var(--surface-2); font-weight: 700; color: var(--ink); min-height: 48px; width: 100%; }
fieldset.rtable > legend.rt-title { float: none; display: flex; }
.rtable-view { border: 1.5px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.rt-add { padding: var(--s3) var(--s4); border-top: 1px solid var(--line); }
.rt-n { width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--yellow); display: inline-grid; place-items: center; font-weight: 700; font-size: var(--fs-sm); }
.rt-del { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--err); cursor: pointer; display: grid; place-items: center; }
.rt-del:hover { background: var(--err-bg); }
.rt-del:focus-visible { outline: 3px solid var(--ink); box-shadow: 0 0 0 5px var(--yellow); }
.rtable-grid { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.rtable-grid th { text-align: start; padding: var(--s2) var(--s3); background: var(--bg); color: var(--muted); font-size: var(--fs-xs); font-weight: 700; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rtable-grid td { padding: var(--s2) var(--s3); border-top: 1px solid var(--line); vertical-align: top; }
.rtable-grid tr[hidden] { display: none; }
.rtable-grid td.rt-no, .rtable-grid th.rt-no { width: 52px; text-align: center; }
.rtable-grid td.rt-act, .rtable-grid th.rt-act { width: 56px; text-align: center; }
.rtable-grid td > input:not([type=checkbox]), .rtable-grid td > select, .rtable-grid td > textarea { min-width: 150px; }
.calc { background: var(--yellow-soft); border-radius: var(--r-sm); padding: 10px var(--s3); min-height: 48px; font-weight: 700; color: var(--ink); display: flex; align-items: center; min-width: 110px; }
.rtable-grid.view td { color: var(--text); vertical-align: middle; }
.rtable-grid td[colspan] { text-align: center; padding: var(--s5); }

@media (max-width: 1023.98px) {
  .rtable .table-wrap, .rtable-view .table-wrap { overflow: visible; }
  .rtable-grid, .rtable-grid tbody { display: block; }
  .rtable-grid thead { display: none; }
  .rtable-grid tr.rt-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); padding: var(--s4); border-top: 1px solid var(--line); position: relative; }
  .rtable-grid tbody tr.rt-row:first-child { border-top: 0; }
  .rtable-grid tr.rt-row[hidden] { display: none; }
  .rtable-grid td { display: block; padding: 0; border: 0; min-width: 0; grid-column: 1 / -1; }
  .rtable-grid td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: var(--fs-xs); font-weight: 700; color: var(--muted); }
  .rtable-grid td.rt-no { grid-column: 1; width: auto; text-align: start; }
  .rtable-grid td.rt-act { position: absolute; top: var(--s2); inset-inline-end: var(--s2); width: auto; }
  .rtable-grid td > input:not([type=checkbox]), .rtable-grid td > select, .rtable-grid td > textarea { min-width: 0; }
  .rtable-grid td.rt-computed { grid-column: auto; }
  .rtable-grid.view tr.rt-empty { display: block; padding: var(--s4); }
}

/* ---- lookup ---- */
.lookup { position: relative; }
.lookup-box { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.lookup-box .lookup-text { flex: 1 1 140px; min-width: 0; }
.lookup-clear { width: 44px; height: 44px; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); border-radius: 50%; }
.lookup-clear:hover { background: var(--surface-2); color: var(--ink); }
.lookup-clear:focus-visible { outline: 3px solid var(--ink); box-shadow: 0 0 0 5px var(--yellow); }
.lookup-results { list-style: none; margin: 4px 0 0; padding: 0; position: absolute; z-index: 40; inset-inline: 0; max-height: 260px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow-3); }
.lookup-results[hidden] { display: none; }
.lookup-results li { padding: var(--s3) var(--s4); min-height: 44px; cursor: pointer; border-top: 1px solid var(--line); }
.lookup-results li:first-child { border-top: 0; }
.lookup-results li:hover, .lookup-results li:focus { background: var(--yellow-soft); outline: 0; }
.lookup-results li.none { color: var(--muted); cursor: default; background: none; }
.lookup-add { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-top: var(--s2); padding: var(--s3); background: var(--bg); border: 1px dashed var(--line-strong); border-radius: var(--r-sm); }
.lookup-add[hidden] { display: none; }
.lookup-add input { flex: 1 1 160px; min-width: 0; }
.lookup-add-error { color: var(--err); font-size: var(--fs-sm); }
.lookup-similar { flex: 1 1 100%; list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.lookup-similar[hidden] { display: none; }
.lookup-similar li { padding: var(--s2) var(--s3); cursor: pointer; border-top: 1px solid var(--line); }
.lookup-similar li:first-child { border-top: 0; }
.lookup-similar li:hover { background: var(--yellow-soft); }

/* ---- signature ---- */
.sig-block { padding-top: var(--s4); border-top: 1px dashed var(--line-strong); display: grid; gap: var(--s3); }
.inline-check { display: flex; gap: var(--s3); align-items: center; min-height: 48px; }
.inline-check input { width: 22px; height: 22px; accent-color: var(--ink); flex: none; }
.inline-check label { margin: 0; font-weight: 700; color: var(--ink); }
.sigpad[hidden] { display: none; }
.sigpad-canvas { display: block; width: 100%; max-width: 560px; height: 180px; background: var(--surface); border: 2px dashed var(--line-strong); border-radius: var(--r); touch-action: none; cursor: crosshair; }
.sigpad-tools { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; margin-top: var(--s2); }
.sig-img { display: block; max-height: 80px; max-width: 240px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }
.sig-img.sig-current { max-height: 48px; max-width: 150px; }
/* PRINT-1: file value with its preview (form page) */
.file-preview { display: inline-flex; align-items: center; gap: var(--s2); }
.file-thumb { display: block; max-height: 64px; max-width: 96px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); object-fit: cover; }
.file-ico { flex: none; }
.sig-note { margin: 0; }

/* ---- breakpoints ---- */
@media (min-width: 700px) {
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rtable-grid tr.rt-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .filters-body { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .rail { margin-inline: 0; border-radius: 0 0 var(--r) var(--r); padding-inline: var(--s3); }
  .savebar { bottom: var(--s4); }
}
@media (min-width: 1360px) {
  .fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-layout { grid-template-columns: 232px minmax(0, 1fr); align-items: start; gap: var(--s5); }
  .rail { top: 84px; flex-direction: column; overflow: visible; margin: 0; padding: 0; border: 0; background: transparent; }
  .rail a { border-radius: var(--r-sm); white-space: normal; padding-block: var(--s2); }
  .rail .rail-t { line-height: 1.5; }
  .sec { scroll-margin-top: 84px; }
}
@media (prefers-reduced-motion: reduce) { .skeleton, .btn .spin { animation: none !important; } }

/* absolute .sr labels inside scroll containers must not leak page-level overflow */
.table-wrap, .list-table, .rtable-grid th { position: relative; }
.rtable-grid td > select { min-width: 96px; }
.rtable-grid td > .lookup { min-width: 190px; }
.list-table .c-meta .muted { margin-inline-start: var(--s2); }
@media (min-width: 1024px) { .list-table .c-meta .muted { margin: 0; } }

/* ---- panels (MC-12): company / project panel shell, list, form, history; reused by every panel page ---- */
.panel { display: grid; gap: var(--s4); grid-template-columns: minmax(0, 1fr); }
.panel-nav { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; padding: var(--s3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.panel-nav-head { display: flex; flex-direction: column; margin-inline-end: var(--s3); font-size: var(--fs-sm); }
.panel-nav-link { padding: var(--s2) var(--s3); border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font-size: var(--fs-sm); min-height: 40px; display: flex; align-items: center; }
.panel-nav-link:hover { background: var(--surface-2); }
.panel-nav-link[aria-current="page"] { background: var(--yellow-soft); font-weight: 700; }
.panel-main { min-width: 0; }
.panel-sort { color: inherit; text-decoration: none; }
.panel-sort:hover { text-decoration: underline; }
.panel-inactive td { color: var(--muted); }
.panel-default td { color: var(--muted); font-style: italic; }
.panel-current td { font-weight: 700; }
.supervisor-chip { display: flex; align-items: center; gap: var(--s2); padding: 4px 12px; border-radius: var(--r-pill); background: var(--yellow); color: var(--ink); font-size: var(--fs-sm); text-decoration: none; min-height: 36px; }
.supervisor-chip:hover { text-decoration: underline; }
.impersonate-bar { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; justify-content: center; gap: var(--s3); flex-wrap: wrap; padding: var(--s2) var(--s4); background: var(--err); color: var(--surface); font-weight: 700; }
.impersonate-bar form { margin: 0; }
.panel-form { display: grid; gap: var(--s4); padding: var(--s4); }
.panel-checks > div { display: grid; gap: var(--s3); }
.panel-checks > div > div > label { font-weight: 700; }
.panel-checks > div > div > div { display: grid; gap: var(--s1); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); padding-block: var(--s2); }
.panel-checks label { display: flex; gap: var(--s2); align-items: center; font-weight: 400; }
.panel-actions { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.panel-history { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.panel-history > li { padding: var(--s3) var(--s4); }
.panel-history-head { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: baseline; }
.panel-changes { margin: var(--s2) 0 0; padding-inline-start: var(--s5); font-size: var(--fs-sm); }
.panel-changes del { color: var(--err); }
.panel-changes ins { color: var(--ok); text-decoration: none; }
.panel-form textarea.print-code { width: 100%; box-sizing: border-box; direction: ltr; text-align: left; font-family: Consolas, Menlo, monospace; font-size: var(--fs-sm); line-height: 1.5; tab-size: 2; white-space: pre; }
.panel-preview { display: grid; gap: var(--s3); padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r); }
.panel-preview h2 { margin: 0; font-size: var(--fs); }
.panel-preview-row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: end; }
.panel-diff { direction: ltr; text-align: left; font-family: Consolas, Menlo, monospace; font-size: var(--fs-sm); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s2); overflow-x: auto; white-space: pre; }
.panel-diff .add { background: var(--ok-bg); }
.panel-diff .del { background: var(--err-bg); }
.panel-diff .same { color: var(--muted); }
.panel-inline { display: inline; margin: 0; }
.panel-unapproved td { background: var(--warn-bg); color: var(--warn); }
.panel-bulk { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-block: var(--s3); }
.panel-merge { display: grid; gap: var(--s3); padding: var(--s4); }
.panel-merge ul { margin: 0; padding-inline-start: var(--s5); }
.panel-bank-group { display: grid; gap: var(--s3); padding: var(--s4); margin-block-end: var(--s4); }
.panel-bank-group h2 { margin: 0; font-size: var(--fs); }
.panel-bank-checks { display: grid; gap: var(--s1); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); padding-block: var(--s2); }
.panel-bank-checks label { display: flex; gap: var(--s2); align-items: center; font-weight: 400; }
@media (min-width: 1024px) {
  .panel { grid-template-columns: 220px minmax(0, 1fr); align-items: start; }
  .panel-nav { flex-direction: column; align-items: stretch; flex-wrap: nowrap; }
  .panel-nav-head { margin: 0 0 var(--s2); }
  .panel-filters { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}
@media (max-width: 1023.98px) {
  .panel-table td::before { content: attr(data-label) ": "; }
  .panel-table td.c-act::before { content: none; }
}
.panel-logo { display: flex; align-items: center; gap: var(--s3); }
.panel-logo-img { max-width: 96px; max-height: 96px; object-fit: contain; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.panel-secret { display: grid; gap: var(--s3); padding: var(--s4); }
.panel-password { font-family: Consolas, Menlo, monospace; font-size: var(--fs-lg, 1.25rem); letter-spacing: 0.08em; padding: var(--s1) var(--s3); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); user-select: all; }
.panel-matrix-types { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* ---------- files page and drive (FM-2) ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s4); border-bottom: 1px solid var(--line); }
.tab { display: inline-flex; align-items: center; gap: var(--s2); min-height: 48px; padding: 0 var(--s4); text-decoration: none; color: var(--muted); font-weight: 700; font-size: var(--fs-sm); border-bottom: 4px solid transparent; }
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--yellow); }
.drive-forms { display: grid; gap: var(--s4); margin-bottom: var(--s5); grid-template-columns: minmax(0, 1fr); }
.drive-form { display: grid; gap: var(--s3); align-content: start; }
.dots-menu .inline-form { display: grid; gap: var(--s2); padding: var(--s3); border-bottom: 1px solid var(--line); }
.dots-menu .inline-form input { width: 100%; min-height: 44px; padding: 0 var(--s3); border: 1.5px solid var(--control-border); border-radius: var(--r-sm); font: inherit; }
.dots-menu .inline-form button { min-height: 44px; padding: 0 var(--s3); }
.drive-access-table select { min-height: 44px; }
@media (min-width: 1024px) {
  .drive-forms { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* FM-3: sharing */
.share-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); margin: 0 0 var(--s3); }
.list-table .c-check { width: 44px; }
.list-table .c-check input { width: 20px; height: 20px; }
.share-files { margin: 0 0 var(--s4); padding-inline-start: var(--s5); }
.share-part { border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s3) var(--s4); margin: var(--s4) 0; }
.share-part legend { font-weight: 700; padding: 0 var(--s2); }
.share-result { display: grid; gap: var(--s3); justify-items: start; }
.share-link { word-break: break-all; user-select: all; }
.share-qr { width: 200px; height: 200px; }
.public-page { padding: 0; }
.public-share h1 { margin-bottom: var(--s3); }

/* ---------- project budget grid (AS-2) ---------- */
.budget-scroll { overflow-x: auto; max-width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); margin-block: var(--s3); }
.budget-table { border-collapse: collapse; font-size: var(--fs-sm); min-width: max-content; }
.budget-table th, .budget-table td { padding: var(--s2) var(--s3); border-top: 1px solid var(--line); white-space: nowrap; text-align: start; vertical-align: middle; }
.budget-table thead th { background: var(--ink); color: #fff; font-weight: 700; border-top: 0; }
.budget-sticky { position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 1; }
.budget-table thead .budget-sticky { background: var(--ink); }
.budget-input { width: 7.5rem; min-height: 36px; padding: 0 var(--s2); text-align: end; font-variant-numeric: tabular-nums; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); color: var(--ink); }
.budget-input.invalid { border-color: var(--err); background: #FFFAF9; }
.budget-total-col { font-weight: 700; }
.budget-sum th, .budget-sum td { background: var(--surface-2); font-weight: 700; }

/* DEMO-1: demo instance bar and the demo users table on the login page */
.demo-bar { position: sticky; top: 0; z-index: 70; padding: var(--s2) var(--s4); background: var(--yellow); color: var(--ink); text-align: center; font-weight: 700; font-size: var(--fs-sm); }
.login .card:has(.demo-users) { max-width: 560px; }
.demo-users { margin-top: var(--s5); text-align: start; }
.demo-users h2 { font-size: var(--fs-md, 1rem); margin: 0 0 var(--s1); }
.demo-users table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.demo-users th, .demo-users td { padding: var(--s1) var(--s2); border-bottom: 1px solid var(--control-border); text-align: start; }

/* PV2-18: budget vs cost report */
.br-indent { display: inline-block; }
.br-depth-1 { padding-inline-start: var(--s4); }
.br-depth-2 { padding-inline-start: var(--s6); }
.br-level-1 td { font-weight: 700; }
.br-over td.num { color: var(--err); }
.br-total th, .br-total td { font-weight: 700; border-top: 2px solid var(--line-strong); }
.formula-notes { font-size: var(--fs-sm); color: var(--muted); }
