:root {
  --ink: #18211f;
  --muted: #69736f;
  --paper: #f7f2f8;
  --paper-deep: #eadfeb;
  --forest: #702082;
  --forest-light: #8d3ba0;
  --brass: #9a6a24;
  --line: rgba(24, 33, 31, .13);
  --white: #fffdf7;
  --danger: #9d3d32;
  --shadow: 0 18px 50px rgba(71, 34, 78, .13);
}

* { box-sizing: border-box; }
html { font-family: "Noto Serif SC", "Source Han Serif SC", "Microsoft YaHei", serif; color: var(--ink); background: var(--paper); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 78% 5%, rgba(112,32,130,.1), transparent 30rem), var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 20px 20px; color: #e9efe8; background: var(--forest); }
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; padding: 0 8px 26px; border-bottom: 1px solid rgba(255,255,255,.13); }
.brand-mark { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; color: var(--forest); background: #fff; border-radius: 50%; font-weight: 800; box-shadow: inset 0 0 0 4px rgba(112,32,130,.12); }
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .08em; }
.brand small { margin-top: 4px; color: rgba(255,255,255,.54); font-size: 11px; letter-spacing: .2em; }
.nav { display: grid; gap: 7px; margin-top: 28px; }
.nav a { display: flex; gap: 12px; align-items: center; padding: 11px 12px; color: rgba(255,255,255,.66); text-decoration: none; border-radius: 9px; transition: .2s ease; }
.nav a span { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; font-size: 12px; }
.nav a.active { color: #fff; background: rgba(255,255,255,.1); }
.nav a[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.sidebar-note { margin-top: auto; padding: 13px; color: rgba(255,255,255,.58); font-size: 12px; border: 1px solid rgba(255,255,255,.1); border-radius: 9px; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; background: #82c69f; border-radius: 50%; }
.logout-form { margin-top: 8px; }
.logout-form button { width: 100%; padding: 9px; color: rgba(255,255,255,.62); background: transparent; border: 1px solid rgba(255,255,255,.1); border-radius: 8px; }
.auth-body { display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 70% 10%, rgba(112,32,130,.16), transparent 32rem), var(--paper); }
.auth-card { width: min(460px, 100%); padding: 42px; background: rgba(255,253,247,.94); border: 1px solid var(--line); box-shadow: var(--shadow); }
.auth-seal { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 22px; color: white; background: var(--forest); border-radius: 50%; font-weight: 800; }
.auth-card h1 { font-size: 34px; }
.auth-intro { color: var(--muted); line-height: 1.7; }
.auth-form { display: grid; gap: 17px; margin-top: 26px; }
.auth-form label { display: grid; gap: 6px; }
.auth-form label span { font-size: 13px; font-weight: 700; }
.auth-form input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 7px; outline: none; }
.auth-form input:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(112,32,130,.09); }
.auth-note { display: block; margin-top: 17px; color: var(--muted); }
.main { min-width: 0; padding: 50px clamp(24px, 5vw, 72px) 72px; }
.page-header { display: flex; justify-content: space-between; gap: 30px; align-items: end; margin-bottom: 30px; }
.eyebrow { margin: 0 0 8px; color: var(--brass); font: 700 11px/1.2 Georgia, serif; letter-spacing: .24em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(34px, 4vw, 52px); font-weight: 600; letter-spacing: -.035em; }
.lede { margin: 0; color: var(--muted); }
.button { border: 0; border-radius: 8px; padding: 11px 18px; font-weight: 700; transition: transform .18s ease, box-shadow .18s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--forest); box-shadow: 0 9px 22px rgba(112,32,130,.2); }
.button.ghost { color: var(--ink); background: transparent; border: 1px solid var(--line); }
.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 24px; background: rgba(255,253,247,.55); border: 1px solid var(--line); }
.stat-strip.case-detail-stats { grid-template-columns: repeat(4, 1fr); }
.stat-strip div { padding: 19px 24px; border-right: 1px solid var(--line); }
.stat-strip div:last-child { border-right: 0; }
.stat-strip span, .stat-strip small { display: block; }
.stat-strip span { font: 600 30px/1 Georgia, serif; }
.stat-strip small { margin-top: 7px; color: var(--muted); }
.panel { background: rgba(255,253,247,.82); border: 1px solid rgba(24,33,31,.11); box-shadow: var(--shadow); }
.panel-heading { display: flex; justify-content: space-between; gap: 24px; align-items: end; padding: 24px 28px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin-bottom: 5px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.search-field span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.search-field input { width: min(300px, 30vw); border: 0; border-bottom: 1px solid var(--line); padding: 7px 0; outline: none; background: transparent; }
.case-list { min-height: 320px; }
.case-row { display: grid; grid-template-columns: 140px minmax(230px, 1.5fr) minmax(180px, 1fr) 120px; gap: 18px; align-items: center; padding: 21px 28px; border-bottom: 1px solid var(--line); }
.case-row:last-child { border-bottom: 0; }
.case-link { color: inherit; text-decoration: none; transition: background .18s ease; }
.case-link:hover { background: rgba(112,32,130,.045); }
.case-code { color: var(--forest-light); font: 700 12px/1.4 Georgia, serif; letter-spacing: .03em; }
.case-title { margin-bottom: 5px; font-size: 17px; }
.case-meta { color: var(--muted); font-size: 13px; }
.case-number { color: var(--muted); font-size: 13px; }
.badge { justify-self: end; padding: 5px 10px; color: var(--forest); background: rgba(112,32,130,.09); border-radius: 999px; font-size: 12px; }
.empty-state { display: grid; place-items: center; align-content: center; min-height: 320px; text-align: center; padding: 40px; }
.empty-seal { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 16px; color: var(--brass); border: 1px solid rgba(185,133,66,.4); border-radius: 50%; }
.empty-state h3 { margin-bottom: 8px; }
.empty-state p { max-width: 420px; color: var(--muted); }
.dialog { width: min(760px, calc(100vw - 30px)); max-height: calc(100vh - 30px); padding: 0; color: var(--ink); background: var(--white); border: 0; box-shadow: 0 30px 100px rgba(10,30,24,.32); }
.dialog::backdrop { background: rgba(11,27,23,.68); backdrop-filter: blur(3px); }
.dialog form { padding: 28px; }
.dialog-header { display: flex; justify-content: space-between; margin-bottom: 25px; }
.dialog-header h2 { margin: 0; font-size: 28px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-size: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.form-grid label { display: grid; gap: 6px; }
.form-grid label > span { font-size: 13px; font-weight: 700; }
.form-grid em { color: var(--muted); font-style: normal; font-weight: 400; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 10px 11px; background: #fffef9; outline: none; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { border-color: var(--forest-light); box-shadow: 0 0 0 3px rgba(112,32,130,.09); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 25px; }
.form-error { margin: 16px 0 0; padding: 10px; color: var(--danger); background: rgba(157,61,50,.07); }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; padding: 12px 16px; color: white; background: var(--forest); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.offline-banner { position: fixed; inset: auto 0 0; z-index: 50; padding: 10px 16px; color: white; background: #842f32; text-align: center; font-size: 13px; }
.dashboard-header { margin-bottom: 24px; }
.notification-panel { margin-bottom: 18px; background: rgba(255,253,247,.82); border: 1px solid rgba(112,32,130,.2); }
.notification-heading { display: flex; justify-content: space-between; padding: 13px 17px; color: white; background: var(--forest); }
.notification-item { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 13px 17px; border-bottom: 1px solid var(--line); }
.notification-item:last-child { border-bottom: 0; }
.notification-item strong, .notification-item small { display: block; }
.notification-item small { margin-top: 4px; color: var(--muted); }
.quick-note-panel { position: relative; padding: 26px 28px 22px; color: white; background: var(--forest); box-shadow: 0 20px 45px rgba(112,32,130,.2); overflow: hidden; }
.quick-note-panel::after { content: ""; position: absolute; width: 220px; height: 220px; right: -90px; top: -100px; border: 1px solid rgba(255,255,255,.15); border-radius: 50%; box-shadow: 0 0 0 30px rgba(255,255,255,.025), 0 0 0 60px rgba(255,255,255,.02); }
.quick-note-copy { position: relative; z-index: 1; display: flex; gap: 13px; align-items: center; margin-bottom: 18px; }
.quick-note-copy h2 { margin: 0 0 3px; font-size: 19px; }
.quick-note-copy p, .quick-hint { margin: 0; color: rgba(255,255,255,.66); font-size: 13px; }
.quick-icon { display: grid; place-items: center; width: 39px; height: 39px; color: var(--forest); background: white; border-radius: 50%; font-weight: 800; }
.quick-note-form { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.quick-note-form input { min-width: 0; padding: 14px 15px; border: 1px solid rgba(255,255,255,.24); border-radius: 8px; color: white; background: rgba(255,255,255,.09); outline: none; }
.quick-note-form input::placeholder { color: rgba(255,255,255,.55); }
.quick-note-form input:focus { border-color: rgba(255,255,255,.72); }
.quick-note-form .button { color: var(--forest); background: white; box-shadow: none; }
.quick-hint { position: relative; z-index: 1; margin-top: 11px; }
.summary-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin: 20px 0; }
.summary-grid article { position: relative; min-width: 0; padding: 16px; background: rgba(255,253,247,.76); border: 1px solid var(--line); overflow: hidden; }
.summary-grid small, .summary-grid strong { display: block; }
.summary-grid small { color: var(--muted); font-size: 12px; }
.summary-grid strong { margin-top: 7px; font: 600 28px/1 Georgia, serif; }
.summary-accent { position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--forest); }
.summary-grid .warning .summary-accent { background: #bb7626; }
.summary-grid .danger .summary-accent { background: var(--danger); }
.work-columns { display: grid; grid-template-columns: 1.15fr .85fr; gap: 20px; margin-bottom: 20px; }
.task-panel { min-height: 330px; box-shadow: none; }
.task-list { padding: 5px 0; }
.task-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.task-item:last-child { border-bottom: 0; }
.task-check { width: 21px; height: 21px; border: 1px solid rgba(112,32,130,.34); border-radius: 50%; background: transparent; }
.task-check:hover { background: rgba(112,32,130,.1); }
.task-title { margin: 0 0 4px; font-size: 14px; }
.task-subtitle, .task-time { color: var(--muted); font-size: 12px; }
.task-empty { display: grid; place-items: center; min-height: 210px; padding: 30px; color: var(--muted); text-align: center; font-size: 14px; }
.upcoming-panel { box-shadow: none; }
.upcoming-groups { display: grid; grid-template-columns: repeat(3, 1fr); }
.upcoming-group { min-height: 170px; padding: 20px; border-right: 1px solid var(--line); }
.upcoming-group:last-child { border-right: 0; }
.upcoming-group h3 { font-size: 14px; }
.upcoming-group ul { margin: 0; padding: 0; list-style: none; }
.upcoming-group li { padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.upcoming-group time { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.settings-panel { max-width: 760px; padding: 0; }
.settings-intro { display: grid; grid-template-columns: auto 1fr auto; gap: 17px; align-items: center; padding: 26px 28px; color: white; background: var(--forest); }
.settings-intro h2 { margin: 0 0 4px; }
.settings-intro p { margin: 0; color: rgba(255,255,255,.66); font-size: 13px; }
.settings-lock { display: grid; place-items: center; width: 43px; height: 43px; color: var(--forest); background: white; border-radius: 50%; font-weight: 800; }
.config-status { padding: 5px 10px; color: rgba(255,255,255,.76); border: 1px solid rgba(255,255,255,.25); border-radius: 999px; font-size: 12px; }
.config-status.ready { color: #fff; background: rgba(255,255,255,.14); }
.settings-form { display: grid; gap: 20px; padding: 28px; }
.settings-form label { display: grid; gap: 7px; }
.settings-form label > span { font-weight: 700; }
.settings-form input { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 7px; background: #fffef9; outline: none; }
.settings-form input:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(112,32,130,.09); }
.settings-form small { color: var(--muted); }
.settings-form .button { justify-self: start; }
.settings-actions { display: flex; gap: 10px; align-items: center; }
.upload-panel { margin-bottom: 18px; padding: 10px; background: rgba(255,253,247,.56); border: 1px solid var(--line); }
.drop-zone { display: grid; place-items: center; width: 100%; min-height: 220px; padding: 34px; color: var(--ink); background: transparent; border: 1px dashed rgba(112,32,130,.38); transition: .2s ease; }
.drop-zone:hover, .drop-zone.dragging { background: rgba(112,32,130,.055); border-color: var(--forest); }
.drop-zone strong, .drop-zone small { display: block; }
.drop-zone strong { margin-top: 12px; font-size: 18px; }
.drop-zone small { margin-top: 7px; color: var(--muted); }
.upload-symbol { display: grid; place-items: center; width: 54px; height: 54px; color: white; background: var(--forest); border-radius: 50%; font: 400 30px/1 Georgia, serif; }
.upload-selection { display: flex; justify-content: space-between; align-items: center; padding: 16px 10px 6px; }
.upload-selection strong, .upload-selection small { display: block; }
.upload-selection small { margin-top: 3px; color: var(--muted); }
.upload-progress { height: 4px; margin: 8px 10px 2px; background: var(--paper-deep); overflow: hidden; }
.upload-progress span { display: block; width: 42%; height: 100%; background: var(--forest); animation: upload-moving 1s ease-in-out infinite alternate; }
@keyframes upload-moving { to { transform: translateX(138%); } }
.inbox-stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; border: 1px solid var(--line); background: rgba(255,253,247,.72); }
.inbox-stats div { padding: 16px 20px; border-right: 1px solid var(--line); }
.inbox-stats div:last-child { border-right: 0; }
.inbox-stats strong, .inbox-stats span { display: block; }
.inbox-stats strong { font: 600 26px/1 Georgia, serif; }
.inbox-stats span { margin-top: 6px; color: var(--muted); font-size: 12px; }
.document-list { min-height: 240px; }
.document-row { display: grid; grid-template-columns: minmax(210px, 1.4fr) minmax(180px, 1fr) minmax(160px, .8fr) auto; gap: 16px; align-items: center; padding: 18px 28px; border-bottom: 1px solid var(--line); }
.document-row:last-child { border-bottom: 0; }
.document-name { min-width: 0; }
.document-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-name small, .document-meta { color: var(--muted); font-size: 12px; }
.status-pill { justify-self: end; padding: 5px 9px; color: var(--forest); background: rgba(112,32,130,.08); border-radius: 999px; font-size: 12px; }
.status-pill.duplicate { color: #8b5b1e; background: rgba(185,133,66,.1); }
.status-pill.failed { color: var(--danger); background: rgba(157,61,50,.08); }
.classification-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.classification-controls select { min-width: 0; width: 100%; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fffef9; }
.document-actions { display: flex; gap: 7px; justify-content: flex-end; }
.mini-button { padding: 7px 9px; color: var(--forest); background: transparent; border: 1px solid rgba(112,32,130,.25); border-radius: 6px; font-size: 12px; white-space: nowrap; }
.mini-button.confirm { color: white; background: var(--forest); }
.ai-reason { grid-column: 1 / -1; margin-top: -6px; padding: 9px 11px; color: var(--muted); background: rgba(112,32,130,.045); font-size: 12px; }
.candidate-list { grid-column: 1 / -1; display: grid; gap: 6px; }
.candidate-item { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 9px 11px; background: rgba(185,133,66,.07); border-left: 3px solid #b98542; }
.candidate-item strong, .candidate-item small { display: block; }
.candidate-item small { margin-top: 3px; color: var(--muted); }
.case-detail-meta { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 13px; }
.case-detail-meta span, .material-summary span { padding: 5px 9px; color: var(--muted); background: rgba(112,32,130,.06); border-radius: 999px; font-size: 12px; }
.material-summary { display: flex; flex-wrap: wrap; gap: 7px; padding: 16px 28px; border-bottom: 1px solid var(--line); }
.case-document-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 14px; align-items: center; padding: 17px 28px; border-bottom: 1px solid var(--line); }
.case-document-row:last-child { border-bottom: 0; }
.document-path { min-width: 0; }
.document-path strong { display: block; overflow-wrap: anywhere; font-size: 13px; }
.document-path small { display: block; margin-top: 5px; color: var(--muted); }
.document-error { color: var(--danger); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 18px; border-top: 1px solid var(--line); }
.pagination button:disabled { opacity: .35; cursor: default; }
.assistant-layout { display: grid; grid-template-rows: auto minmax(340px, 1fr) auto auto; max-width: 960px; min-height: calc(100vh - 120px); margin: 0 auto; }
.assistant-heading { padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.assistant-heading h1 { margin-bottom: 7px; }
.assistant-heading > p:last-child { margin: 0; color: var(--muted); }
.chat-thread { display: flex; flex-direction: column; gap: 15px; padding: 28px 0; overflow-y: auto; }
.chat-message { display: flex; gap: 11px; max-width: 82%; }
.chat-message > div { padding: 13px 15px; background: rgba(255,253,247,.82); border: 1px solid var(--line); border-radius: 3px 13px 13px 13px; }
.chat-message p { margin: 5px 0 0; white-space: pre-wrap; line-height: 1.7; }
.message-avatar { display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; color: white; background: var(--forest); border-radius: 50%; font-size: 12px; }
.user-message { align-self: flex-end; flex-direction: row-reverse; }
.user-message > div { color: white; background: var(--forest); border-color: var(--forest); border-radius: 13px 3px 13px 13px; }
.user-message .message-avatar { color: var(--forest); background: var(--paper-deep); }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chat-suggestions button { padding: 7px 10px; color: var(--forest); background: transparent; border: 1px solid rgba(112,32,130,.2); border-radius: 999px; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px; background: rgba(255,253,247,.9); border: 1px solid var(--line); box-shadow: var(--shadow); }
.chat-form textarea { resize: none; padding: 10px; border: 0; background: transparent; outline: none; }
.assistant-disclaimer { margin: 9px 0 0; color: var(--muted); font-size: 11px; text-align: center; }

@media (max-width: 800px) {
  .shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px 16px; }
  .brand { padding: 0; border: 0; }
  .brand small, .sidebar-note { display: none; }
  .nav { grid-template-columns: repeat(5, 1fr); margin-top: 12px; }
  .nav a { justify-content: center; padding: 8px; font-size: 12px; }
  .nav a span { display: none; }
  .main { padding: 28px 16px 50px; }
  .page-header { align-items: stretch; flex-direction: column; }
  .stat-strip div { padding: 15px; }
  .stat-strip.case-detail-stats { grid-template-columns: repeat(2, 1fr); }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .search-field input { width: 100%; }
  .case-row { grid-template-columns: 1fr auto; padding: 18px; }
  .case-row .case-code, .case-row .case-number { grid-column: 1 / -1; }
  .case-document-row { grid-template-columns: 1fr auto; padding: 15px; }
  .case-document-row > .mini-button, .case-document-row > .document-error { grid-column: 1 / -1; justify-self: start; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .work-columns { grid-template-columns: 1fr; }
  .upcoming-groups { grid-template-columns: 1fr; }
  .upcoming-group { border-right: 0; border-bottom: 1px solid var(--line); }
  .quick-note-form { grid-template-columns: 1fr; }
  .inbox-stats { grid-template-columns: repeat(2, 1fr); }
  .document-row { grid-template-columns: 1fr auto; padding: 16px; }
  .document-row .document-meta, .classification-controls, .document-actions { grid-column: 1 / -1; }
  .document-actions { justify-content: flex-start; }
  .chat-message { max-width: 95%; }
  .chat-form { grid-template-columns: 1fr; }
}
