/* CHARM™ Band operations dashboard demo. */

:root {
  --demo-strip-h: 48px;
  --bg: #f3f5f2;
  --surface: #fffdfa;
  --surface-alt: #eaf4f3;
  --border: #dce4e1;
  --text: #092326;
  --muted: #4f605d;
  --faint: #74817f;

  --navy: #092326;
  --indigo: #28a9e0;
  --indigo-50: #e6f5fb;
  --gold: #d3a657;

  --success: #258765;
  --warning: #d39a36;
  --error: #c95353;
  --success-bg: #e4f4ed;
  --warning-bg: #fbf0da;
  --error-bg: #f8e3e3;

  --transit: #94a3b8;
  --idle: #cbd5e1;

  --radius: 0.5rem;
  --radius-lg: 0.5rem;
  --shadow: 0 8px 28px rgb(9 35 38 / 0.07);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ---- Demo context ---- */
.demo-strip {
  height: var(--demo-strip-h); position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 0 24px; background: #fff3cf; color: var(--navy);
  border-bottom: 1px solid #ead9a3;
}
.demo-strip-back { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.demo-strip-back:hover { text-decoration: underline; text-underline-offset: 3px; }
.demo-strip-back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.demo-strip p { display: flex; align-items: baseline; gap: 10px; margin: 0; font-size: 13px; }
.demo-strip p strong { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.demo-strip p span { opacity: .82; }
.back-short { display: none; }

/* ---- Layout: sidebar + main ---- */
.app { display: flex; min-height: calc(100vh - var(--demo-strip-h)); }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--navy); color: #a8b9b6;
  display: flex; flex-direction: column; padding: 22px 16px; position: sticky; top: var(--demo-strip-h); height: calc(100vh - var(--demo-strip-h));
}
.brand { padding: 6px 8px 26px; }
.brand .logo { width: 120px; height: auto; display: block; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius);
  color: #a8b9b6; font-weight: 500; font-size: 14px;
}
.nav a:hover { background: #10383c; color: #fff; }
.nav a.active { background: #104147; color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar .spacer { flex: 1; }
.sidebar .newbtn { background: #fff; color: var(--navy); border: none; border-radius: var(--radius); padding: 11px; font-weight: 600; font-size: 14px; cursor: pointer; font-family: inherit; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 32px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: var(--demo-strip-h); z-index: 5;
}
.topbar .crumbs { font-size: 13px; color: var(--faint); }
.topbar .crumbs b { color: var(--text); font-weight: 600; }
.topbar .search { flex: 1; max-width: 320px; }
.topbar .search input { width: 100%; padding: 9px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); font-family: inherit; font-size: 14px; }
.topbar .right { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.topbar .user { display: flex; align-items: center; gap: 10px; }
.topbar .user .who { text-align: right; font-size: 13px; }
.topbar .user .who b { display: block; }
.topbar .user .who span { color: var(--faint); font-size: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #147ca8; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.topbar .user { position: relative; }
.topbar .user .avatar { cursor: pointer; }
.user-pop { position: absolute; top: calc(100% + 10px); right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 10px 14px; display: none; white-space: nowrap; z-index: 80; }
.user-pop.show { display: block; }
.user-pop b { display: block; font-size: 14px; }
.user-pop span { color: var(--faint); font-size: 12px; }

.content { padding: 28px 32px 48px; max-width: 1440px; }
.page-title { font-size: 30px; font-weight: 700; letter-spacing: 0; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 22px; }

/* ---- Cards & grid ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card.pad { padding: 22px 24px; }
.grid { display: grid; gap: 20px; }
.kpis { grid-template-columns: repeat(4, 1fr); }
.cols-2-1 { grid-template-columns: 2fr 1fr; align-items: start; }
.cols-1-1 { grid-template-columns: 1fr 1fr; }

.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px 22px; }
.kpi .label { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); display: flex; align-items: center; gap: 8px; }
.kpi .value { font-size: 36px; font-weight: 700; letter-spacing: 0; margin-top: 8px; }
.kpi .delta { font-size: 13px; font-weight: 600; }
.kpi .delta.up { color: var(--success); }
.kpi .delta.warn { color: var(--warning); }
.kpi.alert { border-top: 3px solid var(--error); }

.section-title { font-size: 20px; font-weight: 600; margin: 0 0 2px; letter-spacing: 0; }
.section-sub { color: var(--faint); font-size: 13px; margin: 0 0 18px; }

/* ---- Coverage heatmap bars ---- */
.floorbar { margin-bottom: 16px; }
.floorbar .row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.floorbar .row .pct { color: var(--faint); font-weight: 600; font-size: 12px; }
.track { height: 9px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.track > span { display: block; height: 100%; border-radius: 999px; }
.fill-ok { background: var(--success); }
.fill-warn { background: var(--warning); }
.fill-bad { background: var(--error); }

/* ---- Exceptions ---- */
.exc { display: flex; gap: 12px; padding: 14px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 12px; }
.exc.high { background: var(--error-bg); border-color: #f6cccc; }
.exc.med { background: var(--warning-bg); border-color: #f7e3bf; }
.exc.low { background: var(--surface-alt); }
.severity-marker { width: 9px; height: 9px; flex: 0 0 auto; margin-top: 5px; border-radius: 50%; background: var(--indigo); box-shadow: 0 0 0 4px var(--indigo-50); }
.exc.high .severity-marker { background: var(--error); box-shadow: 0 0 0 4px var(--error-bg); }
.exc.med .severity-marker { background: var(--warning); box-shadow: 0 0 0 4px var(--warning-bg); }
.exc .body { flex: 1; }
.exc .ttl { font-weight: 600; font-size: 14px; }
.exc .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.exc .act { color: var(--indigo); font-size: 12px; font-weight: 600; margin-top: 6px; display: inline-block; }

.ai-insight { background: var(--indigo-50); border-radius: var(--radius); padding: 14px 16px; font-size: 13px; color: #17424c; border-left: 3px solid var(--indigo); }
.ai-insight .tag { font-weight: 700; color: #147ca8; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }

/* ---- Tables ---- */
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.data td { padding: 14px 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
.who-cell { display: flex; align-items: center; gap: 10px; }
.who-cell .avatar { width: 30px; height: 30px; font-size: 11px; }
.mini-track { width: 120px; }

/* ---- Chips ---- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip.ok { background: var(--success-bg); color: #0a7d57; }
.chip.warn { background: var(--warning-bg); color: #9a6400; }
.chip.bad { background: var(--error-bg); color: #b42318; }
.chip.neutral { background: #eef2f7; color: var(--muted); }
.chip.prog { background: var(--indigo-50); color: #146d91; }

/* ---- Buttons ---- */
.btn { font-family: inherit; font-size: 14px; font-weight: 600; padding: 9px 16px; border-radius: var(--radius); cursor: pointer; border: 1px solid transparent; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.row-actions { display: flex; gap: 10px; }

/* ---- Timeline (worker) ---- */
.timeline-wrap { padding: 8px 0 4px; }
.timeline-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-bottom: 8px; }
.timeline { display: flex; height: 28px; border-radius: 8px; overflow: hidden; }
.timeline > span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 0 0; font-size: 13px; }
.legend .k { display: inline-flex; align-items: center; gap: 7px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; }

/* ---- Team master-detail ---- */
.team-grid { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.wlist { display: flex; flex-direction: column; gap: 10px; }
.wcard { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; background: var(--surface); cursor: pointer; transition: background .12s, border-color .12s, box-shadow .12s; }
.wcard:hover { background: var(--surface-alt); }
.wcard.selected { border-color: var(--navy); box-shadow: var(--shadow); }
.wcard .top { display: flex; align-items: center; gap: 10px; }
.wcard .nm { font-weight: 600; }
.wcard .avatar { width: 34px; height: 34px; font-size: 12px; }
.wcard .sub { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
@media (max-width: 900px) { .team-grid { grid-template-columns: 1fr; } }

/* ---- Shift Trace ---- */
.trace { padding-top: 4px; }
.trace-pins { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.trace-pins .pin { display: inline-flex; align-items: center; gap: 7px; }
.trace-pins .pin i { width: 9px; height: 9px; border-radius: 50%; background: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-50); display: inline-block; }
.trace-bars { display: flex; align-items: flex-end; gap: 4px; height: 170px; border-bottom: 2px solid var(--border); }
.trace-bars .seg { flex-basis: 0; min-width: 3px; border-radius: 6px 6px 0 0; transition: filter .15s; }
.trace-bars .seg:hover { filter: brightness(1.08); }
.trace-bars .seg.recede { opacity: .75; }
.trace-labels { display: flex; gap: 4px; margin-top: 8px; }
.trace-labels .lab { flex-basis: 0; min-width: 0; text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.trace-labels .lab small { display: block; color: var(--faint); font-weight: 500; font-size: 10px; }
.trace-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 7px; }
@media (max-width: 640px) {
  .trace-bars { height: 120px; }
  .trace-labels .lab { font-size: 10px; }
  .trace-labels .lab small { font-size: 9px; }
}

.stat { text-align: left; }
.stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }

.check { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.check:last-child { border-bottom: none; }
.check .ok { color: var(--success); }

/* ---- Floor plan (coverage) ---- */
.floorplan { display: grid; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(4, 70px); gap: 8px; }
.zone { border-radius: 8px; border: 1px dashed rgba(0,0,0,.12); padding: 10px; font-size: 12px; font-weight: 600; color: #33405a; display: flex; align-items: flex-start; cursor: pointer; transition: filter .12s, box-shadow .12s; }
.zone:hover { filter: brightness(0.96); }
.zone.selected { outline: 2px solid var(--navy); outline-offset: -2px; box-shadow: var(--shadow); }
.z-ok { background: #d8f3e7; }
.z-warn { background: #fdeccc; }
.z-bad { background: #fbd9d9; }
.z-prog { background: #d9e6ff; }

.floor-tabs { display: inline-flex; gap: 6px; background: var(--surface); border: 1px solid var(--border); padding: 4px; border-radius: var(--radius); }
.floor-tabs button { border: none; background: transparent; padding: 7px 14px; border-radius: 6px; font-family: inherit; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; }
.floor-tabs button.active { background: var(--navy); color: #fff; }
.floor-tabs button:disabled { cursor: default; opacity: .45; }

.zone-detail .kv { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.zone-detail .kv:last-child { border-bottom: none; }
.zone-detail .kv .label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 600; }
.zone-detail .kv .val { font-weight: 600; }

.narrative { background: var(--indigo-50); border-left: 3px solid var(--indigo); border-radius: var(--radius); padding: 18px 20px; font-size: 17px; line-height: 1.55; color: #173d45; }
.narrative .tag { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #147ca8; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }

.filters { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.filters .pill { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; }
.filters .pill.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.filter-select { font-family: inherit; font-size: 13px; font-weight: 500; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 7px 30px 7px 14px; cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2376777d' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.filter-select:focus { outline: none; border-color: var(--indigo); }

.mt { margin-top: 20px; }
.muted { color: var(--faint); }
canvas { max-width: 100%; }

/* ============ MOBILE ============ */
@media (max-width: 768px) {
  .demo-strip { padding: 0 14px; gap: 12px; }
  .demo-strip p { gap: 6px; font-size: 11px; }
  .demo-strip p strong { font-size: 10px; }
  .back-full { display: none; }
  .back-short { display: inline; }
  .app { flex-direction: column; }

  /* Sidebar becomes a fixed bottom tab bar (white, like the mobile mockups) */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: auto; height: auto; flex-direction: row; padding: 6px 6px;
    background: var(--navy); border-top: 1px solid #17464a;
    box-shadow: 0 -3px 14px rgba(0,0,0,.2); z-index: 60;
  }
  .brand { display: none; }
  .nav { flex-direction: row; justify-content: space-around; width: 100%; gap: 0; }
  .nav a { flex-direction: column; align-items: center; gap: 3px; padding: 6px 8px; font-size: 10px; color: #8b93a7; }
  .nav a .ico { width: 22px; height: 22px; }
  .nav a:hover { background: transparent; color: #fff; }
  .nav a.active { background: transparent; color: #fff; box-shadow: none; }
  .nav a.active .ico { color: var(--gold); }

  /* Top bar: keep building name + bell + avatar; drop search and the name block */
  .topbar { padding: 12px 16px; position: sticky; }
  .topbar .search { display: none; }
  .topbar .user .who { display: none; }
  .crumbs { font-size: 13px; }

  /* Main content clears the bottom bar */
  .main { padding-bottom: 76px; }
  .content { padding: 18px 16px 24px; }
  .page-title { font-size: 24px; }

  /* Grids stack; KPIs go 2-up */
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .cols-2-1, .cols-1-1 { grid-template-columns: 1fr; }
  .kpi { padding: 16px; }
  .kpi .value { font-size: 26px; }

  .card.pad { padding: 18px; }
  /* Let wide tables scroll horizontally instead of breaking the layout */
  .card.pad { overflow-x: auto; }
  table.data { min-width: 460px; }

  /* Coverage floor plan: a touch shorter so it fits */
  .floorplan { grid-template-rows: repeat(4, 56px); font-size: 11px; }
  .floor-tabs { flex-wrap: wrap; }
}

/* Mobile detail sheet (Team / Map) */
.sheet-back { display: none; }
@media (max-width: 768px) {
  #detailPane {
    position: fixed; inset: 0; z-index: 55;
    background: var(--bg); overflow-y: auto;
    padding: 16px 16px 90px;
    transform: translateX(100%);
    transition: transform .25s ease;
  }
  #detailPane.open { transform: translateX(0); }
  .sheet-back {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 9px 13px; font-weight: 600; font-size: 14px;
    color: var(--text); cursor: pointer; font-family: inherit; margin-bottom: 14px;
  }
}
