/* Madang Monitor — dark sand palette matching the main app
   (bg #161510 / text #f5e8c0 / accent #d4a843, .admin-table conventions). */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #161510;
  --bg-panel: rgba(255, 255, 255, 0.03);
  --fg: #f5e8c0;
  --muted: rgba(255, 255, 255, 0.55);
  --line: rgba(255, 255, 255, 0.08);
  --accent: #d4a843;
  --accent-soft: rgba(212, 168, 67, 0.16);
  --pos: #6cb86c;
  --neg: #d97a7a;
  --font: -apple-system, BlinkMacSystemFont, 'Pretendard Variable', Pretendard,
          system-ui, 'Apple SD Gothic Neo', 'Segoe UI', sans-serif;
}

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  min-height: 100vh;
}

[hidden] { display: none !important; }

button { font-family: inherit; cursor: pointer; }

/* ── Login / denied ── */
#view-login, #view-denied {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #241c0c 0%, var(--bg) 65%);
}
.login-card {
  text-align: center;
  padding: 48px 56px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-panel);
  max-width: 380px;
}
.login-card h1 { color: var(--accent); font-size: 1.6rem; margin-bottom: 8px; }
.login-sub { color: var(--muted); font-size: 0.92rem; margin-bottom: 28px; word-break: break-all; }
.btn-google {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 22px;
  border: 1px solid var(--line); border-radius: 999px;
  background: #fff; color: #222;
  font-size: 0.98rem; font-weight: 600;
}
.btn-google:hover { filter: brightness(0.95); }
.gmark {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; border: 1.5px solid #444;
  color: #4285f4; font-weight: 800;
}
.login-error { margin-top: 18px; color: var(--neg); font-size: 0.85rem; }
.login-input {
  display: block; width: 100%; margin: 0 0 12px;
  padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: rgba(0, 0, 0, 0.25); color: var(--fg);
  font-size: 0.95rem; font-family: inherit;
}
.login-input:focus { outline: none; border-color: var(--accent); }
.login-code { text-align: center; letter-spacing: 0.4em; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.login-btn { display: block; width: 100%; margin-bottom: 10px; }
.login-hint { color: var(--muted); font-size: 0.84rem; margin-bottom: 14px; line-height: 1.5; }
.login-hint b { color: var(--fg); }
.btn-plain {
  padding: 8px 18px; border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: var(--fg); font-size: 0.88rem;
}
.btn-plain:hover { background: var(--bg-panel); }

/* ── App layout ── */
#view-app { display: flex; min-height: 100vh; }
#sidebar {
  width: 210px; flex-shrink: 0;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { color: var(--accent); font-weight: 800; font-size: 1.25rem; line-height: 1.15; margin: 0 8px 26px; }
.brand span { color: var(--muted); font-weight: 600; font-size: 0.85rem; letter-spacing: 0.12em; text-transform: uppercase; }
#menu { display: flex; flex-direction: column; gap: 4px; }
#menu button {
  text-align: left; padding: 10px 14px; border: none; border-radius: 10px;
  background: transparent; color: var(--muted); font-size: 0.95rem;
}
#menu button:hover { background: var(--bg-panel); color: var(--fg); }
#menu button.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 8px; }
.whoami { color: var(--muted); font-size: 0.78rem; word-break: break-all; }

#content { flex: 1; padding: 30px 36px 60px; min-width: 0; }
#page-root h2 { color: var(--accent); font-size: 1.3rem; margin-bottom: 4px; }
.page-sub { color: var(--muted); font-size: 0.86rem; margin-bottom: 22px; }

/* ── Period selector ── */
.period-row { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.period-row button {
  padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--muted); font-size: 0.82rem;
}
.period-row button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }

/* ── KPI tiles ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 26px; }
.kpi {
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg-panel);
  padding: 16px 18px;
}
.kpi .k { color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.kpi .v { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 0.76rem; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .d.pos { color: var(--pos); }
.kpi .d.neg { color: var(--neg); }
.kpi .d.flat { color: var(--muted); }

/* ── Panels + tables ── */
.panel {
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg-panel);
  padding: 18px 20px; margin-bottom: 22px; overflow-x: auto;
}
.panel h3 { font-size: 0.95rem; color: var(--fg); margin-bottom: 14px; }
table { border-collapse: collapse; width: 100%; font-size: 0.87rem; }
thead th {
  text-align: left; padding: 8px 12px; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }
.muted { color: var(--muted); }
.ok   { color: var(--pos); font-weight: 700; }
.bad  { color: var(--neg); font-weight: 700; }
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700;
}
.tag.blocked { background: rgba(217, 122, 122, 0.16); color: var(--neg); }
.tag.failed  { background: rgba(255, 255, 255, 0.08); color: var(--muted); }

/* ── Chart ── */
.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap svg { display: block; }
.bar { fill: var(--accent); opacity: 0.85; }
.bar.second { fill: #8a6f3a; }
.axis-label { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.legend { display: flex; gap: 18px; margin-top: 8px; font-size: 0.78rem; color: var(--muted); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ── Tabs (Users page) ── */
.tab-row { display: flex; gap: 6px; margin-bottom: 18px; }
.tab-row button {
  padding: 7px 16px; border: 1px solid var(--line); border-radius: 10px;
  background: transparent; color: var(--muted); font-size: 0.85rem;
}
.tab-row button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }

/* ── Settings ── */
.allow-row { display: flex; gap: 10px; margin-bottom: 18px; }
.allow-row input {
  flex: 1; max-width: 340px; padding: 9px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: rgba(0, 0, 0, 0.25); color: var(--fg); font-size: 0.9rem; font-family: inherit;
}
.allow-row input:focus { outline: none; border-color: var(--accent); }
.btn-primary {
  padding: 9px 20px; border: none; border-radius: 10px;
  background: var(--accent); color: #221703; font-weight: 700; font-size: 0.88rem;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger {
  padding: 4px 12px; border: 1px solid rgba(217, 122, 122, 0.4); border-radius: 8px;
  background: transparent; color: var(--neg); font-size: 0.78rem;
}
.btn-danger:hover { background: rgba(217, 122, 122, 0.12); }

.loading, .empty { color: var(--muted); padding: 26px 0; text-align: center; font-size: 0.9rem; }
.error-note { color: var(--neg); padding: 12px 0; font-size: 0.86rem; }

@media (max-width: 760px) {
  #view-app { flex-direction: column; }
  #sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; gap: 10px; overflow-x: auto; }
  .brand { margin: 0 10px 0 0; white-space: nowrap; }
  #menu { flex-direction: row; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  #content { padding: 20px 16px 50px; }
}
