/* 360 Tax Accounting Review — professional accounting/audit SaaS theme.
   Light, calm, data-focused. Custom CSS only (no framework). All class names are
   the ones the templates already use, restyled for a trustworthy enterprise feel. */

:root {
  --bg:        #f6f7f9;
  --surface:   #ffffff;
  --surface-2: #fbfcfd;
  --ink:       #172033;
  --ink-2:     #2b3648;
  --muted:     #667085;
  --faint:     #8b95a5;
  --line:      #e4e7ec;
  --line-2:    #d0d5dd;

  --brand:      #2457c5;
  --brand-ink:  #1b44a0;
  --brand-weak: #eef3ff;
  --brand-ring: rgba(36, 87, 197, .25);

  --ok:      #067647; --ok-bg:   #ecfdf3; --ok-line:   #a9e6c3;
  --warn:    #b54708; --warn-bg: #fffaeb; --warn-line: #fedf89;
  --danger:  #b42318; --dang-bg: #fef3f2; --dang-line: #fecdca;
  --info:    #175cd3; --info-bg: #eff8ff; --info-line: #b2ddff;

  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
  --shadow:    0 1px 3px rgba(16,24,40,.10), 0 1px 2px rgba(16,24,40,.06);
  --shadow-md: 0 4px 12px rgba(16,24,40,.08);

  --r:    8px;
  --r-sm: 6px;
  --sidebar-w: 240px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
          "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 400 14px/1.55 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--ink); margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
p  { margin: 8px 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.tiny  { font-size: 12px; }
.sub   { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.ok    { color: var(--ok); font-weight: 600; }
.error { color: var(--danger); }
.mono  { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.center{ text-align: center; }
.nowrap{ white-space: nowrap; }
.r     { text-align: right; }
.inline{ display: inline; }
.ml-auto { margin-left: auto; }
.mt-2  { margin-top: 10px; }
.span-2 { grid-column: 1 / span 2; }

/* CSP-safe progress-bar widths (no inline style; see review_extras.bar_w) */
.w-0{width:0} .w-5{width:5%} .w-10{width:10%} .w-15{width:15%} .w-20{width:20%}
.w-25{width:25%} .w-30{width:30%} .w-35{width:35%} .w-40{width:40%} .w-45{width:45%}
.w-50{width:50%} .w-55{width:55%} .w-60{width:60%} .w-65{width:65%} .w-70{width:70%}
.w-75{width:75%} .w-80{width:80%} .w-85{width:85%} .w-90{width:90%} .w-95{width:95%} .w-100{width:100%}

/* ---------------------------------------------------------------- app shell */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px; border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 7px; flex: none;
  background: linear-gradient(160deg, var(--brand), var(--brand-ink));
  color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center; letter-spacing: -.02em;
}
.brand-name { font-weight: 700; font-size: 14px; line-height: 1.15; }
.brand-name small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 0; }

.sidebar-nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); font-weight: 600; padding: 12px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 1px 0; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 500; text-decoration: none;
  border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.active { background: var(--brand-weak); color: var(--brand-ink); font-weight: 600; }
.nav-item .ico { width: 16px; height: 16px; flex: none; color: currentColor; opacity: .85; }

.sidebar-foot { border-top: 1px solid var(--line); padding: 12px; }
.userbox { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--brand-weak); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; text-transform: uppercase;
}
.userbox .who { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.userbox .who small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }

.app-main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 28px; background: rgba(255,255,255,.85); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); min-height: 56px;
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.crumbs a { color: var(--muted); font-weight: 500; }
.crumbs a:hover { color: var(--brand); }
.crumbs .sep { color: var(--line-2); }
.crumbs .here { color: var(--ink); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content { padding: 24px 28px 48px; max-width: 1280px; width: 100%; }
.foot { padding: 16px 28px; color: var(--faint); font-size: 12px; border-top: 1px solid var(--line); }

/* anonymous / auth layout (no sidebar) */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 18px; }

/* ------------------------------------------------------------- page header */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }

/* ------------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 20px; box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.card.wide, .card.narrow { margin-bottom: 18px; }
.card > h1 + .sub, .card > h2 + .sub { margin-top: 2px; }
.card-tight { padding: 14px 16px; }

/* -------------------------------------------------------------- subnav tabs */
.subnav { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: -4px 0 16px; }
.subnav a {
  padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 6px 6px 0 0;
}
.subnav a:hover { color: var(--ink); text-decoration: none; background: var(--surface-2); }
.subnav a.active { color: var(--brand-ink); border-bottom-color: var(--brand); }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2);
  border-radius: var(--r-sm); padding: 8px 14px; font: 600 13px/1 var(--font);
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-2); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn.danger { background: var(--surface); border-color: var(--dang-line); color: var(--danger); }
.btn.danger:hover { background: var(--dang-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; }
.btn.xs { padding: 4px 9px; font-size: 12px; border-radius: 5px; }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; }

/* ------------------------------------------------------------------- forms */
label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
input[type=text], input[type=search], input[type=date], input[type=number],
input[type=password], input[type=email], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  width: 100%; max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
input[type=file] { font-size: 13px; }
form p { margin: 10px 0; }
form p label { display: block; margin-bottom: 4px; }
.field { margin: 12px 0; }
.field label { display: block; margin-bottom: 4px; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ tables */
.table-scroll { overflow-x: auto; border-radius: var(--r-sm); }
.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid th, .grid td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid thead th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600; background: var(--surface-2);
  border-bottom: 1px solid var(--line); position: sticky; top: 0;
}
.grid tbody tr:hover { background: var(--surface-2); }
.grid td.r, .grid th.r { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.grid.tiny th, .grid.tiny td { padding: 6px 8px; font-size: 12px; }
table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini td { padding: 6px 8px; border-top: 1px solid var(--line); }
table.mini td.num { width: 56px; text-align: right; font-variant-numeric: tabular-nums; }

.worklist td.memo { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.worklist td.findings { max-width: 200px; }
tr.wl-row td { transition: background .1s; }
tr.sev-row-HIGH td { background: #fffafa; }
tr.sev-row-HIGH:hover td { background: #fff1f0; }

/* ------------------------------------------------------------ badges / pills */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
/* review lifecycle */
.badge.status-ANALYZED, .badge.st-CLEAN, .badge.st-COMPLETED { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.badge.status-ANALYZING, .badge.st-PROCESSING, .badge.st-NEEDS_REVIEW { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.badge.status-ANALYSIS_FAILED, .badge.st-EXCEPTION, .badge.st-FAILED { background: var(--dang-bg); border-color: var(--dang-line); color: var(--danger); }
.badge.status-IMPORTED, .badge.st-UPLOADED { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }

/* severity pills — restrained, not fully saturated */
.sev { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.sev.HIGH   { background: var(--dang-bg); color: var(--danger); border: 1px solid var(--dang-line); }
.sev.MEDIUM { background: var(--warn-bg); color: var(--warn);   border: 1px solid var(--warn-line); }
.sev.LOW    { background: #f2f4f7;        color: #475467;       border: 1px solid var(--line-2); }

.chip { display: inline-block; padding: 2px 7px; margin: 1px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); font-size: 11px; color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.decision { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.decision.ACCEPT   { background: var(--ok-bg);   color: var(--ok); }
.decision.REJECT   { background: #f2f4f7;        color: #475467; }
.decision.ESCALATE { background: var(--warn-bg); color: var(--warn); }
.decision-btn.ACCEPT   { border-color: var(--ok-line);   color: var(--ok); }
.decision-btn.ACCEPT:hover   { background: var(--ok-bg); }
.decision-btn.ESCALATE { border-color: var(--warn-line); color: var(--warn); }
.decision-btn.ESCALATE:hover { background: var(--warn-bg); }
.decision-btn.REJECT:hover   { background: #f2f4f7; }

/* --------------------------------------------------------------------- KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; text-align: left;
}
.kpi .l { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; margin-bottom: 6px; }
.kpi .n { display: block; font-size: 24px; font-weight: 600; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi.high .n  { color: var(--danger); }
.kpi.med .n   { color: var(--warn); }
.kpi.clean .n { color: var(--ok); }

/* --------------------------------------------------------- banners / alerts */
.banner { border: 1px solid var(--line); border-left: 3px solid var(--muted); border-radius: var(--r-sm); padding: 12px 14px; background: var(--surface-2); }
.banner.warn { background: var(--warn-bg); border-color: var(--warn-line); border-left-color: var(--warn); }
.banner.err  { background: var(--dang-bg); border-color: var(--dang-line); border-left-color: var(--danger); }
.banner.info { background: var(--info-bg); border-color: var(--info-line); border-left-color: var(--info); }
ul.tight { padding-left: 18px; margin: 6px 0 0; } ul.tight li { margin: 3px 0; }

/* -------------------------------------------------------------- empty state */
.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty .empty-ico { width: 40px; height: 40px; margin: 0 auto 10px; color: var(--line-2); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty p { margin: 4px 0 14px; }

/* ------------------------------------------------------------- coverage bars */
.split2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cbar { display: flex; height: 12px; border-radius: 7px; overflow: hidden; background: #eef1f5; border: 1px solid var(--line); }
.cbar.sm { height: 8px; }
.cbar i { display: block; height: 100%; }
.seg-high { background: var(--danger); } .seg-med { background: var(--warn); }
.seg-low { background: #98a2b3; } .seg-clean { background: var(--ok); } .seg-accent { background: var(--brand); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: baseline; }
.legend .lg-high::before { background: var(--danger); } .legend .lg-med::before { background: var(--warn); }
.legend .lg-low::before { background: #98a2b3; } .legend .lg-clean::before { background: var(--ok); }

/* --------------------------------------------------- finding detail (panes) */
.detail-panel:empty { display: none; }
.detail-panel { margin-top: 16px; }
.txn-detail { border: 1px solid var(--line); border-radius: var(--r); padding: 16px; background: var(--surface); box-shadow: var(--shadow-sm); }
.panes { display: grid; grid-template-columns: 1fr 1.25fr 1fr; gap: 14px; margin-top: 12px; }
.pane { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; }
.pane.facts    { background: var(--surface-2); }
.pane.analysis { background: #fffdf6; border-color: #f3e9cf; }
.pane.decision { background: #f6faf8; border-color: #d8ece0; }
.pane dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0 0; font-size: 13px; }
.pane dt { color: var(--muted); }
.pane dd { margin: 0; color: var(--ink); }
.finding { border-top: 1px dashed var(--line); padding: 8px 0; font-size: 13px; }
.finding:first-of-type { border-top: none; }
.finding .prop { color: var(--ok); font-size: 12px; margin-top: 2px; }
.pane.decision label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 3px; font-weight: 500; }
.history summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 8px; }

/* ----------------------------------------------------------------- filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin: 0 0 14px; padding: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.filters label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.filters select, .filters input { min-width: 120px; }

/* --------------------------------------------------------------- step guide */
.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 18px; }
.steps li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 500; padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.steps li.active { color: var(--brand-ink); border-color: var(--brand-weak); background: var(--brand-weak); }
.steps .step-n { width: 20px; height: 20px; flex: none; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--muted); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.steps li.active .step-n { background: var(--brand); border-color: var(--brand); color: #fff; }
.mapping h2 { margin-bottom: 4px; }
.result h2 { margin-bottom: 4px; }

/* ------------------------------------------------------------------ exports */
.export-grid { display: flex; flex-direction: column; gap: 8px; max-width: 460px; }
.export-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.export-row span { flex: 1; font-weight: 500; }

/* ------------------------------------------------------- loading / htmx feedback */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.htmx-request button[type=submit], form.htmx-request .btn.primary { opacity: .6; pointer-events: none; }
main .htmx-settling, main .htmx-added { }

/* misc from earlier phases */
.check-img { max-width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm); }
pre.tiny { white-space: pre-wrap; max-height: 220px; overflow: auto; background: var(--surface-2); padding: 8px; border-radius: var(--r-sm); border: 1px solid var(--line); }

/* ============================================================== responsive */
@media (max-width: 1024px) { .panes { grid-template-columns: 1fr; } .split2 { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .sidebar-brand { border-bottom: none; border-right: 1px solid var(--line); padding: 12px 16px; white-space: nowrap; }
  .sidebar-nav { display: flex; padding: 8px; gap: 4px; flex: 1; }
  .nav-group-label { display: none; }
  .nav-item { border-left: none; white-space: nowrap; padding: 8px 12px; }
  .nav-item.active { border-radius: var(--r-sm); }
  .sidebar-foot { border-top: none; border-left: 1px solid var(--line); }
  .userbox .who { display: none; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 12px 16px; }
}
@media (max-width: 560px) {
  .page-head { flex-direction: column; }
  .row-between { flex-direction: column; }
  .filters { gap: 8px; }
  .filters label, .filters select, .filters input { width: 100%; }
}
