:root {
  --ink: #17202a;
  --muted: #6c7480;
  --line: #e5e9ee;
  --paper: #ffffff;
  --canvas: #f3f5f7;
  --red: #a31624;
  --red-dark: #77111b;
  --red-soft: #faecee;
  --navy: #132033;
  --green: #187153;
  --amber: #a95d04;
  --shadow: 0 12px 35px rgba(20, 32, 51, .08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-size: 16px;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); line-height: 1.5; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, .button { min-height: 44px; }

.app-shell { display: grid; grid-template-columns: 245px minmax(0, 1fr); min-height: 100vh; }
aside { position: sticky; top: 0; height: 100vh; padding: 28px 20px 22px; color: #fff; background: linear-gradient(165deg, var(--navy), #1c2b42 65%, #261f2c); display: flex; flex-direction: column; }
.nav-brand { display: flex; gap: 12px; align-items: center; text-decoration: none; margin: 0 8px 38px; line-height: 1.05; }
.nav-brand > span, .brand-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px 5px 14px 5px; background: var(--red); color: #fff; font-weight: 800; letter-spacing: -.04em; box-shadow: 0 8px 24px rgba(163, 22, 36, .35); }
.nav-brand strong { font-size: .98rem; letter-spacing: .01em; }
aside nav { display: grid; gap: 5px; }
aside nav a { display: flex; align-items: center; min-height: 46px; padding: 10px 14px; border-radius: 10px; color: #dce3ec; text-decoration: none; font-weight: 600; }
aside nav a:hover, aside nav a.active { color: #fff; background: rgba(255,255,255,.1); }
aside nav a.active { box-shadow: inset 3px 0 var(--red); }
.sidebar-user { margin-top: auto; padding: 15px 12px 0; border-top: 1px solid rgba(255,255,255,.12); display: grid; }
.sidebar-user span { font-weight: 700; }
.sidebar-user small { color: #aeb9c8; }
.sidebar-user form { margin-top: 10px; }
.sidebar-user button { min-height: auto; padding: 0; color: #dce3ec; background: none; border: 0; text-decoration: underline; cursor: pointer; }

.content { min-width: 0; padding: 46px clamp(24px, 5vw, 72px) 28px; }
.content > * { max-width: 1240px; margin-left: auto; margin-right: auto; }
.page-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 26px; }
.page-head h1 { margin: 2px 0 0; font-size: clamp(2rem, 4vw, 3.1rem); line-height: 1.05; letter-spacing: -.045em; }
.page-head .meta { margin: 9px 0 0; color: var(--muted); }
.eyebrow { margin: 0 0 3px; color: var(--red); text-transform: uppercase; font-size: .75rem; font-weight: 800; letter-spacing: .13em; }
.back { display: inline-block; margin-bottom: 20px; color: var(--muted); text-decoration: none; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border: 1px solid var(--red); border-radius: 10px; color: #fff; background: var(--red); font-weight: 750; text-decoration: none; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); background: var(--red-dark); box-shadow: 0 7px 20px rgba(163,22,36,.18); }
.button.secondary { color: var(--ink); background: #fff; border-color: var(--line); box-shadow: 0 2px 9px rgba(20,32,51,.05); }
.button.secondary:hover { border-color: #cbd1d8; background: #fff; }
.button.small { min-height: 38px; padding: 8px 13px; font-size: .9rem; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 20px; }
.stat { position: relative; min-height: 148px; padding: 21px; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.stat::after { content: ""; position: absolute; right: -25px; bottom: -35px; width: 100px; height: 100px; background: var(--red-soft); border-radius: 50%; }
.stat span, .stat small { position: relative; z-index: 1; display: block; color: var(--muted); }
.stat strong { position: relative; z-index: 1; display: block; margin: 8px 0 2px; font-size: 2.45rem; line-height: 1; letter-spacing: -.05em; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.panel-head { min-height: 83px; padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.panel h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.02em; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 20px; align-items: start; }
.content-grid.wide-left { grid-template-columns: minmax(0, 1.75fr) minmax(300px, .75fr); }
.form-panel { padding: 23px; overflow: visible; }
.form-panel > h2 { margin-bottom: 19px; }
.sticky { position: sticky; top: 24px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 16px 22px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
tbody tr:last-child td { border-bottom: 0; }
td a { color: var(--ink); font-weight: 700; text-decoration-color: #b7bec6; text-underline-offset: 3px; }
td small { display: block; margin-top: 2px; color: var(--muted); }

.form-stack, .form-grid { display: grid; gap: 15px; }
.form-grid { grid-template-columns: 1fr 1fr; align-items: end; }
.form-grid .button { width: fit-content; }
.form-stack label, .form-grid label { display: grid; gap: 6px; color: #343c46; font-weight: 700; font-size: .91rem; }
label > span { color: var(--muted); font-weight: 500; font-size: .78rem; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cfd5dc; border-radius: 9px; color: var(--ink); background: #fff; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(163,22,36,.12); border-color: var(--red); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dropzone { padding: 17px; border: 1px dashed #bac2cc; border-radius: 12px; background: #f8f9fb; cursor: pointer; }
.dropzone input { padding: 0; border: 0; min-height: auto; }
.dropzone span { display: block; }

.employee-grid { display: grid; gap: 10px; }
.employee-card { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 15px; min-height: 82px; padding: 15px 18px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 14px; text-decoration: none; box-shadow: 0 5px 18px rgba(20,32,51,.05); transition: transform .15s ease, border-color .15s ease; }
.employee-card:hover { transform: translateY(-1px); border-color: #c8ced6; }
.avatar { display: grid; place-items: center; width: 47px; height: 47px; border-radius: 50%; color: var(--red-dark); background: var(--red-soft); font-weight: 800; }
.employee-main { min-width: 0; }
.employee-main strong, .employee-main small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.employee-main small, .count small { color: var(--muted); }
.count { min-width: 52px; padding-left: 14px; border-left: 1px solid var(--line); text-align: center; font-weight: 800; }
.count small { display: block; font-size: .7rem; font-weight: 500; }
.soft-count { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--canvas); font-weight: 800; }

.document-list { display: grid; }
.document-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 15px; align-items: center; padding: 17px 21px; border-bottom: 1px solid var(--line); }
.document-row:last-child { border-bottom: 0; }
.file-icon { display: grid; place-items: center; width: 46px; height: 52px; border: 1px solid #e1bfc3; border-radius: 7px 7px 12px 7px; color: var(--red); background: var(--red-soft); font-size: .65rem; font-weight: 900; }
.document-main { min-width: 0; }
.document-main strong, .document-main a, .document-main small { display: block; }
.document-main a { overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; text-underline-offset: 3px; }
.document-main small { margin-top: 4px; color: var(--muted); }
.document-actions { min-width: 125px; display: grid; justify-items: end; gap: 9px; }
.badge { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 10px; border-radius: 99px; font-size: .78rem; font-weight: 800; }
.badge.new { color: #165d83; background: #e8f4fb; }
.badge.reviewed { color: var(--green); background: #e7f5ef; }
.badge.rejected, .badge.expired { color: #8b4a00; background: #fff0d9; }
.badge.archived { color: #5d6570; background: #edf0f3; }
.inline-form { display: flex; gap: 5px; }
.inline-form select { min-height: 36px; padding: 6px 8px; font-size: .82rem; }
.icon-button { width: 36px; min-height: 36px; padding: 0; border: 0; border-radius: 8px; color: #fff; background: var(--navy); cursor: pointer; }

.alert { margin: 0 0 18px; padding: 13px 15px; border-radius: 10px; font-weight: 650; }
.alert.success { color: #115a41; background: #e5f5ee; border: 1px solid #bfe5d5; }
.alert.error { color: #8a2029; background: var(--red-soft); border: 1px solid #efc7cb; }
.empty { padding: 50px 25px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.empty.compact { border: 0; border-radius: 0; }
.empty h1, .empty h2 { margin: 0 0 8px; }
.empty p { margin: 0 0 18px; color: var(--muted); }
footer { padding-top: 35px; color: #858d97; font-size: .78rem; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 75% 15%, rgba(163,22,36,.17), transparent 27%), linear-gradient(145deg, #111d2d, #1d2c43 60%, #3a1721); }
.auth-card { width: min(100%, 450px); padding: clamp(27px, 6vw, 44px); background: #fff; border-radius: 22px 7px 22px 7px; box-shadow: 0 28px 70px rgba(0,0,0,.3); }
.auth-card .brand-mark { margin-bottom: 30px; }
.auth-card h1 { margin: 4px 0 10px; font-size: 2rem; line-height: 1.1; letter-spacing: -.04em; }
.auth-card > p:not(.eyebrow) { margin: 0 0 25px; color: var(--muted); }

@media (max-width: 1020px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .content-grid, .content-grid.wide-left { grid-template-columns: 1fr; }
  .sticky { position: static; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  aside { position: static; height: auto; padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .nav-brand { margin: 0; }
  .nav-brand > span { width: 40px; height: 40px; }
  aside nav { grid-column: 1 / -1; display: flex; gap: 4px; margin-top: 13px; overflow-x: auto; padding-bottom: 3px; }
  aside nav a { flex: 0 0 auto; min-height: 40px; padding: 8px 11px; font-size: .88rem; }
  aside nav a.active { box-shadow: inset 0 -3px var(--red); }
  .sidebar-user { margin: 0; padding: 0; border: 0; text-align: right; }
  .sidebar-user small { display: none; }
  .sidebar-user form { margin-top: 1px; }
  .content { padding: 27px 16px 22px; }
  .page-head { align-items: flex-start; }
  .page-head .button { flex: 0 0 auto; }
  .stat { min-height: 128px; padding: 17px; }
  .stat strong { font-size: 2rem; }
  .document-row { grid-template-columns: auto minmax(0,1fr); }
  .document-actions { grid-column: 1 / -1; width: 100%; grid-auto-flow: column; justify-content: space-between; justify-items: start; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .nav-brand strong { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat { min-height: 114px; }
  .stat span, .stat small { font-size: .75rem; }
  .page-head { display: grid; }
  .page-head .button { width: 100%; }
  .two { grid-template-columns: 1fr; }
  .employee-card { padding: 13px; gap: 11px; }
  th, td { padding: 13px 16px; }
}

/* Workflow and accessibility enhancements. */
:focus-visible { outline: 3px solid #3379b5; outline-offset: 3px; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 100; background: white; color: #17202a; padding: 12px; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.action-bar, .pagination { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.pagination { margin-top: 20px; justify-content: center; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 20px; padding: 18px; background: white; border: 1px solid var(--line); border-radius: 14px; }
.filter-bar label { display: grid; gap: 6px; flex: 1 1 160px; font-size: .85rem; font-weight: 700; }
.filter-bar label:first-of-type { flex-grow: 2; }
.helper { color: var(--muted); font-size: .85rem; margin: 0; }
.secret { display: block; padding: 16px; background: var(--canvas); border: 1px solid var(--line); border-radius: 8px; overflow-wrap: anywhere; white-space: pre-wrap; user-select: all; letter-spacing: .03em; }
.document-note { grid-column: 2 / -1; margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--canvas); font-size: .88rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.document-actions .inline-form { flex-wrap: wrap; max-width: 230px; }
.document-actions .inline-form input { min-height: 36px; font-size: .78rem; flex: 1 1 100%; }
.document-actions .inline-form select { flex: 1; width: auto; }
.document-actions .icon-button { min-width: 36px; }
.manage { margin-top: 8px; min-width: 180px; }
summary { cursor: pointer; font-weight: 650; padding: 10px 0; }
.manage .form-stack { margin-top: 12px; }
.notice { color: #254760; background: #e8f3fc; border: 1px solid #bed7ee; }
.stat-link { text-decoration: none; }
.stat-link .stat { height: 100%; }
.panel td { overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
@media (max-width: 760px) { .document-actions .inline-form { max-width: none; } .document-note { grid-column: 1 / -1; } .filter-bar .button { flex: 1 1 100%; } }
.document-actions { align-items: start; }
.document-actions .badge { align-self: start; }
@media (max-width: 760px) {
  aside .sidebar-user { grid-column: 2; grid-row: 1; }
  aside nav { grid-row: 2; }
}
@media (max-width: 480px) { .action-bar { width: 100%; } }

/* Authenticator enrollment: four-module quiet zone is drawn inside the SVG. */
.totp-qr { margin: 20px 0; max-width: 320px; }
.totp-qr svg { display: block; width: 100%; height: auto; background: #fff; }
