/*
 * Emados SOP Portal — Operational Ledger design system (plain CSS, no build step).
 * Ported from the React prototype's index.css tokens: navy rail #1f4e79/#102f4c,
 * register orange #e08e00, warm paper workbench, ledger rules, mono metadata.
 */

@import url('https://fonts.googleapis.com/css2?family=Newsreader:opsz,wght@6..72,400;6..72,500;6..72,600&family=Manrope:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600;700&display=swap');

:root {
  --background: #f6f5f0;
  --foreground: #162b3c;
  --card: #ffffff;
  --card-foreground: #162b3c;
  --primary: #1f4e79;
  --primary-foreground: #ffffff;
  --secondary: #eaf0f1;
  --secondary-foreground: #19364f;
  --muted: #eef1ee;
  --muted-foreground: #64727b;
  --accent: #fff1d8;
  --accent-foreground: #80510c;
  --destructive: #b54747;
  --destructive-foreground: #ffffff;
  --border: #dfe4e2;
  --input: #d4dcda;
  --ring: #e08e00;
  --sidebar: #102f4c;
  --sidebar-foreground: #ecf3f4;
  --radius: 2px;
  --ease-ledger: cubic-bezier(0.23, 1, 0.32, 1);
  --font-editorial: 'Newsreader', Iowan Old Style, Palatino Linotype, Georgia, serif;
  --font-ui: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

[data-theme="dark"] {
  --background: #0f1920;
  --foreground: #dbe8eb;
  --card: #172731;
  --card-foreground: #dbe8eb;
  --secondary: #1c303a;
  --secondary-foreground: #dbe8eb;
  --muted: #17262e;
  --muted-foreground: #9cafb6;
  --accent: #3c3422;
  --accent-foreground: #f3c66c;
  --border: #29434d;
  --input: #34505a;
  --ring: #e08e00;
  --sidebar: #0a212f;
  --sidebar-foreground: #e7f1f1;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: #fde1a7; color: #102f4c; }

.font-editorial { font-family: var(--font-editorial); }
.font-mono-ledger { font-family: var(--font-mono); }

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; }
@media (min-width: 1024px) {
  .app-shell { display: grid; grid-template-columns: 270px 1fr; }
}

.rail {
  display: flex;
  flex-direction: column;
  width: 270px;
  height: 100%;
  overflow-y: auto;
  background: var(--sidebar);
  color: #dce8eb;
  padding: 24px 16px;
}
.rail-desktop { position: sticky; top: 0; height: 100vh; display: none; overflow: hidden; }
@media (min-width: 1024px) { .rail-desktop { display: block; } }

.rail-logo { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.rail-logo-img { height: 46px; width: 46px; object-fit: contain; flex-shrink: 0; }
.rail-logo-title { margin: 0; font-family: var(--font-editorial); font-weight: 600; font-size: 22px; letter-spacing: -.01em; line-height: 1.2; color: #fff; }

.rail-section-label { margin: 28px 0 10px; padding: 0 8px; font-family: var(--font-mono); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .18em; color: #8ca9b8; }
.rail-nav { display: flex; flex-direction: column; gap: 4px; }
.rail-nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; border: none; background: none;
  border-radius: 2px; padding: 12px; text-align: left; font-size: 14px; font-weight: 600; color: #b8cbd3;
  transition: background-color 180ms var(--ease-ledger), color 180ms var(--ease-ledger), transform 180ms var(--ease-ledger);
  text-decoration: none;
}
.rail-nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.rail-nav-item.active { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 2px 0 0 #e08e00; }
.rail-nav-item:active { transform: scale(0.97); }
.rail-nav-item svg, .rail-nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }

.rail-divider { margin: 20px 8px; height: 1px; background: rgba(255,255,255,.15); }
.rail-mode-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; border: 1px solid rgba(255,255,255,.15); border-radius: 2px; padding: 10px 12px; background: none; color: #fff; font-size: 12px; font-weight: 700; text-decoration: none; }
.rail-mode-toggle:hover { background: rgba(255,255,255,.08); }
.rail-mode-toggle span { display: flex; align-items: center; gap: 8px; }

.rail-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.15); padding-top: 20px; }
.rail-user { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.rail-avatar { display: flex; height: 36px; width: 36px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 999px; background: #e08e00; font-family: var(--font-editorial); font-size: 14px; color: #102f4c; }
.rail-user-name { margin: 0; font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-user-meta { margin: 2px 0 0; font-family: var(--font-mono); font-size: 10px; color: #a9bec8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-logout { display: flex; align-items: center; gap: 8px; width: 100%; border: none; background: none; margin-top: 16px; padding: 8px; font-size: 12px; font-weight: 700; color: #b7c8d0; text-decoration: none; }
.rail-logout:hover { color: #fff; }

/* Mobile drawer */
/* height is set explicitly (not left to inset:0 alone) and in dvh, not just
   vh: on iOS Safari/Chrome and recent Android Chrome, the address bar can be
   collapsed or expanded, and a plain 100vh/inset:0 box is sized against the
   larger "toolbar collapsed" viewport — so when the toolbar is actually
   showing, the bottom slice of the drawer (rail-footer, or the last nav
   items on the longer Admin menu) renders underneath it, invisible. dvh
   tracks whichever viewport is currently visible instead. The vh line stays
   first as a fallback for browsers that don't support dvh. */
.mobile-nav-overlay { position: fixed; inset: 0; height: 100vh; height: 100dvh; z-index: 50; display: none; }
.mobile-nav-overlay.open { display: flex; }
.mobile-nav-scrim { position: absolute; inset: 0; background: rgba(8,31,51,.55); border: none; }
.mobile-nav-panel { position: relative; z-index: 10; height: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.mobile-nav-close { position: absolute; right: 12px; top: 20px; border-radius: 2px; background: rgba(255,255,255,.1); border: none; padding: 8px; color: #fff; }

/* ---------- Main / topbar ---------- */
.main-col { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--background) 94%, transparent); backdrop-filter: blur(8px); padding: 14px 20px; }
@media (min-width: 640px) { .topbar { padding: 14px 28px; } }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-menu-btn { display: inline-flex; border: 1px solid var(--border); background: var(--card); border-radius: 2px; padding: 8px; color: #315167; }
@media (min-width: 1024px) { .topbar-menu-btn { display: none; } }
.topbar-eyebrow { margin: 0; display: none; font-family: var(--font-mono); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .15em; color: #819096; }
@media (min-width: 640px) { .topbar-eyebrow { display: block; } }
.topbar-title { margin: 0; font-family: var(--font-editorial); font-size: 20px; color: var(--primary); }
[data-theme="dark"] .topbar-title { color: #edf4f4; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
/* The topbar search box is a fixed 220px — on a narrow phone it and the
   icon buttons/avatar (all flex-shrink:0) refused to shrink, so the squeeze
   fell entirely on .topbar-left instead, crushing the burger button down to
   almost nothing. Hidden below 640px, same breakpoint as topbar-user/
   topbar-eyebrow already use — search is still reachable via the nav's
   "Pencarian" page and Library's own search on mobile. */
.topbar-search { display: none; }
@media (min-width: 640px) { .topbar-search { display: block; } }
.topbar-avatar { display: flex; height: 32px; width: 32px; align-items: center; justify-content: center; border-radius: 999px; background: #dfece8; font-family: var(--font-editorial); font-size: 14px; color: var(--primary); }
[data-theme="dark"] .topbar-avatar { background: #263b43; }
.topbar-user { display: none; text-align: right; }
@media (min-width: 640px) { .topbar-user { display: block; } }
.topbar-user .name { margin: 0; font-size: 12px; font-weight: 700; color: #304d60; }
[data-theme="dark"] .topbar-user .name { color: #e5eff1; }
.topbar-user .meta { margin: 0; font-family: var(--font-mono); font-size: 9px; color: #7d8c93; }

.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); background: var(--card); border-radius: 2px; padding: 8px; color: #466074; text-decoration: none; }
.icon-btn:hover { background: var(--muted); }
[data-theme="dark"] .icon-btn { color: #dbe8eb; }
.icon-btn .dot { position: absolute; right: 5px; top: 5px; height: 6px; width: 6px; border-radius: 999px; background: #e08e00; }

.content-area { background: var(--background); min-height: calc(100vh - 69px); padding: 28px 20px; }
@media (min-width: 640px) { .content-area { padding: 28px; } }
@media (min-width: 1024px) { .content-area { padding: 28px 36px; } }
.content-area.paper-grid {
  background-color: #f6f5f0;
  background-image: linear-gradient(#18385208 1px, transparent 1px), linear-gradient(90deg, #18385206 1px, transparent 1px);
  background-size: 36px 36px;
}
[data-theme="dark"] .content-area.paper-grid {
  background-color: #0f1b22;
  background-image: linear-gradient(#cbdde008 1px, transparent 1px), linear-gradient(90deg, #cbdde006 1px, transparent 1px);
}
.workbench-flag { margin: 0 0 16px; font-family: var(--font-mono); font-size: 9px; font-weight: 700; letter-spacing: .14em; color: #83b8ca; display: none; }
[data-theme="dark"] .workbench-flag { display: block; }

/* ---------- Typography helpers ---------- */
.eyebrow { margin: 0; font-family: var(--font-mono); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .15em; color: #c37900; }
.page-title { margin: 4px 0 0; font-family: var(--font-editorial); font-size: 34px; color: var(--primary); }
[data-theme="dark"] .page-title { color: #eaf3f5; }
.page-lede { margin: 8px 0 0; max-width: 640px; font-size: 14px; line-height: 1.6; color: var(--muted-foreground); }
.section-title { margin: 4px 0 0; font-family: var(--font-editorial); font-size: 24px; color: var(--primary); }
[data-theme="dark"] .section-title { color: #eaf3f5; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 2px; border: 1px solid transparent; padding: 11px 18px; font-size: 12px; font-weight: 700; text-decoration: none; transition: background-color 160ms var(--ease-ledger), transform 160ms var(--ease-ledger), border-color 160ms var(--ease-ledger); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 7px 14px rgba(31,78,121,.16); }
.btn-primary:hover { background: #163c60; }
.btn-accent { background: #e08e00; color: #102f4c; }
.btn-accent:hover { background: #f0aa27; }
.btn-outline { background: var(--card); border-color: var(--border); color: #385367; }
.btn-outline:hover { background: var(--muted); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); padding: 8px 4px; }
.btn-danger { background: var(--destructive); color: #fff; }
.btn-sm { padding: 8px 12px; font-size: 11px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 18px; }
.field-label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 700; color: #304a5d; }
[data-theme="dark"] .field-label { color: #cfe0e5; }
.field-input, .field-select, .field-textarea {
  width: 100%; border: 1px solid var(--input); background: var(--card); border-radius: 2px;
  padding: 12px 14px; font-size: 13px; outline: none; transition: border-color 160ms, box-shadow 160ms; color: var(--foreground);
}
.field-input:focus, .field-select:focus, .field-textarea:focus { border-color: #e08e00; box-shadow: 0 0 0 3px rgba(224,142,0,.15); }
.field-hint { margin: 6px 0 0; font-size: 11px; color: var(--muted-foreground); }
.field-error { margin: 6px 0 0; font-size: 11px; color: #b54747; font-weight: 600; }
[data-theme="dark"] .field-select option { background: #14242d; color: #e7f0f1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.alert { border-radius: 2px; padding: 12px 16px; font-size: 12px; margin-bottom: 18px; border-left: 3px solid; }
.alert-error { background: #fff3f2; border-color: #b54747; color: #7a2e2e; }
.alert-success { background: #e8f4eb; border-color: #2b7445; color: #1f5732; }
.alert-info { background: #eaf1ed; border-color: #1f4e79; color: #1f4e79; }
[data-theme="dark"] .alert-error { background: #3a2223; color: #ffb3b1; }
[data-theme="dark"] .alert-success { background: #14301f; color: #a9ecc2; }
[data-theme="dark"] .alert-info { background: #17262e; color: #9cc7e8; }

/* ---------- Panels / ledger ---------- */
.ledger-rule { background: linear-gradient(90deg, #e08e00 0 28px, var(--border) 28px 100%); height: 1px; margin: 20px 0; }
.ledger-panel { background: var(--card); border: 1px solid var(--border); box-shadow: 0 10px 32px rgba(25,54,79,.06); border-radius: 2px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); padding: 18px 22px; }
.panel-body { padding: 20px 22px; }
.panel-accent-top { position: relative; }
.panel-accent-top::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: #e08e00; }

.row-hover { transition: background-color 180ms var(--ease-ledger), transform 180ms var(--ease-ledger); }
.row-hover:hover { background-color: #f9faf7; transform: translateX(2px); }
[data-theme="dark"] .row-hover:hover { background-color: #203540; }

/* ---------- Badges / status ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 2px; padding: 4px 8px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.badge::before { content: ""; height: 6px; width: 6px; border-radius: 999px; background: currentColor; }
.badge-approved { background: #e6f3ea; color: #24633e; }
.badge-review { background: #fff2d7; color: #96620d; }
.badge-draft { background: #eceff0; color: #55636b; }
.badge-archived { background: #eceff0; color: #55636b; }
.badge-granted { background: #e8f4eb; color: #2b7445; }
.badge-denied { background: #fff0ef; color: #b44c4b; }
[data-theme="dark"] .badge-approved { background: #183f30; color: #a9ecc2; }
[data-theme="dark"] .badge-review { background: #4b3917; color: #ffd98a; }
[data-theme="dark"] .badge-draft, [data-theme="dark"] .badge-archived { background: #293942; color: #c8d7db; }
[data-theme="dark"] .badge-granted { background: #183f30; color: #a9ecc2; }
[data-theme="dark"] .badge-denied { background: #42292b; color: #ff9d9d; }

/* ---------- Category tiles ---------- */
.tile-grid { display: grid; gap: 1px; overflow: hidden; border: 1px solid var(--border); background: var(--border); grid-template-columns: 1fr; }
@media (min-width: 640px) { .tile-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1280px) { .tile-grid { grid-template-columns: repeat(4, 1fr); } }
.tile { position: relative; min-height: 176px; background: var(--card); padding: 20px; text-align: left; border: none; text-decoration: none; color: inherit; }
.tile-bar { position: absolute; left: 0; top: 0; height: 100%; width: 4px; background: #e08e00; opacity: .4; transition: opacity 160ms; }
.tile:hover .tile-bar { opacity: 1; }
.tile-code { font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: #7c8b92; }
.tile-count { display: flex; height: 36px; width: 36px; align-items: center; justify-content: center; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--primary); background: var(--muted); }
.tile-title { margin: 28px 0 0; font-family: var(--font-editorial); font-size: 20px; color: #163a56; }
[data-theme="dark"] .tile-title { color: #dbe8eb; }
.tile-updated { margin: 8px 0 0; font-size: 11px; color: #7b878e; }
.tile-cta { margin-top: 14px; display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: var(--primary); opacity: 0; transition: opacity 160ms; }
.tile:hover .tile-cta { opacity: 1; }

/* ---------- Tables (ledger register) ---------- */
.ledger-table { width: 100%; border-collapse: collapse; }
.ledger-table thead th { text-align: left; font-family: var(--font-mono); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: #7a888d; background: var(--muted); padding: 12px 20px; border-bottom: 1px solid var(--border); }
.ledger-table tbody td { padding: 14px 20px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.ledger-table tbody tr:last-child td { border-bottom: none; }
.ledger-table-scroll { overflow-x: auto; }
.mono-cell { font-family: var(--font-mono); font-size: 11px; color: var(--muted-foreground); }
.mono-strong { font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--primary); }

/* ---------- Search / autosuggest ---------- */
.search-wrap { position: relative; }
.search-input { width: 100%; border: 1px solid var(--input); background: var(--card); border-radius: 2px; padding: 12px 14px 12px 38px; font-size: 13px; outline: none; }
.search-input:focus { border-color: #e08e00; box-shadow: 0 0 0 3px rgba(224,142,0,.1); }
.search-icon { position: absolute; left: 12px; top: 12px; width: 15px; height: 15px; color: #7e8d93; pointer-events: none; }
.suggest-panel { position: absolute; z-index: 40; margin-top: 4px; width: 100%; overflow: hidden; border: 1px solid var(--border); background: var(--card); box-shadow: 0 14px 30px rgba(25,54,79,.16); max-height: 320px; overflow-y: auto; }
.suggest-item { display: flex; width: 100%; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); padding: 12px 14px; text-align: left; background: none; border-left: none; border-right: none; border-top: none; text-decoration: none; color: inherit; }
.suggest-item:last-child { border-bottom: none; }
.suggest-empty { padding: 16px; font-size: 12px; color: var(--muted-foreground); }

/* ---------- Login screen ---------- */
.login-shell { min-height: 100vh; background: #102f4c; color: #fff; }
.login-grid { display: grid; min-height: 100vh; }
@media (min-width: 1024px) { .login-grid { grid-template-columns: 1.08fr .92fr; } }
.login-hero { position: relative; display: none; overflow: hidden; }
@media (min-width: 1024px) { .login-hero { display: block; } }
.login-hero-bg { position: absolute; inset: 0; height: 100%; width: 100%; object-fit: cover; opacity: .9; }
.login-hero-overlay { position: absolute; inset: 0; background: linear-gradient(to right, rgba(16,47,76,.8), rgba(16,47,76,.48), rgba(16,47,76,.2)); }
.login-hero-content { position: relative; display: flex; height: 100%; max-width: 640px; flex-direction: column; justify-content: space-between; padding: 48px 64px; }
.login-hero-title { font-family: var(--font-editorial); font-size: 46px; line-height: 1.05; margin: 20px 0 0; }
.login-hero-title span { color: #f4c46a; }
.login-form-side { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px; background-color: #f6f5f0; background-image: linear-gradient(#18385208 1px, transparent 1px), linear-gradient(90deg, #18385206 1px, transparent 1px); background-size: 36px 36px; }
.login-card-wrap { width: 100%; max-width: 420px; }
.login-card { background: #fff; border-radius: 2px; padding: 32px; box-shadow: 0 10px 32px rgba(25,54,79,.1); }
.login-mobile-brand { display: flex; align-items: center; justify-content: space-between; margin-bottom: 32px; }
@media (min-width: 1024px) { .login-mobile-brand { display: none; } }

/* ---------- Viewer ---------- */
.viewer-toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
@media (min-width: 1024px) { .viewer-toolbar { flex-direction: row; align-items: center; justify-content: space-between; } }
.secure-stripe { background: repeating-linear-gradient(135deg, #f9e6bd 0 7px, #fff4de 7px 14px); border: 1px solid #f2d08c; color: #80520e; padding: 8px 12px; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
[data-theme="dark"] .secure-stripe { background: repeating-linear-gradient(135deg, #473713 0 7px, #382b11 7px 14px); border-color: #745714; color: #f3ce80; }
.viewer-frame { border: 1px solid var(--border); background: var(--card); box-shadow: 0 18px 40px rgba(20,48,72,.11); overflow: hidden; }
.viewer-frame-head { display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--border); background: var(--card); padding: 16px 20px; }
@media (min-width: 1024px) { .viewer-frame-head { flex-direction: row; align-items: center; justify-content: space-between; } }
/* Mobile: stack the page-nav column below the document (full width for the
   actual PDF, thumbs become a horizontal scroll strip) — a fixed 90px side
   column left too little room for the document itself on narrow phones.
   Tablet/desktop keeps the original side-by-side grid, thumbs on the left. */
.viewer-body { display: flex; flex-direction: column; background: var(--muted); }
@media (min-width: 640px) { .viewer-body { display: grid; grid-template-columns: 126px 1fr; min-height: 580px; } }
.viewer-thumbs { order: 2; border-top: 1px solid var(--border); background: var(--muted); padding: 10px; }
@media (min-width: 640px) { .viewer-thumbs { order: 0; border-top: none; border-right: 1px solid var(--border); overflow-y: auto; max-height: 80vh; } }
#thumbList { display: flex; gap: 8px; overflow-x: auto; }
@media (min-width: 640px) { #thumbList { display: block; overflow-x: visible; } }
.viewer-thumb { position: relative; display: flex; aspect-ratio: .72; width: 52px; flex-shrink: 0; align-items: center; justify-content: center; border: 1px solid var(--border); background: var(--card); font-size: 10px; font-weight: 700; color: #7b888d; margin-bottom: 0; }
@media (min-width: 640px) { .viewer-thumb { width: 100%; margin-bottom: 8px; } }
.viewer-thumb.active { border-color: #e08e00; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.viewer-thumb.active::after { content: ""; position: absolute; bottom: 0; left: 0; height: 2px; width: 100%; background: #e08e00; }
.viewer-page-nav { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: var(--card); padding: 12px 20px; }
.viewer-canvas-wrap { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 24px; min-height: 500px; }
.viewer-canvas-wrap canvas { box-shadow: 0 12px 28px rgba(20,48,72,.18); background: #fffefb; max-width: 100%; max-height: 100%; }
.viewer-status-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--border); background: var(--card); padding: 10px 20px; font-size: 10px; color: #6d7c83; }
.viewer-blur-guard { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(16,47,76,.92); padding: 24px; text-align: center; color: #fff; }
.viewer-blur-guard.hidden { display: none; }
.viewer-notice { margin-top: 16px; display: flex; align-items: flex-start; gap: 8px; font-size: 12px; line-height: 1.6; color: var(--muted-foreground); }

/* Two-page spread on tablet/desktop, single page on mobile — mode itself is
   decided in JS (assets/js/viewer.js) via a 768px matchMedia check; this
   just lays out however many <canvas> elements are left visible. */
.canvas-stage { position: relative; z-index: 1; display: flex; align-items: flex-start; justify-content: center; gap: 20px; width: 100%; flex-wrap: nowrap; }
.viewer-nav-label { display: none; }
@media (min-width: 480px) { .viewer-nav-label { display: inline; } }

/* Manual 1-page/2-page override — defaults to the responsive auto mode
   (assets/js/viewer.js decides via matchMedia) until the reader picks one,
   at which point the choice is remembered in localStorage. */
.viewer-layout-toggle { display: flex; border: 1px solid var(--border); border-radius: 2px; overflow: hidden; }
.layout-toggle-btn { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: none; background: var(--card); color: #7c8b92; cursor: pointer; }
.layout-toggle-btn + .layout-toggle-btn { border-left: 1px solid var(--border); }
.layout-toggle-btn .icon { width: 16px; height: 16px; }
.layout-toggle-btn.active { background: var(--muted); color: var(--primary); }
#viewerStage.is-fullscreen .viewer-layout-toggle { border-color: #34404d; }
#viewerStage.is-fullscreen .layout-toggle-btn { background: #222b35; color: #9aa8b3; }
#viewerStage.is-fullscreen .layout-toggle-btn + .layout-toggle-btn { border-left-color: #34404d; }
#viewerStage.is-fullscreen .layout-toggle-btn.active { background: #2c3947; color: #f1bd5e; }

/* Base position must live here, not as an inline style on the element —
   an inline style would win over #viewerStage.is-fullscreen below
   regardless of selector specificity, silently defeating fullscreen mode. */
#viewerStage { position: relative; }

/* Fullscreen reading mode: #viewerStage (page-nav + canvas + status bar,
   deliberately excluding the page-thumbnail rail) is the fullscreen target.
   The .is-fullscreen class is a CSS-only pseudo-fullscreen driven by our own
   JS state (see viewer.js) rather than the real Fullscreen API/:fullscreen
   pseudo-class — iOS doesn't support Element.requestFullscreen() on iPhone
   at all, and even where the native API works it suppresses pinch-zoom. */
#viewerStage.is-fullscreen { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; background: #10151b; padding: 0; }
#viewerStage.is-fullscreen .viewer-page-nav { background: #1a2029; border-color: #2a323d; color: #dbe8eb; }
#viewerStage.is-fullscreen .viewer-page-nav .btn-ghost,
#viewerStage.is-fullscreen .viewer-page-nav .mono-cell { color: #dbe8eb; }
#viewerStage.is-fullscreen .viewer-page-nav .icon-btn { border-color: #34404d; background: #222b35; color: #dbe8eb; }
#viewerStage.is-fullscreen .viewer-canvas-wrap { flex: 1; min-height: 0; border-radius: 0; overflow: hidden; }
#viewerStage.is-fullscreen .viewer-status-bar { display: none; }
.info-dot { display: inline-flex; height: 16px; width: 16px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 999px; background: var(--muted); font-size: 10px; font-weight: 700; color: var(--primary); }

/* ---------- Tooltip ---------- */
.tt-trigger { position: relative; }
.tt-bubble { position: absolute; z-index: 60; top: calc(100% + 8px); right: 0; min-width: 200px; background: #102f4c; color: #fff; padding: 8px 12px; font-size: 11px; border-radius: 2px; box-shadow: 0 10px 24px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transform: translateY(-4px); transition: opacity 140ms var(--ease-ledger), transform 140ms var(--ease-ledger); }
.tt-trigger:hover .tt-bubble, .tt-trigger:focus-within .tt-bubble { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* ---------- Modal (guided tour / confirm) ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; background: rgba(6,24,35,.72); padding: 16px; backdrop-filter: blur(2px); }
@media (min-width: 640px) { .modal-overlay { align-items: center; justify-content: center; } }
.modal-card { width: 100%; max-width: 520px; overflow: hidden; border-radius: 2px; border: 1px solid rgba(255,255,255,.15); background: #102f4c; color: #fff; box-shadow: 0 24px 70px rgba(0,0,0,.36); }
.modal-head { display: flex; align-items: center; justify-content: between; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,.15); padding: 16px 24px; }
.modal-body { position: relative; padding: 32px 24px 28px; }
.modal-progress { position: absolute; left: 0; top: 0; height: 4px; width: 100%; background: rgba(255,255,255,.15); }
.modal-progress-bar { height: 100%; background: #e08e00; transition: width 300ms var(--ease-ledger); }
.modal-close { border: none; background: none; padding: 6px; border-radius: 2px; color: #c4d5db; }
.modal-close:hover { background: rgba(255,255,255,.1); color: #fff; }

.confirm-modal .modal-card { background: #fff; color: var(--foreground); max-width: 420px; }
[data-theme="dark"] .confirm-modal .modal-card { background: #172731; color: #dbe8eb; }
.confirm-modal .modal-body { padding: 24px; }

/* ---------- Simplified shell (view-only role landing page) ---------- */
.simple-topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--background) 94%, transparent); backdrop-filter: blur(8px); padding: 14px 20px; }
@media (min-width: 640px) { .simple-topbar { padding: 14px 28px; } }
.simple-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; flex-shrink: 0; }
.simple-brand-img { height: 42px; width: 42px; object-fit: contain; flex-shrink: 0; }
.simple-brand-text { font-family: var(--font-editorial); font-weight: 600; font-size: 19px; letter-spacing: -.01em; color: var(--primary); }
[data-theme="dark"] .simple-brand-text { color: #eaf3f5; }
.simple-topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.simple-main { min-height: calc(100vh - 69px); padding: 32px 20px; }
@media (min-width: 640px) { .simple-main { padding: 36px 28px; } }

/* ---------- Folder cards + document list (Library SOP: folders replace
   category/department filtering — see PANDUAN_MENU_DAN_ALUR.md). Every
   folder-browsing surface (Viewer home, admin Library SOP, public catalog)
   shows folders as cards; the documents inside a folder are shown as a
   compact row list instead. ---------- */
.folder-card-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.folder-card { display: flex; flex-direction: column; gap: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 2px; padding: 20px; text-decoration: none; color: inherit; position: relative; overflow: hidden; transition: transform 180ms var(--ease-ledger), box-shadow 180ms var(--ease-ledger); }
.folder-card::before { content: ""; position: absolute; left: 0; top: 0; height: 100%; width: 3px; background: #e08e00; opacity: .4; transition: opacity 160ms; }
.folder-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(25,54,79,.1); }
.folder-card:hover::before { opacity: 1; }
.folder-card-icon { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 2px; background: var(--muted); color: #e08e00; }
.folder-card-icon .icon { width: 24px; height: 24px; }
.folder-card-name { font-family: var(--font-editorial); font-size: 17px; color: var(--primary); line-height: 1.3; }
[data-theme="dark"] .folder-card-name { color: #eaf3f5; }
/* The HTML [hidden] attribute loses to any author rule that sets display
   (e.g. .badge { display:inline-flex }), so elements toggled via .hidden=true
   would stay visible. Make it win. */
[hidden] { display: none !important; }
.folder-card-owner { font-size: 11px; line-height: 1.4; color: var(--muted-foreground); }
.folder-card-locked { background: var(--muted); border-style: dashed; }
.folder-card-locked:hover { transform: none; box-shadow: none; }
.folder-card-locked::before { background: #b0babf; opacity: .6; }
.folder-card-locked .folder-card-icon { color: #7b888d; }
.folder-card-locked .folder-card-name { color: #5d6c75; }
.folder-card-request { display: flex; flex-direction: column; gap: 8px; }
.rail-badge { margin-left: auto; min-width: 18px; padding: 1px 6px; border-radius: 999px; background: #e08e00; color: #102f4c; font-size: 10px; font-weight: 700; text-align: center; }
.folder-card-meta { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-family: var(--font-mono); font-size: 11px; color: var(--muted-foreground); }

.folder-list { border: 1px solid var(--border); background: var(--card); overflow: hidden; border-radius: 2px; box-shadow: 0 10px 32px rgba(25,54,79,.06); }
.folder-row { display: flex; align-items: center; gap: 14px; padding: 16px 20px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--border); }
.folder-row:last-child { border-bottom: none; }
.folder-row-icon { display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; flex-shrink: 0; border-radius: 2px; background: var(--muted); color: #e08e00; }
.folder-row-icon .icon { width: 22px; height: 22px; }
.folder-row-body { min-width: 0; flex: 1; }
.folder-row-name { display: block; font-family: var(--font-editorial); font-size: 16px; color: var(--primary); }
[data-theme="dark"] .folder-row-name { color: #eaf3f5; }
.folder-row-meta { display: block; margin-top: 3px; font-size: 11px; font-family: var(--font-mono); color: var(--muted-foreground); }
.breadcrumb-trail { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .13em; color: #7d898e; }
.breadcrumb-trail a { color: #7d898e; text-decoration: none; }
.breadcrumb-trail a:hover { color: var(--primary); }
.breadcrumb-trail .icon { width: 12px; height: 12px; }
.breadcrumb-trail .current { color: #c37900; }

/* ---------- Credential reveal box (new/reset password) ---------- */
.credential-box { position:relative; overflow:hidden; border-radius:2px; border-left:4px solid #e08e00; background:#102f4c; padding:18px 22px; color:#fff; }

/* ---------- Stat / dashboard cards ---------- */
.stat-grid { display: grid; gap: 1px; overflow: hidden; border: 1px solid var(--border); background: var(--border); grid-template-columns: 1fr; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1280px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card { background: var(--card); padding: 20px; }
.stat-value { margin: 20px 0 0; font-family: var(--font-editorial); font-size: 34px; color: var(--primary); }
[data-theme="dark"] .stat-value { color: #eaf3f5; }
.stat-note { margin: 4px 0 0; font-size: 11px; color: #7a888e; }

.timeline-dot { height: 8px; width: 8px; border-radius: 999px; flex-shrink: 0; margin-top: 6px; }

/* ---------- Utilities ---------- */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.hidden { display: none !important; }
.text-muted { color: var(--muted-foreground); }
.mt-4 { margin-top: 16px; }
.w-full { width: 100%; }

@media (prefers-reduced-motion: no-preference) {
  .fade-in { animation: ledger-in 320ms var(--ease-ledger) both; }
}
/* The "to" state must be transform: none, not translateY(0) — with
   animation-fill-mode: both (see .fade-in above) the final keyframe stays
   applied forever, and ANY non-none transform value (even a zero one)
   creates a new containing block for position:fixed descendants, silently
   breaking fixed-position overlays/panels nested anywhere inside a
   .fade-in wrapper (this is what broke the PDF viewer's fullscreen mode). */
@keyframes ledger-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
