:root {
  --brand-navy: #2d3192;
  --brand-navy-hover: #23266f;
  --brand-navy-soft: #eceefa;
  --brand-red: #ec1f24;
  --cta: #d71920;
  --cta-hover: #b9151b;
  --heading: #000033;
  --on-navy: #ffffff;
  --on-navy-2: #d6d8f0;
  --on-navy-hover: rgba(255, 255, 255, 0.12);
  --on-navy-line: rgba(255, 255, 255, 0.28);

  --bg: #f6f8f5;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e3e6f1;
  --border: #dfe2ea;
  --border-strong: #c3c8d6;
  --text: #242424;
  --text-2: #4d5260;
  --text-3: #686d7a;
  --accent: var(--brand-navy);
  --accent-hover: var(--brand-navy-hover);
  --accent-soft: var(--brand-navy-soft);
  --accent-text: #ffffff;
  --ok: #1d7444;
  --ok-soft: #e5f3eb;
  --warn: #8a5000;
  --warn-soft: #fdf3e1;
  --warn-border: #f1d9ad;
  --danger: #b3261e;
  --danger-hover: #931f18;
  --danger-soft: #fcebea;
  --info-border: #cfd2ef;
  --c-sheet: #1e8a3e;
  --c-pdf: #d71920;
  --c-other: #6b7180;
  --c-folder: #5357b5;
  --icon-inner: #ffffff;
  --g-blue: #4285f4;
  --g-green: #34a853;
  --g-yellow: #fbbc05;
  --g-red: #ea4335;
  --focus: var(--brand-navy);
  --overlay: rgba(0, 0, 51, 0.45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 51, 0.06);
  --shadow: 0 4px 16px rgba(0, 0, 51, 0.08), 0 1px 3px rgba(0, 0, 51, 0.06);
  --shadow-lg: 0 18px 48px rgba(0, 0, 51, 0.18), 0 2px 8px rgba(0, 0, 51, 0.08);

  --font: "Lato", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Forum", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs: 15px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 28px;
  --fs-label: 14px;
  --fs-2xs: 11px;
  --fs-brand-sm: 17px;
  --fs-modal: 24px;
  --fs-hero: 30px;
  --lh: 1.55;
  --fw-medium: 700;
  --fw-bold: 700;
  --tracking-caps: 0.04em;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --gutter: var(--sp-5);
  --indent: 16px;

  --r-sm: 3px;
  --r: 4px;
  --r-lg: 8px;
  --r-pill: 999px;

  --utility-h: 36px;
  --topbar-h: 76px;
  --logo-h: 52px;
  --logo-h-sm: 30px;
  --sidebar-w: 272px;
  --control-h: 38px;
  --control-h-sm: 32px;
  --icon: 18px;
  --modal-w: 520px;
  --modal-wide-w: 960px;
  --menu-w: 220px;
  --t-fast: 120ms ease;
  --z-sticky: 10;
  --z-drawer: 40;
  --z-menu: 60;
  --z-modal: 80;
  --z-toast: 100;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { color: var(--heading); }
h1 { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 400; line-height: 1.2; }
h2 { font-size: var(--fs-lg); font-weight: var(--fw-bold); line-height: 1.3; }
h3 { font-size: var(--fs-md); font-weight: var(--fw-bold); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
strong, b { font-weight: var(--fw-bold); }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
h1:focus-visible { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--sp-3); top: -100px; z-index: var(--z-toast);
  background: var(--surface); padding: var(--sp-2) var(--sp-3); border-radius: var(--r); box-shadow: var(--shadow);
}
.skip-link:focus { top: var(--sp-3); }

.ico { width: var(--icon); height: var(--icon); flex: none; }
.ico-sm { width: 14px; height: 14px; }
.ico-in { fill: none; stroke: var(--icon-inner); stroke-width: 1.4; stroke-linecap: round; }
.ico-sheet { color: var(--c-sheet); }
.ico-pdf { color: var(--c-pdf); }
.ico-other { color: var(--c-other); }
.ico-folder { color: var(--c-folder); }
.ico-file, .ico-folder { width: 20px; height: 20px; }

/* ---------- utilities shared with FEATURES ---------- */
.muted { color: var(--text-2); }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.row-tight { gap: var(--sp-1); }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }
.plain-list { padding-left: var(--sp-5); list-style: disc; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.card-head h2 { font-family: var(--font-display); font-weight: 400; font-size: var(--fs-lg); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--control-h); padding: 0 var(--sp-4);
  border: 1px solid var(--accent); border-radius: var(--r);
  background: var(--surface); color: var(--accent);
  font-weight: var(--fw-bold); font-size: var(--fs-label); line-height: 1.2; white-space: nowrap;
  cursor: pointer; text-decoration: none; user-select: none;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.btn:hover { background: var(--accent-soft); text-decoration: none; }
.btn:active { background: var(--surface-3); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface); }
.btn .ico { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover, .btn-primary:active { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled:hover { background: var(--accent); }
.btn-cta { background: var(--cta); border-color: var(--cta); color: var(--accent-text); }
.btn-cta:hover, .btn-cta:active { background: var(--cta-hover); border-color: var(--cta-hover); }
.btn-cta:disabled:hover { background: var(--cta); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--accent-text); }
.btn-danger:hover, .btn-danger:active { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-danger:disabled:hover { background: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--accent); }
.btn-ghost:disabled:hover { background: transparent; }
.btn-ghost.text-danger { color: var(--danger); }
.btn-ghost.text-danger:hover { background: var(--danger-soft); }
.btn-sm { min-height: var(--control-h-sm); padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn-caps { text-transform: uppercase; letter-spacing: var(--tracking-caps); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--control-h); height: var(--control-h); padding: 0;
  border: 0; border-radius: var(--r); background: transparent; color: var(--accent); cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); }
.btn.icon-btn { width: var(--control-h-sm); min-height: var(--control-h-sm); height: var(--control-h-sm); border-color: transparent; background: transparent; color: var(--text-2); }
.btn.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; border: 0; margin: 0; padding: 0; }
.field > label, .field > .label, .field > legend { font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--heading); padding: 0; }
.field-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.field-row > * { flex: 1 1 160px; }
.field-hint { font-size: var(--fs-xs); color: var(--text-2); }
.field-hint:empty, .field-error:empty { display: none; }
.field-error { font-size: var(--fs-sm); color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-height: var(--control-h); padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface);
  font-size: var(--fs); line-height: 1.3;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--text-2); }
.input-sm { min-height: var(--control-h-sm); padding: var(--sp-1) var(--sp-2); font-size: var(--fs-sm); }
.textarea { min-height: 80px; resize: vertical; }
.select { appearance: auto; padding-right: var(--sp-2); }
.checks { gap: var(--sp-2); }
.check { display: flex; align-items: center; gap: var(--sp-2); cursor: pointer; }
.check input, .col-check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

/* ---------- badges, banners, progress, empty ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 1px var(--sp-2); border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent);
  font-size: var(--fs-xs); font-weight: var(--fw-bold); line-height: 1.6; white-space: nowrap; vertical-align: middle;
  text-transform: uppercase; letter-spacing: var(--tracking-caps);
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r);
  border: 1px solid var(--border); border-left-width: 4px; background: var(--surface); color: var(--text);
}
.banner > div:first-child { flex: 1 1 260px; }
.banner-warn { background: var(--warn-soft); border-color: var(--warn-border); border-left-color: var(--brand-red); }
.banner-info { background: var(--accent-soft); border-color: var(--info-border); border-left-color: var(--accent); }
.banner-sm { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); }

.progress { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 300ms ease; }
.progress[data-tone="ok"] > span { background: var(--ok); }
.progress[data-tone="error"] > span { background: var(--danger); }

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2);
  padding: var(--sp-7) var(--sp-4); border: 1px dashed var(--border-strong); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text-2);
}
.empty-ico .ico { width: 40px; height: 40px; color: var(--border-strong); }
.empty-title { color: var(--heading); font-family: var(--font-display); font-size: var(--fs-lg); }
.empty-actions { margin-top: var(--sp-2); flex-wrap: wrap; justify-content: center; }

.loading { padding: var(--sp-6) var(--sp-4); color: var(--text-2); text-align: center; }

/* ---------- tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs); }
.table th, .table td { padding: var(--sp-2) var(--sp-3); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table th {
  font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--accent); background: var(--surface-2);
  white-space: nowrap; text-transform: uppercase; letter-spacing: var(--tracking-caps);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-selected { background: var(--accent-soft); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap > .table th:first-child, .table-wrap > .table td:first-child { padding-left: var(--sp-4); }
.table-wrap > .table th:last-child, .table-wrap > .table td:last-child { padding-right: var(--sp-4); }

.th-sort {
  display: inline-flex; align-items: center; gap: var(--sp-1); padding: var(--sp-1) 0; border: 0; background: none;
  font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer;
}
.th-sort:hover, .th-sort.is-active { color: var(--heading); }
.sort-dir { font-size: var(--fs-xs); }

.files .col-name { width: 100%; min-width: 0; }
.files .col-date, .files .col-mod, .files .col-size { white-space: nowrap; color: var(--text-2); }
.files .col-size, .files th.col-size { text-align: right; }
.files .col-act { width: 1%; white-space: nowrap; text-align: right; }
.files .col-check { width: 1%; }
.name-cell { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.name-text { min-width: 0; flex: 1; }
.name-line { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.file-link, .file-name { color: var(--heading); font-weight: var(--fw-bold); overflow-wrap: anywhere; }
.file-link:hover { color: var(--accent); }
.cell-sub { font-size: var(--fs-xs); color: var(--text-2); overflow-wrap: anywhere; }
.cell-sub:empty { display: none; }
.cell-path { display: block; }
.cell-by { font-size: var(--fs-xs); }
.show-sm { display: none; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-rows: auto 1fr; height: 100vh; height: 100dvh; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm); z-index: var(--z-sticky); }

.utility {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  min-height: var(--utility-h); padding: 0 var(--gutter);
  background: var(--brand-navy); color: var(--on-navy); font-size: var(--fs-sm);
}
.utility-left { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.utility-tag { color: var(--on-navy-2); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: var(--tracking-caps); font-size: var(--fs-xs); white-space: nowrap; }
.utility-badge {
  padding: 0 var(--sp-2); border: 1px solid var(--on-navy-line); border-radius: var(--r-sm);
  color: var(--on-navy); font-size: var(--fs-xs); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: var(--tracking-caps); white-space: nowrap;
}
.utility-login { min-height: 6px; }

.topbar-main {
  display: flex; align-items: center; gap: var(--sp-3) var(--sp-5); flex-wrap: wrap;
  min-height: var(--topbar-h); padding: var(--sp-2) var(--gutter);
}
.menu-btn { display: none; }
.brand { display: flex; align-items: center; gap: var(--sp-4); color: var(--heading); white-space: nowrap; flex: none; }
.brand:hover { text-decoration: none; }
.brand picture { display: block; flex: none; }
.brand-logo { height: var(--logo-h); width: auto; }
.brand-name {
  font-family: var(--font-display); font-size: var(--fs-lg); color: var(--heading); line-height: 1.15;
  padding-left: var(--sp-4); border-left: 1px solid var(--border-strong);
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--r); background: var(--accent); color: var(--surface);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-mark .ico-in { stroke: var(--accent); }
.brand-mark-lg { width: 48px; height: 48px; border-radius: var(--r-lg); }
.brand-mark-lg svg { width: 32px; height: 32px; }

.search {
  flex: 1 1 240px; min-width: 200px; max-width: 560px; display: flex; align-items: center; gap: var(--sp-2);
  min-height: var(--control-h); padding: 0 var(--sp-1) 0 var(--sp-3);
  border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-ico { color: var(--accent); }
.search-input { flex: 1; min-width: 0; border: 0; background: transparent; padding: var(--sp-2) 0; outline: none; }
.search-input::placeholder { color: var(--text-3); }
.search-input::-webkit-search-cancel-button { cursor: pointer; }
.search-opt {
  display: flex; align-items: center; gap: var(--sp-1); padding: var(--sp-1) var(--sp-2);
  font-size: var(--fs-xs); color: var(--text-2); white-space: nowrap; cursor: pointer; border-radius: var(--r-sm);
}
.search-opt:hover { background: var(--surface-2); color: var(--accent); }
.search-opt input { margin: 0; accent-color: var(--accent); }

.user { margin-left: auto; min-width: 0; }
.user-btn {
  display: flex; align-items: center; gap: var(--sp-2); max-width: 100%; min-height: 28px; padding: 2px var(--sp-2) 2px 2px;
  border: 0; border-radius: var(--r); background: transparent; cursor: pointer; color: var(--on-navy);
}
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--on-navy-hover); }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%; object-fit: cover;
  background: var(--surface); color: var(--brand-navy); font-weight: var(--fw-bold); font-size: var(--fs-xs);
}
.user-text { display: flex; align-items: baseline; gap: var(--sp-1); min-width: 0; line-height: 1.25; text-align: left; }
.user-name { color: var(--on-navy-2); font-size: var(--fs-xs); white-space: nowrap; }
.user-email { color: var(--on-navy); font-weight: var(--fw-bold); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role {
  padding: 0 var(--sp-1); border-radius: var(--r-sm); background: var(--cta); color: var(--on-navy);
  font-size: var(--fs-2xs); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: var(--tracking-caps);
}
.user-btn .ico { color: var(--on-navy-2); }

.actionbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-left: auto; }
.actionbar .btn { font-size: var(--fs-label); text-transform: uppercase; letter-spacing: var(--tracking-caps); padding: 0 var(--sp-3); }

.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 0; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; padding: var(--sp-3) var(--sp-2) var(--sp-6);
}
.sidebar-head { display: none; }
.main { position: relative; overflow-y: auto; min-width: 0; }
.view { padding: var(--sp-5) var(--gutter) var(--sp-7); max-width: 1400px; display: flex; flex-direction: column; gap: var(--sp-4); }
.view:focus { outline: none; }
.scrim { display: none; }

/* sidebar navigation */
.nav-section + .nav-section { margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.nav-heading { padding: var(--sp-1) var(--sp-3) var(--sp-2); font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-3); text-transform: uppercase; letter-spacing: var(--tracking-caps); }
.nav-note { padding: var(--sp-1) var(--sp-3) var(--sp-2) calc(var(--sp-3) + 24px); font-size: var(--fs-xs); color: var(--text-2); }
.tree-row {
  position: relative; display: flex; align-items: center; gap: 2px;
  padding-left: calc(var(--sp-1) + var(--depth, 0) * var(--indent));
  border-radius: var(--r); min-height: 34px;
}
.tree-row:hover { background: var(--surface-2); }
.tree-row.is-active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.tree-row.is-active .tree-link { color: var(--accent); font-weight: var(--fw-bold); }
.tree-toggle, .tree-spacer { flex: none; width: 22px; height: 22px; }
.tree-toggle {
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-3); cursor: pointer;
}
.tree-toggle:hover { background: var(--surface-3); color: var(--accent); }
.tree-toggle .ico { width: 14px; height: 14px; transition: transform var(--t-fast); }
.tree-toggle.is-open .ico { transform: rotate(90deg); }
.tree-link {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-1); color: var(--text); font-size: var(--fs);
}
.tree-link:hover { text-decoration: none; color: var(--accent); }
.tree-link .ico { width: 18px; height: 18px; color: var(--accent); }
.tree-link .ico-folder { color: var(--c-folder); }
.tree-link.is-static { cursor: default; }
.tree-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-more {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; margin-right: 2px; padding: 0; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-2); cursor: pointer; opacity: 0;
}
.tree-more:hover { background: var(--surface-3); color: var(--accent); }
.tree-row:hover .tree-more, .tree-more:focus-visible, .tree-more[aria-expanded="true"], .tree-row.is-active .tree-more { opacity: 1; }
.tree-new { padding: var(--sp-1) var(--sp-2) var(--sp-1) calc(var(--sp-1) + var(--depth, 1) * var(--indent) + 24px); }
.tree-new-hint { font-size: var(--fs-xs); color: var(--warn); }
.tree-new-hint:empty { display: none; }

.nav-link {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r); color: var(--heading); min-height: 38px;
  font-size: var(--fs-sm); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: var(--tracking-caps);
}
.nav-link .ico { color: var(--accent); }
.nav-link:hover { background: var(--surface-2); color: var(--accent); text-decoration: none; }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }

/* view header */
.view-head { display: flex; flex-direction: column; gap: var(--sp-2); }
.crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--text-2); }
.crumbs li { display: flex; align-items: center; gap: var(--sp-1); min-width: 0; }
.crumbs li + li::before { content: "/"; color: var(--text-3); }
.crumbs a { color: var(--accent); }
.crumbs [aria-current] { color: var(--heading); font-weight: var(--fw-bold); }
.view-title-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.view-title-row h1 { overflow-wrap: anywhere; }
.view-actions { flex-wrap: wrap; }
.view-sub { max-width: 72ch; }
.section-title { font-family: var(--font-display); font-weight: 400; font-size: var(--fs-lg); margin-top: var(--sp-2); }
.banners { gap: var(--sp-2); }

/* settings */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--sp-4); align-items: start; }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* drop overlay */
.drop-overlay {
  position: absolute; inset: var(--sp-3); display: none; align-items: center; justify-content: center;
  border: 2px dashed var(--accent); border-radius: var(--r-lg); background: var(--accent-soft);
  pointer-events: none; z-index: var(--z-sticky);
}
.drop-box { font-family: var(--font-display); font-size: var(--fs-xl); color: var(--accent); }
.main.is-dragging .drop-overlay { display: flex; }

/* folder picker */
.picker-box { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r); padding: var(--sp-1); background: var(--surface); }
.picker { display: flex; flex-direction: column; }
.picker-item {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%; text-align: left;
  min-height: 34px; padding: var(--sp-1) var(--sp-2) var(--sp-1) calc(var(--sp-2) + var(--depth, 0) * var(--indent));
  border: 0; border-radius: var(--r-sm); background: transparent; cursor: pointer; color: var(--text);
}
.picker-item:hover { background: var(--surface-2); }
.picker-item.is-selected { background: var(--accent-soft); color: var(--accent); font-weight: var(--fw-bold); box-shadow: inset 3px 0 0 var(--accent); }
.picker-item .ico { color: var(--accent); }
.picker-item .ico-folder { color: var(--c-folder); }
.picker-name { overflow-wrap: anywhere; }
.picker-note { font-size: var(--fs-xs); font-weight: normal; }
.cx-picker { margin-top: var(--sp-2); max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r); padding: var(--sp-1); }
.path-box {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--info-border); border-radius: var(--r); background: var(--accent-soft);
}
.path-box strong { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--heading); }

/* upload list */
.upload-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.upload-item { display: flex; flex-direction: column; gap: var(--sp-1); }
.upload-top { display: flex; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-sm); }
.upload-name { font-weight: var(--fw-bold); overflow-wrap: anywhere; min-width: 0; }
.upload-status { flex: none; max-width: 55%; text-align: right; }

/* ---------- menu ---------- */
.menu {
  position: fixed; z-index: var(--z-menu); min-width: var(--menu-w); max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px); overflow-y: auto;
  padding: var(--sp-1); background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--accent);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
}
.menu-item {
  display: flex; align-items: center; width: 100%; min-height: 34px; padding: var(--sp-1) var(--sp-3);
  border: 0; border-radius: var(--r-sm); background: transparent; text-align: left; cursor: pointer; color: var(--text);
}
.menu-item:hover, .menu-item:focus-visible { background: var(--accent-soft); color: var(--accent); outline: none; }
.menu-item:disabled { color: var(--text-3); cursor: not-allowed; background: transparent; }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger:hover, .menu-item.is-danger:focus-visible { background: var(--danger-soft); color: var(--danger); }
.menu-sep { height: 1px; margin: var(--sp-1) 0; background: var(--border); }
.menu-header { display: flex; flex-direction: column; padding: var(--sp-1) var(--sp-3); font-size: var(--fs-sm); overflow-wrap: anywhere; color: var(--heading); }
.menu-header .muted { font-size: var(--fs-xs); }

/* ---------- modal (markup from ui.js) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center; padding: var(--sp-5) var(--sp-4);
  background: var(--overlay);
  animation: fade-in 120ms ease;
}
.modal {
  display: flex; flex-direction: column; width: 100%; max-width: var(--modal-w); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
  background: var(--surface); border-radius: var(--r-lg); border-top: 4px solid var(--accent); box-shadow: var(--shadow-lg); overflow: hidden;
  animation: rise-in 160ms ease;
}
.modal-wide { max-width: var(--modal-wide-w); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); flex: none;
}
.modal-head h2 { font-family: var(--font-display); font-weight: 400; font-size: var(--fs-modal); overflow-wrap: anywhere; min-width: 0; }
.modal-close { flex: none; width: var(--control-h-sm); padding: 0; }
.modal-body { flex: 1 1 auto; overflow-y: auto; padding: var(--sp-4) var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); }
.modal-body > p { overflow-wrap: anywhere; }
.modal-foot {
  position: sticky; bottom: 0; flex: none;
  display: flex; justify-content: flex-end; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); background: var(--surface-2);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- toast (markup from ui.js) ---------- */
.toast-wrap {
  position: fixed; z-index: var(--z-toast); right: var(--sp-4); bottom: var(--sp-4);
  display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-2);
  max-width: calc(100vw - 32px); pointer-events: none;
}
.toast {
  pointer-events: auto; max-width: 420px; padding: var(--sp-3) var(--sp-4);
  background: var(--heading); color: var(--on-navy); border-radius: var(--r); box-shadow: var(--shadow-lg);
  font-size: var(--fs); overflow-wrap: anywhere; animation: rise-in 160ms ease;
  border-left: 4px solid var(--accent);
}
.toast a { color: inherit; font-weight: var(--fw-bold); text-decoration: underline; }
.toast-success { border-left-color: var(--g-green); }
.toast-error { border-left-color: var(--brand-red); }
.toast-info { border-left-color: var(--on-navy-2); }

/* ---------- login ---------- */
.login-page { display: flex; flex-direction: column; min-height: 100%; }
.login-wrap {
  margin: auto; width: 100%; max-width: 440px; padding: var(--sp-6) var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-4);
}
.login-card { display: flex; flex-direction: column; gap: var(--sp-4); padding: var(--sp-6) var(--sp-5); border-top: 4px solid var(--accent); }
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2); }
.login-logo { width: 176px; height: auto; }
.login-brand h1 { margin-top: var(--sp-3); font-size: var(--fs-hero); }
.btn-google {
  min-height: 48px; width: 100%; font-size: var(--fs-label); text-transform: uppercase; letter-spacing: var(--tracking-caps);
}
.g-chip { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface); }
.g-chip .ico { width: 18px; height: 18px; }
.g-blue { fill: var(--g-blue); }
.g-green { fill: var(--g-green); }
.g-yellow { fill: var(--g-yellow); }
.g-red { fill: var(--g-red); }
.login-alt { text-align: center; font-size: var(--fs-sm); }
.login-foot { text-align: center; font-size: var(--fs-sm); }
.dev-login { padding-top: var(--sp-4); border-top: 1px dashed var(--border-strong); }
.dev-login .row .input { flex: 1; }

/* ---------- responsive ---------- */
@media (hover: none) {
  .tree-more { opacity: 1; }
}

@media (max-width: 1400px) {
  .search { order: 3; flex: 1 1 100%; max-width: none; }
}

@media (max-width: 900px) {
  :root { --gutter: var(--sp-4); --logo-h: 40px; }
  .menu-btn { display: inline-flex; margin-left: calc(var(--sp-2) * -1); }
  .actionbar { order: 4; margin-left: 0; width: 100%; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: var(--z-drawer);
    width: min(var(--sidebar-w), 86vw); padding-top: 0;
    transform: translateX(-100%); transition: transform 200ms ease; visibility: hidden;
    box-shadow: var(--shadow-lg);
  }
  .drawer-open .sidebar { transform: none; visibility: visible; }
  .sidebar-head {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 1; background: var(--brand-navy); color: var(--on-navy);
    min-height: 56px; padding: 0 var(--sp-2) 0 var(--sp-4); margin: 0 calc(var(--sp-2) * -1) var(--sp-2);
    font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: var(--tracking-caps); font-size: var(--fs-label);
  }
  .sidebar-head .icon-btn { color: var(--on-navy); }
  .sidebar-head .icon-btn:hover { background: var(--on-navy-hover); }
  .scrim { display: block; position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1); background: var(--overlay); }
  .scrim[hidden] { display: none !important; }
  .tree-more { opacity: 1; }
}

@media (max-width: 640px) {
  :root { --logo-h: var(--logo-h-sm); --fs-xl: 24px; }
  .app { display: block; height: auto; min-height: 100%; }
  .main { overflow: visible; }
  .utility-tag { display: none; }
  .user-name { display: none; }
  .topbar-main { gap: var(--sp-2) var(--sp-3); padding-top: var(--sp-2); padding-bottom: var(--sp-3); min-height: 0; }
  .brand { gap: var(--sp-3); }
  .brand-name { font-size: var(--fs-brand-sm); padding-left: var(--sp-3); }
  .search { flex-wrap: wrap; padding: 0 var(--sp-1) 0 var(--sp-3); }
  .search-input { flex: 1 1 50%; }
  .actionbar { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--sp-2); }
  .actionbar .btn { min-height: var(--control-h-sm); padding: 0 var(--sp-2); font-size: var(--fs-xs); grid-column: span 2; }
  .actionbar [data-cmd="invoice"], .actionbar [data-cmd="excel"] { grid-column: span 3; order: -1; }
  .actionbar [data-cmd="invoice"] { order: -2; }
  .view { padding-top: var(--sp-4); }
  .hide-sm { display: none; }
  .show-sm { display: inline; }
  .table th, .table td { padding: var(--sp-2); }
  .table-wrap > .table th:first-child, .table-wrap > .table td:first-child { padding-left: var(--sp-3); }
  .table-wrap > .table th:last-child, .table-wrap > .table td:last-child { padding-right: var(--sp-2); }
  .card { padding: var(--sp-4); }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .field-row > * { flex-basis: 100%; }

  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal, .modal-wide { max-width: none; max-height: none; height: 100%; border-radius: 0; }
  .modal-head { padding: var(--sp-3) var(--sp-4); }
  .modal-body { padding: var(--sp-4); }
  .modal-foot { padding: var(--sp-3) var(--sp-4); }
  .modal-foot .btn { flex: 1 1 auto; }

  .toast-wrap { left: var(--sp-4); right: var(--sp-4); align-items: stretch; }
  .toast { max-width: none; }
  .login-card { padding: var(--sp-5) var(--sp-4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
