:root {
  --ink: #17251f;
  --muted: #64716b;
  --paper: #f6f4ee;
  --surface: rgba(255, 255, 255, 0.92);
  --line: #dfe4df;
  --green: #176f5b;
  --green-dark: #0d4f40;
  --mint: #dceee7;
  --amber: #bd781c;
  --amber-bg: #fff0d5;
  --blue: #315e83;
  --shadow: 0 18px 50px rgba(28, 52, 43, 0.10);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.ambient { position: fixed; border-radius: 50%; filter: blur(2px); pointer-events: none; opacity: .6; }
.ambient-one { width: 430px; height: 430px; right: -150px; top: -180px; background: #d2e9df; }
.ambient-two { width: 300px; height: 300px; left: -130px; bottom: -140px; background: #f4dcb4; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; z-index: 1; }
.login-card { width: min(470px, 100%); padding: 44px; border: 1px solid rgba(255,255,255,.8); background: var(--surface); border-radius: 28px; box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.brand-mark { display: grid; place-items: center; width: 62px; height: 62px; border-radius: 18px; color: white; background: var(--green); font-weight: 800; letter-spacing: -.06em; margin-bottom: 28px; }
.brand-mark.small { width: 44px; height: 44px; border-radius: 13px; margin: 0; font-size: 14px; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
h1, h2, h3 { margin: 0; letter-spacing: -.035em; }
.login-card h1 { font-size: clamp(34px, 7vw, 48px); line-height: 1; }
.lede { color: var(--muted); font-size: 17px; line-height: 1.55; margin: 18px 0 30px; }
.stack { display: grid; gap: 12px; }
label { display: grid; gap: 7px; color: #425049; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #ced7d1; background: white; color: var(--ink); border-radius: 12px; padding: 12px 13px; outline: none; transition: border .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,111,91,.13); }
textarea { resize: vertical; }
.password-row { display: flex; gap: 8px; }
.password-row input { flex: 1; }
.button { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 750; color: var(--ink); background: #e9ece9; transition: transform .12s, background .12s; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: var(--green-dark); }
.button.ghost { background: transparent; border: 1px solid var(--line); }
.button.wide { width: 100%; }
.icon-button { border: 1px solid var(--line); background: white; border-radius: 10px; padding: 9px 11px; color: var(--ink); }
.security-note { color: var(--muted); font-size: 12px; text-align: center; margin: 18px 0 0; }

.app-shell { position: relative; z-index: 1; min-height: 100vh; }
.topbar { height: 76px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.82); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.brand-inline, .topbar-actions { display: flex; align-items: center; gap: 13px; }
.brand-inline h1 { font-size: 19px; }
.brand-inline .eyebrow { margin-bottom: 2px; font-size: 9px; }
.session-badge { padding: 7px 10px; border-radius: 999px; background: var(--mint); color: var(--green-dark); font-size: 12px; font-weight: 750; }
.safety-banner { min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 9px; padding: 10px 20px; color: #68440f; background: var(--amber-bg); border-bottom: 1px solid #ecd6ae; font-size: 13px; }
.safety-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px rgba(189,120,28,.13); }

.workspace-grid { display: grid; grid-template-columns: 330px 1fr; min-height: calc(100vh - 122px); }
.sidebar { padding: 22px 18px; background: rgba(250,250,247,.82); border-right: 1px solid var(--line); }
.sidebar-heading { display: flex; justify-content: space-between; align-items: center; margin: 28px 3px 12px; }
.sidebar-heading h2 { font-size: 21px; }
.filter-row { display: flex; gap: 5px; padding: 4px; background: #e9ece8; border-radius: 12px; }
.filter { flex: 1; border: 0; padding: 7px 5px; border-radius: 9px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 750; }
.filter.active { background: white; color: var(--ink); box-shadow: 0 2px 8px rgba(20,40,32,.08); }
.case-list { display: grid; gap: 8px; margin-top: 14px; }
.case-card { width: 100%; text-align: left; border: 1px solid transparent; background: transparent; border-radius: 14px; padding: 13px; }
.case-card:hover, .case-card.active { border-color: var(--line); background: white; }
.case-card.active { box-shadow: 0 8px 22px rgba(33,52,45,.07); }
.case-card-top { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.case-card strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-card p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.mini-state { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); margin-top: 4px; }
.mini-state.approved { background: var(--green); }

.empty-state { display: grid; place-content: center; justify-items: center; text-align: center; padding: 40px; color: var(--muted); }
.empty-state h2 { color: var(--ink); font-size: 32px; }
.empty-state p:last-child { max-width: 500px; line-height: 1.6; }
.compass { display: grid; place-items: center; width: 78px; height: 78px; margin-bottom: 22px; border: 1px solid #cad7d0; border-radius: 50%; background: rgba(255,255,255,.7); color: var(--green); font-size: 28px; }

.case-workspace { padding: 28px; overflow: auto; }
.case-header { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.case-header h2 { font-size: clamp(28px, 4vw, 42px); }
.case-header .muted { margin: 8px 0 0; }
.muted { color: var(--muted); }
.state-pill { display: inline-flex; padding: 8px 12px; border-radius: 999px; background: var(--amber-bg); color: #795019; font-size: 12px; font-weight: 800; }
.state-pill.approved { background: var(--mint); color: var(--green-dark); }
.action-strip { display: flex; gap: 9px; flex-wrap: wrap; margin: 22px 0; min-height: 1px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.panel { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 9px 28px rgba(29,52,43,.05); }
.panel.span-two { grid-column: span 2; }
.panel h3 { font-size: 20px; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.panel-content { margin-top: 16px; line-height: 1.5; }
.amount { color: var(--green); font-size: 25px; font-weight: 850; letter-spacing: -.04em; }
.facts-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin: 20px 0 0; }
.facts-grid div { min-width: 0; }
.facts-grid dt { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.facts-grid dd { margin: 5px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.info-block { padding: 12px; border-radius: 12px; background: #f3f5f2; margin-top: 10px; }
.info-block strong { display: block; margin-bottom: 4px; }
.hash { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.counter { color: var(--muted); font-size: 12px; }
.timeline { list-style: none; margin: 18px 0 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 12px 1fr auto; gap: 12px; padding: 0 0 17px; position: relative; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 5px; top: 12px; bottom: 0; width: 1px; background: var(--line); }
.timeline-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--green); margin-top: 3px; position: relative; z-index: 1; box-shadow: 0 0 0 4px white; }
.timeline strong { font-size: 13px; }
.timeline p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.timeline time { color: var(--muted); font-size: 10px; }

.dialog { width: min(720px, calc(100% - 28px)); border: 0; border-radius: 22px; padding: 0; box-shadow: 0 30px 80px rgba(12,30,23,.28); }
.dialog::backdrop { background: rgba(18,34,28,.46); backdrop-filter: blur(4px); }
.dialog form { padding: 26px; }
.compact-dialog { max-width: 480px; }
.dialog-heading, .dialog-actions { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.dialog-heading { margin-bottom: 18px; }
.dialog-actions { justify-content: flex-end; margin-top: 22px; }
.form-warning { padding: 11px 13px; border-radius: 11px; color: #6a4717; background: var(--amber-bg); font-size: 12px; line-height: 1.4; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-two { grid-column: span 2; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: min(420px, calc(100% - 44px)); padding: 13px 16px; color: white; background: #24362f; border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { background: #7a302e; }

@media (max-width: 900px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .case-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .topbar { padding: 0 16px; }
  .session-badge { display: none; }
  .safety-banner { align-items: start; flex-wrap: wrap; justify-content: start; }
  .case-list, .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .panel.span-two, .form-grid .span-two { grid-column: span 1; }
  .case-workspace { padding: 20px 14px; }
  .facts-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 30px 22px; }
}
