:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F6F6F3;
  --surface-3: #ECEBE7;
  --border: #E7E4DE;
  --text: #262523;
  --text-muted: #767676;
  --text-faint: #A0A0A0;
  --accent: #EA7933;
  --accent-ink: #FFFFFF;
  --accent-strong: #A54D12;
  --accent-soft: #FCF1E8;
  --accent-soft-border: #F1C9AC;
  --ok: #2F8F5B;
  --ok-soft: #E7F3EC;
  --warn: #B8860B;
  --warn-soft: #FBF1D9;
  --danger: #C6432E;
  --danger-soft: #FBEAE7;
  --info: #2F6FB0;
  --info-soft: #E9F1FA;
  --hold: #767676;
  --hold-soft: #EDEDED;
  --shadow-sm: 0 1px 2px rgba(35,35,35,0.06);
  --shadow-md: 0 6px 20px rgba(35,35,35,0.08);
  --shadow-lg: 0 16px 40px rgba(35,35,35,0.16);
  --radius: 16px;
  --radius-sm: 10px;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-display: "Fraunces", "Iowan Old Style", ui-serif, Georgia, serif;

  /* Hero / dashboard-specific tokens */
  --hero-bg: #323232;
  --hero-bg-2: #282828;
  --hero-text: #FFFFFF;
  --hero-text-muted: rgba(255,255,255,0.62);
  --hero-track: #4c4c4c;
  --hero-border: rgba(255,255,255,0.08);

  --chip-peach-bg: #FCF0E6; --chip-peach-fg: #C56B2E;
  --chip-mint-bg: #ECF5EF; --chip-mint-fg: #3F7A5C;
  --chip-blush-bg: #F7ECE9; --chip-blush-fg: #C0503A;
  --chip-neutral-bg: #EDECE9; --chip-neutral-fg: #57554F;

  --step-done-bg: #4B8664; --step-done-fg: #FFFFFF;
  --step-current-bg: var(--accent); --step-current-fg: #FFFFFF; --step-current-halo: var(--accent-soft);
  --step-upcoming-bg: #ECECEC; --step-upcoming-fg: #8A8A85;

  --avatar-bg: #E7D5CE; --avatar-fg: #8A5A47;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17130F;
    --surface: #221C17;
    --surface-2: #2A231C;
    --surface-3: #332B22;
    --border: #3D342A;
    --text: #F3EEE7;
    --text-muted: #B4A99B;
    --text-faint: #8A7D6C;
    --accent: #F0985E;
    --accent-ink: #221505;
    --accent-strong: #F8C7A3;
    --accent-soft: #33220F;
    --accent-soft-border: #5C3B1B;
    --ok: #6FBE93;
    --ok-soft: #1C2E24;
    --warn: #E0BB55;
    --warn-soft: #332A11;
    --danger: #E2897A;
    --danger-soft: #35201C;
    --info: #7FB0E0;
    --info-soft: #1B2A38;
    --hold: #A79C8E;
    --hold-soft: #2A251F;

    --hero-bg: #100D0A;
    --hero-bg-2: #1A1611;
    --hero-text: #F6F1EA;
    --hero-text-muted: rgba(246,241,234,0.6);
    --hero-track: #3A332B;
    --hero-border: rgba(255,255,255,0.08);

    --chip-peach-bg: #33241A; --chip-peach-fg: #F0985E;
    --chip-mint-bg: #1C2E24; --chip-mint-fg: #6FBE93;
    --chip-blush-bg: #35201C; --chip-blush-fg: #E2897A;
    --chip-neutral-bg: #2A251F; --chip-neutral-fg: #B4A99B;

    --step-done-bg: #3F7A5C; --step-done-fg: #F6F1EA;
    --step-current-bg: var(--accent); --step-current-fg: #221505; --step-current-halo: var(--accent-soft);
    --step-upcoming-bg: #2E2820; --step-upcoming-fg: #8A7D6C;

    --avatar-bg: #3A2A23; --avatar-fg: #E8C9B8;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #17130F;
  --surface: #221C17;
  --surface-2: #2A231C;
  --surface-3: #332B22;
  --border: #3D342A;
  --text: #F3EEE7;
  --text-muted: #B4A99B;
  --text-faint: #8A7D6C;
  --accent: #F0985E;
  --accent-ink: #221505;
  --accent-strong: #F8C7A3;
  --accent-soft: #33220F;
  --accent-soft-border: #5C3B1B;
  --ok: #6FBE93;
  --ok-soft: #1C2E24;
  --warn: #E0BB55;
  --warn-soft: #332A11;
  --danger: #E2897A;
  --danger-soft: #35201C;
  --info: #7FB0E0;
  --info-soft: #1B2A38;
  --hold: #A79C8E;
  --hold-soft: #2A251F;

  --hero-bg: #100D0A;
  --hero-bg-2: #1A1611;
  --hero-text: #F6F1EA;
  --hero-text-muted: rgba(246,241,234,0.6);
  --hero-track: #3A332B;
  --hero-border: rgba(255,255,255,0.08);

  --chip-peach-bg: #33241A; --chip-peach-fg: #F0985E;
  --chip-mint-bg: #1C2E24; --chip-mint-fg: #6FBE93;
  --chip-blush-bg: #35201C; --chip-blush-fg: #E2897A;
  --chip-neutral-bg: #2A251F; --chip-neutral-fg: #B4A99B;

  --step-done-bg: #3F7A5C; --step-done-fg: #F6F1EA;
  --step-current-bg: var(--accent); --step-current-fg: #221505; --step-current-halo: var(--accent-soft);
  --step-upcoming-bg: #2E2820; --step-upcoming-fg: #8A7D6C;

  --avatar-bg: #3A2A23; --avatar-fg: #E8C9B8;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
a { color: inherit; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { text-wrap: balance; font-family: var(--font-display); margin: 0; }

.app-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { padding: 22px 20px 14px; }
.brand-lockup { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.brand-mark-svg { width: 34px; height: 42px; flex-shrink: 0; color: var(--accent); }
.brand-mark-img { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--border); flex-shrink: 0; }
.brand-mark-wrap { position: relative; display: inline-block; line-height: 0; }
.brand-mark-upload {
  position: absolute; bottom: -5px; right: -5px; width: 20px; height: 20px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: 2px solid var(--surface);
}
.brand-mark-upload:hover { filter: brightness(1.08); }
.brand-sub { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-faint); font-weight: 700; margin-top: 4px; }
.brand-word { font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 27px; color: var(--accent); margin: 2px 0 0; letter-spacing: -0.01em; }
.brand-rule { border: none; border-top: 1px solid var(--border); margin: 14px 0 0; }

.mode-switch {
  display: flex; gap: 4px; margin: 14px 14px 14px; padding: 3px;
  background: var(--surface-2); border-radius: 999px;
}
.mode-switch button {
  flex: 1; border: none; background: transparent; padding: 7px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: var(--text-muted); cursor: pointer;
}
.mode-switch button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.project-card {
  display: flex; align-items: center; gap: 10px; margin: 0 14px 8px; padding: 11px 12px;
  background: var(--accent-soft); border: 1px solid var(--accent-soft-border); border-radius: var(--radius);
}
.project-card-avatar {
  width: 34px; height: 34px; border-radius: var(--radius-sm); background: var(--surface);
  color: var(--accent-strong); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.project-card-name { font-size: 13px; font-weight: 700; color: var(--text); }
.project-card-code { font-size: 10.5px; color: var(--text-faint); margin-top: 1px; font-variant-numeric: tabular-nums; }

.nav-group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint);
  padding: 14px 18px 6px;
}
.nav-list { display: flex; flex-direction: column; gap: 1px; padding: 0 10px; }
.nav-item {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600;
  color: var(--text-muted); cursor: pointer; border: none; background: transparent; text-align: left; width: 100%;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-strong); }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 20px; border-radius: 0 4px 4px 0; background: var(--accent);
}
.nav-count { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.nav-item.active .nav-count { color: var(--accent-strong); }
.nav-badge {
  font-size: 10.5px; font-weight: 700; color: var(--accent-strong); background: var(--accent-soft);
  border-radius: 999px; padding: 1px 7px; font-variant-numeric: tabular-nums;
}
.nav-item.active .nav-badge { background: var(--surface); }

.assist-card {
  margin: 18px 14px 0; padding: 16px; border-radius: var(--radius); background: var(--hero-bg); color: var(--hero-text);
}
.assist-icon {
  width: 30px; height: 30px; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; margin-bottom: 10px;
}
.assist-title { font-size: 13.5px; font-weight: 700; margin-bottom: 4px; }
.assist-body { font-size: 12px; color: var(--hero-text-muted); line-height: 1.45; }
.assist-link { display: inline-block; margin-top: 10px; font-size: 12px; font-weight: 600; color: var(--hero-text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; background: none; border: none; padding: 0; }

.sidebar-tagline { margin-top: auto; padding: 20px 18px 22px; font-size: 12px; font-style: italic; font-family: var(--font-display); color: var(--text-faint); text-align: center; line-height: 1.5; }

/* ---------- Topbar ---------- */
.app-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 36px; background: var(--bg); position: sticky; top: 0; z-index: 15;
}
.topbar-greet-label { font-size: 13px; color: var(--text-muted); }
.topbar-greet-name { font-family: var(--font-display); font-size: 19px; font-weight: 600; margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.topbar-icon-btn {
  width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; justify-content: center; color: var(--text); position: relative; flex-shrink: 0;
}
.topbar-icon-badge {
  position: absolute; top: -5px; right: -5px; background: var(--accent); color: var(--accent-ink);
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
.topbar-user { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.avatar-chip {
  width: 36px; height: 36px; border-radius: 999px; background: var(--avatar-bg); color: var(--avatar-fg);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12.5px; flex-shrink: 0;
}
.topbar-user-name { font-size: 13px; font-weight: 700; }
.topbar-user-role { font-size: 11px; color: var(--text-faint); }

.topbar-mobile {
  display: none; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 14px; font-weight: 600; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; cursor: pointer;
  color: var(--text);
}

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; }
.main-inner { max-width: 1120px; margin: 0 auto; padding: 32px 36px 80px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent-strong); font-weight: 700; margin-bottom: 6px; }
.page-title { font-size: 25px; font-weight: 600; letter-spacing: -0.01em; }
.page-sub { font-size: 13.5px; color: var(--text-muted); margin-top: 5px; max-width: 60ch; }

.banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 12.5px; margin-bottom: 18px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted);
}
.banner.readonly { background: var(--info-soft); border-color: var(--info); color: var(--info); }
.banner.saved { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.banner.error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
  padding: 9px 15px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer; white-space: nowrap; line-height: 1.1;
}
.btn:hover { border-color: var(--text-faint); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.05); border-color: var(--accent); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }

/* ---------- Cards / KPIs ---------- */
.grid { display: grid; gap: 14px; }
.kpi-grid { grid-template-columns: repeat(4, 1fr); margin-bottom: 22px; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); margin-bottom: 8px; }
.kpi-value { font-family: var(--font-display); font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-note { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

.progress-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; }

/* ---------- Hero ---------- */
.hero-card {
  position: relative; overflow: hidden; background: var(--hero-bg); color: var(--hero-text);
  border-radius: 22px; padding: 30px 32px; margin-bottom: 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.hero-ring-deco {
  position: absolute; top: -140px; right: 120px; width: 380px; height: 380px; border-radius: 999px;
  border: 1px solid var(--hero-border); pointer-events: none;
}
.hero-live { display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.hero-live-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--ok); box-shadow: 0 0 0 3px rgba(111,190,147,0.25); }
.hero-title { font-family: var(--font-display); font-size: 34px; font-weight: 600; color: var(--hero-text); }
.hero-sub { font-size: 14px; color: var(--hero-text-muted); margin-top: 6px; }
.hero-stats { display: flex; gap: 32px; margin-top: 22px; flex-wrap: wrap; }
.hero-stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--hero-text-muted); margin-bottom: 4px; }
.hero-stat-value { font-size: 13.5px; font-weight: 700; color: var(--hero-text); }
.hero-donut-wrap { position: relative; width: 168px; height: 168px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.hero-donut-num { font-family: var(--font-display); font-size: 32px; font-weight: 600; color: var(--hero-text); line-height: 1; }
.hero-donut-label { font-size: 11px; color: var(--hero-text-muted); margin-top: 4px; text-align: center; }

/* ---------- KPI cards with icon chip ---------- */
.kpi-card { display: flex; align-items: flex-start; gap: 12px; }
.kpi-chip {
  width: 38px; height: 38px; border-radius: var(--radius-sm); display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.kpi-chip-peach { background: var(--chip-peach-bg); color: var(--chip-peach-fg); }
.kpi-chip-mint { background: var(--chip-mint-bg); color: var(--chip-mint-fg); }
.kpi-chip-blush { background: var(--chip-blush-bg); color: var(--chip-blush-fg); }
.kpi-chip-neutral { background: var(--chip-neutral-bg); color: var(--chip-neutral-fg); }
.kpi-card-label { font-size: 12px; color: var(--text-faint); margin-bottom: 2px; }
.kpi-card-value { font-size: 15.5px; font-weight: 700; color: var(--text); }
.kpi-card-note { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Timeline stepper ---------- */
.stepper { display: flex; align-items: flex-start; gap: 0; overflow-x: auto; padding-bottom: 4px; }
.step { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; width: 130px; text-align: center; position: relative; }
.step-line { position: absolute; top: 19px; left: -50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.step:first-child .step-line { display: none; }
.step-line-fill { position: absolute; top: 19px; left: -50%; width: 100%; height: 2px; background: var(--step-done-bg); z-index: 0; }
.step-circle {
  position: relative; z-index: 1; width: 38px; height: 38px; border-radius: 999px; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 13px; margin-bottom: 10px; font-variant-numeric: tabular-nums;
}
.step-circle.done { background: var(--step-done-bg); color: var(--step-done-fg); }
.step-circle.current { background: var(--step-current-bg); color: var(--step-current-fg); box-shadow: 0 0 0 6px var(--step-current-halo); }
.step-circle.upcoming { background: var(--step-upcoming-bg); color: var(--step-upcoming-fg); }
.step-name { font-size: 12.5px; font-weight: 700; color: var(--text); line-height: 1.3; }
.step-meta { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.step-progress-underline { width: 40px; height: 3px; border-radius: 999px; background: var(--step-current-bg); margin-top: 6px; }

/* ---------- Action list ---------- */
.action-list { display: flex; flex-direction: column; }
.action-item { display: flex; gap: 13px; padding: 15px 0; border-top: 1px solid var(--border); align-items: center; }
.action-list .action-item:first-child { border-top: none; padding-top: 4px; }
.action-thumb {
  width: 54px; height: 54px; border-radius: var(--radius-sm); background: var(--surface-3); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: var(--text-faint); font-weight: 700; font-size: 13px; overflow: hidden;
}
.action-thumb img { width: 100%; height: 100%; object-fit: cover; }
.action-body { flex: 1; min-width: 0; }
.action-title { font-size: 13.5px; font-weight: 700; color: var(--text); }
.action-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Pills / status ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
}
.pill-dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-hold { background: var(--hold-soft); color: var(--hold); }
.pill-accent { background: var(--accent-soft); color: var(--accent-strong); }

/* ---------- Filter row ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.search-input {
  flex: 1; min-width: 160px; padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13px;
}
.chip-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
thead th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint);
  font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2);
  position: sticky; top: 0;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-muted { color: var(--text-muted); font-size: 12px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.thumb { width: 40px; height: 40px; border-radius: 7px; object-fit: cover; background: var(--surface-3); flex-shrink: 0; }
.empty-state { padding: 46px 20px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* ---------- Card list (mobile-friendly alt to table) ---------- */
.item-cards { display: grid; gap: 10px; }
.item-card { display: flex; gap: 12px; padding: 13px 14px; }
.item-card-body { flex: 1; min-width: 0; }
.item-card-title { font-weight: 600; font-size: 13.5px; margin-bottom: 2px; }
.item-card-meta { font-size: 12px; color: var(--text-muted); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.field input[type=text], .field input[type=number], .field input[type=date],
.field input[type=time], .field input[type=email], .field input[type=password],
.field input[type=url], .field input[type=tel], .field input[type=search],
.field textarea, .field select {
  padding: 9px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13.5px; font-family: inherit; width: 100%;
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:disabled, .field textarea:disabled, .field select:disabled {
  background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; opacity: 1;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Client login screen ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px; box-shadow: var(--shadow-md); text-align: center;
}
.login-card .brand-mark-svg { width: 40px; height: 40px; color: var(--accent); }
.login-card .brand-mark-img { width: 52px; height: 52px; border-radius: 12px; object-fit: contain; padding: 4px; }
.login-title { font-family: var(--font-display); font-size: 22px; margin: 0 0 6px; color: var(--text); }
.login-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 18px; line-height: 1.45; }
.login-card .field { text-align: left; margin-bottom: 12px; }
.login-card .banner { text-align: left; margin-bottom: 14px; }

/* ---------- Admin project switcher ---------- */
.project-switcher {
  width: 100%; padding: 9px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 12.5px; font-weight: 600; font-family: inherit;
  cursor: pointer;
}

.image-field { display: flex; align-items: center; gap: 12px; }
.image-preview {
  width: 76px; height: 76px; border-radius: var(--radius-sm); background: var(--surface-2);
  border: 1px dashed var(--border); object-fit: cover; flex-shrink: 0;
}
.image-preview.empty { display: flex; align-items: center; justify-content: center; color: var(--text-faint); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 16, 12, 0.5); display: flex; align-items: flex-end;
  justify-content: center; z-index: 100; padding: 0;
}
@media (min-width: 720px) { .modal-overlay { align-items: center; padding: 24px; } }
.modal {
  background: var(--surface); width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto;
  border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
@media (min-width: 720px) { .modal { border-radius: 16px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow-md); text-align: center; }
.login-tag { font-size: 12.5px; color: var(--text-muted); margin: 6px 0 24px; }
.role-btn {
  display: flex; width: 100%; align-items: center; gap: 12px; text-align: left; padding: 12px 14px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); margin-bottom: 8px; cursor: pointer;
}
.role-btn:hover { border-color: var(--accent); }
.role-avatar { width: 34px; height: 34px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.role-name { font-size: 13.5px; font-weight: 600; }
.role-desc { font-size: 11.5px; color: var(--text-faint); }

/* ---------- Detail sections ---------- */
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 26px 0 10px; }
.section-title:first-child { margin-top: 0; }
.two-col { display: grid; grid-template-columns: 1.3fr 0.9fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
@media (max-width: 560px) { .kv-grid { grid-template-columns: 1fr; } }
.kv-label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.kv-value { font-size: 13.5px; margin-top: 2px; }

.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gallery-tile { position: relative; border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 1; background: var(--surface-2); border: 1px solid var(--border); }
/* display:block matters: an inline image sits on the text baseline and
   leaves a one-pixel strip of tile background showing under it. */
.gallery-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-tile .cat-tag { position: absolute; top: 6px; left: 6px; font-size: 9.5px; font-weight: 700; text-transform: uppercase; background: rgba(255,255,255,0.92); color: #232323; padding: 2px 6px; border-radius: 5px; }
.gallery-tile .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 8px 6px;
  font-size: 10.5px; line-height: 1.35; color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,.72), transparent);
  /* Long drawing names used to be sliced mid-character at the tile edge. */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere;
}
.gallery-tile .cap-edit { position: absolute; top: 6px; right: 6px; }

/* ---- phones ------------------------------------------------------- */

/* Shown only once the menu is open on a small screen. Without it the only
   way out was the thin strip of scrim beside the panel, because the panel
   covers the hamburger that opened it. */
.sidebar-close { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar-mobile { display: flex; }
  .app-topbar { display: none; }
  .main-inner { padding: 18px 14px 60px; }

  .sidebar.open {
    display: flex; position: fixed; inset: 0 14% 0 0; z-index: 50;
    box-shadow: var(--shadow-lg); overflow-y: auto;
  }
  .sidebar-scrim { display: none; }
  .sidebar.open ~ .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; }
  .sidebar.open .sidebar-close {
    display: flex; position: absolute; top: 12px; right: 12px; z-index: 2;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  }
  /* Fingers, not cursors: give the menu rows room to be tapped. */
  .nav-item { padding-top: 11px; padding-bottom: 11px; }

  /* The hero is the tallest thing on the page. Stack it, shrink the ring,
     and let the whole card breathe less so the KPI cards are reachable
     without a long scroll. */
  .hero-card { padding: 22px 20px; border-radius: 18px; gap: 16px; }
  .hero-title { font-size: 26px; }
  .hero-stats { gap: 18px 22px; margin-top: 16px; }
  .hero-donut-wrap { width: 124px; height: 124px; margin: 0 auto; }
  .hero-donut-wrap svg { width: 124px; height: 124px; }
  .hero-donut-num { font-size: 25px; }
  .hero-ring-deco { display: none; }

  /* Two KPI cards side by side at 390px left every value wrapping over
     three lines. One per row reads in a glance instead. */
  .kpi-grid { grid-template-columns: 1fr; margin-bottom: 18px; }
  .kpi-card { align-items: center; }

  .page-title { font-size: 24px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }

  /* A table with seven columns cannot fit; it scrolls in its own box, and
     this makes that obvious rather than leaving the last column cut off. */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  /* Squeezing every column into 390px broke sentences one word per line and
     made rows twelve lines tall. Give the columns a floor and let the box
     scroll instead. */
  table { min-width: 760px; font-size: 12.5px; }
  thead th { white-space: nowrap; }
  tbody td { padding: 10px 12px; }
  th.wide, td.wide { min-width: 230px; }
  .clamp3 {
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
    overflow: hidden; overflow-wrap: anywhere;
  }

  /* The close button sits over the header, so keep the wordmark clear of it. */
  .sidebar.open .brand { padding-right: 52px; }

  /* Safari zooms the whole page in when a field under 16px takes focus, and
     never zooms back out. 16px keeps the layout still while typing. */
  .field input, .field select, .field textarea, .search-input { font-size: 16px; }
  .table-wrap::after {
    content: "Swipe the table sideways to see more →";
    display: block; padding: 8px 14px; font-size: 11px; color: var(--text-faint);
    border-top: 1px solid var(--border); position: sticky; left: 0;
  }
}

@media (max-width: 420px) {
  .hero-title { font-size: 23px; }
  .chip { font-size: 11.5px; }
}

/* Grid and flex children default to min-width:auto, so a wide child (the
   Project Journey stepper, a table, a long file name) stretches its parent
   past the viewport instead of scrolling inside its own box. On a phone that
   showed up as the whole page sliding sideways. */
.grid > *, .two-col > *, .flex-between > *, .form-grid > *, .field, .stack-sm > * { min-width: 0; }
.card { min-width: 0; max-width: 100%; }
.stepper, .table-wrap { max-width: 100%; }
.field input, .field select, .field textarea { max-width: 100%; }

/* ---- Contact & Legal --------------------------------------------- */
.legal-prose {
  font-size: 13px; line-height: 1.65; color: var(--text-muted);
  white-space: pre-wrap; word-break: break-word;
}
.info-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 22px;
}
.info-label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 3px; }
.info-value { font-size: 13.5px; color: var(--text); word-break: break-word; }

.portal-footer {
  margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 11.5px; line-height: 1.7; color: var(--text-faint);
  display: flex; flex-direction: column; gap: 2px;
}
.portal-footer strong { color: var(--text-muted); font-weight: 600; }
.portal-footer a { color: var(--accent-strong); text-decoration: none; }
.portal-footer a:hover { text-decoration: underline; }

/* ---- PDF attachments -------------------------------------------- */
.pdf-field { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pdf-card {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); min-width: 0; max-width: 100%;
}
.pdf-card.empty { color: var(--text-faint); border-style: dashed; background: transparent; }
.pdf-glyph {
  flex: none; width: 38px; height: 46px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid var(--accent-soft-border);
}
.pdf-card.empty .pdf-glyph { background: var(--surface-2); color: var(--text-faint); border-color: var(--border); }
.pdf-meta { min-width: 0; flex: 1; }
.pdf-name { font-size: 13px; font-weight: 600; word-break: break-word; }
.pdf-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; word-break: break-word; }
.pdf-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.pdf-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; margin-left: 6px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .03em;
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid transparent; cursor: pointer; vertical-align: middle;
}
.pdf-chip:hover { border-color: var(--danger); }
.pdf-chip svg { width: 11px; height: 11px; }
.gallery-tile .pdf-badge {
  position: absolute; left: 8px; bottom: 34px;
  padding: 2px 7px; border-radius: 999px; font-size: 10px; font-weight: 700;
  background: rgba(198,67,46,.92); color: #fff; letter-spacing: .04em;
}

.pdf-viewer-overlay {
  position: fixed; inset: 0; z-index: 120; /* above .modal-overlay (100) */
  background: rgba(20,18,16,.72);
  display: flex; align-items: center; justify-content: center; padding: 3vh 2vw;
}
.pdf-viewer {
  background: var(--surface); border-radius: var(--radius);
  width: min(1100px, 100%); height: 100%;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.pdf-viewer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.pdf-viewer-title { font-size: 14px; font-weight: 600; flex: 1; min-width: 0; word-break: break-word; }
.pdf-viewer-body { flex: 1; min-height: 0; background: var(--surface-3); position: relative; }
.pdf-viewer-body object, .pdf-viewer-body iframe, .pdf-viewer-body embed {
  width: 100%; height: 100%; border: 0; display: block;
}
.pdf-viewer-foot {
  padding: 9px 16px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.pdf-fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; text-align: center;
  padding: 24px; color: var(--text-muted); font-size: 13px;
}
@media (max-width: 860px) {
  .pdf-viewer-overlay { padding: 0; }
  .pdf-viewer { border-radius: 0; height: 100%; }
}

.hidden { display: none !important; }
.helper-text { font-size: 11.5px; color: var(--text-faint); }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: none; }
.text-right { text-align: right; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* The full logo lockup on the sign-in screens. Transparent PNG, so it
   sits on either theme without a white plate behind it. */
.login-logo {
  display: block; width: 132px; height: auto; margin: 0 auto 10px;
}

/* The sidebar mark keeps its own transparency too - no cover-cropping,
   or the wordmark gets sliced. */
.brand-mark-img {
  object-fit: contain; background: transparent; border: none;
}

/* ---- boot splash -------------------------------------------------- */
.boot-splash {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); font-size: 14px; background: var(--bg);
}
.hero-next { margin-top: 14px; }
