:root {
  --ink: #17221e;
  --muted: #64736c;
  --line: #dbe4df;
  --paper: #f6f8f7;
  --white: #fff;
  --green: #176b4a;
  --green-dark: #0d5237;
  --green-soft: #e8f4ee;
  --amber: #8a5909;
  --amber-soft: #fff4d8;
  --red: #9d342f;
  --red-soft: #fdebea;
  --blue: #155e91;
  --blue-soft: #e8f3fa;
  --nav: #102a22;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--green); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid #62a9d4; outline-offset: 2px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 252px 1fr; }
.sidebar { background: var(--nav); color: #dce9e3; padding: 28px 18px; display: flex; flex-direction: column; gap: 28px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: #d7f3e5; color: var(--nav); font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand small { opacity: .72; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { color: #c8d8d1; text-decoration: none; padding: 10px 13px; border-radius: 9px; }
.sidebar nav a:hover, .sidebar nav a.active { background: #1f4639; color: #fff; }
.sidebar-note { margin-top: auto; border: 1px solid #416759; background: #16372d; padding: 14px; color: #b9d0c6; font-size: 12px; border-radius: 10px; }
.sidebar-note strong { color: #fff; }
main { min-width: 0; }
.topbar { min-height: 92px; background: var(--white); border-bottom: 1px solid var(--line); padding: 18px 34px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.topbar h2 { font-size: 18px; margin: 1px 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-size: 11px; font-weight: 750; }
.company-picker { display: flex; align-items: center; gap: 10px; }
.company-picker label { color: var(--muted); font-size: 13px; }
.company-picker select { width: auto; min-width: 170px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.signed-in { display: grid; line-height: 1.3; padding-left: 14px; border-left: 1px solid var(--line); }
.signed-in small { color: var(--muted); }
.admin-nav { border-top: 1px solid #416759; padding-top: 16px; }
.demo-banner { background: #fff3c7; border-bottom: 1px solid #e7cf7a; padding: 10px 34px; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: #624600; }
.demo-banner strong, .demo-banner span { display: block; }
.demo-banner span { font-size: 13px; }
.demo-banner a { color: #4f3800; font-weight: 750; }
.page { padding: 32px 34px 60px; max-width: 1500px; }
.page-heading { margin-bottom: 24px; max-width: 850px; }
.page-heading h1 { font-size: 30px; line-height: 1.15; margin: 4px 0; }
.page-heading p { color: var(--muted); font-size: 16px; margin: 8px 0 0; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 16px; margin-bottom: 26px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: 0 1px 2px #17221e0a; }
.metric-link { color: inherit; text-decoration: none; display: block; transition: border-color .15s, transform .15s; }
.metric-link:hover { border-color: #78ad95; transform: translateY(-1px); }
.metric-link strong { display: block; font-size: 30px; margin-top: 8px; }
.metric-link span { color: var(--muted); }
.metric-link small { display: block; margin-top: 9px; color: var(--green); font-weight: 700; }
.grid-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 0 0 15px; gap: 12px; }
.section-title h2 { font-size: 18px; margin: 0; }
h2 { margin-top: 30px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
table { border-collapse: collapse; width: 100%; min-width: 680px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); background: #fafcfb; }
tr:last-child td { border-bottom: 0; }
.status { display: inline-block; padding: 3px 8px; border-radius: 999px; background: #eef2f0; color: #3f5149; font-size: 11px; font-weight: 750; white-space: nowrap; }
.status-posted, .status-matched, .status-open, .status-imported, .status-approved { background: var(--green-soft); color: var(--green); }
.status-needs-review, .status-partial, .status-new { background: var(--amber-soft); color: var(--amber); }
.status-rejected, .status-failed, .status-locked { background: var(--red-soft); color: var(--red); }
.status-auto-classified, .status-previewed { background: var(--blue-soft); color: var(--blue); }
.notice { padding: 14px 16px; border-radius: 10px; margin: 0 0 18px; border: 1px solid transparent; }
.notice.success { background: var(--green-soft); color: var(--green-dark); border-color: #b7ddca; }
.notice.error { background: var(--red-soft); color: var(--red); border-color: #efc4c1; }
.notice.info { background: var(--blue-soft); color: #154e72; border-color: #bfdbea; }
.notice.warning { background: var(--amber-soft); color: #684306; border-color: #ebd18e; }
.empty { padding: 35px; text-align: center; background: var(--white); border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); }
form.panel { display: grid; gap: 16px; max-width: 760px; background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.form-field { display: grid; gap: 5px; }
label { font-weight: 700; font-size: 13px; }
.field-help { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 2px; }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; border: 1px solid #adbeb6; border-radius: 8px; padding: 10px 11px; background: #fff; color: var(--ink); }
textarea { min-height: 90px; resize: vertical; }
button, .button { width: auto; display: inline-block; border: 0; border-radius: 8px; padding: 10px 15px; background: var(--green); color: #fff; font-weight: 750; cursor: pointer; text-decoration: none; }
button:hover, .button:hover { background: var(--green-dark); }
.button.secondary, button.secondary { background: #eaf0ed; color: var(--ink); }
.button.danger, button.danger { background: var(--red); color: #fff; }
.button.warning, button.warning { background: var(--amber); color: #fff; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; margin-bottom: 18px; padding: 16px; border: 1px solid var(--line); background: var(--white); border-radius: 12px; }
.filters .form-field { min-width: 210px; }
.hint { color: var(--muted); font-size: 13px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.report-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.report-tabs a { padding: 8px 11px; border-radius: 8px; background: #eaf0ed; color: var(--ink); text-decoration: none; }
.report-tabs a.active { background: var(--green); color: #fff; }
.report-guide { max-width: 850px; margin: 12px 0 18px; padding: 15px 17px; background: var(--blue-soft); border-left: 4px solid var(--blue); border-radius: 0 10px 10px 0; }
.guide-intro { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; margin-bottom: 24px; }
.guide-steps { display: grid; gap: 14px; counter-reset: guide; }
.guide-step { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 16px; background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.guide-step::before { counter-increment: guide; content: counter(guide); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 18px; font-weight: 800; }
.guide-step h2 { margin: 0 0 3px; font-size: 18px; }
.guide-step p { margin: 0; color: var(--muted); }
.guide-step .expected { color: var(--ink); font-size: 13px; margin-top: 6px; }
.guide-reports { margin-top: 22px; }
.guide-reports .actions { margin-top: 12px; }
.outcome { max-width: 850px; }
.outcome h2 { margin-top: 0; }
.outcome-list { display: grid; gap: 0; margin: 18px 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.outcome-row { display: grid; grid-template-columns: 190px 1fr; gap: 14px; padding: 12px 14px; background: #fff; border-bottom: 1px solid var(--line); }
.outcome-row:last-child { border-bottom: 0; }
.outcome-row dt { color: var(--muted); font-weight: 700; }
.outcome-row dd { margin: 0; }
.review-list { display: grid; gap: 18px; }
.review-card { background: var(--white); border: 1px solid var(--line); border-left: 5px solid #d79a2d; border-radius: 14px; padding: 22px; }
.review-card.resolved { border-left-color: #95aa9f; opacity: .86; }
.review-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; margin-bottom: 16px; }
.review-head h2 { margin: 0 0 3px; font-size: 20px; }
.review-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 15px 0; }
.fact { padding: 12px; background: var(--paper); border-radius: 9px; }
.fact small, .fact strong { display: block; }
.fact small { color: var(--muted); margin-bottom: 3px; }
.suggestion { background: var(--blue-soft); border-radius: 10px; padding: 14px; margin: 14px 0; }
.review-actions { display: grid; grid-template-columns: 1.4fr .8fr; gap: 16px; margin-top: 18px; align-items: start; }
.review-actions form { display: grid; gap: 12px; }
details { border: 1px solid var(--line); border-radius: 10px; background: #fff; }
summary { cursor: pointer; padding: 13px 15px; font-weight: 750; }
details > div, details > form { padding: 0 15px 15px; }
.advanced { margin-top: 18px; }
.advanced[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.warning-box { background: var(--amber-soft); border: 1px solid #e6ca83; border-radius: 10px; padding: 15px; color: #634205; }
.plain-steps { margin: 0; padding-left: 22px; }
.plain-steps li { margin: 8px 0; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 12px; }
legend { font-weight: 750; padding: 0 6px; }
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #edf5f1, #f9fbfa); }
.auth-shell { width: min(100%, 540px); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; }
.auth-brand strong, .auth-brand small { display: block; }
.auth-brand small { color: var(--muted); }
.auth-card { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 30px; box-shadow: 0 16px 50px #173e2d18; }
.auth-card form { display: grid; gap: 16px; }
.secret-link { word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--paper); padding: 12px; border-radius: 8px; border: 1px solid var(--line); }
.setup-list { display: grid; gap: 10px; padding: 0; list-style: none; }
.setup-list li { padding: 12px 14px; border-radius: 9px; background: var(--paper); display: flex; gap: 10px; align-items: center; }
.setup-list .done { color: var(--green); }
.setup-list .todo { color: var(--amber); }

@media (max-width: 1000px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .review-facts { grid-template-columns: repeat(2, 1fr); }
  .review-actions, .guide-intro { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; padding: 16px; }
  .sidebar nav { grid-template-columns: repeat(3, 1fr); }
  .sidebar-note { display: none; }
  .topbar { height: auto; padding: 16px; }
  .topbar-actions { justify-content: flex-start; }
  .demo-banner { padding: 10px 16px; }
  .page { padding: 22px 16px; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .sidebar nav { grid-template-columns: 1fr 1fr; }
  .topbar, .demo-banner, .topbar-actions { align-items: flex-start; gap: 14px; flex-direction: column; }
  .company-picker { width: 100%; flex-wrap: wrap; }
  .company-picker select { flex: 1; }
  .metrics { grid-template-columns: 1fr; }
  .guide-step { grid-template-columns: 42px 1fr; }
  .guide-step form { grid-column: 1 / -1; }
  .review-facts { grid-template-columns: 1fr; }
  .outcome-row { grid-template-columns: 1fr; gap: 2px; }
}
