[hidden] { display: none !important; }

:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --panel: #ffffff;
  --ink: #1c2427;
  --muted: #64707a;
  --line: #dde3e1;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #e2f3ef;
  --warn: #b45309;
  --warn-soft: #fdf0d7;
  --danger: #b91c1c;
  --danger-soft: #fee9e9;
  --info: #1d4ed8;
  --info-soft: #dfe8fd;
  --ok: #15803d;
  --ok-soft: #ddf3e4;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

h1 { margin: 0; font-size: 20px; }
p { margin: 8px 0; }
a { color: var(--accent-strong); }
hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }

button, input, select, textarea { font: inherit; }

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  min-height: 34px;
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

button:hover { border-color: #b9c4c1; background: #fafcfb; }
button.primary { border-color: var(--accent); background: var(--accent); color: white; }
button.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
button.danger { border-color: var(--danger); color: var(--danger); background: white; }
button.danger:hover { background: var(--danger-soft); }
button:disabled { cursor: not-allowed; opacity: 0.5; }
.small-btn { min-height: 28px; padding: 2px 10px; font-size: 12px; }
.icon-btn { border: 0; background: none; font-size: 18px; line-height: 1; padding: 2px 6px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 8px 10px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}
textarea { min-height: 80px; resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0; display: grid; gap: 8px; }
legend { font-size: 12px; font-weight: 700; color: #334044; padding: 0 4px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.prewrap { white-space: pre-wrap; word-break: break-word; margin: 8px 0 0; }
.empty { color: var(--muted); padding: 14px; text-align: center; }
.grid { display: grid; gap: 16px; }
.two-col { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.chips { margin-top: 8px; }

/* ---------- pills & chips ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent-strong);
  white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.muted { background: #eef0ef; color: var(--muted); }

.chip {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7fafa;
  padding: 1px 7px;
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
}
.chip.link:hover { border-color: var(--accent); }

/* ---------- shell ---------- */
.app-shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

.sidebar {
  border-right: 1px solid var(--line);
  background: #eef4f2;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand { display: flex; gap: 10px; align-items: center; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  font-weight: 800;
}
.brand-title { font-size: 18px; font-weight: 750; letter-spacing: -0.01em; }

.user-card { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); background: white; border-radius: 10px; padding: 10px; }
.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--info-soft);
  color: var(--info);
  font-weight: 800;
  flex-shrink: 0;
}

.nav { display: grid; gap: 6px; }
.nav button { justify-content: space-between; text-align: left; display: flex; align-items: center; }
.nav button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); font-weight: 700; }
.nav-badge {
  background: var(--danger);
  color: white;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
}
.sidebar-foot { margin-top: auto; }

.main { min-width: 0; padding: 22px 26px 40px; }

.topbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* ---------- stats ---------- */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 12px 14px; }
.stat-value { font-size: 24px; font-weight: 800; }
.stat-value.info { color: var(--info); }
.stat-value.warn { color: var(--warn); }
.stat-value.danger { color: var(--danger); }
.stat-value.muted { color: var(--muted); }

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-body { padding: 14px 16px; }

.dashboard-grid { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(3, minmax(120px, 1fr));
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
tr.request-row { cursor: pointer; }
tr.request-row:hover { background: #f2f9f7; }

/* ---------- notifications ---------- */
.notif-list { display: grid; gap: 8px; max-height: 70vh; overflow-y: auto; }
.notification {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  row-gap: 2px;
  text-align: left;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-left-color: var(--accent);
  border-radius: 8px;
  background: white;
  padding: 8px 10px;
  min-height: 0;
}
.notification.high { border-left-color: var(--warn); }
.notification.critical { border-left-color: var(--danger); }
.notification.medium { border-left-color: var(--info); }
.notif-number { font-weight: 800; font-size: 12px; }
.notif-label { grid-column: 1 / -1; color: #334044; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(200px, 1fr)); gap: 12px; }
.field { display: grid; gap: 5px; align-content: start; }
.field.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 700; color: #334044; }
.hint { font-size: 11.5px; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; cursor: pointer; }
.check input[type="checkbox"] { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--accent); }

.callout {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  background: #f6fbfa;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 4px 0 10px;
}
.callout ul { margin: 6px 0 0; padding-left: 18px; }
.callout.warn { border-left-color: var(--warn); background: var(--warn-soft); }

.email-only legend { color: var(--accent-strong); }

/* ---------- redaction workspace ---------- */
.redaction-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.redaction-pages { display: grid; gap: 20px; overflow: auto; }
.redaction-page { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 12px; width: fit-content; }
.redaction-page-label { margin-bottom: 6px; }
.redaction-canvas { position: relative; }
.redaction-canvas img { display: block; max-width: 100%; height: auto; image-rendering: auto; user-select: none; }
.redaction-overlay { position: absolute; inset: 0; touch-action: none; }
.redaction-loading .redaction-canvas::after { content: "Rendering page…"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; background: #f8faf9; }
.rbox { position: absolute; cursor: pointer; border-radius: 2px; box-sizing: border-box; }
.rbox.on { background: rgba(249, 112, 140, 0.5); border: 1px solid #fc8fa7; }
.rbox.off { background: rgba(34, 222, 141, 0.22); border: 1px solid #22de8d; }
.rbox.manual.on { background: rgba(245, 189, 43, 0.45); border: 1px solid #f5bd2b; }
.rbox.manual.off { background: rgba(33, 199, 243, 0.18); border: 1px solid #21c7f3; }
.rbox.drawing { background: rgba(15, 118, 110, 0.25); border: 1px dashed var(--accent-strong); pointer-events: none; }
.redaction-sidebar { display: grid; gap: 14px; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.redaction-group { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.redaction-group:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.redaction-candidate { display: flex; align-items: center; gap: 6px; padding: 4px 0; flex-wrap: wrap; }
.redaction-candidate.disabled span { text-decoration: line-through; color: var(--muted); }
.small-btn { font-size: 11.5px; padding: 2px 8px; border: 1px solid var(--line); background: white; border-radius: 6px; cursor: pointer; }
@media (max-width: 1100px) { .redaction-layout { grid-template-columns: 1fr; } }

/* ---------- items ---------- */
.item-list { display: grid; gap: 10px; }
.item { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: white; min-width: 0; }
.subitem { border-top: 1px dashed var(--line); padding: 8px 0 2px; margin-top: 8px; }
.item-list > .subitem:first-child, .item .item-list .subitem:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.highlight-warn { border-left: 4px solid var(--warn); background: #fffdf6; }

.comm-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }

.task.done span strong { text-decoration: line-through; color: var(--muted); }

.fee-line { display: grid; grid-template-columns: 150px 1fr 90px 100px; gap: 8px; margin-bottom: 8px; }
.fee-lines-header { display: grid; grid-template-columns: 150px 1fr 90px 100px; gap: 8px; margin-bottom: 4px; }
.fee-totals { display: grid; gap: 4px; margin: 10px 0; max-width: 320px; margin-left: auto; }
.fee-totals div { display: flex; justify-content: space-between; gap: 20px; }
.fee-totals .grand { border-top: 1px solid var(--line); padding-top: 6px; font-size: 15px; }

/* ---------- workspace ---------- */
.workspace-header {
  display: grid;
  gap: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.workspace-title h1 { font-size: 19px; margin: 2px 0 4px; }
.request-number { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; color: var(--accent-strong); text-transform: uppercase; }

.facts { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 10px; }
.fact { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; background: #fbfcfc; }
.fact-label { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 3px; }
.fact-value { font-weight: 600; }

.action-bar { display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px dashed var(--line); padding-top: 12px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); padding: 8px 10px 0; }
.tabs button { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: 0; text-transform: capitalize; }
.tabs button.active { background: var(--accent); color: white; border-color: var(--accent); }

.timeline { display: grid; gap: 0; }
.timeline-entry { display: grid; grid-template-columns: 14px 1fr; gap: 10px; position: relative; padding: 8px 0 8px 4px; }
.timeline-entry:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 26px;
  bottom: -6px;
  width: 2px;
  background: var(--line);
}
.timeline-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-top: 5px; }

.audit-entry details { margin-top: 6px; }
.audit-entry summary { cursor: pointer; color: var(--muted); }
.audit-entry pre { background: #f6f8f8; border: 1px solid var(--line); border-radius: 8px; padding: 8px; overflow-x: auto; }

/* ---------- login ---------- */
.login { max-width: 1020px; margin: 0 auto; padding: 56px 20px; }
.login-grid { display: grid; grid-template-columns: 1fr 380px; gap: 24px; align-items: start; margin-top: 24px; }
.org-cards { display: grid; gap: 12px; }
.org-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: white; box-shadow: var(--shadow); }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}
.modal.wide { width: min(720px, 100%); }
.modal-header { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 16px 18px; overflow-y: auto; display: grid; gap: 12px; align-content: start; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #fbfcfc; }
.modal-error { color: var(--danger); background: var(--danger-soft); border-radius: 8px; padding: 8px 10px; font-size: 13px; }

/* ---------- toasts ---------- */
.toast-stack { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; }
.toast {
  background: #17332e;
  color: white;
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  max-width: 360px;
  animation: toast-in 160ms ease-out;
  font-weight: 600;
  font-size: 13px;
}
.toast.error { background: #58151c; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all 280ms ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 1080px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .facts { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .login-grid, .form-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .fee-line, .fee-lines-header { grid-template-columns: 1fr 1fr; }
}
