/* PQRS-D — light/dark theme via [data-theme]. No inline styles anywhere (strict CSP). */
:root {
  --bg: #f4f7fb; --surface: #ffffff; --surface-2: #eef3fa; --ink: #0e1a2b; --muted: #5a6b82; --line: #d9e2ef;
  --brand: #0066cc; --brand-ink: #ffffff; --brand-soft: #e3f0ff; --link: #0057b3;
  --ok: #12805c; --ok-bg: #dff5ec; --warn: #8a5a00; --warn-bg: #fff2cc; --bad: #b3261e; --bad-bg: #fde4e1;
  --info-bg: #e3f0ff; --shadow: 0 1px 2px rgba(14,26,43,.06), 0 6px 18px rgba(14,26,43,.06);
  --radius: 14px; --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0b121d; --surface: #131c2b; --surface-2: #192436; --ink: #e8eef8; --muted: #9db0c9; --line: #26344b;
  --brand: #4c9bff; --brand-ink: #06121f; --brand-soft: #14304f; --link: #7db6ff;
  --ok: #4fd1a1; --ok-bg: #11352a; --warn: #ffd166; --warn-bg: #3a2f10; --bad: #ff8a80; --bad-bg: #3d1a18;
  --info-bg: #14304f; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}
:root[data-theme="dark"] .brand img, :root[data-theme="dark"] .hero-logo { filter: brightness(1.45) saturate(.9); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.6 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--link); }
img { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); }
h2 { font-size: 1.4rem; margin-top: 1.6em; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.wrap { width: min(1280px, 100% - 32px); margin-inline: auto; }
main.wrap { padding: 28px 0 56px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--brand); color: var(--brand-ink); padding: 8px 12px; z-index: 99; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.bar { display: flex; align-items: center; gap: 14px; padding: 10px 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.25rem; letter-spacing: .02em; }
.brand b { color: var(--brand); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: .95rem; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--link); }
.tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; min-width: 38px; height: 36px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; font: 700 .85rem var(--font); cursor: pointer; text-decoration: none; }
.chip:hover { border-color: var(--brand); }
form.inline { display: inline; margin: 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer; text-decoration: none;
  background: var(--brand); color: var(--brand-ink); font: 700 1rem var(--font); padding: 12px 20px; border-radius: 12px; min-height: 44px; }
.btn:hover { filter: brightness(1.08); }
.btn-sm { padding: 7px 14px; min-height: 36px; font-size: .9rem; border-radius: 10px; }
.btn-ghost { background: transparent; color: var(--link); border: 1px solid var(--line); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* cards & layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.grid > .card, .grid > article.card { margin-top: 0; }
.chip svg { width: 18px; height: 18px; fill: currentColor; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.narrow { max-width: 520px; margin-inline: auto; }
.mid { max-width: 780px; margin-inline: auto; }
.hero { display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: center; padding: 18px 0 8px; }
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 60ch; }
.hero-logo { width: 150px; height: auto; }
@media (max-width: 640px) { .hero { grid-template-columns: 1fr; } .hero-logo { display: none; } }

.stat { text-align: center; padding: 18px 10px; }
.stat .num { font-size: 2.3rem; font-weight: 800; color: var(--brand); line-height: 1; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--muted); font-size: .9rem; margin-top: 6px; }

/* forms */
label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: .95rem; }
.req::after { content: " *"; color: var(--bad); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: 11px 12px; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-height: 44px; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 2px solid var(--brand-soft); }
.hint { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.field-err { display: block; color: var(--bad); font-size: .85rem; margin-top: 4px; font-weight: 600; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; margin: 10px 0; }
.check input { width: 20px; height: 20px; margin-top: 3px; flex: none; }
.check-row { display: flex; gap: 18px; flex-wrap: wrap; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 6px 16px 12px; margin: 16px 0; }
legend { font-weight: 700; padding: 0 8px; }
.four { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 18px; }
.span2 { grid-column: span 2; }
@media (max-width: 900px) { .four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .four { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.counter { float: right; font-size: .8rem; color: var(--muted); }
.captcha { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.captcha-img { border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.captcha-input { flex: 1; min-width: 130px; width: auto !important; letter-spacing: .2em; text-transform: uppercase; font-weight: 700; }

/* alerts, badges */
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; border: 1px solid transparent; font-weight: 500; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.alert-err { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.alert-info { background: var(--info-bg); color: var(--link); border-color: var(--brand); }
.note { background: var(--surface-2); border-left: 4px solid var(--brand); padding: 12px 16px; border-radius: 8px; margin: 14px 0; }
.note.warn { border-color: #e0a800; background: var(--warn-bg); }
.note.bad { border-color: var(--bad); background: var(--bad-bg); }
.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.st-draft, .es-none { background: var(--surface-2); color: var(--muted); }
.st-waiting { background: var(--info-bg); color: var(--link); }
.st-answered { background: var(--warn-bg); color: var(--warn); }
.st-escalated { background: var(--bad-bg); color: var(--bad); }
.st-solved, .es-confirmed { background: var(--ok-bg); color: var(--ok); }
.st-unsolved { background: var(--bad-bg); color: var(--bad); }
.es-reported { background: var(--info-bg); color: var(--link); }
.es-court { background: var(--warn-bg); color: var(--warn); }

/* tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .88em; overflow-wrap: anywhere; word-break: normal; }

/* directory */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.tabs button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 16px; border-radius: 999px; font: 600 .92rem var(--font); cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.co-card h3 { margin: 0; }
.co-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.co-mail { background: var(--surface-2); padding: 8px 12px; border-radius: 10px; margin: 10px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.co-mail .mono { flex: 1; min-width: 180px; }

/* deadline widget */
.deadline { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.days { font-size: 3rem; font-weight: 800; line-height: 1; color: var(--brand); text-align: center; min-width: 96px; }
.days small { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); }
.days.late { color: var(--bad); }
.bar-track { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.bar-fill { height: 100%; background: var(--brand); border-radius: 999px; }
.bar-fill.late { background: var(--bad); }
progress { width: 100%; height: 12px; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 3px solid var(--line); }
.timeline li { padding: 4px 0 14px 18px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -9px; top: 9px; width: 15px; height: 15px; border-radius: 50%; background: var(--brand); border: 3px solid var(--surface); }
.steps { counter-reset: s; list-style: none; padding: 0; }
.steps > li { counter-increment: s; position: relative; padding: 0 0 18px 52px; }
.steps > li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 800; display: grid; place-items: center; }
.comment { border-top: 1px solid var(--line); padding: 12px 0; }
.comment:first-child { border-top: 0; }
.comment .meta { font-size: .85rem; color: var(--muted); }
.comment p { margin: .3em 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; background: var(--surface-2); padding: 12px; border-radius: 10px; font-size: .9rem; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.foot { border-top: 1px solid var(--line); background: var(--surface); padding: 24px 0; font-size: .88rem; color: var(--muted); }
.foot p { margin: 0 0 .5em; }

@media (max-width: 640px) {
  .bar { gap: 8px; } .nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .deadline { grid-template-columns: 1fr; } .card { padding: 16px; }
}
@media print { .topbar, .foot, .btn, .tools { display: none !important; } body { background: #fff; color: #000; } }

hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
progress { accent-color: var(--brand); border-radius: 999px; }

/* signature pad */
.sigpad canvas { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; width: 100%; height: auto; aspect-ratio: 3 / 1; display: block; touch-action: none; cursor: crosshair; border: 2px dashed var(--line); border-radius: 12px;
  background: linear-gradient(transparent 73%, #bcc8dc 73%, #bcc8dc 74%, transparent 74%) #fff; }
.sigpad .btn-row { margin: 8px 0 4px; }
.sig-preview { display: block; width: 100%; max-height: 120px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin: 10px 0; }
