/* Grouper console — deep-sea theme.
   Palette: deep teal/navy chrome, cyan-teal accent, warm amber for warnings.
   Goal: a distinctive, professional appliance console — dense and quiet, not flashy. */

:root {
  --bg: #eaeef1;
  --card: #ffffff;
  --ink: #15262e;
  --muted: #697d86;
  --line: #e0e7eb;
  --line-strong: #cfdade;

  --sb-bg: #0c2a33;
  --sb-bg-2: #0a232b;
  --sb-ink: #aecbd1;
  --sb-ink-dim: #6f939c;

  --accent: #0e97a8;
  --accent-deep: #0b7b8a;
  --accent-soft: #e3f4f6;
  --warm: #d9832f;
  --warm-soft: #fbeede;
  --ok: #1f9d6b;
  --ok-soft: #e3f5ec;
  --err: #c8453b;
  --err-soft: #fae6e4;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16,40,48,.06), 0 6px 20px rgba(16,40,48,.06);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 15px; margin: 0; letter-spacing: .1px; }

/* ---- App shell ---- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; flex: 0 0 248px;
  background: linear-gradient(180deg, var(--sb-bg), var(--sb-bg-2));
  color: var(--sb-ink);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand-mark { color: var(--accent); display: inline-flex; }
.brand-name { font-weight: 700; font-size: 18px; color: #fff; letter-spacing: .3px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--sb-ink); font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item.active .nav-dot { background: #fff; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sb-ink-dim); flex: 0 0 auto; }

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.who { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 0 6px; }
.avatar {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  background: var(--accent); color: #fff; font-weight: 700;
  display: grid; place-items: center;
}
.who-name { color: #fff; font-weight: 600; font-size: 13px; }
.who-role { color: var(--sb-ink-dim); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }

/* ---- Main column ---- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px; background: rgba(255,255,255,.7);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; backdrop-filter: blur(6px); z-index: 5;
}
.topbar-title { font-size: 17px; font-weight: 700; }
.pill {
  font-size: 12px; color: var(--accent-deep); background: var(--accent-soft);
  padding: 4px 11px; border-radius: 999px; font-weight: 600;
}
.tabs { display: flex; gap: 2px; padding: 10px 26px 0; background: rgba(255,255,255,.7); border-bottom: 1px solid var(--line); }
.tab { padding: 9px 15px; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; }
.tab:hover { color: var(--ink); background: rgba(0,0,0,.03); text-decoration: none; }
.tab.active { color: var(--accent-deep); border-bottom-color: var(--accent); }

.banners { padding: 14px 26px 0; display: flex; flex-direction: column; gap: 10px; }
.content { padding: 18px 26px 40px; }

/* ---- Banners ---- */
.banner { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid transparent; }
.banner-warn { background: var(--warm-soft); border-color: #efd2ab; color: #8a531a; }
.banner-error { background: var(--err-soft); border-color: #f0c2bd; color: #9a302a; }
.banner-ok { background: var(--ok-soft); border-color: #bfe6d2; color: #186a4b; }
.banner-apply { background: var(--accent-soft); border-color: #b8e2e8; color: var(--accent-deep); display: flex; align-items: center; gap: 14px; }
.banner-apply form { margin-left: auto; }

/* ---- Cards ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.two-col { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.two-col-even { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.preview { background: #f5f8f9; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; white-space: pre-wrap; color: #33474f; }
.src summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent-deep); margin-top: 12px; }
.src[open] summary { margin-bottom: 8px; }

/* ---- Stat cards ---- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat-row-6 { grid-template-columns: repeat(6, 1fr); }
.stat-sub { font-size: 18px; color: var(--muted); font-weight: 600; }
.dash-foot { font-size: 12.5px; margin-top: 2px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.stat-card.primary { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); border: none; color: #fff; }
.stat-num { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat-card.primary .stat-label { color: rgba(255,255,255,.85); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table.dense { width: 100%; border-collapse: collapse; font-size: 13px; }
table.dense thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); font-weight: 600; padding: 9px 12px; background: #f5f8f9;
  border-bottom: 1px solid var(--line-strong); position: sticky; top: 0;
}
table.dense tbody td { padding: 7px 12px; border-bottom: 1px solid var(--line); }
table.dense tbody tr:last-child td { border-bottom: none; }
table.dense tbody tr:hover { background: var(--accent-soft); }
/* Formerly monospace; kept as a class for IPs/addresses but rendered in the UI
   sans face per preference, with tabular figures so numbers still align. */
.mono { font-family: var(--sans); font-variant-numeric: tabular-nums; }
code { font-family: var(--sans); background: #f0f3f5; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.code-block { background: #0c2a33; color: #cde3e6; padding: 14px 16px; border-radius: var(--radius-sm); overflow-x: auto; font-size: 12.5px; line-height: 1.5; white-space: pre; }
.empty { text-align: center; color: var(--muted); padding: 22px; }
.result-meta { font-size: 12.5px; color: var(--muted); margin: 12px 2px; }

/* ---- Easter egg ---- */
#grouper-egg { position: fixed; inset: 0; z-index: 9999; background: rgba(8,30,36,.92); display: grid; place-items: center; cursor: pointer; animation: egg-fade .25s ease; }
#grouper-egg .egg-inner { text-align: center; animation: egg-pop .5s cubic-bezier(.18,.9,.3,1.2); }
#grouper-egg img { max-width: min(82vw, 900px); max-height: 70vh; border-radius: 14px; box-shadow: 0 24px 80px rgba(0,0,0,.6); }
#grouper-egg .egg-cap { margin-top: 18px; color: #fff; font-size: 30px; font-weight: 800; letter-spacing: 2px; }
#grouper-egg .egg-sub { margin-top: 6px; color: #9fc6cd; font-size: 13px; letter-spacing: .5px; }
@keyframes egg-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes egg-pop { from { transform: scale(.7) translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Message detail ---- */
.clickable { cursor: pointer; }
.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv th { text-align: left; color: var(--muted); font-weight: 600; padding: 5px 10px 5px 0; vertical-align: top; white-space: nowrap; width: 110px; }
.kv td { padding: 5px 0; word-break: break-all; }
.score-row { display: flex; align-items: baseline; gap: 10px; }
.score-big { font-size: 34px; font-weight: 700; letter-spacing: -1px; }
.score-meta { color: var(--muted); font-size: 13px; }
.score-track { height: 8px; background: #eef2f4; border-radius: 5px; overflow: hidden; margin: 10px 0; }
.score-fill { height: 100%; background: var(--accent); border-radius: 5px; }
.score-pos { color: var(--err); }
.score-neg { color: var(--ok); }

/* ---- Donut (action mix) ---- */
.donut-wrap { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; border-radius: 50%; flex: 0 0 auto; position: relative; }
.donut-hole { position: absolute; inset: 27px; background: var(--card); border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-total { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.donut-cap { font-size: 11px; color: var(--muted); }
.donut-legend { display: flex; flex-direction: column; gap: 7px; min-width: 200px; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend-sw { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.legend-val { color: var(--muted); margin-left: auto; }
a.stat-card { color: inherit; }
a.stat-card:hover { text-decoration: none; box-shadow: 0 2px 4px rgba(16,40,48,.1), 0 10px 28px rgba(16,40,48,.1); transform: translateY(-1px); transition: .12s; }

/* ---- Bar charts with Y-axis scale ---- */
.chart-wrap { display: flex; gap: 8px; margin-top: 6px; }
.chart-yaxis { flex: 0 0 auto; width: 38px; height: var(--chart-h, 150px); display: flex; flex-direction: column; justify-content: space-between; text-align: right; font-size: 9px; color: var(--muted); }
.chart-main { flex: 1; min-width: 0; }
.chart { height: var(--chart-h, 150px); display: flex; align-items: flex-end; gap: 3px;
  border-bottom: 1px solid var(--line-strong);
  background:
    linear-gradient(var(--line), var(--line)) left 0/100% 1px no-repeat,
    linear-gradient(var(--line), var(--line)) left 50%/100% 1px no-repeat; }
.chart-col { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 0; }
.chart-bar { background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; display: flex; flex-direction: column; }
.chart-bar-blocked { background: var(--err); border-radius: 3px 3px 0 0; }
.chart-xrow { display: flex; gap: 3px; margin-top: 3px; }
.chart-x { flex: 1 1 0; min-width: 0; font-size: 9px; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; }

/* dashboard top: charts stacked left, donut full-height right */
.dash-top { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: stretch; margin-bottom: 18px; }
.dash-left { display: flex; flex-direction: column; gap: 18px; }
.dash-top .card { margin-bottom: 0; }
.donut-card { display: flex; flex-direction: column; }
.donut-card .donut-wrap { flex: 1; justify-content: center; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 3px 0 8px; vertical-align: middle; }
.legend-ok { background: var(--accent); }
.legend-err { background: var(--err); }

/* ---- Tags ---- */
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; letter-spacing: .2px; }
.tag-ok { background: var(--ok-soft); color: #186a4b; }
.tag-off { background: #eef2f4; color: var(--muted); }
.tag-tls { background: var(--accent-soft); color: var(--accent-deep); }
.tag-admin { background: #e7ecfb; color: #3b50b0; }
.tag-user { background: #eef2f4; color: #4a5b63; }
.tag-warn { background: var(--warm-soft); color: #8a531a; }
.tag-err { background: var(--err-soft); color: #9a302a; }

/* ---- Bulk action toolbar ---- */
.toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 0; flex-wrap: wrap; }
#selcount { min-width: 72px; }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: inline-block; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 190px;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 5px; display: flex; flex-direction: column; }
.menu-item { text-align: left; background: none; border: none; padding: 8px 11px; border-radius: 6px;
  font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; white-space: nowrap; }
.menu-item:hover { background: var(--accent-soft); color: var(--accent-deep); }

/* ---- Filters ---- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 4px; }
.filter-search { flex: 1 1 280px; min-width: 220px; }
input, select { font-family: inherit; font-size: 13px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 8px 11px; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { cursor: pointer; }

/* ---- Forms ---- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.field input, .field select { font-weight: 400; color: var(--ink); }
.hint { font-size: 12px; color: var(--muted); margin: 0; }

/* ---- Buttons ---- */
.btn-primary, .btn-ghost { font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1.4; padding: 9px 16px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent; box-sizing: border-box; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { background: #f4f7f8; text-decoration: none; }
.btn-block { width: 100%; display: block; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--sb-ink-dim); padding: 14px 11px 5px; }
.sidebar-foot .btn-ghost { color: var(--sb-ink); border-color: rgba(255,255,255,.16); }
.sidebar-foot .btn-ghost:hover { background: rgba(255,255,255,.06); }
.muted { color: var(--muted); }
.link { font-size: 13px; font-weight: 600; }

/* ---- Login ---- */
.login-body { background: radial-gradient(1200px 600px at 70% -10%, #14464f, var(--sb-bg-2)); min-height: 100vh; display: grid; place-items: center; }
.login-wrap { width: 100%; max-width: 380px; padding: 20px; }
.login-card { background: var(--card); border-radius: 18px; box-shadow: 0 18px 50px rgba(0,0,0,.3); padding: 28px 26px; }
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.brand-mark.lg { color: var(--accent); }
.login-name { font-size: 22px; font-weight: 700; }
.login-sub { font-size: 12.5px; color: var(--muted); }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.login-foot { text-align: center; color: rgba(255,255,255,.6); font-size: 12px; margin-top: 18px; }

@media (max-width: 880px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .stat-row-6 { grid-template-columns: repeat(3, 1fr); }
  .two-col-even { grid-template-columns: 1fr; }
  .dash-top { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .sidebar { width: 72px; flex-basis: 72px; }
  .brand-name, .nav-item span:not(.nav-dot), .who-meta { display: none; }
}
