/* Doc Tool — design tokens + shared components. Plain look of vn-document.net: white surfaces, neutral greys, dark
   text, yellow keyword highlight, ONE accent = the vn-document purple (#9B59B6 family). No green/blue anywhere:
   "success"/"info" are neutral, only warning (amber) and danger (red) keep a hue. Every colour in the page CSS
   comes from these tokens. Open Sans (self-hosted), 8px buttons, 10px inputs, 16px cards. */
@font-face {
    font-family: 'Open Sans'; font-style: normal; font-weight: 300 800; font-stretch: 100%; font-display: swap;
    src: url('/fonts/open-sans-normal.woff2') format('woff2');
}
:root {
    --primary: #8e44ad; --primary-hover: #793693; --primary-active: #6a2f81; --primary-focus: #b98ccb;
    --primary-soft: #f5eef8; --primary-tint: #faf6fb; --primary-ring: rgba(142, 68, 173, .2); --primary-line: #e3d0ea;
    --bg: #f5f5f5; --surface: #fff; --surface-2: #f8f8f8; --hover: #f0f0f0;
    --border: #e4e4e4; --border-soft: #eeeeee; --border-input: #d0d0d0; --border-hover: #b5b5b5;
    --text: #222222; --text-2: #333333; --muted: #666666; --faint: #8a8a8a; --placeholder: #aaaaaa;
    --danger: #c0392b; --danger-text: #9b2c22; --danger-soft: #fbedeb; --danger-border: #f0cbc5;
    --warning: #b7791f; --warning-text: #7a5212; --warning-soft: #fbf4e6; --warning-border: #ecdcb6; --warning-hover: #f6ead0;
    --success: var(--text-2); --success-text: var(--text-2); --success-soft: var(--surface-2); --success-border: var(--border);
    --info: var(--text-2); --info-text: var(--text-2); --info-soft: var(--surface-2); --info-border: var(--border);
    --mark: #fff200; --mark-text: #111111;
    /* chart series (stats page): posted = accent, waiting = amber, other = neutral; validated as one palette (dataviz) */
    --chart-published: var(--primary); --chart-pending: var(--warning); --chart-other: #a8a8a8; --chart-avg: var(--text-2);
    --chart-grid: var(--border-soft); --chart-axis: var(--muted);
    --radius-sm: 6px; --radius: 8px; --radius-input: 10px; --radius-lg: 12px; --radius-xl: 16px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05); --shadow-md: 0 4px 14px rgba(0, 0, 0, .07);
    --shadow-lg: 0 16px 40px -18px rgba(0, 0, 0, .28);
    --font: 'Open Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --top-h: 56px;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.55 var(--font); color: var(--text-2); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; color: var(--text); line-height: 1.3; font-weight: 600; }
p, ul, ol { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--primary-line); color: var(--text); } /* not the yellow of matched keywords */
.icon { flex: none; display: inline-block; vertical-align: middle; }
.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; }
.mono { font-family: var(--mono); font-size: .92em; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 13px; }
.err { margin: 8px 0 0; color: var(--danger); font-size: 13px; }
code { padding: 1px 6px; border-radius: 5px; background: var(--border-soft); color: var(--text); font: 12.5px var(--mono); }
kbd, .kbd { display: inline-block; min-width: 22px; padding: 0 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: #fff; font: 600 12px/20px var(--mono); color: var(--text); text-align: center; }

/* ── Buttons (sano-nic Button: md 42px, sm 32px, 8px radius, 600 weight) ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 16px;
    border: 1px solid transparent; border-radius: var(--radius); background: none; font-size: 14px; font-weight: 600;
    line-height: 1; white-space: nowrap; text-decoration: none; cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(142, 68, 173, .2); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-primary:active:not(:disabled) { background: var(--primary-active); border-color: var(--primary-active); }
.btn-secondary { background: #fff; border-color: var(--border-input); color: var(--text-2); box-shadow: var(--shadow-sm); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-outline { background: #fff; border-color: var(--primary); color: var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--border-soft); color: var(--text); }
.btn-warning { background: #fff; border-color: var(--warning-border); color: var(--warning-text); }
.btn-warning:hover:not(:disabled) { background: var(--warning-soft); color: var(--warning-text); }
.btn-sm { height: 32px; padding: 0 12px; gap: 6px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { width: 42px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.topbar-logout-form { display: contents; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: var(--primary); font-weight: 600; cursor: pointer; }
.link-btn:hover { color: var(--primary-hover); text-decoration: underline; }

/* ── Form controls (42px, 10px radius, teal focus ring) ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input {
    width: 100%; height: 42px; padding: 0 14px; background: #fff; border: 1px solid var(--border-input);
    border-radius: var(--radius-input); color: var(--text); font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--placeholder); }
.input:hover:not(:focus):not(:disabled) { border-color: var(--border-hover); }
.input:focus { outline: none; border-color: var(--primary-focus); box-shadow: 0 0 0 4px var(--primary-ring); }
.input-sm { height: 34px; padding: 0 10px; border-radius: var(--radius); font-size: 13px; }
.hint { font-size: 12px; color: var(--muted); }
.control { position: relative; display: flex; align-items: center; min-width: 0; }
.control > .icon { position: absolute; left: 13px; color: var(--faint); pointer-events: none; }
.control > .icon + .input { padding-left: 40px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--primary); cursor: pointer; }
.check strong { display: block; color: var(--text); font-weight: 600; }
.check small { display: block; color: var(--muted); font-size: 13px; }

/* ── Chips (radio pills / quick filters) + segmented control ── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; display: inline-flex; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
label.chip > span, a.chip, button.chip {
    display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 32px; padding: 5px 12px; border: 1px solid var(--border);
    border-radius: 16px; background: #fff; color: var(--text-2); font-size: 13px; font-weight: 500; line-height: 1.35; text-align: left;
    overflow-wrap: anywhere; cursor: pointer; transition: border-color .15s, background-color .15s, color .15s;
}
label.chip > span:hover, a.chip:hover, button.chip:hover { border-color: var(--border-hover); background: var(--surface-2); color: var(--text); }
.chip input:checked + span, a.chip.active, button.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-ring); }
.chip-count { flex: none; white-space: nowrap; font-size: 11.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--border-soft); border-radius: var(--radius); max-width: 100%; overflow-x: auto; }
.segmented label { position: relative; flex: none; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 6px; color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer; }
.segmented span:hover { color: var(--text); }
.segmented input:checked + span { background: #fff; color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-ring); }

/* ── Card, badge, alert ── */
.card { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--text); }
.card-title .icon { color: var(--primary); }
.card-body { padding: 20px; }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--border-soft); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid; border-radius: var(--radius-lg); font-size: 14px; line-height: 1.5; }
.alert > .icon { margin-top: 1px; }
.alert-body { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.alert a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.alert-info { background: var(--info-soft); border-color: var(--info-border); color: var(--info-text); }
.alert-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success-text); }
.alert-success > .icon, .alert-info > .icon { color: var(--primary); }
.alert-warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning-text); }
.alert-danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-text); }
.alert-neutral { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 48px 24px; text-align: center; color: var(--muted); }
.empty-state .icon { color: var(--placeholder); margin-bottom: 4px; }
.empty-state strong { font-size: 15px; color: var(--text); }
.spinner { display: inline-block; flex: none; width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 640px) {
    .card-head { padding: 14px 16px; }
    .card-body { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
