/* ── Theme variables ─────────────────────────────────────────────────────── */
:root[data-theme="dark"] {
  --bg:       #080f0f;
  --surface:  #0d1a1a;
  --surface2: #122020;
  --border:   #1a2e2e;
  --text:     #e0e8e8;
  --muted:    #6a8888;
  --metallic: #a8b8b8;
  --accent:   #4456f5;
  --accent2:  #7080fb;
  --shadow:   rgba(0,0,0,.5);
}
:root[data-theme="light"] {
  --bg:       #eef4f4;
  --surface:  #ffffff;
  --surface2: #f5fafa;
  --border:   #ccdede;
  --text:     #1a2424;
  --muted:    #7a9898;
  --metallic: #5a6868;
  --accent:   #4456f5;
  --accent2:  #7080fb;
  --shadow:   rgba(0,0,0,.12);
}

/* ── Reset & base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  transition: background .2s, color .2s;
}
a { color: var(--accent); text-decoration: none; }

/* ── Layout shell ────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */
#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 46px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#topbar h1 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text);
  white-space: nowrap;
}
#topbar h1 span { color: var(--accent); }
#lu { font-size: 11px; color: var(--muted); margin-left: auto; white-space: nowrap; }

/* ── KPI strip ───────────────────────────────────────────────────────────── */
#kpi-strip {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}
.kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  padding: 6px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.kpi:hover { border-color: var(--accent2); background: var(--surface); }
.kpi.active { border-color: var(--accent); background: var(--surface); }
.kpi-val { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1; }
.kpi-lbl { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 3px; text-align: center; }

/* ── Charts row ──────────────────────────────────────────────────────────── */
#charts-row {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}
.chart-card {
  flex: 1;
  min-width: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  overflow: hidden;
}
.chart-card h3 {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 4px;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
#toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
#rc { font-size: 11px; color: var(--muted); margin-left: auto; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface); border-color: var(--accent2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn.has-sel { border-color: var(--accent); color: var(--accent); }

/* ── Multi-select status dropdown ────────────────────────────────────────── */
.ms-wrap { position: relative; }
.ms-drop {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  min-width: 180px;
  box-shadow: 0 4px 16px var(--shadow);
}
.ms-drop.open { display: block; }
.ms-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.ms-item:hover { background: var(--surface2); }
.ms-item input[type=checkbox] { accent-color: var(--accent); cursor: pointer; }

/* ── Table wrapper ───────────────────────────────────────────────────────── */
#tbl-wrap {
  flex: 1;
  overflow: auto;
  padding: 0 0 8px 0;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
thead th:hover { color: var(--text); }
.srt { font-size: 9px; margin-left: 3px; color: var(--muted); }
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:hover { background: var(--surface2); }
tbody td {
  padding: 6px 8px;
  color: var(--text);
  vertical-align: middle;
}
.state-row td { text-align: center; color: var(--muted); padding: 24px; font-size: 13px; }

/* Column widths */
.td-id   { min-width: 60px; font-weight: 600; font-size: 11px; color: var(--muted); }
.td-co   { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-ono  { min-width: 80px; font-size: 11px; }
.td-proj { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-mgr  { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.td-site { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.td-sell { min-width: 90px; text-align: right; font-variant-numeric: tabular-nums; font-size: 11px; }
.td-del  { min-width: 90px; font-variant-numeric: tabular-nums; font-size: 11px; white-space: nowrap; }
.td-type { min-width: 80px; font-size: 11px; }

/* ── Status badges ───────────────────────────────────────────────────────── */
.sb {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .03em;
}
.s-new  { background: rgba(68,86,245,.18);  color: #7080fb; }
.s-ip   { background: rgba(77,204,204,.18); color: #4dcccc; }
.s-pp   { background: rgba(109,204,109,.18);color: #6dcc6d; }
.s-ps   { background: rgba(109,204,109,.25);color: #50cc80; }
.s-am   { background: rgba(255,200,50,.18); color: #e0a800; }
.s-done { background: rgba(77,187,128,.18); color: #4dbb80; }
.s-can  { background: rgba(120,120,120,.18);color: #909090; }
.s-def  { background: rgba(120,120,120,.12);color: #808080; }

/* ── Engineer / task dropdowns in table ──────────────────────────────────── */
.ec-sel {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  width: 100%;
  min-width: 70px;
}
.ec-sel:hover, .ec-sel:focus {
  border-color: var(--border);
  background: var(--surface2);
  outline: none;
}
.ec-sel.tbc  { color: var(--muted); }
.ec-sel.pend { color: #e0a800; }
.ec-sel.done { color: #4dbb80; }
.ec-sel.na   { color: var(--muted); opacity: .6; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
#footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
}
