/*
 * Zynoptes portal design system — shared by dashboard.zynoptes.com and
 * admin.zynoptes.com. Dark-only, flat monochrome surfaces separated by
 * hairlines, white primary actions, one electric-blue accent (#0099ff, the
 * zynoptes.com brand accent) reserved for links, focus, active states and
 * data-viz strokes. Typography: Geist / Geist Mono, self-hosted (OFL-1.1).
 */

@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/geist-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/geist-mono-latin.woff2") format("woff2");
}

:root {
  --canvas: #090909;
  --surface: #0d0d0f;
  --surface-hover: #141416;
  --ink: #ededed;
  --ink-muted: #a9a9a9;
  --ink-faint: #8a8a8a;
  --hairline: #262626;
  --hairline-soft: #1a1a1a;
  --accent: #0099ff;
  --accent-soft: rgba(0, 153, 255, 0.12);
  --ring: rgba(0, 153, 255, 0.4);
  --success: #22c55e;
  --success-ink: #4ade80;
  --danger: #ff4d5e;
  --danger-ink: #ff8f9a;
  --warning: #f5a524;
  --warning-ink: #ffcd6b;
  --radius: 8px;
  --radius-lg: 12px;
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 22px;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "rlig" 1, "calt" 1, "cv11" 1;
}

::selection { background: rgba(0, 153, 255, 0.32); color: var(--ink); }

* { scrollbar-width: thin; scrollbar-color: #2e2e2e transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #2e2e2e; border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: #3d3d3d; }
*::-webkit-scrollbar-track { background: transparent; }

h1, h2, h3, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--font-mono); font-size: 12.5px; }
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.num { font-family: var(--font-mono); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Buttons ---------- */
button {
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  line-height: 20px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--ink);
  color: #161618;
  cursor: pointer;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out, transform 80ms ease-out;
}
button:hover { background: #d9d9d9; }
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

button.quiet { background: #1d1d20; color: var(--ink); border-color: var(--hairline); }
button.quiet:hover { background: #262629; }
button.ghost { background: transparent; color: var(--ink); border-color: var(--hairline); }
button.ghost:hover { background: var(--surface-hover); }
button.danger { background: var(--danger); color: #fff; }
button.danger:hover { background: #e63a4b; }
button.link {
  background: none;
  border: 0;
  color: var(--accent);
  font-weight: 500;
  padding: 0;
  border-radius: 4px;
}
button.link:hover { text-decoration: underline; background: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible { outline: none; }

/* ---------- Forms ---------- */
form { display: grid; gap: 14px; margin: 0; }
label { display: grid; gap: 6px; font-weight: 500; font-size: 13px; color: var(--ink-muted); min-width: 0; }
input, select {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #101012;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 9px 12px;
  width: 100%;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}
input::placeholder { color: var(--ink-faint); }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
input:disabled, select:disabled { opacity: 0.55; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%), linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

/* Password requirement checklist */
.checklist { list-style: none; margin: 2px 0 0; padding: 0; display: grid; gap: 4px; }
.checklist li {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; line-height: 16px; color: var(--ink-faint);
  transition: color 150ms ease-out;
}
.checklist li::before {
  content: "";
  width: 14px; height: 14px; flex: none;
  border: 1px solid var(--hairline); border-radius: 50%;
  transition: background-color 150ms ease-out, border-color 150ms ease-out;
}
.checklist li.met { color: var(--success-ink); }
.checklist li.met::before {
  content: "✓";
  background: var(--success); border-color: var(--success);
  color: #090909; font-size: 10px; font-weight: 800; line-height: 14px; text-align: center;
}

/* ---------- Notices ---------- */
.notice {
  display: none;
  font-size: 13px; line-height: 20px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.notice.show { display: block; }
.notice.error { background: rgba(255, 77, 94, 0.08); border-color: rgba(255, 77, 94, 0.28); color: var(--danger-ink); }
.notice.success { background: rgba(34, 197, 94, 0.08); border-color: rgba(34, 197, 94, 0.28); color: var(--success-ink); }
.notice.info { background: var(--accent-soft); border-color: rgba(0, 153, 255, 0.28); color: #7cc4ff; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; border-radius: 7px; display: block; }
.brand .brand-sub { color: var(--ink-faint); font-weight: 500; }

/* ---------- Auth ---------- */
.auth-layout {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 48px 16px;
  background-image: radial-gradient(ellipse 55% 45% at 50% 30%, rgba(0, 153, 255, 0.09), transparent 70%);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-lg);
  padding: 32px;
  display: grid;
  gap: 22px;
  animation: auth-in 300ms ease-out;
}
@keyframes auth-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.auth-brand { display: grid; justify-items: center; gap: 14px; text-align: center; }
.auth-brand img { width: 44px; height: 44px; border-radius: 12px; }
.auth-brand .wordmark { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.02em; }
.auth-brand p { color: var(--ink-muted); font-size: 13px; }
.auth-view { display: grid; gap: 16px; }
.auth-view > h1 { font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: -0.01em; }
.auth-view > p.hint { font-size: 13px; color: var(--ink-muted); }
.auth-links { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
.auth-foot { text-align: center; font-size: 12px; color: var(--ink-faint); }
.auth-foot a { color: var(--ink-muted); }

/* ---------- Shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px; height: 57px;
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline-soft);
}
.topbar-user { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--ink-muted); min-width: 0; }
.topbar-user .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; display: grid; gap: 20px; align-content: start; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.02em; }
.page-head .sub { color: var(--ink-muted); font-size: 13px; margin-top: 2px; }

/* ---------- Sidebar shell (admin) ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--hairline-soft);
  padding: 16px 12px;
  background: var(--canvas);
}
.sidebar .brand { padding: 4px 8px 16px; }
.nav { display: grid; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint); padding: 12px 8px 6px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--ink-muted);
  font-size: 13.5px; font-weight: 500;
  background: none; border: 0; width: 100%; text-align: left;
  cursor: pointer;
  transition: background-color 150ms ease-out, color 150ms ease-out;
}
.nav-item:hover { background: var(--surface-hover); color: var(--ink); transform: none; }
.nav-item.active { color: var(--accent); background: var(--accent-soft); }
.nav-item.active::before {
  content: "";
  position: absolute; left: -12px; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 2px 2px 0;
  background: var(--accent);
}
.nav-item svg { width: 16px; height: 16px; flex: none; }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid var(--hairline-soft); }
.sidebar-foot .email { font-size: 12px; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.main-col .content { max-width: 1080px; width: 100%; }

/* ---------- Panels & cards ---------- */
.panel {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: grid;
  gap: 16px;
  align-content: start;
  position: relative;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-title { font-size: 15px; line-height: 22px; font-weight: 600; letter-spacing: -0.01em; }
.panel-sub { font-size: 12.5px; color: var(--ink-faint); }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: grid; gap: 6px;
  min-width: 0;
  align-content: start;
}
.metric .metric-label { font-size: 12px; line-height: 16px; color: var(--ink-faint); font-weight: 500; }
.metric .metric-value {
  font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.metric .metric-note { font-size: 12px; color: var(--ink-muted); }
.metric .meter { margin-top: 4px; }

/* Allowance / usage meter (SVG built in JS; no inline CSS per CSP) */
.meter svg { display: block; width: 100%; height: 6px; }
.meter .meter-track { fill: #1d1d20; }
.meter .meter-legend { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-faint); margin-top: 6px; }

/* ---------- Tables ---------- */
.scroll { overflow: auto; border: 1px solid var(--hairline-soft); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface);
  color: var(--ink-faint);
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 10px 12px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--hairline-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; transition: background-color 120ms ease-out; }
tbody tr.clickable:hover { background: var(--surface-hover); }
td.num, th.num { text-align: right; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; line-height: 18px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  color: var(--ink-muted);
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint); }
.badge.success { color: var(--success-ink); border-color: rgba(34, 197, 94, 0.3); background: rgba(34, 197, 94, 0.08); }
.badge.success::before { background: var(--success); }
.badge.danger { color: var(--danger-ink); border-color: rgba(255, 77, 94, 0.3); background: rgba(255, 77, 94, 0.08); }
.badge.danger::before { background: var(--danger); }
.badge.info { color: #7cc4ff; border-color: rgba(0, 153, 255, 0.3); background: var(--accent-soft); }
.badge.info::before { background: var(--accent); }

/* ---------- Detail groups ---------- */
details { border: 1px solid var(--hairline-soft); border-radius: var(--radius); overflow: hidden; }
details > summary {
  cursor: pointer;
  padding: 10px 14px;
  font-size: 13px; font-weight: 600;
  color: var(--ink-muted);
  background: var(--surface);
  list-style: none;
  display: flex; align-items: center; gap: 8px;
  transition: color 120ms ease-out;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: "";
  width: 7px; height: 7px; flex: none;
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 150ms ease-out;
}
details[open] > summary { color: var(--ink); border-bottom: 1px solid var(--hairline-soft); }
details[open] > summary::before { transform: rotate(45deg); }
details > .details-body { padding: 12px 14px; display: grid; gap: 6px; }
.detail-line { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; }
.detail-line .k { color: var(--ink-faint); }
.detail-line .v { font-family: var(--font-mono); font-size: 12.5px; text-align: right; overflow-wrap: anywhere; }

/* ---------- Definition grid (customer detail) ---------- */
.defgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; }
.defgrid .def { display: grid; gap: 2px; min-width: 0; }
.defgrid dt { font-size: 12px; color: var(--ink-faint); }
.defgrid dd { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.defgrid dd.mono { font-size: 12.5px; }

/* ---------- Code / key block ---------- */
.codeblock {
  font-family: var(--font-mono);
  font-size: 12.5px; line-height: 20px;
  background: #0b0b0d;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
}
.keyrow { display: flex; gap: 10px; align-items: stretch; }
.keyrow .codeblock { flex: 1; display: flex; align-items: center; }
.keyrow button { flex: none; align-self: center; }

/* ---------- Segmented control (chart metric switch) ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--hairline-soft); border-radius: 9px; }
.seg button {
  background: transparent; color: var(--ink-muted);
  border: 0; border-radius: 6px;
  padding: 5px 12px; font-size: 12.5px; font-weight: 500;
}
.seg button:hover { background: transparent; color: var(--ink); }
.seg button.active { background: #26262a; color: var(--ink); }

/* ---------- Filter bar ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters label { flex: 1 1 140px; max-width: 220px; }
.filters button { flex: none; }

/* ---------- Empty state ---------- */
.empty { padding: 36px 20px; text-align: center; display: grid; justify-items: center; gap: 8px; }
.empty .empty-title { font-size: 14px; font-weight: 600; }
.empty p { color: var(--ink-muted); font-size: 13px; max-width: 46ch; }

/* ---------- Busy bar ---------- */
.busy-bar {
  position: absolute; top: -1px; left: 12px; right: 12px; height: 2px;
  overflow: hidden; border-radius: 2px; display: none;
}
.busy-bar::after {
  content: ""; position: absolute; inset: 0;
  background: var(--accent);
  transform: translateX(-100%);
  animation: busy-slide 1.1s ease-in-out infinite;
}
.busy .busy-bar { display: block; }
@keyframes busy-slide {
  0% { transform: translateX(-100%); }
  55% { transform: translateX(20%); }
  100% { transform: translateX(100%); }
}

/* ---------- Chart ---------- */
.daily-chart figure { margin: 0; display: grid; gap: 8px; }
.daily-chart figcaption { font-size: 12px; color: var(--ink-faint); }
.daily-chart svg { display: block; width: 100%; height: auto; }
.daily-chart text { font-family: var(--font-mono); font-size: 11px; fill: var(--ink-faint); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto;
    flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px;
    border-right: 0; border-bottom: 1px solid var(--hairline-soft);
    padding: 10px 16px;
  }
  .sidebar .brand { padding: 0 12px 0 0; }
  .nav { display: flex; flex-wrap: wrap; }
  .nav-label { display: none; }
  .nav-item.active::before { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; align-items: center; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .defgrid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .content { padding: 20px 14px 48px; }
  .auth-card { padding: 24px 20px; }
  .topbar { padding: 0 14px; }
  .topbar-user .email { display: none; }
  .cards { grid-template-columns: 1fr; }
}

/* Motion is a state change, never decoration — and always optional */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
