/* ==========================================================================
   LienTrace FL
   Navy #0D1B4B · Gold #C9A84C · Green #1E7C44 · Red #C0392B · Amber #E67E22
   Same visual family as the Tax Deed app; risk colour is the organising idea.
   ========================================================================== */

:root {
  --navy:       #0D1B4B;
  --navy-800:   #16265c;
  --navy-700:   #23346f;
  --gold:       #C9A84C;
  --gold-soft:  #f3e9cd;
  --green:      #1E7C44;
  --green-soft: #e3f2e9;
  --blue:       #24589c;
  --blue-soft:  #e4edf9;
  --amber:      #E67E22;
  --amber-soft: #fdf0e2;
  --red:        #C0392B;
  --red-soft:   #fbe9e7;
  --crimson:    #7d1d13;
  --gray:       #6b7280;
  --gray-soft:  #f1f2f4;
  --line:       #e2e5ea;
  --ink:        #1a1d24;
  --bg:         #f7f8fa;
  --white:      #ffffff;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;

  --radius: 6px;
  --shadow: 0 1px 3px rgba(13, 27, 75, .08), 0 1px 2px rgba(13, 27, 75, .04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--sans);
  font-size: 14px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--gray); }
.xs { font-size: 11px; }
.hint { font-weight: 400; color: var(--gray); font-size: 12px; }
.good { color: var(--green); font-weight: 600; }
.bad  { color: var(--red); font-weight: 600; }
.warn-text { color: var(--amber); font-weight: 600; }
.r { text-align: right; }

/* ------------------------------------------------------------- Layout ---- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; flex: 0 0 220px;
  background: var(--navy); color: #d7dcea;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--gold); color: var(--navy);
  font-weight: 700; font-family: var(--mono);
  border-radius: var(--radius); letter-spacing: .5px;
}
.brand-mark.lg { width: 48px; height: 48px; font-size: 18px; margin: 0 auto 12px; }
.brand-name { color: #fff; font-weight: 700; letter-spacing: 1.5px; font-size: 13px; }
.brand-sub  { color: var(--gold); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; }

.sidebar nav { padding: 12px 0; flex: 1; }
.sidebar nav a {
  display: block; padding: 10px 18px;
  color: #b9c2d8; font-size: 13px;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: var(--navy-800); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--navy-800); color: #fff; border-left-color: var(--gold); font-weight: 600; }

.sidebar-foot { padding: 16px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.sidebar-foot .who { color: #fff; font-weight: 600; }
.sidebar-foot .role { color: var(--gold); text-transform: uppercase; letter-spacing: 1px; font-size: 10px; margin-bottom: 8px; }
.small-link { display: block; color: #9aa6c4; font-size: 12px; padding: 2px 0; }
.small-link:hover { color: #fff; }

.content { flex: 1; min-width: 0; padding: 0 24px 48px; }
.topbar { padding: 20px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.topbar h1 { margin: 0; font-size: 20px; font-weight: 600; font-family: var(--mono); }
.crumbs { margin-bottom: 12px; font-size: 13px; }

.nav-toggle {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 60;
  background: var(--navy); color: #fff; border: none;
  border-radius: var(--radius); width: 38px; height: 38px;
  font-size: 18px; cursor: pointer;
}

/* -------------------------------------------------------------- Panels --- */

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.panel.narrow { max-width: 460px; }
.panel h2 {
  margin: 0 0 14px; font-size: 14px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; color: var(--navy);
  padding-bottom: 8px; border-bottom: 2px solid var(--gold);
  display: flex; align-items: center; gap: 10px;
}
.panel h4 { margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--gray); }

.panel.bid-bid      { border-left: 4px solid var(--green); }
.panel.bid-research { border-left: 4px solid var(--amber); }
.panel.bid-pass     { border-left: 4px solid var(--red); }

/* --------------------------------------------------------------- Stats --- */

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--white); border: 1px solid var(--line);
  border-top: 3px solid var(--navy); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow);
}
.stat-n { font-family: var(--mono); font-size: 22px; font-weight: 700; color: var(--navy); }
.stat-l { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--gray); }
.stat-green { border-top-color: var(--green); }
.stat-amber { border-top-color: var(--amber); }
.stat-red   { border-top-color: var(--red); }

/* ------------------------------------------------------ Search + tabs ---- */

.search-panel { border-top: 3px solid var(--gold); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tab {
  background: transparent; border: none; border-bottom: 3px solid transparent;
  padding: 10px 16px; font-family: var(--sans); font-size: 13px; font-weight: 600;
  color: var(--gray); cursor: pointer;
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); border-bottom-color: var(--gold); }

.big-input { font-size: 15px !important; padding: 11px 13px !important; }

.inline-error {
  margin-top: 8px; padding: 8px 12px;
  background: var(--red-soft); color: var(--crimson);
  border-left: 3px solid var(--red);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 12.5px;
}
.inline-error[hidden] { display: none; }
.inline-error.ok { background: var(--green-soft); color: #14562f; border-left-color: var(--green); }

.inline-warn {
  margin-top: 10px; padding: 8px 12px;
  background: var(--amber-soft); color: #8a4a0d;
  border-left: 3px solid var(--amber);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 12.5px;
}

/* ---------------------------------------------------------------- Form --- */

label { display: block; font-size: 12px; font-weight: 600; margin: 10px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], input[type=date], select, textarea {
  width: 100%; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: var(--radius);
  font-family: var(--sans); font-size: 13px;
  background: var(--white); color: var(--ink);
}
input[type=url], input[type=number] { font-family: var(--mono); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(13, 27, 75, .09);
}
textarea { resize: vertical; }

.checkline { display: flex; flex-wrap: wrap; gap: 18px; margin: 12px 0; }
.checkline label { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; font-size: 13px; }
.checkline input[type=checkbox] { width: auto; margin: 0; }

/* ------------------------------------------------------------- Filters --- */

.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.filter { display: flex; flex-direction: column; gap: 4px; }
.filter label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--gray); }
.filter input, .filter select { min-width: 160px; }
.filter-actions { flex-direction: row; gap: 8px; }

/* ------------------------------------------------------------- Buttons --- */

.btn {
  display: inline-block; padding: 7px 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--white); color: var(--ink);
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.4;
}
.btn:hover { background: var(--gray-soft); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-700); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #a53125; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 14px; margin-top: 18px; }
.btn-block { width: 100%; margin-top: 18px; }

.action-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* -------------------------------------------------------------- Tables --- */

.table-wrap {
  overflow-x: auto; background: var(--white);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); -webkit-overflow-scrolling: touch;
}
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  background: var(--navy); color: #fff; text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; padding: 9px 12px; white-space: nowrap;
}
table.grid th.r { text-align: right; }
table.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tbody tr:hover { background: #fafbfc; }
table.grid td.empty { text-align: center; color: var(--gray); padding: 32px 12px; }
table.grid td.input-cell { max-width: 300px; word-break: break-word; }
table.grid td.actions { white-space: nowrap; }
table.grid td.actions .btn { margin-right: 4px; }
table.grid tr.row-survives { background: #fff8f7; }
table.grid tr.row-survives:hover { background: #fdefed; }

dl.extracted { margin: 6px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; font-size: 11px; }
dl.extracted dt { color: var(--gray); }
dl.extracted dd { margin: 0; }

/* --------------------------------------------------------------- Pills --- */

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .5px; white-space: nowrap;
}
.risk-clear    { background: var(--green-soft); color: var(--green); }
.risk-low      { background: var(--blue-soft);  color: var(--blue); }
.risk-medium   { background: var(--amber-soft); color: var(--amber); }
.risk-high     { background: var(--red-soft);   color: var(--red); }
.risk-critical { background: var(--crimson);    color: #fff; }

.pill-bid      { background: var(--green-soft); color: var(--green); }
.pill-research { background: var(--amber-soft); color: var(--amber); }
.pill-pass     { background: var(--gray-soft);  color: var(--gray); }

.st-pending    { background: var(--gray-soft);  color: var(--gray); }
.st-processing { background: var(--amber-soft); color: var(--amber); }
.st-complete   { background: var(--green-soft); color: var(--green); }
.st-failed     { background: var(--red-soft);   color: var(--red); }

/* --------------------------------------------------------------- Facts --- */

dl.facts { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; margin: 0; }
dl.facts dt { font-size: 12px; color: var(--gray); font-weight: 600; }
dl.facts dd { margin: 0; font-size: 13px; word-break: break-word; }

/* --------------------------------------------------------- Risk banner --- */

.risk-banner {
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
  padding: 18px 22px; border-radius: var(--radius);
  margin-bottom: 20px; color: #fff;
  box-shadow: var(--shadow);
}
.rb-label { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; opacity: .85; }
.rb-value { font-size: 28px; font-weight: 700; letter-spacing: 2px; font-family: var(--mono); }
.rb-stats { display: flex; gap: 28px; flex-wrap: wrap; }
.rb-stats > div { display: flex; flex-direction: column; }
.rb-n { font-size: 18px; font-weight: 700; }
.rb-t { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; opacity: .85; }

.risk-bg-clear    { background: var(--green); }
.risk-bg-low      { background: var(--blue); }
.risk-bg-medium   { background: var(--amber); }
.risk-bg-high     { background: var(--red); }
.risk-bg-critical { background: var(--crimson); }

/* ---------------------------------------------------------- Lien cards --- */

.lien-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.lien-card {
  border: 1px solid var(--line); border-left: 4px solid var(--green);
  border-radius: var(--radius); padding: 12px 14px; background: var(--green-soft);
}
.lien-card.found { border-left-color: var(--red); background: var(--red-soft); }
.lc-type { font-size: 12px; font-weight: 700; color: var(--navy); }
.lc-status { font-size: 12px; color: var(--gray); margin-top: 2px; }
.lien-card.found .lc-status { color: var(--red); font-weight: 600; }
.lc-amount { font-size: 15px; font-weight: 700; color: var(--red); margin-top: 4px; }

/* ----------------------------------------------------------------- KPIs -- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi-l { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--gray); }
.kpi-v { font-size: 17px; font-weight: 700; color: var(--navy); margin-top: 2px; }

.rationale { margin: 14px 0 0; font-size: 13px; line-height: 1.6; }
.flag-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-top: 16px; }
ul.flags { margin: 0; padding-left: 18px; font-size: 12.5px; }
ul.flags.risk li { color: var(--red); }
ul.flags.pos  li { color: var(--green); }

.disclaimer {
  margin: 16px 0 0; padding: 10px 12px;
  background: var(--gray-soft); border-radius: var(--radius);
  font-size: 12px; color: var(--gray);
}

/* ----------------------------------------------------- Surviving liens --- */

.surviving-box { border-left: 4px solid var(--red); }
ul.surviving-list { margin: 0 0 14px; padding-left: 18px; font-size: 13px; }
ul.surviving-list li { padding: 3px 0; }
.surviving-total {
  padding: 12px 14px; background: var(--red-soft);
  border-radius: var(--radius); font-weight: 700; color: var(--crimson);
}
.surviving-total .mono { font-size: 17px; }

/* ------------------------------------------------------------ Progress --- */

ul.progress-steps { list-style: none; margin: 16px 0; padding: 0; font-size: 13px; }
ul.progress-steps li {
  padding: 8px 0 8px 26px; position: relative; color: var(--gray);
}
ul.progress-steps li::before {
  content: '○'; position: absolute; left: 4px; top: 7px; font-size: 13px;
}
ul.progress-steps li.active { color: var(--navy); font-weight: 600; }
ul.progress-steps li.active::before { content: '◐'; color: var(--gold); }
ul.progress-steps li.done { color: var(--green); }
ul.progress-steps li.done::before { content: '●'; color: var(--green); }
ul.progress-steps li.failed { color: var(--red); font-weight: 600; }
ul.progress-steps li.failed::before { content: '✕'; color: var(--red); }

/* -------------------------------------------------------------- Flashes -- */

.flash {
  padding: 10px 14px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: 13px; border-left: 4px solid;
}
.flash-ok    { background: var(--green-soft); border-color: var(--green); color: #14562f; }
.flash-warn  { background: var(--amber-soft); border-color: var(--amber); color: #8a4a0d; }
.flash-error { background: var(--red-soft);   border-color: var(--red);   color: var(--crimson); }

/* --------------------------------------------------------------- Modal --- */

.modal {
  position: fixed; inset: 0;
  background: rgba(13, 27, 75, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
}
.modal[hidden] { display: none !important; }
.modal-card {
  background: var(--white); border-radius: var(--radius);
  padding: 22px 24px; width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(13, 27, 75, .3);
}
.modal-card h3 { margin: 0 0 14px; font-size: 15px; color: var(--navy); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------------------------------------------------------- Login/setup -- */

.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background: linear-gradient(160deg, var(--navy) 0%, #1b2c66 100%);
}
.login-card {
  background: var(--white); border-radius: 10px;
  padding: 34px 32px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand h1 { margin: 0; font-size: 18px; letter-spacing: 3px; color: var(--navy); }
.login-brand p  { margin: 4px 0 0; font-size: 12px; color: var(--gray); }

.setup-card {
  background: var(--white); border-radius: 10px; padding: 32px;
  width: 100%; max-width: 720px; box-shadow: 0 20px 50px rgba(0,0,0,.3);
  max-height: 92vh; overflow-y: auto;
}
.setup-card h1 { margin: 0 0 18px; font-size: 20px; color: var(--navy); }
.setup-card h2 { margin: 0 0 10px; font-size: 14px; color: var(--navy); }
.setup-log { font-size: 13px; padding-left: 20px; }
.setup-log li.bad { color: var(--red); font-weight: 600; }

.check-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.check-list li { padding: 5px 0; }
.check-list li.pass strong { color: var(--green); }
.check-list li.fail { color: var(--red); font-weight: 600; }
.fixhint { font-weight: 400; color: var(--gray); font-size: 12px; margin: 3px 0 0 18px; font-family: var(--mono); }

.keybox { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 18px 0; }
.apikey {
  display: block; font-family: var(--mono); font-size: 13px; word-break: break-all;
  background: var(--navy); color: var(--gold); padding: 12px;
  border-radius: var(--radius); margin-bottom: 12px;
}
.keybox pre, .danger-note pre {
  background: var(--navy); color: #d7dcea; padding: 10px 12px;
  border-radius: var(--radius); overflow-x: auto;
  font-family: var(--mono); font-size: 12px;
}
.warn { color: var(--red); font-size: 12px; }
.danger-note {
  background: var(--red-soft); border-left: 4px solid var(--red);
  padding: 14px 16px; border-radius: var(--radius); margin: 18px 0;
}
code { font-family: var(--mono); font-size: 12px; background: var(--gray-soft); padding: 1px 5px; border-radius: 3px; }

/* ---------------------------------------------------------- Responsive --- */

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .sidebar {
    position: fixed; left: -240px; top: 0; z-index: 50;
    transition: left .2s ease; box-shadow: 4px 0 20px rgba(0,0,0,.2);
  }
  .sidebar.open { left: 0; }
  .content { padding: 0 16px 40px; }
  .topbar { padding-left: 48px; }
  dl.facts { grid-template-columns: 1fr; gap: 2px 0; }
  dl.facts dt { margin-top: 8px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filter input, .filter select { min-width: 0; width: 100%; }
  .risk-banner { gap: 16px; }
  .rb-stats { gap: 16px; }
  .tabs { flex-direction: column; }
  .tab { text-align: left; border-bottom: none; border-left: 3px solid transparent; }
  .tab.active { border-left-color: var(--gold); background: var(--bg); }
}
