/* ============================================================
   FILEBOUND — Document Management System
   Design system: quiet paper, deep ledger-blue, mono metadata
   ============================================================ */

:root {
  /* --- Palette --- */
  --paper:        #FAFAF8;
  --paper-dim:     #F3F2EE;
  --surface:       #FFFFFF;
  --line:          #E7E5DF;
  --line-strong:   #D8D5CC;

  --ink:           #1E1D1B;
  --ink-soft:      #57544C;
  --ink-faint:     #928F85;

  --ledger:        #223A5E;   /* deep ledger blue — primary accent   */
  --ledger-700:    #1A2D48;
  --ledger-100:    #E7ECF3;

  --sage:          #6E8F72;   /* filed / active / success            */
  --sage-100:      #E9F0E9;

  --amber:         #B8791A;   /* pending / needs review               */
  --amber-100:     #F6EBD8;

  --brick:         #A3432D;   /* overdue / danger                     */
  --brick-100:     #F3E4E0;

  --tab-a: #C9A66B; /* folder tab accent colors, rotate across folders */
  --tab-b: #8CA3B0;
  --tab-c: #A98FA0;
  --tab-d: #8FAE8A;

  /* --- Type --- */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  /* --- Layout --- */
  --sidebar-w: 248px;
  --topbar-h: 68px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 2px rgba(30,29,27,0.04), 0 1px 0 rgba(30,29,27,0.03);
  --shadow-pop: 0 12px 32px rgba(30,29,27,0.12), 0 2px 8px rgba(30,29,27,0.06);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
body { min-height: 100vh; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }

:focus-visible {
  outline: 2px solid var(--ledger);
  outline-offset: 2px;
}

/* ============ App shell ============ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ============ Sidebar ============ */
.sidebar {
  background: var(--ledger-700);
  color: #E9EEF5;
  padding: 22px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 22px;
  border-bottom: 1px solid rgba(233,238,245,0.12);
  margin-bottom: 14px;
}
.sidebar-brand .mark {
  width: 30px; height: 30px;
  border-radius: 7px;
  background: linear-gradient(155deg, var(--tab-a), var(--amber));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand .mark svg { width: 16px; height: 16px; stroke: var(--ledger-700); }
.sidebar-brand .word {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
}
.sidebar-brand .word small {
  display: block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: #A9BAD1;
  font-weight: 500;
  text-transform: uppercase;
  margin-top: 1px;
}

.nav-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8296B2;
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: #C7D3E3;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item svg { width: 17px; height: 17px; stroke-width: 1.8; flex-shrink: 0; opacity: 0.9; }
.nav-item:hover { background: rgba(233,238,245,0.08); color: #fff; }
.nav-item.active {
  background: #fff;
  color: var(--ledger-700);
  font-weight: 600;
}
.nav-item.active svg { stroke: var(--ledger-700); opacity: 1; }
.nav-item .count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: rgba(233,238,245,0.14);
  padding: 1px 6px;
  border-radius: 20px;
  color: #C7D3E3;
}
.nav-item.active .count { background: var(--ledger-100); color: var(--ledger-700); }

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(233,238,245,0.12);
}
.storage-meter {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(233,238,245,0.07);
}
.storage-meter .label {
  font-size: 11px; color: #A9BAD1; margin-bottom: 7px;
  display: flex; justify-content: space-between;
  font-family: var(--font-mono);
}
.storage-meter .bar {
  height: 5px; border-radius: 4px; background: rgba(233,238,245,0.14); overflow: hidden;
}
.storage-meter .bar span {
  display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--tab-a), var(--amber));
}

/* ============ Main column ============ */
.main-col { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  gap: 20px;
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--ink-faint);
}
.topbar-search svg { width: 15px; height: 15px; stroke-width: 2; flex-shrink: 0; }
.topbar-search input {
  border: none; outline: none; background: transparent; width: 100%;
  font-size: 13px; color: var(--ink); font-family: var(--font-body);
}
.topbar-search kbd {
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint);
  background: var(--paper-dim); padding: 2px 5px; border-radius: 4px; border: 1px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 18px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid transparent;
  display: flex; align-items: center; justify-content: center; background: none;
  color: var(--ink-soft); position: relative;
}
.icon-btn:hover { background: var(--paper-dim); border-color: var(--line); }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.8; }
.icon-btn .dot {
  position: absolute; top: 6px; right: 7px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--brick); border: 1.5px solid var(--paper);
}
.topbar-user { display: flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1px solid var(--line); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--ledger-100); color: var(--ledger-700);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; font-family: var(--font-display);
  flex-shrink: 0;
}
.topbar-user .who { line-height: 1.25; }
.topbar-user .who .name { font-size: 12.5px; font-weight: 600; }
.topbar-user .who .role { font-size: 10.5px; color: var(--ink-faint); font-family: var(--font-mono); }

.content { padding: 28px 32px 60px; flex: 1; }
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; gap: 20px; flex-wrap: wrap;
}
.eyebrow {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 6px; display: block;
}
.page-head h1 { font-size: 26px; color: var(--ink); }
.page-head .sub { color: var(--ink-soft); font-size: 13.5px; margin-top: 6px; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; transition: all .15s ease;
}
.btn svg { width: 15px; height: 15px; stroke-width: 2; }
.btn-primary { background: var(--ledger); color: #fff; }
.btn-primary:hover { background: var(--ledger-700); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--ink-faint); }
.btn-ghost { background: none; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--paper-dim); }
.btn-sm { padding: 6px 11px; font-size: 12px; }

/* ============ Cards / grids ============ */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { padding: 18px 20px; }
.stat-card .top-row { display: flex; justify-content: space-between; align-items: flex-start; }
.stat-card .icon-chip {
  width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
}
.stat-card .icon-chip svg { width: 17px; height: 17px; stroke-width: 1.8; }
.stat-card .value { font-family: var(--font-display); font-size: 30px; margin-top: 14px; }
.stat-card .label { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }
.stat-card .delta { font-family: var(--font-mono); font-size: 11px; margin-top: 10px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 20px; }
.delta.up { background: var(--sage-100); color: var(--sage); }
.delta.down { background: var(--brick-100); color: var(--brick); }
.delta.flat { background: var(--paper-dim); color: var(--ink-faint); }

.two-col { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; align-items: start; }

.card-head {
  padding: 18px 20px 0; display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;
}
.card-head h3 { font-size: 15.5px; }
.card-head .link { font-size: 12px; color: var(--ledger); font-weight: 600; }

/* ============ Folder grid (signature element) ============ */
.folder-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.folder-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 16px 16px 14px; position: relative; overflow: hidden; box-shadow: var(--shadow-card);
  transition: transform .15s ease, box-shadow .15s ease;
}
.folder-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
.folder-card .tab {
  position: absolute; top: 0; left: 18px; width: 40px; height: 6px; border-radius: 0 0 4px 4px;
}
.folder-card .row-top { display: flex; justify-content: space-between; align-items: flex-start; margin-top: 6px; }
.folder-card .fico {
  width: 38px; height: 32px; border-radius: 4px 8px 8px 8px; display: flex; align-items: center; justify-content: center;
}
.folder-card .fico svg { width: 18px; height: 18px; stroke-width: 1.7; color: #fff; }
.folder-card h4 { font-size: 14px; margin-top: 14px; }
.folder-card .meta { font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); margin-top: 4px; }

/* ============ Table ============ */
.table-wrap { overflow-x: auto; }
table.doc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.doc-table th {
  text-align: left; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600; padding: 10px 20px; border-bottom: 1px solid var(--line);
  background: var(--paper-dim);
}
table.doc-table th:first-child { border-top-left-radius: var(--radius-md); }
table.doc-table th:last-child { border-top-right-radius: var(--radius-md); }
table.doc-table td { padding: 13px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.doc-table tr:last-child td { border-bottom: none; }
table.doc-table tr:hover td { background: var(--paper-dim); }
.file-cell { display: flex; align-items: center; gap: 10px; }
.file-ico { width: 30px; height: 30px; border-radius: 6px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.file-ico svg { width: 15px; height: 15px; stroke-width: 1.8; color: #fff; }
.file-name { font-weight: 600; font-size: 13px; }
.file-sub { font-size: 11px; color: var(--ink-faint); font-family: var(--font-mono); margin-top: 1px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.03em;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; }
.badge.filed { background: var(--sage-100); color: var(--sage); }
.badge.filed::before { background: var(--sage); }
.badge.review { background: var(--amber-100); color: var(--amber); }
.badge.review::before { background: var(--amber); }
.badge.draft { background: var(--paper-dim); color: var(--ink-faint); }
.badge.draft::before { background: var(--ink-faint); }
.badge.overdue { background: var(--brick-100); color: var(--brick); }
.badge.overdue::before { background: var(--brick); }

.avatars-mini { display: flex; }
.avatars-mini .avatar { width: 24px; height: 24px; font-size: 10px; margin-left: -7px; border: 2px solid var(--surface); }
.avatars-mini .avatar:first-child { margin-left: 0; }

/* ============ Forms ============ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 11px; color: var(--ink-faint); }
.field input, .field select, .field textarea {
  padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 13px;
  font-family: var(--font-body); background: var(--surface); color: var(--ink); outline: none;
  transition: border-color .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ledger); }
.field textarea { resize: vertical; min-height: 80px; }

.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--ledger); }

.toggle { position: relative; width: 38px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle .track { position: absolute; inset: 0; background: var(--line-strong); border-radius: 20px; transition: .15s; cursor: pointer; }
.toggle .track::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.toggle input:checked + .track { background: var(--sage); }
.toggle input:checked + .track::before { transform: translateX(16px); }

/* ============ Upload dropzone ============ */
.dropzone {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg); padding: 44px 24px;
  text-align: center; background: var(--paper-dim);
}
.dropzone .icon-wrap {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px; background: var(--ledger-100);
  display: flex; align-items: center; justify-content: center;
}
.dropzone .icon-wrap svg { width: 24px; height: 24px; stroke-width: 1.6; color: var(--ledger); }
.dropzone h4 { font-size: 15px; margin-bottom: 5px; }
.dropzone p { font-size: 12.5px; color: var(--ink-soft); }

/* ============ Version timeline ============ */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 1.5px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 22px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ''; position: absolute; left: -26px; top: 3px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--ledger);
}
.tl-item.current::before { background: var(--ledger); }
.tl-item .tl-top { display: flex; justify-content: space-between; align-items: center; }
.tl-item .ver { font-family: var(--font-mono); font-weight: 700; font-size: 12.5px; }
.tl-item .when { font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); }
.tl-item .desc { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }

/* ============ Org chart ============ */
.org-tree { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 20px 0 10px; }
.org-node {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 18px;
  text-align: center; box-shadow: var(--shadow-card); min-width: 170px;
}
.org-node .name { font-weight: 700; font-size: 13px; }
.org-node .title { font-size: 11px; color: var(--ink-soft); margin-top: 2px; }
.org-node .dept { font-family: var(--font-mono); font-size: 9.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; margin-top: 6px; }
.org-branch { display: flex; gap: 28px; position: relative; padding-top: 30px; margin-top: -1px; flex-wrap: wrap; justify-content: center; }
.org-branch::before { content: ''; position: absolute; top: 0; left: 50%; width: 1.5px; height: 30px; background: var(--line-strong); }
.org-branch .org-col { display: flex; flex-direction: column; align-items: center; position: relative; }
.org-branch .org-col::before { content: ''; position: absolute; top: -30px; left: 50%; width: 1.5px; height: 30px; background: var(--line-strong); }

/* ============ Login page ============ */
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-art {
  background: var(--ledger-700); position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; padding: 44px;
}
.login-art .brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.login-art .brand .mark { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(155deg, var(--tab-a), var(--amber)); display: flex; align-items: center; justify-content: center; }
.login-art .brand .mark svg { width: 17px; height: 17px; stroke: var(--ledger-700); }
.login-art .brand span { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.login-quote { color: #E9EEF5; }
.login-quote p.big { font-family: var(--font-display); font-size: 26px; line-height: 1.4; max-width: 420px; }
.login-quote .attr { font-family: var(--font-mono); font-size: 11.5px; color: #A9BAD1; margin-top: 14px; }
.stack-illustration { position: absolute; right: -40px; bottom: -40px; opacity: 0.5; }

.login-form-side { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-box { width: 100%; max-width: 360px; }
.login-box .eyebrow { margin-bottom: 4px; }
.login-box h1 { font-size: 25px; margin-bottom: 6px; }
.login-box .sub { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 28px; }
.divider-or { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--ink-faint); font-size: 11px; font-family: var(--font-mono); text-transform: uppercase; }
.divider-or::before, .divider-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ============ Misc ============ */
.pill-tabs { display: flex; gap: 4px; background: var(--paper-dim); padding: 4px; border-radius: 9px; width: fit-content; margin-bottom: 20px; }
.pill-tabs button { border: none; background: none; padding: 7px 14px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.pill-tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }

.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 3px 9px; border-radius: 20px; background: var(--ledger-100); color: var(--ledger); font-weight: 600; }

.audit-row { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.audit-row:last-child { border-bottom: none; }
.audit-ico { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.audit-ico svg { width: 14px; height: 14px; stroke-width: 2; }
.audit-text { font-size: 13px; }
.audit-text b { font-weight: 700; }
.audit-time { font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); margin-top: 2px; }

.progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.progress-row .plabel { font-size: 12.5px; width: 100px; flex-shrink: 0; color: var(--ink-soft); }
.progress-row .ptrack { flex: 1; height: 7px; border-radius: 6px; background: var(--paper-dim); overflow: hidden; }
.progress-row .ptrack span { display: block; height: 100%; border-radius: 6px; }
.progress-row .pval { font-family: var(--font-mono); font-size: 11.5px; width: 40px; text-align: right; color: var(--ink-soft); }

.checklist-permissions td { padding: 10px 20px; }
.perm-yes { color: var(--sage); }
.perm-no { color: var(--line-strong); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .folder-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
