/* Peyda (commercial font): put the licensed files next to this stylesheet with these names; until then the system font is used. */
@font-face { font-family: "Peyda"; src: url("/shared/Peyda-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Peyda"; src: url("/shared/Peyda-Medium.woff2") format("woff2"); font-weight: 500 560; font-display: swap; }
@font-face { font-family: "Peyda"; src: url("/shared/Peyda-SemiBold.woff2") format("woff2"); font-weight: 600 650; font-display: swap; }
@font-face { font-family: "Peyda"; src: url("/shared/Peyda-Bold.woff2") format("woff2"); font-weight: 700 900; font-display: swap; }

/* Design tokens. Light follows Apple's system palette; dark is its own selection, not an inversion. */
:root {
  color-scheme: light;
  --bg: #f5f5f7; --bg-2: #ebebf0; --panel: #ffffff; --panel-2: #f9f9fb; --raised: #ffffff;
  --ink: #1d1d1f; --ink-2: #6e6e73; --ink-3: #8e8e93; --line: rgba(0, 0, 0, .08); --line-2: rgba(0, 0, 0, .14);
  --fill: rgba(118, 118, 128, .12); --fill-2: rgba(118, 118, 128, .2);
  --accent: #0071e3; --accent-ink: #fff; --accent-soft: rgba(0, 113, 227, .1);
  --ok: #248a3d; --ok-solid: #34c759; --ok-soft: rgba(52, 199, 89, .14);
  --warn: #b25000; --warn-solid: #ff9f0a; --warn-soft: rgba(255, 159, 10, .16);
  --bad: #d70015; --bad-solid: #ff3b30; --bad-soft: rgba(255, 59, 48, .12);
  --info: #0066cc; --info-soft: rgba(0, 122, 255, .1);
  --series-1: #257de0; --grid: rgba(0, 0, 0, .06);
  --side: rgba(255, 255, 255, .72); --side-line: rgba(0, 0, 0, .06);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .05);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .18);
  --r: 16px; --r-sm: 10px;
  --font: "Peyda", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Vazirmatn, Tahoma, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000; --bg-2: #0e0e10; --panel: #1c1c1e; --panel-2: #232325; --raised: #2c2c2e;
  --ink: #f5f5f7; --ink-2: #98989d; --ink-3: #6e6e73; --line: rgba(255, 255, 255, .08); --line-2: rgba(255, 255, 255, .14);
  --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .36);
  --accent: #0a84ff; --accent-ink: #fff; --accent-soft: rgba(10, 132, 255, .18);
  --ok: #30d158; --ok-solid: #30d158; --ok-soft: rgba(48, 209, 88, .16);
  --warn: #ffb340; --warn-solid: #ff9f0a; --warn-soft: rgba(255, 159, 10, .18);
  --bad: #ff6961; --bad-solid: #ff453a; --bad-soft: rgba(255, 69, 58, .18);
  --info: #64d2ff; --info-soft: rgba(100, 210, 255, .14);
  --series-1: #338ced; --grid: rgba(255, 255, 255, .07);
  --side: rgba(22, 22, 24, .8); --side-line: rgba(255, 255, 255, .06);
  --shadow: none; --shadow-lg: 0 24px 80px rgba(0, 0, 0, .6);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #000000; --bg-2: #0e0e10; --panel: #1c1c1e; --panel-2: #232325; --raised: #2c2c2e;
    --ink: #f5f5f7; --ink-2: #98989d; --ink-3: #6e6e73; --line: rgba(255, 255, 255, .08); --line-2: rgba(255, 255, 255, .14);
    --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .36);
    --accent: #0a84ff; --accent-ink: #fff; --accent-soft: rgba(10, 132, 255, .18);
    --ok: #30d158; --ok-solid: #30d158; --ok-soft: rgba(48, 209, 88, .16);
    --warn: #ffb340; --warn-solid: #ff9f0a; --warn-soft: rgba(255, 159, 10, .18);
    --bad: #ff6961; --bad-solid: #ff453a; --bad-soft: rgba(255, 69, 58, .18);
    --info: #64d2ff; --info-soft: rgba(100, 210, 255, .14);
    --series-1: #338ced; --grid: rgba(255, 255, 255, .07);
    --side: rgba(22, 22, 24, .8); --side-line: rgba(255, 255, 255, .06);
    --shadow: none; --shadow-lg: 0 24px 80px rgba(0, 0, 0, .6);
  }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; overflow-y: scroll; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.65; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.35; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.07rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: .35rem 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .9em; unicode-bidi: isolate; }
code { overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; border-radius: 8px; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--ink-2); } .small { font-size: .86rem; } .grow { flex: 1; min-width: 0; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; } .between { justify-content: space-between; } .end { justify-content: flex-end; }
.stack { display: grid; gap: 1rem; min-width: 0; align-content: start; }
.cols { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }
.cols-2-1 { display: grid; gap: 1rem; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: stretch; }
.cols-2-1 > * { min-width: 0; }
@media (max-width: 1100px) { .cols-2-1 { grid-template-columns: minmax(0, 1fr); } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 36px; padding: .35rem 1rem; border: 0; border-radius: 999px; background: var(--fill); color: var(--ink); font-weight: 560; cursor: pointer; white-space: nowrap; transition: background .15s, transform .1s, opacity .15s; text-decoration: none; }
.btn:hover { background: var(--fill-2); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: progress; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad-soft) 70%, var(--bad-solid) 30%); color: #fff; }
.btn.sm { min-height: 30px; padding: .2rem .8rem; font-size: .86rem; }
.btn.ghost { background: transparent; } .btn.ghost:hover { background: var(--fill); }
.btn.icon { padding: 0; width: 36px; }
.btn svg.i { width: 18px; height: 18px; }

/* Surfaces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 1.15rem 1.25rem; min-width: 0; box-shadow: var(--shadow); }
.card > h2, .card > h3, .card > .row:first-child { margin-bottom: .8rem; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .9rem; }
.card-title h2 { display: flex; align-items: center; gap: .5rem; }
.card-title { flex-wrap: wrap; } .card-title h2 { white-space: nowrap; }
@media (max-width: 560px) { .card-title > .seg { flex: 1 1 100%; } .card-title > .seg button { padding-inline: .5rem; } }
.section-label { font-size: .78rem; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; margin: 0 .2rem .5rem; }

/* Status pills: always a word, color only reinforces it */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .05rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--fill); color: var(--ink-2); white-space: nowrap; line-height: 1.7; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.info { background: var(--info-soft); color: var(--info); }
.badge.plain::before { display: none; }

/* Tables become clean lists */
.tablewrap { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }
table { border-collapse: collapse; width: 100%; }
th { font-weight: 600; color: var(--ink-2); font-size: .8rem; }
th, td { text-align: start; padding: .7rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th:first-child, td:first-child { padding-inline-start: 0; } th:last-child, td:last-child { padding-inline-end: 0; }
td.wrap { white-space: normal; min-width: 180px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; transition: background .12s; }
tbody tr.click:hover td { background: var(--panel-2); }
.empty { color: var(--ink-2); padding: 1.6rem 0; text-align: center; }

/* Key-value rows */
.kv { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .62rem 0; border-bottom: 1px solid var(--line); min-height: 44px; }
.kv:last-child { border: 0; }
.kv > span { color: var(--ink-2); flex: none; }
.kv > div { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; min-width: 0; text-align: end; }
.kv b { font-weight: 600; overflow-wrap: anywhere; }
.copy { border: 0; background: var(--fill); border-radius: 8px; padding: .1rem .55rem; font-size: .8rem; cursor: pointer; color: var(--ink-2); flex: none; font-weight: 560; }
.copy:hover { background: var(--fill-2); color: var(--ink); }

/* Forms */
.form { display: grid; gap: .9rem 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.full { grid-column: 1 / -1; }
.field { display: grid; gap: .3rem; align-content: start; min-width: 0; }
.field label { font-size: .84rem; color: var(--ink-2); font-weight: 500; }
.field small { color: var(--ink-3); font-size: .8rem; }
input:not([type=checkbox]):not([type=file]), select, textarea { width: 100%; min-width: 0; background: var(--fill); border: 1px solid transparent; border-radius: var(--r-sm); padding: .55rem .8rem; min-height: 40px; transition: border-color .15s, background .15s, box-shadow .15s; }
input:not([type=checkbox]):not([type=file]):focus, select:focus, textarea:focus { outline: none; background: var(--panel); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
textarea { resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: left 14px center, left 9px center; background-size: 5px 5px; background-repeat: no-repeat; padding-left: 2rem; }
input[type=file] { font-size: .9rem; color: var(--ink-2); }
input[type=file]::file-selector-button { border: 0; border-radius: 999px; background: var(--fill); padding: .45rem 1rem; margin-inline-end: .7rem; cursor: pointer; font-weight: 560; color: var(--ink); }
/* iOS-style switch for every checkbox */
input[type=checkbox] { appearance: none; flex: none; width: 46px; height: 28px; border-radius: 999px; background: var(--fill-2); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
input[type=checkbox]::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: inset-inline-start .2s cubic-bezier(.3, .7, .4, 1); }
input[type=checkbox]:checked { background: var(--ok-solid); }
input[type=checkbox]:checked::after { inset-inline-start: 20px; }
.check { display: flex; gap: .7rem; align-items: center; justify-content: space-between; cursor: pointer; padding: .35rem 0; }
.check > span { order: -1; }
.inline { display: flex; gap: .6rem; } .inline > * { min-width: 0; flex: 1; } .inline .btn { flex: none; }
fieldset { border: 1px solid var(--line); border-radius: var(--r-sm); padding: .8rem 1rem; margin: 0; display: grid; gap: .65rem; min-width: 0; background: var(--panel-2); }
legend { padding: 0 .4rem; font-weight: 650; }
.rows { display: grid; gap: .45rem; }

/* Segmented control */
.seg { display: flex; padding: 3px; gap: 2px; background: var(--fill); border-radius: 12px; overflow-x: auto; scrollbar-width: none; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: .45rem .9rem; font-weight: 560; color: var(--ink-2); cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; display: inline-flex; gap: .4rem; align-items: center; justify-content: center; }
.seg button.on { background: var(--raised); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg button svg.i { width: 17px; height: 17px; }

/* Sheets, toasts */
.modal { border: 0; border-radius: 20px; background: var(--panel); color: inherit; padding: 0; width: min(560px, 94vw); max-height: 88vh; box-shadow: var(--shadow-lg); }
.modal.wide { width: min(860px, 94vw); }
.modal[open] { animation: sheet .22s cubic-bezier(.2, .8, .3, 1); }
@keyframes sheet { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal::backdrop { background: rgba(0, 0, 0, .35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.3rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(12px); z-index: 1; }
.modal .body h3:not(.section-title) { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.modal .body > h3:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.modal .body { padding: 1.2rem 1.3rem; }
.x { border: 0; background: var(--fill); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 1.15rem; line-height: 1; color: var(--ink-2); }
.x:hover { background: var(--fill-2); color: var(--ink); }
.toasts { position: fixed; inset: auto; bottom: 1.4rem; left: 50%; transform: translateX(-50%); margin: 0; padding: 0; border: 0; background: none; overflow: visible; }
.toasts:popover-open { display: grid; gap: .5rem; justify-items: center; }
.toast { background: color-mix(in srgb, var(--raised) 85%, transparent); backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6); color: var(--ink); padding: .65rem 1.2rem; border-radius: 999px; max-width: min(460px, 92vw); box-shadow: var(--shadow-lg); border: 1px solid var(--line); font-weight: 560; animation: sheet .2s ease-out; display: flex; gap: .5rem; align-items: center; }
.toast.bad { color: var(--bad); }
.note { background: var(--fill); border-radius: var(--r-sm); padding: .75rem 1rem; display: flex; gap: .6rem; align-items: flex-start; }
.note.warn { background: var(--warn-soft); color: var(--warn); } .note.bad { background: var(--bad-soft); color: var(--bad); overflow-wrap: anywhere; } .note.ok { background: var(--ok-soft); color: var(--ok); }
.note svg.i { margin-top: .15rem; }

/* Progress */
.bar { height: 6px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .4s; }
.bar.warn > i { background: var(--warn-solid); } .bar.bad > i { background: var(--bad-solid); }

/* App shell */
.app { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); backdrop-filter: blur(24px) saturate(1.5); -webkit-backdrop-filter: blur(24px) saturate(1.5); border-inline-end: 1px solid var(--side-line); padding: 1.1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: .65rem; padding: .2rem .6rem 1.1rem; font-weight: 700; font-size: 1.1rem; letter-spacing: -.01em; }
.logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(145deg, #34c759, #0a84ff); color: #fff; box-shadow: 0 4px 14px rgba(10, 132, 255, .35); }
.logo svg.i { width: 20px; height: 20px; stroke-width: 2.2; }
.nav-label { font-size: .74rem; font-weight: 600; color: var(--ink-3); padding: .9rem .75rem .3rem; }
.side a.nav { display: flex; align-items: center; gap: .7rem; padding: .5rem .75rem; border-radius: 10px; color: var(--ink); font-weight: 520; text-decoration: none; transition: background .12s; }
.side a.nav svg.i { color: var(--ink-2); }
.side a.nav:hover { background: var(--fill); }
.side a.nav.on { background: var(--accent); color: #fff; }
.side a.nav.on svg.i { color: #fff; }
.side a.nav .count { margin-inline-start: auto; font-size: .76rem; font-weight: 600; color: var(--ink-2); background: var(--fill); padding: 0 .5rem; border-radius: 999px; min-width: 1.6rem; text-align: center; }
.side a.nav.on .count { background: rgba(255, 255, 255, .22); color: #fff; }
.side a.nav .count.bad { background: var(--bad-solid); color: #fff; }
.side .foot { margin-top: auto; padding-top: 1rem; display: grid; gap: .5rem; }
.status-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: .75rem .9rem; display: grid; gap: .2rem; }
.status-card b { display: flex; align-items: center; gap: .45rem; font-size: .92rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot.ok { background: var(--ok-solid); box-shadow: 0 0 0 4px var(--ok-soft); } .dot.bad { background: var(--bad-solid); box-shadow: 0 0 0 4px var(--bad-soft); }
.me-row { display: flex; align-items: center; gap: .6rem; padding: .4rem .5rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--fill-2); display: grid; place-items: center; font-weight: 700; color: var(--ink-2); flex: none; }
.main { padding: 1.8rem clamp(1rem, 2.6vw, 2.6rem) 3rem; min-width: 0; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.head .sub { color: var(--ink-2); margin-top: .1rem; }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.search { position: relative; flex: 1; min-width: 220px; }
.search svg.i { position: absolute; inset-inline-start: .75rem; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 18px; }
.search input { padding-inline-start: 2.4rem !important; }

/* KPI tiles */
.kpis { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.15rem; display: grid; gap: .15rem; box-shadow: var(--shadow); }
.kpi .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; margin-bottom: .4rem; background: var(--accent-soft); color: var(--accent); }
.kpi .ico.ok { background: var(--ok-soft); color: var(--ok); } .kpi .ico.warn { background: var(--warn-soft); color: var(--warn); } .kpi .ico.bad { background: var(--bad-soft); color: var(--bad); }
.kpi .ico svg.i { width: 19px; height: 19px; }
.kpi span { color: var(--ink-2); font-size: .86rem; }
.kpi b { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; font-variant-numeric: tabular-nums; }

/* Chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .grid text, .chart .axis text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .v { fill: var(--series-1); transition: opacity .12s; }
.chart .v.zero { fill: var(--fill-2); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .v.hot { opacity: .7; }
.tip { position: absolute; pointer-events: none; background: var(--raised); border: 1px solid var(--line); border-radius: 10px; padding: .4rem .7rem; font-size: .84rem; box-shadow: var(--shadow-lg); white-space: nowrap; transform: translate(-50%, -110%); z-index: 2; }
.tip b { display: block; }

/* Line charts: series 1 blue, series 2 orange (validated adjacent pair of the dataviz palette) */
:root { --series-2: #f47230; }
:root[data-theme="dark"] { --series-2: #e76624; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) { --series-2: #e76624; } }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { stroke: none; opacity: .14; }
.chart .s1 { stroke: var(--series-1); fill: var(--series-1); } .chart .s2 { stroke: var(--series-2); fill: var(--series-2); }
.chart .line.s1, .chart .line.s2 { fill: none; }
.chart .cross { stroke: var(--line-2); stroke-width: 1; }
.chart circle.dot { stroke: var(--panel); stroke-width: 2; }
.legend { display: flex; gap: 1rem; margin-bottom: .4rem; font-size: .84rem; color: var(--ink-2); }
.legend span, .tip .row { display: inline-flex; align-items: center; gap: .35rem; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.s1 { background: var(--series-1); } .sw.s2 { background: var(--series-2); }
.tiles { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.tile { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; }
.tile span { display: block; font-size: .8rem; color: var(--ink-2); } .tile b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.tile b, .kpi b { display: block; unicode-bidi: plaintext; text-align: right; }
.log { display: grid; max-height: 520px; overflow: auto; }
.log .e { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: .8rem; padding: .5rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.log .e:last-child { border: 0; } .log .e time { color: var(--ink-2); font-size: .82rem; }
.log .e code { color: var(--ink-2); font-size: .8rem; }

.loading { display: grid; place-items: center; min-height: 50vh; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--fill-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Activity feed */
.feed { display: grid; }
.feed .item { display: flex; gap: .8rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--line); min-width: 0; }
.feed .item:last-child { border: 0; }
.feed .item .ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.feed .item .ico svg.i { width: 17px; height: 17px; }
.feed .item .t { min-width: 0; flex: 1; }
.feed .item .t b { display: block; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .item .t small { color: var(--ink-2); }

/* Node capacity */
.node-row { display: grid; gap: .35rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.node-row:last-child { border: 0; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.login .card { width: min(400px, 100%); padding: 2rem; border-radius: 22px; box-shadow: var(--shadow-lg); }
.login .logo { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 1rem; }
.login .logo svg.i { width: 30px; height: 30px; }
.login h1 { text-align: center; font-size: 1.5rem; } .login .sub { text-align: center; color: var(--ink-2); margin-bottom: 1.4rem; }
.login .form { grid-template-columns: 1fr; } .login .form .btn.primary { width: 100%; min-height: 44px; }

/* Template preview */
.tree { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); }
.tree li { padding: .4rem .9rem; border-bottom: 1px solid var(--line); font-size: .92rem; }
.tree li:last-child { border: 0; } .tree li.sub { padding-inline-start: 2rem; color: var(--ink-2); }
.gallery { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.tpl { border: 1px solid var(--line); border-radius: 14px; padding: 1rem; display: grid; gap: .5rem; align-content: start; background: var(--panel-2); transition: border-color .15s, transform .15s; }
.tpl:hover { border-color: var(--line-2); transform: translateY(-1px); }
.tpl p { margin: 0; }

/* Customer panel */
.cust { max-width: 1480px; margin: auto; padding: 1.2rem clamp(1rem, 2.6vw, 2.6rem) 3rem; }
.pane { min-height: 62vh; }
.cust-top { display: flex; justify-content: space-between; align-items: center; padding: .3rem 0 1.2rem; gap: 1rem; }
.cust-top .brand { padding: 0; }
.hero { background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 2rem 1.5rem 1.5rem; display: grid; justify-items: center; text-align: center; gap: .4rem; box-shadow: var(--shadow); }
.power { --c: var(--ink-3); width: 150px; height: 150px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; color: #fff; background: var(--c); box-shadow: 0 0 0 10px color-mix(in srgb, var(--c) 14%, transparent), 0 0 0 22px color-mix(in srgb, var(--c) 6%, transparent), 0 18px 50px color-mix(in srgb, var(--c) 45%, transparent); transition: transform .15s, box-shadow .3s, background .3s; margin: .6rem 0 1.1rem; }
.power:hover { transform: scale(1.03); } .power:active { transform: scale(.97); } .power:disabled { cursor: progress; opacity: .8; }
.power svg.i { width: 56px; height: 56px; stroke-width: 2.4; }
.power.on { --c: var(--ok-solid); } .power.busy { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 16px color-mix(in srgb, var(--c) 18%, transparent), 0 0 0 30px color-mix(in srgb, var(--c) 6%, transparent); } }
.hero .state { font-size: 1.3rem; font-weight: 700; } .hero .state.on { color: var(--ok); }
.hero .addr { font-family: var(--mono); font-size: clamp(1.05rem, 4vw, 1.5rem); font-weight: 600; overflow-wrap: anywhere; direction: ltr; }
.hero .actions { margin-top: .8rem; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.info-grid > div { padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); border-inline-end: 1px solid var(--line); min-width: 0; }
.info-grid > div:nth-child(2n) { border-inline-end: 0; } .info-grid > div:nth-last-child(-n+2) { border-bottom: 0; }
.info-grid span { display: block; color: var(--ink-2); font-size: .8rem; }
.info-grid b { font-weight: 650; overflow-wrap: anywhere; }
.tabs { margin: 1.4rem 0 1rem; }
.feature { display: flex; align-items: center; gap: .9rem; padding: .85rem 1.1rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.feature .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--ok-solid); color: #fff; flex: none; }
.feature .ico.blue { background: var(--accent); } .feature .ico.orange { background: var(--warn-solid); } .feature .ico.purple { background: #af52de; }
.feature .ico svg.i { width: 19px; height: 19px; }

/* Tablets: the sidebar shrinks to icons */
@media (max-width: 1180px) and (min-width: 821px) {
  .app { grid-template-columns: 76px minmax(0, 1fr); }
  .side { padding: 1rem .6rem; align-items: center; overflow-x: hidden; }
  .brand { padding: .2rem 0 1rem; } .brand > :not(.logo) { display: none; }
  .nav-label { font-size: 0; padding: .5rem 0; } .nav-label::after { content: ""; display: block; width: 24px; height: 1px; background: var(--line-2); }
  .side a.nav { width: 48px; height: 44px; justify-content: center; padding: 0; position: relative; }
  .side a.nav > span:not(.count) { display: none; }
  .side a.nav .count { position: absolute; top: 3px; inset-inline-end: 3px; min-width: 16px; height: 16px; line-height: 16px; padding: 0 .2rem; font-size: .62rem; background: var(--accent); color: #fff; } .side a.nav.on .count { background: #fff; color: var(--accent); }
  .side .foot { align-items: center; } .status-card, .me-row .grow, .me-row .avatar { display: none; } .me-row { flex-direction: column; padding: 0; }
}

/* Phones */
@media (max-width: 820px) {
  .app { display: block; }
  .side { position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: .5rem; gap: .25rem; border-inline-end: 0; border-bottom: 1px solid var(--side-line); scrollbar-width: none; }
  .side .brand, .nav-label, .side .foot .status-card, .side .foot .me-row .grow, .side .foot .me-row .avatar { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; } .kpis > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi { padding: .85rem .9rem; } .kpi b { font-size: 1.35rem; } .kpi .ico { width: 30px; height: 30px; margin-bottom: .2rem; }
  .side a.nav { white-space: nowrap; padding: .45rem .7rem; }
  .side a.nav .count { display: none; }
  .side .foot { margin: 0; padding: 0; display: flex; }
  .main { padding: 1.2rem 1rem 3rem; }
  h1 { font-size: 1.45rem; }
  .power { width: 124px; height: 124px; } .power svg.i { width: 46px; height: 46px; }
  .tablewrap { margin: 0 -1rem; padding: 0 1rem; }
  .card { padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.price-cell { display: grid; gap: .3rem; min-width: 110px; } .price-cell input { min-height: 34px; padding: .35rem .6rem; }
.section-title { margin-top: .6rem; padding-top: .9rem; border-top: 1px solid var(--line); } .form > .section-title:first-child { border: 0; margin: 0; padding: 0; }
