:root {
  /* Frontier Waste brand (frontierwaste.co): navy #1B2A4A + green #7AC143 */
  --brand: #1b2a4a;
  --brand-2: #2c3f66;
  --brand-ink: #ffffff;
  --accent: #7ac143;
  --accent-2: #69ad35;
  --accent-ink: #3f7a1c;
  --accent-soft: #e2f0d7;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-2: #4b5563;
  --muted: #8a919c;
  --won: #12803f;
  --won-bg: #e5f4ea;
  --lost: #c23a3a;
  --lost-bg: #fbeaea;
  --open: #2a78d6;
  --open-bg: #e8f1fc;
  --warn: #a86b00;
  --warn-bg: #fdf3dd;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 20, .06), 0 2px 8px rgba(20, 30, 20, .04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand-2); font-weight: 500; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; color: var(--brand); }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }

/* Layout */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.sidebar { background: var(--brand); color: var(--brand-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.logo-mark { width: 34px; height: 34px; border-radius: 8px; background: #ffffff; display: grid; place-items: center; }
.logo-mark svg { width: 20px; height: 20px; }
.logo b { display: block; font-size: 15px; }
.logo small { opacity: .7; font-size: 12px; }
.logo-full { flex-direction: column; align-items: flex-start; gap: 6px; padding: 2px 8px 20px; }
.logo-full img { width: 128px; height: auto; display: block; }
.logo-auth { align-items: center; padding: 0; }
.logo-auth img { width: 150px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--brand-ink); opacity: .82; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; opacity: 1; }
.nav a.active { background: rgba(255,255,255,.12); opacity: 1; box-shadow: inset 3px 0 0 var(--accent); }
.nav a.active svg { color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar .me { margin-top: auto; padding: 10px; border-top: 1px solid rgba(255,255,255,.15); font-size: 13px; }
.sidebar .me button { margin-top: 6px; }
.main { padding: 24px 28px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1100px) { .g2, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .logo { padding: 0 8px 0 0; }
  .sidebar .logo-full img { width: auto; height: 44px; }
  .sidebar .logo-full small { display: none; }
  .nav { display: flex; flex-wrap: wrap; }
  .sidebar .me { display: none; }
  .main { padding: 16px; }
}

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 0; gap: 8px; }
.card-head + .card-body { padding-top: 10px; }
.card-body { padding: 14px 16px 16px; }
.kpi { padding: 14px 16px; }
.kpi .label { color: var(--text-2); font-size: 12px; font-weight: 500; }
.kpi .value { font-size: 24px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }

/* Controls */
button, .btn { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover { background: var(--surface-2); border-color: #cfd3ca; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
button.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
button.win { background: var(--won); border-color: var(--won); color: #fff; }
button.lose { background: var(--surface); border-color: #e6b8b8; color: var(--lost); }
button.danger { color: var(--lost); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: rgba(0,0,0,.05); }
.sidebar button.ghost { color: var(--brand-ink); padding: 4px 0; }
button.sm { padding: 4px 9px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; background: #fff; color: var(--text); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(122,193,67,.35); border-color: var(--accent-2); }
textarea { resize: vertical; min-height: 70px; width: 100%; }
.search { min-width: 240px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); font-weight: 500; }
label.field input, label.field select, label.field textarea { width: 100%; font-size: 14px; color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 4px; margin-top: 6px; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 9px 12px; color: var(--text-2); }
.tabs button.active { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; }
.tabs .count { background: var(--bg); border-radius: 10px; padding: 0 7px; font-size: 12px; color: var(--text-2); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--text-2); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #f4f9ef; }
td.r, th.r { text-align: right; }
td .sub { color: var(--muted); font-size: 12px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; color: var(--text-2); gap: 10px; flex-wrap: wrap; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--bg); color: var(--text-2); }
.pill.won, .pill.Active { background: var(--won-bg); color: var(--won); }
.pill.lost, .pill.Former, .pill.Inactive { background: var(--lost-bg); color: var(--lost); }
.pill.open, .pill.Prospect { background: var(--open-bg); color: var(--open); }
.pill.warn, .pill.On.Hold { background: var(--warn-bg); color: var(--warn); }

/* Stage progress */
.progress { display: flex; gap: 3px; align-items: center; }
.progress i { width: 18px; height: 6px; border-radius: 3px; background: var(--border); }
.progress i.on { background: var(--accent); }
.progress.won i { background: var(--won); }
.progress.lost i.on { background: var(--lost); }
.progress span { margin-left: 8px; font-size: 12px; color: var(--text-2); white-space: nowrap; }

.stepper { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 12px 0; }
.stepper button { border-radius: 6px; font-size: 12px; padding: 8px 4px; justify-content: center; background: var(--surface-2); color: var(--text-2); white-space: normal; text-align: center; line-height: 1.2; }
.stepper button.done { background: var(--accent-soft); color: var(--brand); border-color: #c9e3b3; }
.stepper button.current { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Kanban */
.board { display: grid; grid-template-columns: repeat(5, minmax(210px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { background: #e9ecf1; border-radius: var(--radius); padding: 10px; min-height: 300px; display: flex; flex-direction: column; gap: 8px; transition: background .15s; }
.col.over { background: var(--accent-soft); outline: 2px dashed var(--accent-2); }
.col-head { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 4px 6px; }
.col-head b { font-size: 13px; }
.col-head .meta { color: var(--text-2); font-size: 12px; text-align: right; }
.col-head .bar { height: 3px; background: var(--accent); border-radius: 2px; margin-top: 6px; }
.deal { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; cursor: grab; box-shadow: var(--shadow); }
.deal:hover { border-color: #c4ccbf; }
.deal.dragging { opacity: .5; }
.deal .t { font-weight: 600; font-size: 13px; line-height: 1.3; }
.deal .c { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.deal .f { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.deal .f b { color: var(--text); }
.deal .due.late { color: var(--lost); font-weight: 600; }
.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 6px 0; }
.drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 12px; text-align: center; font-weight: 600; transition: transform .1s; }
.drop small { font-weight: 400; color: var(--text-2); }
.drop.won { border-color: #9fd0b0; color: var(--won); background: #f3faf5; }
.drop.lost { border-color: #e6b8b8; color: var(--lost); background: #fdf6f6; }
.drop.over { transform: scale(1.02); border-style: solid; }

/* Funnel */
.funnel { display: flex; flex-direction: column; gap: 6px; }
.funnel-row { display: grid; grid-template-columns: 160px 1fr 120px; align-items: center; gap: 12px; }
.funnel-row .lbl { font-size: 13px; font-weight: 500; }
.funnel-row .track { height: 28px; display: flex; justify-content: center; }
.funnel-row .fill { height: 100%; background: var(--brand); border-radius: 4px; min-width: 3px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 600; transition: width .3s; }
.funnel-row.won .fill { background: var(--won); }
.funnel-row .stat { font-size: 12px; color: var(--text-2); text-align: right; }

/* Timeline */
.timeline { display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.tl:last-child { border-bottom: 0; }
.tl .ic { width: 28px; height: 28px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 13px; }
.tl .ic.won { background: var(--won-bg); }
.tl .ic.lost { background: var(--lost-bg); }
.tl .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tl .body { white-space: pre-wrap; word-break: break-word; }
.task-done { text-decoration: line-through; color: var(--muted); }

/* Detail */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 18px; }
.info-grid div small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.info-grid div span { font-weight: 500; word-break: break-word; }

/* Modal / drawer */
.overlay { position: fixed; inset: 0; background: rgba(15, 25, 18, .35); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 5vh 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 680px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal.sm { max-width: 440px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 12px 12px; }
.overlay.drawer { justify-content: flex-end; padding: 0; }
.overlay.drawer .modal { max-width: 620px; min-height: 100vh; border-radius: 0; }

/* Toast */
#toast-root { position: fixed; bottom: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1d2320; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 360px; }
.toast.err { background: var(--lost); }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--brand-2) 0%, var(--brand) 100%); padding: 20px; }
.auth .card { border-top: 4px solid var(--accent); width: 100%; max-width: 400px; padding: 28px; }
.auth form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.auth .err { color: var(--lost); font-size: 13px; min-height: 18px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.muted { color: var(--muted); }
.list-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); align-items: center; }
.list-item:last-child { border-bottom: 0; }

/* footer: policy links, version, copyright */
.main-col { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.main-col > .main { flex: 1; }
.app-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; padding: 14px 20px 18px; border-top: 1px solid var(--line, #e5e7eb); color: var(--muted, #6b7280); font-size: 12.5px; }
.app-foot a { color: inherit; text-decoration: underline; }
.app-foot a:hover { color: var(--text, #1b2a4a); }
.auth { grid-auto-flow: row; align-content: center; gap: 14px; }
.auth .app-foot { border-top: 0; color: rgba(255,255,255,.8); padding: 0; }
.auth .app-foot a:hover { color: #fff; }
@media (max-width: 760px) { .main-col { min-height: 0; } .app-foot .sep { display: none; } .app-foot { gap: 2px 14px; } }
