/* ==========================================================
   Uternet admin - shared styles (light theme only, flat colours)
   Layout: bottom nav below 768px, left sidebar from 768px up
   ========================================================== */

:root {
  --bg: #f1f4f2;
  --surface: #ffffff;
  --line: #dde3e0;
  --line-strong: #c8d0cc;
  --text: #12231f;
  --muted: #5b6b66;

  --primary: #0a7a5f;
  --primary-dark: #075f4a;
  --primary-soft: #e0f1ea;

  --ok: #14733a;
  --ok-soft: #e3f3e8;
  --warn: #9a5b00;
  --warn-soft: #fcefd6;
  --danger: #b3261e;
  --danger-soft: #fbe8e6;
  --info: #1c5db0;
  --info-soft: #e5eefa;
  --neutral: #4d5a56;
  --neutral-soft: #e8ecea;

  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --nav-width: 248px;
  --bottom-nav: 64px;
  --radius: 12px;
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; color-scheme: light; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.feather { width: 18px; height: 18px; stroke-width: 2; flex: none; }
.mono { font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.01em; }
.muted { color: var(--muted); }
.sub { font-size: 12.5px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 8px;
  background: none; font-weight: 600; font-size: 14px;
  white-space: nowrap; cursor: pointer;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn--block { width: 100%; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn--sm .feather { width: 16px; height: 16px; }

.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn--ok { background: var(--ok); color: #fff; }
.btn--ok:hover:not(:disabled) { background: #0f5d2e; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { background: #8f1d17; }
.btn--outline { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn--outline:hover:not(:disabled) { background: var(--bg); }
.btn--outline-danger { background: var(--surface); border-color: #e3b4b0; color: var(--danger); }
.btn--outline-danger:hover:not(:disabled) { background: var(--danger-soft); }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); cursor: pointer;
}
.icon-btn:hover { background: var(--bg); }

.link-btn {
  border: 0; background: none; padding: 8px 0;
  color: var(--primary); font-weight: 600; cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field label, .field .label { font-weight: 600; font-size: 14px; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.field-row { display: grid; gap: 16px; }

.input {
  width: 100%; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); font-size: 16px;
}
.input:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
select.input { padding-right: 8px; }

.input-wrap { position: relative; }
.input-wrap .input { padding-right: 48px; }
.input-wrap__btn {
  position: absolute; top: 0; right: 0; width: 46px; height: 44px;
  display: grid; place-items: center;
  border: 0; background: none; color: var(--muted); cursor: pointer;
}

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--primary); }

.form-error, .form-ok, .alert {
  padding: 10px 12px; border-radius: 8px; font-size: 14px;
}
.form-error, .alert--danger { background: var(--danger-soft); color: var(--danger); }
.form-ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- Status badges ---------- */
.badge {
  display: inline-flex; align-items: center; width: fit-content;
  padding: 2px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--neutral { background: var(--neutral-soft); color: var(--neutral); }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand__mark {
  display: grid; place-items: center; width: 36px; height: 36px;
  border-radius: 10px; background: var(--primary); color: #fff;
}
.brand__name { font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }

/* ==========================================================
   Login page
   ========================================================== */
.auth { min-height: 100vh; display: grid; }
.auth__aside { display: none; }
.auth__main { display: grid; place-items: center; padding: 24px 16px; }
.auth__card {
  width: min(420px, 100%); padding: 28px 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
}
.auth__card .brand { margin-bottom: 24px; }
.auth__card h1 { font-family: var(--font-display); font-size: 28px; line-height: 1.15; letter-spacing: -0.02em; }
.auth__card .lead { margin: 6px 0 24px; color: var(--muted); }

@media (min-width: 900px) {
  .auth { grid-template-columns: minmax(380px, 5fr) 6fr; }
  .auth__aside {
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 40px 48px; background: var(--primary-dark); color: #fff;
  }
  .auth__aside .brand__mark { background: #fff; color: var(--primary-dark); }
  .auth__pitch h2 {
    font-family: var(--font-display); font-size: 40px; line-height: 1.08;
    letter-spacing: -0.025em; font-weight: 700; max-width: 14ch;
  }
  .auth__points { margin-top: 28px; display: grid; gap: 14px; }
  .auth__points li { display: flex; align-items: center; gap: 12px; color: #d3ece3; }
  .auth__foot { color: #9fcfc0; font-size: 13.5px; }
  .auth__card { border: 0; background: transparent; padding: 0; }
  .auth__card .brand { display: none; }
}

/* ==========================================================
   Dashboard shell
   ========================================================== */
.is-loading .nav,
.is-loading .main { visibility: hidden; }

.splash {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: var(--bg); color: var(--muted); font-weight: 600;
}

/* Navigation: bottom bar on small screens */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav__brand, .nav__foot { display: none; }
.nav__list {
  height: var(--bottom-nav);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
}
.nav__link {
  position: relative; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11.5px; font-weight: 600; color: var(--muted);
}
.nav__link:hover { text-decoration: none; }
.nav__link[aria-current="page"] { color: var(--primary); }
.nav__link[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 22%; right: 22%;
  height: 3px; border-radius: 0 0 3px 3px; background: var(--primary);
}
.nav__badge {
  position: absolute; top: 5px; left: calc(50% + 4px);
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* Seven nav items on narrow phones */
@media (max-width: 420px) {
  .nav__link { font-size: 10.5px; }
}

/* Main column */
.main { min-height: 100vh; padding-bottom: calc(var(--bottom-nav) + env(safe-area-inset-bottom) + 24px); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; min-height: 60px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-family: var(--font-display); font-size: 21px; font-weight: 700; letter-spacing: -0.015em; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }
.topbar__actions .btn { min-height: 40px; }
.topbar__actions .icon-btn { width: 40px; height: 40px; }
.btn__text { display: none; }

.content { max-width: 1240px; margin: 0 auto; padding: 16px; }

/* Connection indicator */
.conn { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.conn__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.conn[data-state="online"] .conn__dot { background: #1fa563; }
.conn[data-state="offline"] .conn__dot { background: var(--danger); }
.topbar .conn__text { display: none; }

@media (min-width: 480px) {
  .btn__text { display: inline; }
  .field-row { grid-template-columns: 1fr 1fr; }
}

/* Navigation: sidebar from 768px */
@media (min-width: 768px) {
  .nav {
    top: 0; right: auto; bottom: 0; width: var(--nav-width);
    display: flex; flex-direction: column;
    padding: 20px 14px; border-top: 0; border-right: 1px solid var(--line);
  }
  .nav__brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 24px; }
  .nav__brand .brand__name { font-family: var(--font-display); font-weight: 700; font-size: 21px; }
  .nav__brand .brand__mark {
    display: grid; place-items: center; width: 36px; height: 36px;
    border-radius: 10px; background: var(--primary); color: #fff;
  }
  .nav__list { height: auto; display: flex; flex-direction: column; gap: 4px; }
  .nav__link {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    height: 44px; padding: 0 12px; border-radius: 8px; font-size: 14.5px;
  }
  .nav__link:hover { background: var(--bg); }
  .nav__link[aria-current="page"] { background: var(--primary-soft); }
  .nav__link[aria-current="page"]::before { display: none; }
  .nav__badge { position: static; margin-left: auto; }
  .nav__foot { display: grid; gap: 10px; margin-top: auto; padding: 14px 6px 0; border-top: 1px solid var(--line); }
  .nav__user { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

  .main { margin-left: var(--nav-width); padding-bottom: 40px; }
  .topbar { padding: 12px 32px; min-height: 68px; }
  .topbar .btn--logout { display: none; }
  .topbar .conn { display: none; }
  .content { padding: 28px 32px; }
}

/* ---------- Page blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.card__head h2 { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.card__body { padding: 16px; }
.card + .card, .stats + .grid-2, .grid-2 + .card { margin-top: 16px; }

.grid-2 { display: grid; gap: 16px; }
@media (min-width: 1024px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Stat strip: one connected block, not separate cards */
.stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.stat {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  padding: 16px; background: var(--surface); text-align: left; border: 0;
}
button.stat { cursor: pointer; }
button.stat:hover { background: #f8faf9; }
.stat__label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); font-weight: 500; }
.stat__value { font-family: var(--font-display); font-size: 26px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; }
.stat__sub { font-size: 12.5px; color: var(--muted); }
@media (min-width: 768px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 768px) { .stats--four { grid-template-columns: repeat(4, 1fr); } }

/* Row lists */
.rows li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.rows li:last-child { border-bottom: 0; }
.rows__main { flex: 1; min-width: 0; display: grid; }
.rows__main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows__side { display: flex; align-items: center; gap: 8px; flex: none; }

.tasks li {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.tasks li:last-child { border-bottom: 0; }
.tasks__main { flex: 1 1 220px; min-width: 0; display: grid; gap: 2px; }
.tasks__mac { display: flex; align-items: center; gap: 8px; }

.empty { display: grid; justify-items: center; gap: 6px; padding: 36px 20px; text-align: center; color: var(--muted); }
.empty .feather { width: 28px; height: 28px; color: var(--line-strong); }
.empty strong { color: var(--text); font-size: 15px; }
.empty .btn { margin-top: 8px; }

.note { display: grid; gap: 6px; padding: 14px 16px; font-size: 14px; }
.note ol { margin: 0; padding-left: 20px; display: grid; gap: 4px; }

/* Toolbar: search and filter chips */
.toolbar { display: grid; gap: 12px; margin-bottom: 16px; }
.toolbar--row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.search { position: relative; display: block; }
.search .feather { position: absolute; left: 12px; top: 13px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 40px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer;
}
.chip__count { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip[aria-pressed="true"] .chip__count { color: #cfe9e0; }

@media (min-width: 768px) {
  .toolbar { grid-template-columns: minmax(240px, 340px) 1fr; align-items: center; }
}

/* ---------- Tables (turn into stacked cards on phones) ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  padding: 12px 14px; text-align: left; white-space: nowrap;
  font-size: 13px; font-weight: 600; color: var(--muted);
  background: #f8faf9; border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cell--actions { flex-direction: row; flex-wrap: wrap; gap: 6px; }

@media (max-width: 767px) {
  .table-wrap { border: 0; background: none; overflow: visible; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr {
    margin-bottom: 12px; padding: 8px 14px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  }
  .table td {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
    padding: 7px 0; border: 0; text-align: right;
  }
  .table td::before { content: attr(data-label); flex: none; max-width: 42%; font-weight: 600; color: var(--muted); text-align: left; }
  .table td[data-label=""]::before { display: none; }
  .table td .cell { align-items: flex-end; }
  .table td.td-actions { justify-content: flex-end; margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line); }
  .table td.td-actions .cell--actions { justify-content: flex-end; }
}

/* ---------- Segmented data meter ---------- */
.meter { display: flex; gap: 2px; width: 130px; }
.meter span { flex: 1; height: 9px; border-radius: 2px; background: var(--neutral-soft); }
.meter span.on { background: var(--primary); }
.meter--warn span.on { background: #d98a00; }
.meter--danger span.on { background: var(--danger); }

/* ---------- Bar chart (plain CSS) ---------- */
.chart { display: flex; align-items: stretch; gap: 8px; height: 220px; padding: 16px; }
.chart__col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart__value { font-size: 12px; font-weight: 600; color: var(--muted); height: 16px; white-space: nowrap; }
.chart__track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.chart__bar { width: 100%; max-width: 48px; min-height: 3px; background: var(--primary); border-radius: 6px 6px 0 0; }
.chart__bar--empty { background: var(--line); }
.chart__label { font-size: 12.5px; color: var(--muted); }

/* ---------- Plans ---------- */
.plans { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.plan { display: grid; gap: 14px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.plan__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.plan__name { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.plan__price { font-family: var(--font-display); font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.plan__facts { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.plan__facts li { display: flex; align-items: center; gap: 8px; }
.plan__actions { display: flex; gap: 8px; }

/* ---------- Dialogs ---------- */
.dialog {
  width: min(520px, calc(100% - 24px)); max-height: calc(100% - 24px);
  padding: 0; border: 0; border-radius: 14px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 12px 40px rgba(18, 35, 31, 0.25);
}
.dialog::backdrop { background: rgba(18, 35, 31, 0.5); }
.dialog--small { width: min(420px, calc(100% - 24px)); }
.dialog__form { display: flex; flex-direction: column; max-height: calc(100vh - 24px); }
.dialog__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line);
}
.dialog__head h2 { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.dialog__body { display: grid; gap: 16px; padding: 20px; overflow-y: auto; }
.dialog__body h2 { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.dialog__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.dialog__info { padding: 10px 12px; border-radius: 8px; background: var(--bg); font-size: 14px; display: grid; gap: 2px; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; z-index: 60; left: 12px; right: 12px;
  bottom: calc(var(--bottom-nav) + env(safe-area-inset-bottom) + 14px);
  display: grid; gap: 8px; pointer-events: none;
}
.toast {
  padding: 12px 14px; border-radius: 10px; font-size: 14px; font-weight: 500;
  background: var(--text); color: #fff; pointer-events: auto;
}
.toast--error { background: var(--danger); }
@media (min-width: 768px) {
  .toasts { left: auto; right: 24px; bottom: 24px; width: 360px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
