:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --ink: #18202f;
  --ink-2: #4a5468;
  --ink-3: #7a8396;
  --line: #e4e0d6;
  --navy: #1d2a44;
  --accent: #e08a1e;
  --accent-ink: #9a5a08;
  --accent-soft: #fdf0dc;
  --ok: #1f7a4d; --ok-soft: #e3f3ea;
  --warn: #9a6a00; --warn-soft: #fff4d6;
  --bad: #b3261e; --bad-soft: #fde7e5;
  --info: #2b5aa8; --info-soft: #e6eefb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(24, 32, 47, .06), 0 4px 16px rgba(24, 32, 47, .05);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151d; --surface: #1a2030; --surface-2: #151a26; --ink: #eef0f5; --ink-2: #b7bdcb; --ink-3: #8a91a3;
    --line: #2b3346; --navy: #0c1220; --accent: #f2a33a; --accent-ink: #f6bb68; --accent-soft: #3a2a12;
    --ok: #5fcf96; --ok-soft: #173826; --warn: #f2c14e; --warn-soft: #3a3014; --bad: #ff8a80; --bad-soft: #3d1a18;
    --info: #8db4ff; --info-soft: #18294a; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
[hidden] { display: none !important; }

/* top bar */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; }
.brand-mark { min-width: 38px; padding: 0 6px; height: 32px; letter-spacing: .02em; border-radius: 9px; background: var(--accent); color: #1d2a44; display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a, .nav button { color: #dfe4ee; text-decoration: none; background: none; border: 0; font: inherit; padding: 8px 12px; border-radius: 8px; cursor: pointer; }
.nav a:hover, .nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.nav .who { color: #aab3c5; font-size: 13px; padding: 0 8px; }
@media (max-width: 640px) { .brand-text { display: none; } .nav .who { display: none; } .nav a, .nav button { padding: 8px 9px; } }

/* layout */
.app { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: 2fr 1fr; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.accent { border-top: 3px solid var(--accent); }

/* auth */
.auth-wrap { min-height: calc(100vh - 40px); display: grid; grid-template-columns: 1.1fr 1fr; max-width: 1040px; margin: 0 auto; gap: 0; align-items: stretch; padding: 20px 0; }
.auth-hero { background: var(--navy); color: #fff; border-radius: var(--radius) 0 0 var(--radius); padding: 44px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-hero::after { content: ""; position: absolute; right: -80px; bottom: -80px; width: 280px; height: 280px; border-radius: 50%; border: 40px solid rgba(242,163,58,.18); }
.auth-hero h1 { font-size: 34px; max-width: 14ch; }
.auth-hero p { color: #c6cedd; max-width: 38ch; }
.auth-hero .props { display: flex; gap: 8px; flex-wrap: wrap; }
.auth-hero .props span { border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; padding: 44px; display: flex; flex-direction: column; justify-content: center; }
.auth-card h2 { font-size: 22px; margin-bottom: 4px; }
.auth-card .sub { color: var(--ink-2); margin: 0 0 22px; }
.auth-foot { margin-top: 18px; color: var(--ink-2); font-size: 14px; }
@media (max-width: 820px) {
  .auth-wrap { grid-template-columns: 1fr; padding: 0; }
  .auth-hero { border-radius: var(--radius) var(--radius) 0 0; padding: 28px; }
  .auth-hero h1 { font-size: 26px; }
  .auth-card { border-left: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); padding: 28px; }
}

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field label, .label { font-weight: 600; font-size: 13px; color: var(--ink-2); }
.req { color: var(--bad); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%; min-width: 0; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 130px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[readonly] { color: var(--ink-3); }
.hint { color: var(--ink-3); font-size: 12px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1 1 180px; margin-bottom: 0; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 64px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--ink-3); font: 600 12px var(--font); cursor: pointer; padding: 6px 8px; }
.meter { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 2px; }
.meter i { display: block; height: 100%; width: 0; background: var(--bad); transition: width .2s, background .2s; }

.btn { font: 600 14px var(--font); border-radius: 10px; padding: 10px 16px; border: 1px solid transparent; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; justify-content: center; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--accent); color: #1d2a44; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-dark { background: var(--navy); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--line); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.alert { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
.alert-error { background: var(--bad-soft); color: var(--bad); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }

/* inventory rows */
.inv-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.inv-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px; align-items: end; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.inv-row .num { width: 28px; height: 28px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.inv-row .field { margin: 0; }
@media (max-width: 600px) { .inv-row { grid-template-columns: 28px minmax(0, 1fr); align-items: start; } .inv-row > .num { grid-row: 1; margin-top: 26px; } .inv-row > .field, .inv-row > .rm { grid-column: 2; } .inv-row > .rm { justify-self: start; } }
.unit-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.unit-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px 8px 12px; }
.unit-chip b { font-weight: 700; }
.unit-chip .x { background: none; border: 0; color: var(--ink-3); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; border-radius: 6px; }
.unit-chip .x:hover { color: var(--bad); background: var(--bad-soft); }

/* steps */
.steps { display: flex; gap: 8px; margin: 0 0 18px; padding: 0; list-style: none; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px 6px 6px; }
.steps li span { width: 22px; height: 22px; border-radius: 50%; background: var(--line); color: var(--ink-2); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.steps li.done span { background: var(--ok); color: #fff; }
.steps li.now { color: var(--ink); font-weight: 600; border-color: var(--accent); }
.steps li.now span { background: var(--accent); color: #1d2a44; }
.section-num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--navy); color: #fff; font-size: 12px; font-weight: 700; margin-right: 8px; vertical-align: 1px; }

/* lists */
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed li { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; padding-top: 0; }
.date-tile { flex: 0 0 52px; height: 56px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
.date-tile b { font-size: 20px; }
.date-tile small { font-size: 11px; text-transform: uppercase; font-weight: 700; letter-spacing: .05em; }
.feed .body { min-width: 0; flex: 1; }
.feed .title { font-weight: 600; }
.feed .text { color: var(--ink-2); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.feed .meta { color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.empty { color: var(--ink-3); font-size: 14px; padding: 18px; text-align: center; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 12px; }

/* table */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td .details { color: var(--ink-2); max-width: 420px; white-space: pre-wrap; overflow-wrap: anywhere; }
td .clip { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.nowrap { white-space: nowrap; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-open { background: var(--bad-soft); color: var(--bad); }
.s-in_progress { background: var(--warn-soft); color: var(--warn); }
.s-resolved { background: var(--ok-soft); color: var(--ok); }
.r-superadmin { background: var(--navy); color: #fff; }
.r-admin { background: var(--info-soft); color: var(--info); }
.r-user { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-ink); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input { flex: 1 1 220px; width: auto; }
.toolbar select { flex: 0 1 170px; width: auto; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; color: var(--ink-3); font-size: 13px; flex-wrap: wrap; }
.pager .btns { display: flex; gap: 6px; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 36px; gap: 10px; align-items: center; font-size: 13px; }
.bar { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .o { background: var(--bad); } .bar .p { background: var(--warn); } .bar .r { background: var(--ok); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-3); margin-top: 10px; flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; background: var(--c); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; font-size: 14px; max-width: calc(100% - 32px); }
.toast.err { background: var(--bad); }
.inline-edit { display: flex; flex-direction: column; gap: 6px; min-width: 200px; }
.inline-edit textarea { min-height: 60px; font-size: 13px; }
.back { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); text-decoration: none; font-size: 14px; margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.spinner { padding: 60px 0; text-align: center; color: var(--ink-3); }

#ulist tbody tr { cursor: pointer; }
#ulist tbody tr:hover td { background: var(--surface-2); }

.note { margin: 14px 0 0; font-size: 13px; color: var(--ink-2); background: var(--accent-soft); border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: 0 8px 8px 0; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #1d2a44; font-size: 11px; font-weight: 800; margin-left: 4px; }
.count:empty { display: none; }
.muted-count { background: var(--line); color: var(--ink-2); }
.a-approved { background: var(--ok-soft); color: var(--ok); }
.a-pending { background: var(--warn-soft); color: var(--warn); }
.a-rejected { background: var(--bad-soft); color: var(--bad); }
h1 .badge { vertical-align: middle; font-size: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 14px; }
.tabs button { background: none; border: 0; font: 600 14px var(--font); color: var(--ink-3); padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.hold { max-width: 560px; margin: 40px auto; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 36px 28px; }
.hold h1 { font-size: 22px; margin: 14px 0 8px; }
.hold > p { color: var(--ink-2); margin: 0 0 18px; }
.hold-icon { width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; background: var(--warn-soft); display: grid; place-items: center; font-size: 28px; }
.hold-icon.no { background: var(--bad-soft); color: var(--bad); }
.hold-kv { text-align: left; background: var(--surface-2); border-radius: 12px; padding: 14px 16px; margin-bottom: 4px; }
.hold .note { text-align: left; margin-bottom: 18px; }

.phone-row { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr); gap: 8px; }
select:disabled { color: var(--ink-3); opacity: 1; }

.grid-tri { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
@media (max-width: 1000px) { .grid-tri { grid-template-columns: 1fr; } }
.feed li > .btn, .feed li > .notice-actions { align-self: flex-start; }
.notice-actions { display: flex; gap: 6px; flex-wrap: wrap; }
td .details { min-width: 220px; }

.eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: 12px; font-weight: 700; color: var(--accent); margin: 0 0 8px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 18px 0; position: relative; z-index: 1; }
.hero-stats div { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 12px; }
.hero-stats b { display: block; font-size: 26px; color: #fff; font-variant-numeric: tabular-nums; }
.hero-stats span { font-size: 12px; color: #aab3c5; }
.auth-hero > * { position: relative; z-index: 1; }

.type-cards { border: 0; padding: 0; margin: 0 0 14px; }
.type-cards legend { margin-bottom: 8px; padding: 0; }
.type-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1000px) { .type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .type-grid { grid-template-columns: 1fr; } }
.type-card { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.type-card:hover { border-color: var(--accent); }
.type-card input { position: absolute; opacity: 0; pointer-events: none; }
.type-card .t-name { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-ink); }
.type-card .t-title { font-weight: 700; }
.type-card .t-desc { font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }
.type-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.type-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.strength { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 24px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: center; position: relative; overflow: hidden; }
.strength::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; border: 34px solid rgba(242,163,58,.15); }
.strength > * { position: relative; z-index: 1; }
.strength .big { font-size: 64px; font-weight: 800; line-height: 1; letter-spacing: -.02em; color: #fff; font-variant-numeric: tabular-nums; }
.strength .big-label { font-size: 16px; color: #dfe4ee; margin-top: 6px; font-weight: 600; }
.strength-cta { color: #aab3c5; font-size: 14px; margin: 14px 0 0; max-width: 42ch; }
.strength-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.strength-grid div { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 14px; }
.strength-grid b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.strength-grid span { font-size: 13px; color: #aab3c5; }
@media (max-width: 800px) { .strength { grid-template-columns: 1fr; } .strength .big { font-size: 48px; } }
.hbars { display: flex; flex-direction: column; gap: 14px; }
.hbar-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.hbar-track { height: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.hbar-track i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.proj { display: flex; flex-direction: column; }
.proj-row { display: grid; grid-template-columns: 1fr auto auto; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); align-items: baseline; }
.proj-row:first-child { border-top: 0; padding-top: 0; }
.proj-name { font-weight: 700; }
.foot { max-width: 1180px; margin: 0 auto; padding: 0 16px 28px; color: var(--ink-3); font-size: 12px; text-align: center; }

/* ---------- mobile menu ---------- */
.menu-btn { display: none; margin-left: auto; width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.2); border-radius: 10px; background: transparent; cursor: pointer; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.menu-btn span { display: block; width: 18px; height: 2px; background: #fff; border-radius: 2px; }
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; }
  .brand-text { display: inline; font-size: 14px; }
  .menu-btn { display: inline-flex; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 2px; margin: 4px 0 6px; }
  .nav.open { display: flex; }
  .nav a, .nav button { padding: 12px; text-align: left; font-size: 16px; }
  .nav .who { display: block; padding: 8px 12px 4px; order: -1; color: #aab3c5; }
}
/* ---------- tables become cards on phones ---------- */
@media (max-width: 760px) {
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .table-wrap { margin: 0; padding: 0; overflow: visible; }
  .rtable tr { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; background: var(--surface-2); }
  .rtable td { border: 0; padding: 6px 0; display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; align-items: start; white-space: normal; }
  .rtable td::before { content: attr(data-label); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding-top: 2px; }
  .rtable td[data-label=""] { grid-template-columns: 1fr; }
  .rtable td[data-label=""]::before { display: none; }
  td .details { min-width: 0; max-width: none; }
  .inline-edit { min-width: 0; }
  .app { padding-top: 18px; }
  h1 { font-size: 22px; }
  .card { padding: 16px; }
  .stat .value { font-size: 24px; }
  .toolbar select { flex: 1 1 140px; }
  .page-head .btn { width: 100%; }
  .hero-stats b { font-size: 20px; }
  .auth-hero h1 { font-size: 24px; }
  .phone-row { grid-template-columns: minmax(0, 130px) minmax(0, 1fr); }
  .proj-row { grid-template-columns: 1fr auto; } .proj-row .muted { grid-column: 2; }
  .kv { grid-template-columns: 100px minmax(0, 1fr); }
}
input, select, textarea { font-size: 16px; } /* prevents iOS zoom on focus */

/* documents */
.doc-grid { display: flex; flex-direction: column; gap: 16px; }
.doc-row { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.doc-row-head { margin-bottom: 6px; }
.doc-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.doc-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; }
.doc-chip a { color: var(--accent); text-decoration: none; word-break: break-all; }
.doc-chip a:hover { text-decoration: underline; }
.doc-chip .x { background: transparent; border: none; cursor: pointer; color: var(--ink-3); font-size: 16px; line-height: 1; padding: 2px 6px; border-radius: 50%; }
.doc-chip .x:hover { background: var(--bad-soft); color: var(--bad); }
.doc-pick { cursor: pointer; display: inline-flex; }

/* check row (pin / modal checkboxes) */
.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 10px 0; cursor: pointer; }
.check-row input { width: auto; margin: 0; }

/* modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-box { background: var(--surface); border-radius: 16px; padding: 22px; max-width: 420px; width: 100%; max-height: 85vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-box h2 { margin: 0 0 6px; }
.modal-box p { color: var(--ink-2); font-size: 14px; margin: 0 0 12px; }
.modal-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
