/* ArkCase Cleanup Review Workbench — shared stylesheet (Phase A "calm console" shell).
   Preserves all legacy component classes so existing pages render unchanged; adds the
   sidebar shell, refined typography, and one calm accent. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #f7f8fa;
  --text: #1f2733;
  --muted: #6b7280;
  --line: #e3e7ee;
  --line-strong: #cdd4e0;
  --link: #4f46e5;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-line: #c7d0fb;
  --success-bg: #edf7ed; --success-line: #9ed29e;
  --error-bg: #fdecec; --error-line: #e2a5a5;
  --warn-bg: #fff8e1; --warn-line: #f0c36d;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --sidebar-w: 236px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text); background: var(--bg); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App shell: sidebar + main column ─────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; align-items: stretch; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--surface);
  border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh;
  overflow-y: auto; padding: 16px 12px 28px; display: flex; flex-direction: column;
}
.sb-brand { font-weight: 700; font-size: 15px; padding: 4px 10px; letter-spacing: -.01em; }
.sb-sub { font-size: 11.5px; color: var(--muted); padding: 0 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.nav-group { margin-top: 16px; }
.nav-group-label { text-transform: uppercase; font-size: 10.5px; letter-spacing: .07em; color: var(--muted); padding: 0 10px; margin-bottom: 4px; font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px;
  color: var(--text); font-size: 13.5px; line-height: 1.2; margin: 1px 0;
}
.nav-link:hover { background: var(--surface-alt); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }
.nav-link .tag-new { margin-left: auto; font-size: 9px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 6px; padding: 1px 5px; letter-spacing: .03em; }
.sb-spacer { flex: 1; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  min-height: 54px; padding: 8px 22px; background: rgba(255,255,255,0.9);
  backdrop-filter: saturate(1.1) blur(6px); border-bottom: 1px solid var(--line);
}
.topbar-title { font-weight: 600; font-size: 15px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sb-toggle { display: none; }
.content { padding: 24px 22px 40px; width: 100%; max-width: 1340px; margin: 0 auto; flex: 1; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); }

/* ── Legacy component classes (preserved; refined) ───────────────────────── */
.app-shell { width: 100%; }  /* legacy no-op wrapper */
.page { display: flex; flex-direction: column; gap: 18px; }
.page-header { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: end; margin-bottom: 4px; }
.page-header h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.page-header p { margin: 6px 0 0; color: var(--muted); }
.section, .content-card, .panel, .card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}
.section-title, .content-card h2, .panel h2, .section h2 { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 12px; background: var(--surface-alt); margin-right: 6px; }
.notice { padding: 12px 14px; border-radius: 10px; margin: 0 0 16px; }
.notice.success { background: var(--success-bg); border: 1px solid var(--success-line); }
.notice.error { background: var(--error-bg); border: 1px solid var(--error-line); }
.toolbar, .action-row { display: flex; gap: 10px 14px; align-items: center; flex-wrap: wrap; }
.grid-2, .page-grid, .metric-grid, .panel-grid, .form-grid { display: grid; gap: 16px; align-items: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.page-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.panel-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.metric-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 > *, .page-grid > *, .panel-grid > *, .metric-grid > *, .form-grid > * { min-width: 0; }
.metric-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.metric-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.metric-value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
form.inline { display: inline; }
form .row { margin: 8px 0; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type="text"], input[type="number"], input[type="password"], textarea, select {
  width: 100%; max-width: 100%; box-sizing: border-box; padding: 9px 10px; min-height: 42px;
  border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; font-size: inherit; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 88px; }
button, .button-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; min-height: 42px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: #fff; cursor: pointer; color: var(--text); font-size: inherit; font-family: inherit;
}
button:hover, .button-link:hover { background: var(--surface-alt); text-decoration: none; }
.button-primary, button.button-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button-primary:hover { background: #4338ca; }
.btn-danger { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.btn-danger:hover { background: #fee2e2; }
.button-link { text-decoration: none; }
.codebox { background: var(--surface-alt); border: 1px solid var(--line); padding: 8px; border-radius: 9px; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; }
details.accordion { border: 1px solid var(--line); border-radius: var(--radius); padding: 0; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
details.accordion + details.accordion { margin-top: 16px; }
details.accordion > summary { background: var(--surface-alt); padding: 13px 16px; cursor: pointer; font-weight: 700; list-style: none; }
details.accordion > summary::-webkit-details-marker { display: none; }
details.accordion > .accordion-body { padding: 16px; }
.tag-yes { color: #0a6b2c; font-weight: bold; }
.tag-no { color: #8b1e1e; font-weight: bold; }
.tag-band { font-weight: bold; }
.nav-chip { display: inline-flex; align-items: center; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface-alt); color: var(--text); font-size: 12px; text-decoration: none; }
.nav-chip:hover { background: var(--accent-soft); text-decoration: none; }
.table-wrap { width: 100%; overflow-x: auto; overflow-y: hidden; border: 1px solid var(--line); border-radius: 10px; background: #fff; position: relative; -webkit-overflow-scrolling: touch; }
.table-wrap table { margin: 0; border: 0; min-width: 100%; }
table { border-collapse: collapse; width: 100%; margin: 12px 0 20px; background: #fff; }
th, td { border: 1px solid var(--line); padding: 8px 10px; vertical-align: top; word-break: normal; }
th { background: var(--surface-alt); text-align: left; white-space: nowrap; font-size: 12.5px; }
.table-wrap table th, .table-wrap table td { white-space: nowrap; }
.table-wrap table { font-size: 13px; }
tbody tr:hover { background: var(--surface-alt); }
.cell-wrap { white-space: normal; word-break: break-word; max-width: 260px; min-width: 100px; }
.empty-state { padding: 22px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 10px; }
.row-green td { background: #e9f8ee; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line-strong); background: var(--surface-alt); }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }

/* ── Phase B: utilities + small components (additive — used to retire inline styles) ── */
.flex-between { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.flex-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 12px; } .mt-2 { margin-top: 18px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 12px; } .mb-2 { margin-bottom: 18px; }
.w-full { width: 100%; } .nowrap { white-space: nowrap; } .text-right { text-align: right; }
.text-success { color: #1b5e20; font-weight: 700; }
.h-sec { font-size: 15px; font-weight: 600; margin: 0 0 12px; }   /* section heading */
.card-accent-blue  { border-top: 3px solid #0d47a1; }
.card-accent-green { border-top: 3px solid #1b5e20; }
.card-accent-info  { border-left: 4px solid #1565c0; }
.button-success { background: #1b5e20; color: #fff; border-color: #1b5e20; }
.button-success:hover { background: #155218; }
.btn-sm { font-size: 12px; padding: 5px 10px; min-height: 32px; }
.pill-success { background: #edf7ed; border-color: #9ed29e; color: #155724; }
.pill-warn    { background: #fff8e1; border-color: #f5c342; color: #7a5000; }
.pill-info    { background: #e3f2fd; border-color: #90caf9; color: #0d47a1; }
.pill-purple  { background: #f3e5f5; border-color: #ce93d8; color: #4a148c; }
.kv { font-size: 12px; margin: 8px 0; border: 0; }
.kv td { border: 0; padding: 2px 10px 2px 0; }
.kv td.k { color: var(--muted); }
.kv tr:hover { background: transparent; }
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 9999; display: none; align-items: center; justify-content: center; }
.overlay.show { display: flex; }
.overlay-box { background: #fff; border-radius: 16px; padding: 30px 40px; text-align: center; box-shadow: 0 16px 40px rgba(0,0,0,.2); max-width: 380px; }
.ml-auto { margin-left: auto; }
.subpanel { margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-alt); }
.pair-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: #fff; }
/* compact forms / tier review */
.progressbar { flex: 1; background: #e9ecef; border-radius: 4px; height: 10px; }
.progressbar-fill { background: #1b5e20; height: 10px; border-radius: 4px; transition: width .3s; }
.req { color: #c00; }
.mono { font-family: monospace; }
.variant-chip { display: inline-block; background: var(--surface-alt); border: 1px solid var(--line); border-radius: 4px; padding: 3px 10px; margin: 2px 4px 2px 0; font-size: 13px; font-family: monospace; }
.decision-banner { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 8px 14px; margin-bottom: 12px; font-size: 12px; }
.lbl-sm { font-size: 12px; display: block; margin-bottom: 4px; font-weight: 600; }
.input-sm { min-height: 36px; padding: 4px 8px; font-size: 13px; }
.case-decided { border-left: 4px solid #9ed29e; }
.case-open { border-left: 4px solid var(--line-strong); }
.form-divider { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.flex-end { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.flex-start-16 { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.d-inline { display: inline; }
.bold { font-weight: 700; }
.c-green { color: #0a6b2c; } .c-red { color: #8b1e1e; } .c-amber { color: #92610a; }
.check-row { font-weight: normal; display: flex; gap: 6px; align-items: center; cursor: pointer; }
.btn-xs { min-height: 32px; padding: 3px 8px; font-size: 12px; }
.hl-amber { background: #fef9ec; } .hl-green { background: #edf7ed; }
.th-amber { background: #fef9ec; border-bottom: 2px solid #e5c97a; }
.th-green { background: #edf7ed; border-bottom: 2px solid #9ed29e; }
.filter-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }

/* ── Responsive: sidebar becomes a top drawer ─────────────────────────────── */
@media (max-width: 920px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { display: none; }
  .sidebar.open nav { display: block; }
  .sb-toggle { display: inline-flex; }
  .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 18px 14px 32px; }
}
@media (max-width: 600px) {
  .page-header h1 { font-size: 19px; }
  .metric-value { font-size: 22px; }
  .table-wrap::after { content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 28px; background: linear-gradient(to right, transparent, rgba(255,255,255,0.9)); pointer-events: none; border-radius: 0 10px 10px 0; }
  .col-mobile-hide { display: none; }
}
