:root {
  color-scheme: light;
  --ink: #10161c;
  --ink-soft: #1b242d;
  --paper: #f4f2ec;
  --surface: #ffffff;
  --surface-soft: #eeece5;
  --line: #d9d7cf;
  --muted: #66717a;
  --gold: #b98938;
  --gold-dark: #7f5c22;
  --danger: #a63f3f;
  --success: #317557;
  --warning: #a06420;
  --radius: 10px;
  --shadow: 0 14px 40px rgba(16, 22, 28, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); font-size: 16px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 16px 18px; color: #ecf0f2; background: var(--ink); border-right: 1px solid #28343e; z-index: 20; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 10px 30px; letter-spacing: .09em; }
.brand > div:last-child { display: grid; gap: 2px; font-family: Georgia, serif; }
.brand span { color: #aab3b9; font-family: Inter, sans-serif; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; color: var(--gold); border: 1px solid #5a4a31; border-radius: 50%; font-family: Georgia, serif; font-size: 1.3rem; }
nav { display: grid; gap: 5px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 12px; color: #b9c1c7; background: transparent; border: 0; border-radius: 8px; text-align: left; font-size: .9rem; }
.nav-item span { width: 20px; color: #7e8b94; text-align: center; }
.nav-item:hover, .nav-item.active { color: #fff; background: #202b34; }
.nav-item.active { box-shadow: inset 3px 0 0 var(--gold); }
.nav-item.active span { color: var(--gold); }
.sidebar-bottom { margin-top: auto; border-top: 1px solid #2c3842; padding-top: 12px; }
main { min-width: 0; }
.topbar { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 32px; background: rgba(244, 242, 236, .92); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10; }
.topbar h1 { margin: 2px 0 0; font-family: Georgia, serif; font-size: 1.75rem; font-weight: 500; }
.eyebrow { margin: 0; color: var(--gold-dark); font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.search-button { min-width: 290px; display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.search-button span:nth-child(2) { flex: 1; text-align: left; }
kbd { padding: 2px 6px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 4px; font-size: .72rem; }
.content { padding: 28px 32px 48px; }
.button { min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 8px; font-weight: 650; }
.button.primary { color: #fff; background: var(--ink); border-color: var(--ink); }
.button.primary:hover { background: #26333d; }
.button.secondary { color: var(--ink); background: var(--surface); border-color: var(--line); }
.button.ghost { min-height: 34px; padding: 6px 9px; color: var(--muted); background: transparent; border-color: transparent; }
.button.wide { width: 100%; }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; padding: 0; background: transparent; border: 1px solid var(--line); border-radius: 8px; }
.mobile-only { display: none; }

.grid { display: grid; gap: 18px; }
.metrics { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.metric { min-height: 126px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--ink); border-radius: var(--radius); }
.metric.attention { border-top-color: var(--gold); }
.metric.danger { border-top-color: var(--danger); }
.metric p { margin: 0; color: var(--muted); font-size: .82rem; }
.metric strong { display: block; margin: 14px 0 5px; font-family: Georgia, serif; font-size: 2rem; font-weight: 500; }
.metric small { color: var(--muted); font-size: .75rem; }
.dashboard-grid { grid-template-columns: minmax(0, 1.7fr) minmax(290px, .85fr); margin-top: 20px; align-items: start; }
.stack { display: grid; gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 5px 18px rgba(16, 22, 28, .03); overflow: hidden; }
.panel-head { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-family: Georgia, serif; font-size: 1.15rem; font-weight: 500; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: .8rem; }
.panel-body { padding: 18px; }
.section-title { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin: 6px 0 18px; }
.section-title h2 { margin: 0; font-family: Georgia, serif; font-size: 1.35rem; font-weight: 500; }
.section-title p { margin: 4px 0 0; color: var(--muted); }

.task-list, .activity-list, .systems-list { display: grid; }
.task-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 13px 0; border-bottom: 1px solid #e8e6df; }
.task-row:last-child { border-bottom: 0; }
.task-row input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--ink); }
.task-row.completed .task-title { color: var(--muted); text-decoration: line-through; }
.task-title { font-weight: 650; line-height: 1.35; }
.task-meta { margin-top: 5px; color: var(--muted); font-size: .78rem; }
.date-chip { padding: 5px 8px; color: var(--muted); background: var(--surface-soft); border-radius: 5px; font-size: .74rem; white-space: nowrap; }
.date-chip.overdue { color: #fff; background: var(--danger); }
.status { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 999px; background: #edf1ef; color: var(--success); font-size: .72rem; font-weight: 700; }
.status.warning { color: var(--warning); background: #f7eee1; }
.status.danger { color: var(--danger); background: #f8e8e8; }
.status.neutral { color: #59636b; background: #eceeef; }
.case-list { display: grid; gap: 10px; }
.case-card { display: grid; grid-template-columns: 1fr auto; gap: 14px; padding: 15px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.case-card:hover { border-color: #a8a49a; box-shadow: var(--shadow); transform: translateY(-1px); }
.case-card h3 { margin: 0 0 5px; font-size: .97rem; }
.case-card p { margin: 0; color: var(--muted); font-size: .78rem; }
.case-card .next { grid-column: 1/-1; padding-top: 10px; border-top: 1px solid #e8e6df; }
.case-card .next strong { color: var(--gold-dark); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.case-card .next span { margin-left: 7px; font-size: .82rem; }

.systems-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.spaced-grid { margin-top: 18px; }
.system-card { padding: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.system-top { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.system-icon { width: 42px; height: 42px; display: grid; place-items: center; color: var(--gold-dark); background: #f4ebd9; border-radius: 9px; font-family: Georgia, serif; font-size: 1.2rem; }
.system-card h3 { margin: 13px 0 5px; }
.system-card p { min-height: 38px; margin: 0 0 14px; color: var(--muted); font-size: .82rem; }
.system-actions { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #e8e6df; padding-top: 12px; }
.system-actions a { color: var(--ink); font-size: .8rem; font-weight: 700; text-decoration: none; }
.system-actions a.disabled { color: var(--muted); pointer-events: none; }
.notice { padding: 13px 15px; color: #72521e; background: #fbf3e3; border: 1px solid #ead6af; border-radius: 8px; font-size: .82rem; line-height: 1.5; }
.section-actions { display: flex; gap: 10px; align-items: center; }
.tribunal-section { margin-top: 24px; }
.tribunal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tribunal-card { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.tribunal-card h3 { margin: 0 0 5px; font-size: .94rem; }
.tribunal-card p { margin: 0 0 6px; color: var(--muted); font-size: .79rem; }
.tribunal-card small { color: var(--gold-dark); font-weight: 700; }

.content-metrics { grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: 18px; }
.mini-metric { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.mini-metric span { color: var(--muted); font-size: .76rem; }
.mini-metric strong { font-family: Georgia, serif; font-size: 1.4rem; font-weight: 500; }
.content-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, .75fr); gap: 18px; align-items: start; }
.calendar-panel .panel-head { justify-content: center; }
.calendar-panel .panel-head h2 { min-width: 220px; text-align: center; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays { border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.calendar-weekdays span { padding: 9px; color: var(--muted); text-align: center; font-size: .7rem; font-weight: 700; text-transform: uppercase; }
.calendar-day { min-height: 104px; padding: 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); overflow: hidden; }
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day.empty-day { background: #f7f6f2; }
.day-number { width: 26px; height: 26px; display: grid; place-items: center; color: var(--muted); font-size: .76rem; border-radius: 50%; }
.calendar-day.today .day-number { color: #fff; background: var(--ink); }
.calendar-post { margin-top: 5px; padding: 5px 6px; color: var(--ink); background: #f2e6cf; border-left: 3px solid var(--gold); border-radius: 4px; font-size: .68rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calendar-post strong { margin-right: 4px; color: var(--gold-dark); }
.post-list { display: grid; gap: 0; }
.post-item { display: grid; grid-template-columns: auto 1fr auto; gap: 11px; align-items: start; padding: 13px 0; border-bottom: 1px solid #e8e6df; }
.post-item:last-child { border-bottom: 0; }
.post-date { width: 44px; display: grid; place-items: center; padding: 7px 3px; color: #fff; background: var(--ink); border-radius: 7px; }
.post-date strong { font-family: Georgia, serif; font-size: 1.15rem; font-weight: 500; line-height: 1; }
.post-date span { margin-top: 3px; color: #c7ced2; font-size: .64rem; text-transform: uppercase; }
.post-item h3 { margin: 0 0 4px; font-size: .86rem; }
.post-item p { margin: 0 0 8px; color: var(--muted); font-size: .72rem; }
.post-item select { max-width: 150px; padding: 6px; color: var(--ink); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 5px; font-size: .72rem; }
.post-item > a { color: var(--gold-dark); text-decoration: none; font-weight: 700; }

.control-grid { grid-template-columns: minmax(0, 1.4fr) minmax(280px, .7fr); align-items: start; }
.checklist { display: grid; gap: 10px; }
.check-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.check-row input { width: 18px; height: 18px; accent-color: var(--ink); }
.check-row strong { display: block; font-size: .9rem; }
.check-row span { color: var(--muted); font-size: .76rem; }
.week-card { color: #f0f3f4; background: var(--ink); border-radius: var(--radius); padding: 20px; }
.week-card h2 { margin: 0 0 8px; font-family: Georgia, serif; font-weight: 500; }
.week-card p { color: #b8c1c7; font-size: .82rem; line-height: 1.5; }
.week-card .button { width: 100%; color: var(--ink); background: var(--gold); margin-top: 8px; }
.week-card ol { padding-left: 20px; font-size: .82rem; line-height: 1.55; }

.dossier { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(270px, .6fr); gap: 18px; }
.dossier-sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.dossier-cover { padding: 22px; color: #fff; background: var(--ink); border-radius: 9px 9px 0 0; }
.dossier-cover h2 { margin: 8px 0 6px; font-family: Georgia, serif; font-size: 1.55rem; font-weight: 500; }
.dossier-cover p { margin: 0; color: #b8c1c7; font-size: .82rem; }
.dossier-sections { display: grid; grid-template-columns: repeat(2, 1fr); }
.dossier-section { min-height: 132px; padding: 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.dossier-section:nth-child(2n) { border-right: 0; }
.dossier-section h3 { margin: 0 0 9px; color: var(--gold-dark); font-size: .74rem; letter-spacing: .07em; text-transform: uppercase; }
.dossier-section p { margin: 0; font-size: .87rem; line-height: 1.55; white-space: pre-line; }
.template-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.template-card { min-height: 160px; display: flex; flex-direction: column; padding: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.template-card h3 { margin: 12px 0 7px; font-size: .96rem; }
.template-card p { margin: 0; color: var(--muted); font-size: .79rem; line-height: 1.45; }
.template-card footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 14px; }
.activity-item { display: grid; grid-template-columns: 150px 1fr; gap: 16px; padding: 14px 0; border-bottom: 1px solid #e8e6df; }
.activity-item time { color: var(--muted); font-size: .76rem; }
.activity-item p { margin: 0; font-size: .85rem; }
.empty { padding: 28px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

dialog { padding: 0; border: 0; border-radius: 12px; box-shadow: 0 28px 80px rgba(0,0,0,.26); }
dialog::backdrop { background: rgba(9, 13, 16, .62); backdrop-filter: blur(2px); }
.dialog-card { width: min(620px, calc(100vw - 30px)); max-height: 88vh; overflow: auto; padding: 22px; background: var(--surface); }
.dialog-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 18px; }
.dialog-head h2 { margin: 4px 0 0; font-family: Georgia, serif; font-weight: 500; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1/-1; }
.field label, #login-form label { color: #3f4a52; font-size: .78rem; font-weight: 700; }
.field input, .field select, .field textarea, #login-form input { width: 100%; padding: 10px 11px; color: var(--ink); background: #fff; border: 1px solid #c9c7c0; border-radius: 7px; }
.field textarea { min-height: 82px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, #login-form input:focus { outline: 3px solid rgba(185, 137, 56, .18); border-color: var(--gold); }
.form-error { min-height: 18px; margin: 9px 0 0; color: var(--danger); font-size: .8rem; }
.command-card { width: min(620px, calc(100vw - 30px)); background: var(--surface); border-radius: 10px; overflow: hidden; }
.command-card > input { width: 100%; padding: 18px; border: 0; border-bottom: 1px solid var(--line); font-size: 1.05rem; outline: none; }
.search-results { max-height: 420px; overflow: auto; padding: 8px; }
.search-result { width: 100%; display: grid; gap: 3px; padding: 12px; text-align: left; background: transparent; border: 0; border-radius: 7px; }
.search-result:hover { background: var(--surface-soft); }
.search-result small { color: var(--gold-dark); font-weight: 700; text-transform: uppercase; }
.search-result span { color: var(--muted); font-size: .79rem; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; max-width: 360px; padding: 13px 16px; color: #fff; background: var(--ink); border-left: 4px solid var(--gold); border-radius: 7px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 15%, #26333d 0, var(--ink) 48%, #0a0f13 100%); }
.login-card { width: min(420px, 100%); padding: 38px; background: var(--surface); border-top: 4px solid var(--gold); border-radius: 10px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.login-card .brand-mark { margin-bottom: 28px; background: var(--ink); }
.login-card h1 { margin: 7px 0 9px; font-family: Georgia, serif; font-size: 2rem; font-weight: 500; }
.login-card .muted { margin: 0 0 24px; color: var(--muted); }
#login-form { display: grid; gap: 8px; }
.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; }

@media (max-width: 1150px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .template-grid { grid-template-columns: repeat(2, 1fr); }
  .content-metrics { grid-template-columns: repeat(3, 1fr); }
  .content-layout { grid-template-columns: 1fr; }
  .search-button { min-width: 46px; width: 46px; }
  .search-button span:nth-child(2), .search-button kbd { display: none; }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-102%); width: 260px; transition: transform .2s ease; box-shadow: 18px 0 50px rgba(0,0,0,.25); }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: grid; }
  .topbar { padding: 16px 18px; min-height: 76px; }
  .topbar > div:nth-child(2) { flex: 1; }
  .topbar h1 { font-size: 1.35rem; }
  .topbar .eyebrow { display: none; }
  .content { padding: 20px 16px 40px; }
  .dashboard-grid, .control-grid, .dossier { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .systems-grid { grid-template-columns: 1fr; }
  .tribunal-grid { grid-template-columns: 1fr; }
  .section-actions { align-items: stretch; flex-direction: column; }
  .top-actions .button { width: 42px; overflow: hidden; white-space: nowrap; padding: 8px 11px; }
  .top-actions .button { font-size: 0; }
  .top-actions .button::before { content: "+"; font-size: 1.2rem; line-height: 1; }
}
@media (max-width: 520px) {
  .metrics, .template-grid, .dossier-sections, .field-grid, .content-metrics { grid-template-columns: 1fr; }
  .dossier-section { border-right: 0; }
  .metric { min-height: 110px; }
  .activity-item { grid-template-columns: 1fr; gap: 4px; }
  .search-button { display: none; }
  .login-card { padding: 28px 22px; }
  .calendar-panel { overflow-x: auto; }
  .calendar-weekdays, .calendar-grid { min-width: 680px; }
  .tribunal-card { grid-template-columns: auto 1fr; }
  .tribunal-card .button, .tribunal-card > .status { grid-column: 1/-1; width: 100%; }
}
