@font-face { font-family: 'Geist Mono'; src: url('fonts/GeistMono-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Geist Mono'; src: url('fonts/GeistMono-Medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }

:root {
  --bg: #0b0d12;
  --panel: #12151c;
  --sunken: #181c25;
  --raised: #1d2230;
  --line: #242a36;
  --text: #e6e9ef;
  --muted: #98a0ae;
  --faint: #636b7a;
  --accent: #6d9bff;
  --accent-strong: #3f6fe0;
  --accent-soft: rgba(109, 155, 255, .13);
  --good: #4ade80;
  --warn: #f5b84a;
  --warn-soft: rgba(245, 184, 74, .12);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, .12);
  --radius: 10px;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
  background: var(--bg); color: var(--text);
  display: grid; grid-template-columns: 232px 1fr; min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
.num, td.num, .mono { font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* sidebar */
.sidebar { background: var(--bg); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 14px; letter-spacing: -0.01em; }
.sidebar nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar nav a { padding: 7px 10px; border-radius: 7px; color: var(--muted); display: flex; align-items: center; gap: 9px; }
.sidebar nav a:hover { background: var(--sunken); color: var(--text); }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar nav a .amt { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--faint); }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; }
.side-foot { margin-top: auto; padding-top: 12px; }
.side-foot a { padding: 7px 10px; border-radius: 7px; color: var(--muted); display: block; }
.side-foot a.active, .side-foot a:hover { background: var(--sunken); color: var(--text); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }

main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 28px 10px; background: var(--bg); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 18px; margin: 0; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.actions { display: flex; gap: 8px; }
#view { padding: 24px 28px 60px; max-width: 1280px; }

/* buttons & inputs */
.btn { appearance: none; border: 1px solid transparent; background: var(--raised); color: var(--text); padding: 7px 13px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: #262c3b; }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.icon-btn { border: 0; background: none; color: var(--muted); font-size: 17px; cursor: pointer; padding: 0 4px; line-height: 1; }
.icon-btn:hover { color: var(--text); }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid transparent; border-radius: 7px; padding: 7px 9px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input, select, textarea { background: var(--sunken); }
input:disabled { opacity: .55; }
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(.8); }
input[type=checkbox] { width: auto; }
input[type=color] { padding: 2px; height: 34px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
label.check { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; } .span4 { grid-column: 1 / -1; }

/* cards / stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 28px; margin: 6px 0 28px; }
.stat { padding: 0; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font: 500 26px/1.2 var(--mono); margin-top: 6px; letter-spacing: -0.03em; }
.stat .sub { font-size: 12px; color: var(--faint); margin-top: 2px; }
.panel { background: var(--panel); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; gap: 12px; }
.panel-head h2 { font-size: 14px; margin: 0; font-weight: 600; }
.panel-body { padding: 14px 16px; }
.cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--faint); font-weight: 500; padding: 10px 16px 6px; white-space: nowrap; }
td { padding: 10px 16px; border-top: 1px solid rgba(255, 255, 255, .04); vertical-align: middle; }

tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: rgba(255, 255, 255, .025); }
th.num, td.num { text-align: right; white-space: nowrap; }
tr.cancelled td { opacity: .5; }
.group-row td { font-size: 12px; color: var(--muted); font-weight: 600; padding: 18px 16px 6px; border-top: 0; }

.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: var(--sunken); color: var(--muted); white-space: nowrap; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.svc-name { font-weight: 500; }
.svc-vendor { font-size: 12px; color: var(--muted); }
.soon { color: var(--warn); }
td.date { font-family: var(--mono); font-weight: 500; font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.date .faint, td.date .small { font-family: inherit; font-weight: 400; }

/* alerts */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 16px; font-size: 13px; cursor: pointer; }
.alert:hover { background: var(--sunken); }
.alert .kind { flex: none; }

/* category bars */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 92px; gap: 10px; align-items: center; font-size: 13px; }
.bar { height: 8px; background: var(--sunken); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* daily usage chart */
.daily { display: flex; align-items: flex-end; gap: 2px; height: 90px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.daily i { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-width: 2px; opacity: .85; }
.daily i:hover { opacity: 1; }
.daily i.m { box-shadow: -1px 0 0 var(--faint); }

/* calendar */
.month-block { margin-bottom: 18px; }
.month-head { display: flex; justify-content: space-between; padding: 0 2px 6px; font-weight: 600; }

/* modal */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); background: var(--panel); color: var(--text); box-shadow: 0 24px 60px rgba(0,0,0,.6); }
dialog.wide { width: min(1080px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .65); }
.modal-head { padding: 18px 20px 6px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-content { padding: 18px 20px; overflow: auto; max-height: calc(100vh - 190px); }
.modal-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.modal-foot .left { margin-right: auto; }
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; margin: 18px 0 8px; }
.section-label:first-child { margin-top: 0; }
.note { background: var(--sunken); border-radius: 8px; padding: 9px 12px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.item-card { background: var(--sunken); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.review-split { display: grid; grid-template-columns: 340px 1fr; gap: 18px; }
.preview { border-radius: 10px; overflow: hidden; background: var(--sunken); height: 100%; min-height: 420px; }
.preview iframe, .preview img { width: 100%; height: 100%; min-height: 420px; border: 0; display: block; object-fit: contain; }

#drop-overlay { position: fixed; inset: 0; background: rgba(109, 155, 255, .10); border: 3px dashed var(--accent); display: none; place-items: center; z-index: 50; pointer-events: none; }
#drop-overlay div { background: var(--panel); padding: 18px 28px; border-radius: 12px; font-weight: 600; font-size: 16px; }
body.dragging #drop-overlay { display: grid; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--raised); color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,.5); padding: 10px 16px; border-radius: 9px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; font-size: 13px; }
#toast.show { opacity: 1; transform: translateX(-50%); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-head, .side-foot { display: none; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cols, .review-split { grid-template-columns: 1fr; }
  .g3, .g4 { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 14px 16px; flex-wrap: wrap; }
  #view { padding: 16px; }
  .table-wrap { overflow-x: auto; }
}

/* colour picker */
.color-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 0; cursor: pointer; padding: 0; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.swatch.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.swatch-picker { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); cursor: pointer; }
.swatch-picker::-webkit-color-swatch-wrapper { padding: 0; opacity: 0; }
.color-row .hex { width: 100px; font-family: var(--mono); text-transform: lowercase; }

.me { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px 0; }
.me-name { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* sign in / setup */
#auth { display: none; }
body.auth-mode { display: block; }
body.auth-mode > aside, body.auth-mode > main { display: none; }
body.auth-mode #auth { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.auth-card { width: min(400px, 100%); background: var(--panel); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.auth-card .brand { padding: 0; font-size: 15px; color: var(--muted); }
.auth-card h2 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.auth-card p { margin: -6px 0 0; }
.auth-error { color: var(--bad); font-size: 13px; min-height: 1em; }
