:root {
  --bg: #10171e;
  --panel: #1b2733;
  --panel-2: #233140;
  --line: #314050;
  --text: #e7eef5;
  --muted: #9fb0c0;
  --accent: #3da9fc;
  --new: #3da9fc;
  --quoted: #f5a623;
  --booked: #4caf78;
  --done: #7a8a99;
  --invoiced: #b07cf0;
  --cancelled: #8a6b72;
  --danger: #e5484d;
  --emergency: #e5484d;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 20px; margin: 0; letter-spacing: .3px; }
.top-actions { display: flex; gap: 8px; }
.ghost {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; font-size: 14px; cursor: pointer;
}
.tabs { display: flex; gap: 8px; padding: 10px 16px; }
.tab {
  flex: 1; background: var(--panel); color: var(--muted); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.tab.active { color: var(--text); background: var(--panel-2); border-color: var(--accent); }
main { padding: 4px 12px 32px; }
.view { display: none; }
.view.active { display: block; }

/* Search */
.search-row { padding: 4px 0 10px; }
.search-row[hidden] { display: none; }
#search {
  width: 100%; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; -webkit-appearance: none;
}
#search::placeholder { color: var(--muted); }
#search:focus { outline: none; border-color: var(--accent); }

/* Board */
.column { margin-bottom: 18px; }
.column h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); margin: 8px 4px; display: flex; align-items: center; gap: 8px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.new { background: var(--new); } .dot.quoted { background: var(--quoted); }
.dot.booked { background: var(--booked); } .dot.done { background: var(--done); }
.dot.invoiced { background: var(--invoiced); }
.dot.cancelled { background: var(--cancelled); }
.count { margin-left: auto; color: var(--muted); font-weight: 400; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--new);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; cursor: pointer;
}
.card.urg-emergency { border-left-color: var(--emergency); }
.card.stale { border-left-color: var(--danger); }
.card .name .bang { margin-right: 5px; }
.card .name { font-weight: 700; }
.card .problem { color: var(--text); margin: 4px 0; }
.card .meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 10px; }
.badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  padding: 2px 7px; border-radius: 999px; background: var(--panel-2); color: var(--muted);
}
.badge.emergency { background: var(--emergency); color: #fff; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 4px 14px; }

/* Calendar */
.wx-strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px 4px 14px; -webkit-overflow-scrolling: touch; }
.wx-cell {
  flex: 0 0 auto; min-width: 58px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 6px;
}
.wx-dow { font-size: 12px; color: var(--muted); }
.wx-emoji { font-size: 20px; line-height: 1.5; }
.wx-temp { font-weight: 600; font-size: 14px; }
.wx-rain { font-size: 11px; color: var(--accent); min-height: 14px; }
.day { margin-bottom: 18px; }
.day h3 { font-size: 14px; color: var(--accent); margin: 6px 4px; }
.day h3 .wx { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 8px; }
.slot { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.slot .time { color: var(--muted); width: 64px; flex: none; font-variant-numeric: tabular-nums; }
.slot .what .name { font-weight: 600; }
.slot .what .sub { color: var(--muted); font-size: 13px; }

/* Sheet */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }      /* hidden must beat display:flex above */
.toast[hidden] { display: none; }
.sheet-inner {
  background: var(--panel); width: 100%; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 18px 18px calc(env(safe-area-inset-bottom) + 24px);
  border-top: 1px solid var(--line);
}
.sheet-close { position: sticky; top: 0; float: right; background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }
.field { margin: 12px 0; }
.field label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; font-size: 16px;
}
.field textarea { min-height: 80px; resize: vertical; }
.statusrow { display: flex; gap: 8px; flex-wrap: wrap; }
.statusrow button {
  flex: 1 1 auto; padding: 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-weight: 600; cursor: pointer;
}
.statusrow button.sel { border-color: var(--accent); background: var(--accent); color: #062033; }
.raw { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; white-space: pre-wrap; color: var(--muted); font-size: 13px; max-height: 220px; overflow: auto; }
.btn-primary { width: 100%; padding: 14px; border: none; border-radius: 12px; background: var(--accent); color: #062033; font-weight: 700; font-size: 16px; cursor: pointer; margin-top: 14px; }
.callrow { display: flex; gap: 10px; margin: 8px 0 4px; }
.callrow a { flex: 1; text-align: center; padding: 11px; border-radius: 10px; background: var(--panel-2); color: var(--text); text-decoration: none; border: 1px solid var(--line); font-weight: 600; }

/* Attachments */
.attach-list { display: flex; flex-direction: column; gap: 6px; }
.attach { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.attach-ico { flex: none; }
.attach-name { flex: 1; color: var(--accent); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-size { color: var(--muted); font-size: 12px; flex: none; }
.attach-del { background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; flex: none; padding: 0 2px; }
.attach-add { width: 100%; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px; z-index: 40; font-size: 14px;
}
h2.section { font-size: 15px; margin: 6px 4px; }
