/* iLamp Territory Pipeline. Summary strip, stage bars, a dense filterable table, a right-hand detail drawer. */
:root {
  --bg: #F6F8FB;
  --surface: #FFFFFF;
  --surface-2: #EEF2F7;
  --line: #D5DCE6;
  --fg: #16202B;
  --muted: #5B6B7D;
  --accent: #1879D9;
  --accent-ink: #FFFFFF;
  --accent-soft: #E3EFFB;
  --ok: #1E8E5A;
  --warn: #B9771A;
  --danger: #B43A3A;
  --shadow: 0 10px 30px rgba(22, 32, 43, 0.12);
  --font-ui: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F141B; --surface: #161D27; --surface-2: #1E2733; --line: #2B3645;
    --fg: #E8EDF3; --muted: #93A1B3; --accent: #4C9BE8; --accent-ink: #0B1420; --accent-soft: #15283D;
    --ok: #4FBF86; --warn: #D9A04A; --danger: #E06C6C; --shadow: 0 10px 30px rgba(0,0,0,0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F141B; --surface: #161D27; --surface-2: #1E2733; --line: #2B3645;
  --fg: #E8EDF3; --muted: #93A1B3; --accent: #4C9BE8; --accent-ink: #0B1420; --accent-soft: #15283D;
  --ok: #4FBF86; --warn: #D9A04A; --danger: #E06C6C; --shadow: 0 10px 30px rgba(0,0,0,0.5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 14px; line-height: 1.45; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 0 32px; max-width: 1400px; margin: 0 auto; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 12px; }

/* header */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; background: var(--surface); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 14px; padding-block: 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { width: 40px; height: 40px; border-radius: 6px; }
.brand h1 { font-size: 17px; font-weight: 600; letter-spacing: 0.1px; }
.brand .sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.spacer { flex: 1 1 auto; }
.status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); display: inline-block; }
.dot.live { background: var(--ok); }
.dot.off { background: var(--warn); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 7px 12px; cursor: pointer; font-weight: 500; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 4px 9px; font-size: 12px; }

/* kpis */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .v { font-size: 24px; font-weight: 600; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; margin-top: 4px; }
.kpi .s { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* stage bars */
.stages { margin-top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stages h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.bars { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; }
.bar { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: var(--surface); cursor: pointer; text-align: left; position: relative; overflow: hidden; }
.bar .fill { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--accent); }
.bar .c { font-size: 20px; font-weight: 600; line-height: 1; }
.bar .n { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.25; }
.bar.active { border-color: var(--accent); background: var(--accent-soft); }

/* filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.filters input[type="search"], .filters select { border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: var(--radius); padding: 7px 10px; font: inherit; font-size: 13px; }
.filters input[type="search"] { flex: 1 1 220px; min-width: 0; }
.filters label.chk { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }
.count { color: var(--muted); font-size: 12.5px; margin-left: auto; }

/* table */
.tablewrap { margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; cursor: pointer; white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.sel { background: var(--accent-soft); }
td .t { font-weight: 600; }
td .c { color: var(--muted); font-size: 12.5px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.pill.s0 { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.pill.s1 { background: var(--accent-soft); color: var(--accent); }
.pill.s2 { background: var(--accent); color: var(--accent-ink); }
.pill.s3 { background: var(--ok); color: #fff; }
.pill.sx { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.flag { font-size: 10.5px; color: var(--danger); font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty strong { color: var(--fg); display: block; font-size: 16px; margin-bottom: 6px; }

/* cards for narrow screens */
.cards { display: none; }
@media (max-width: 760px) {
  .tablewrap { display: none; }
  .cards { display: grid; gap: 10px; margin-top: 10px; }
  .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer; }
  .card .row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
  .card .t { font-weight: 600; }
  .card .c { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
}

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(10, 16, 24, 0.35); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow); z-index: 21; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-right: env(safe-area-inset-right, 0px); }
.drawer header { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer header h2 { font-size: 17px; font-weight: 600; }
.drawer header .c { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.drawer .body { overflow-y: auto; padding: 14px 16px 24px; flex: 1 1 auto; min-width: 0; }
.drawer footer { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: max(10px, env(safe-area-inset-bottom, 0px)); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }
.sec { margin-top: 18px; }
.sec h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.doclist { display: grid; gap: 6px; }
.doc { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.doc .r { font-family: var(--font-mono); font-size: 12px; }
.doc .d { font-size: 12.5px; color: var(--muted); }
.notes { display: grid; gap: 8px; }
.note { padding: 8px 10px; background: var(--surface-2); border-radius: 6px; font-size: 13px; }
.note .when { color: var(--muted); font-size: 11.5px; }
ul.points { margin: 0; padding-left: 18px; }
form .f { display: grid; gap: 4px; margin-bottom: 10px; }
form label { font-size: 12px; color: var(--muted); }
form input, form select, form textarea { border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 6px; padding: 7px 9px; font: inherit; font-size: 13px; width: 100%; }
form textarea { min-height: 70px; resize: vertical; }
form input[type="checkbox"], .userrow input[type="checkbox"] { width: auto; margin: 0; }
.userrow .m label { display: inline-flex; align-items: center; gap: 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } .kv { grid-template-columns: 1fr; } }
.docedit { display: grid; grid-template-columns: 1.1fr 1.6fr 0.8fr 0.9fr 0.8fr auto; gap: 6px; margin-bottom: 6px; align-items: center; }
@media (max-width: 640px) { .docedit { grid-template-columns: 1fr 1fr; } }
.hint { font-size: 12px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 9px 14px; border-radius: 8px; font-size: 13px; z-index: 40; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.dropzone { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.inbox { margin-top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.inbox h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); font-weight: 600; }
.inboxlist { display: grid; gap: 8px; margin-top: 10px; }
.inboxitem { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.inboxitem .n { font-weight: 600; }
.inboxitem .m { color: var(--muted); font-size: 12.5px; }
.inboxitem .ctl { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inboxitem select { border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 6px; padding: 5px 8px; font: inherit; font-size: 12.5px; max-width: 220px; }
.confirm { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin-top: 10px; }
footer.page { color: var(--muted); font-size: 12px; margin-top: 28px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
@media (prefers-reduced-motion: no-preference) { .drawer { animation: slide 180ms ease-out; } @keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } } }

/* self-hosted additions: user chip, login and password pages, users panel */
.who { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.who b { color: var(--fg); font-weight: 600; }
.role { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); text-transform: uppercase; letter-spacing: 0.4px; }
.menu { position: relative; }
.menu .pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 230px; padding: 6px; z-index: 30; display: grid; }
.menu .pop button, .menu .pop a { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--fg); text-decoration: none; display: block; }
.menu .pop button:hover, .menu .pop a:hover { background: var(--surface-2); }
.menu .pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.authcard { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 26px 24px; box-shadow: var(--shadow); }
.authcard .brand { margin-bottom: 18px; }
.authcard h1 { font-size: 18px; }
.authcard .err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 6px 0 2px; }
.authcard .btn.primary { width: 100%; justify-content: center; padding: 9px 12px; margin-top: 6px; }
.userrow { display: grid; grid-template-columns: 1.3fr 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.userrow .n { font-weight: 600; }
.userrow .m { color: var(--muted); font-size: 12.5px; }
.userrow .ctl { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.userrow select { border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 6px; padding: 4px 6px; font: inherit; font-size: 12px; }
@media (max-width: 560px) { .userrow { grid-template-columns: 1fr; } .userrow .ctl { justify-content: flex-start; } }
.secret { font-family: var(--font-mono); font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; user-select: all; word-break: break-all; }
.inactive { opacity: 0.55; }
