/* ============================================================
   moizz — application styles
   Consumes tokens.css only. Sections:
     1 reset · 2 base · 3 public shell · 4 portal shell
     5 sidebar · 6 topbar · 7 grid · 8 components · 9 responsive
   ============================================================ */

/* ---- 1 reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* ---- 2 base ---- */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  min-height: 100vh;
}
h1, h2, h3 { line-height: var(--lh-head); font-weight: 600; }
h1 { font-size: var(--fs-hero); }
h2 { font-size: var(--fs-title); }
h3 { font-size: var(--fs-emph); }
code, .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
::selection { background: var(--accent); color: var(--bg); }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-ctl);
}
.muted  { color: var(--muted); }
.faint  { color: var(--faint); }
.label {
  font-size: var(--fs-caption);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--muted);
}

/* ---- 3 public shell: a centered column, nothing else ---- */
.public {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-5);
  padding: var(--s-6);
  text-align: center;
}
.public .wordmark {
  font-size: var(--fs-hero);
  font-weight: 600;
  letter-spacing: -0.02em;
}
/* Brand: The Gate — official lockup on public/auth pages */
.brand-lockup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-4);
  color: var(--text);
}
.brand-lockup .brand-mark { width: 46px; height: 46px; }
.brand-lockup .brand-wm { width: 132px; height: auto; display: block; }
.brand-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-4);
}
.public nav { display: flex; gap: var(--s-4); }
.public nav a {
  color: var(--muted);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-ctl);
}
.public nav a:hover { color: var(--text); background: var(--raised); }
.public .card { width: 100%; max-width: 360px; text-align: left; }

/* ---- 4 portal shell ---- */
.portal {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.content {
  min-width: 0;
}
.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-7);
}
.page-head { display: flex; flex-direction: column; gap: var(--s-1); }

/* ---- 5 sidebar ---- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: var(--s-4);
  gap: var(--s-5);
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.sidebar .brand .brand-mark {
  width: 22px; height: 22px;
  color: var(--text);
  flex: none;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-ctl);
  color: var(--muted);
  position: relative;
}
.nav-item svg { width: 16px; height: 16px; flex: none; }
button.nav-item {           /* the sign-out form's button wears the same coat */
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}
.nav-item:hover { color: var(--text); background: var(--raised); }
.nav-item.active {
  color: var(--text);
  background: var(--raised);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--s-4));
  top: 6px; bottom: 6px;
  width: 2px;
  background: var(--accent);
  border-radius: var(--r-pill);
}
.nav-item .kbd { margin-left: auto; }
.sidebar .foot {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  border-top: 1px solid var(--border);
  padding-top: var(--s-4);
}

/* ---- 6 topbar ---- */
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 0 var(--s-6);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.topbar .title { font-size: var(--fs-emph); font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .clock {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-caption);
  color: var(--muted);
}

/* ---- 7 dashboard grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--s-4);
}
.span-4  { grid-column: span 4; }
.span-6  { grid-column: span 6; }
.span-8  { grid-column: span 8; }
.span-12 { grid-column: span 12; }

/* ---- 8 components ---- */

/* card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--s-5);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  font-size: var(--fs-caption);
  color: var(--faint);
  border-top: 1px solid var(--border);
  padding-top: var(--s-3);
  margin-top: auto;
}
.card-foot a { color: var(--muted); }
.card-foot a:hover { color: var(--text); }

/* stat */
.stat { display: flex; flex-direction: column; gap: var(--s-1); }
.stat .value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-title);
  font-weight: 600;
}
.stat .delta { font-size: var(--fs-caption); }
.stat-row { display: flex; gap: var(--s-6); }
.delta.up   { color: var(--ok); }
.delta.down { color: var(--danger); }

/* status pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-caption);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 2px var(--s-3);
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: var(--r-pill); }
.pill.ok     .dot { background: var(--ok); }
.pill.warn   .dot { background: var(--warn); }
.pill.danger .dot { background: var(--danger); }
.pill.info   .dot { background: var(--info); }
.pill.idle   .dot { background: var(--faint); }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: var(--ctl-h);
  padding: 0 var(--s-4);
  border-radius: var(--r-ctl);
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { border-color: var(--faint); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--raised); }

/* inputs */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.input {
  height: var(--ctl-h);
  padding: 0 var(--s-3);
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r-ctl);
  color: var(--text);
  width: 100%;
}
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--accent); }

/* dense table */
.table { width: 100%; border-collapse: collapse; }
.table th {
  font-size: var(--fs-caption);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--muted);
  text-align: left;
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border);
}
.table td {
  height: var(--row-h);
  padding: 0 var(--s-3);
  border-bottom: 1px solid var(--border);
}
.table tr:hover td { background: var(--raised); }

/* activity feed */
.feed { display: flex; flex-direction: column; }
.feed-row {
  display: flex;
  align-items: baseline;
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border);
}
.feed-row:last-child { border-bottom: none; }
.feed-row time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-caption);
  color: var(--faint);
  flex: none;
}
.feed-row .src { color: var(--muted); flex: none; font-size: var(--fs-caption); }

/* kbd */
.kbd {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  color: var(--muted);
  background: var(--raised);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--r-ctl);
  padding: 1px var(--s-2);
  white-space: nowrap;
}

/* empty state */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-8) var(--s-5);
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--r-card);
}
.empty h3 { color: var(--text); }

/* quick-launch list */
.launch { display: flex; flex-direction: column; gap: var(--s-1); }
.launch a {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-ctl);
  color: var(--muted);
}
.launch a:hover { color: var(--text); background: var(--raised); }
.launch a .kbd { margin-left: auto; }

/* meter (vps bars) */
.meter { display: flex; flex-direction: column; gap: var(--s-1); }
.meter .bar {
  height: 4px;
  background: var(--raised);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.meter .bar i {
  display: block;
  height: 100%;
  background: var(--muted);
  border-radius: var(--r-pill);
}
.meter .row {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-caption);
  color: var(--muted);
}
.meter .row .mono { color: var(--text); }

/* ---- 9 responsive ---- */
@media (max-width: 1024px) {
  .portal { grid-template-columns: 64px 1fr; }
  .sidebar { padding: var(--s-3) var(--s-2); align-items: center; }
  .sidebar .brand span, .nav-item span, .nav-item .kbd { display: none; }
  .nav-item { justify-content: center; padding: var(--s-3); }
  .nav-item.active::before { left: calc(-1 * var(--s-2)); }
  .span-4, .span-8 { grid-column: span 6; }
}
@media (max-width: 640px) {
  .portal { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: auto; bottom: 0; left: 0; right: 0;
    height: auto;
    flex-direction: row;
    justify-content: center;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: var(--s-2);
    z-index: 20;
  }
  .sidebar .brand, .sidebar .foot { display: none; }
  .sidebar nav { flex-direction: row; flex: none; gap: var(--s-2); }
  .nav-item.active::before { display: none; }
  .nav-item.active { color: var(--accent); }
  .page { padding: var(--s-4); padding-bottom: var(--s-8); gap: var(--s-6); }
  .topbar { padding: 0 var(--s-4); }
  .span-4, .span-6, .span-8 { grid-column: span 12; }
  .stat-row { flex-wrap: wrap; gap: var(--s-4); }
}

@media (prefers-reduced-motion: no-preference) {
  .nav-item, .btn, .launch a, .public nav a { transition: background 120ms ease, color 120ms ease; }
}
