/* H3LL Control: owner dashboard Mini App. Own stylesheet, H3LL design tokens (src/styles/main.css). */
@font-face { font-family: 'Cormorant Garamond'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/cormorant-medium.ttf') format('truetype'), url('../assets/fonts/cormorant-medium.ttf') format('truetype'); }
@font-face { font-family: 'Manrope'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/manrope-latin-400-normal.woff2') format('woff2'), url('../assets/fonts/manrope-latin-400-normal.woff2') format('woff2'); }
:root {
  color-scheme: dark;
  --h3ll-ink: #09090c; --h3ll-surface: #101015; --h3ll-raised: #16151c; --h3ll-line: #8e795c40; --h3ll-line-strong: #8e795c8c;
  --h3ll-paper: #d5c9bd; --h3ll-muted: #a99b95; --h3ll-bronze: #8e795c; --h3ll-accent: #a777c1; --h3ll-focus: #e2b7f4;
  --ok: #7fb38a; --warn: #d9a650; --critical: #d0534b;
  --h3ll-display: 'Cormorant Garamond', Georgia, serif; --h3ll-ui: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 14px; --touch: 44px; --gutter: 16px;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px));
}
* { box-sizing: border-box; }
html { background: var(--h3ll-ink); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100svh; background: radial-gradient(ellipse at 80% -10%, #3a1d4a33, transparent 55%), var(--h3ll-ink); color: var(--h3ll-paper); font: 400 15px/1.45 var(--h3ll-ui); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--h3ll-focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
abbr { text-decoration: none; }
code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .85em; color: var(--h3ll-paper); }

.control { width: min(100%, 760px); margin: 0 auto; padding: 0 var(--gutter); }
.control-header { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin: 0 calc(-1 * var(--gutter)); padding: calc(var(--safe-top) + 10px) var(--gutter) 10px; background: linear-gradient(#09090cf7, #09090ce6); backdrop-filter: blur(10px); border-bottom: 1px solid var(--h3ll-line); }
.ch-title { display: flex; align-items: center; gap: 10px; }
.ch-title h1 { margin: 0; font: 500 1.5rem/1 var(--h3ll-display); letter-spacing: .06em; }
.ch-title em { font-style: normal; color: var(--h3ll-accent); }
.ch-sigil, .refusal-sigil { width: 18px; height: 18px; border: 1px solid var(--h3ll-bronze); transform: rotate(45deg); box-shadow: inset 0 0 0 3px var(--h3ll-ink), inset 0 0 0 9px #a777c155; }
.ch-status { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--h3ll-muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.ch-mode { color: var(--h3ll-paper); }
.ch-updated::before { content: '·'; margin-right: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #6b6670; }
.dot--stream { background: var(--ok); box-shadow: 0 0 0 0 #7fb38a99; animation: pulse 2s infinite; }
.dot--poll { background: var(--warn); }
.dot--connecting, .dot--idle { background: var(--h3ll-accent); animation: pulse 1.4s infinite; }
.dot--offline, .dot--refused, .dot--stopped { background: var(--critical); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 #7fb38a80; } 70% { box-shadow: 0 0 0 7px #7fb38a00; } 100% { box-shadow: 0 0 0 0 #7fb38a00; } }

.control-main { padding: 14px 0 calc(var(--safe-bottom) + 92px); outline: none; }
.control-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr); max-width: 760px; margin: 0 auto; padding: 6px 6px calc(var(--safe-bottom) + 6px); background: linear-gradient(#0d0c11f0, #09090cfa); border-top: 1px solid var(--h3ll-line); backdrop-filter: blur(10px); }
.tab { position: relative; display: grid; justify-items: center; gap: 2px; min-height: 52px; padding: 6px 2px; border: 0; border-radius: 10px; background: transparent; color: var(--h3ll-muted); font-size: .72rem; letter-spacing: .02em; }
.tab[aria-current="page"] { color: var(--h3ll-paper); background: #a777c11f; }
.tab-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] .tab-icon { stroke: var(--h3ll-focus); }
.tab-badge { position: absolute; top: 3px; right: calc(50% - 22px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--critical); color: #fff; font-size: .68rem; line-height: 18px; text-align: center; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpis--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 560px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 479px) { .kpis--3 { grid-template-columns: 1fr; gap: 8px; } .kpis--3 .kpi { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; } .kpis--3 .kpi h3 { margin: 0; } }
.kpi { min-width: 0; padding: 12px; border: 1px solid var(--h3ll-line); border-radius: var(--radius); background: linear-gradient(160deg, #18161e, #0f0e13); }
.kpi h3 { margin: 0 0 6px; color: var(--h3ll-muted); font-size: .74rem; font-weight: 400; letter-spacing: .08em; text-transform: uppercase; }
/* Figures use the UI face: this Cormorant build has old-style figures only, which read badly in a dashboard. */
.kpi-value { margin: 0; font: 400 1.55rem/1.15 var(--h3ll-ui); letter-spacing: -.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-value-2 { display: block; margin-top: 2px; font-size: 1.05rem; color: var(--h3ll-muted); }
.kpi-sub { margin: 4px 0 0; color: var(--h3ll-muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.kpi .meter { margin-top: 8px; }
.kpi--ok { border-color: #7fb38a55; } .kpi--warn { border-color: #d9a65088; } .kpi--critical { border-color: #d0534b; background: linear-gradient(160deg, #2a1414, #120c0d); }
.kpi--na .kpi-value { color: var(--h3ll-muted); }

.panel { margin-top: 14px; padding: 14px; border: 1px solid var(--h3ll-line); border-radius: var(--radius); background: #0f0e13d9; }
.panel h2, .section-head h2 { margin: 0 0 10px; font: 500 1.2rem/1.2 var(--h3ll-display); letter-spacing: .05em; }
.panel h3 { margin: 0; font-size: .95rem; font-weight: 400; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-head h2 { margin: 0; }
.panel-note, .footnote { margin: 8px 0 0; color: var(--h3ll-muted); font-size: .78rem; }
.footnote { margin: 14px 2px 0; }
.na { margin: 6px 0 0; color: var(--h3ll-muted); font-size: .85rem; font-style: italic; }
.badge { display: inline-block; padding: 1px 7px; border: 1px solid var(--warn); border-radius: 999px; color: var(--warn); font: 400 .66rem/1.5 var(--h3ll-ui); letter-spacing: .08em; text-transform: uppercase; vertical-align: middle; }
.warning { margin: 0 0 10px; padding: 8px 10px; border-left: 3px solid var(--warn); background: #d9a65014; font-size: .85rem; }
.warn-text { color: var(--warn); }

.segmented { display: inline-flex; padding: 2px; border: 1px solid var(--h3ll-line); border-radius: 999px; }
.segmented button { min-height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--h3ll-muted); font-size: .78rem; }
.segmented button[aria-pressed="true"] { background: #a777c133; color: var(--h3ll-paper); }
.trends { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.trend { padding: 10px; border: 1px solid var(--h3ll-line); border-radius: 10px; }
.trend h3 { color: var(--h3ll-muted); font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; }
.trend-figures { display: flex; justify-content: space-between; gap: 6px; margin: 4px 0 6px; font-variant-numeric: tabular-nums; font-size: .9rem; }
.trend-figures span { display: grid; }
.trend-figures span:last-child { text-align: right; }
.trend-figures small { color: var(--h3ll-muted); font-size: .68rem; }
.spark { display: block; width: 100%; height: auto; overflow: visible; }
.spark-line { fill: none; stroke: var(--h3ll-accent); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: #a777c122; }
.spark-dot { fill: var(--h3ll-focus); }
.spark--empty line { stroke: var(--h3ll-line-strong); stroke-dasharray: 3 3; }
.meter { display: block; width: 100%; height: 8px; }
.meter-track { fill: #ffffff12; }
.meter-fill { fill: var(--h3ll-accent); }
.meter--ok .meter-fill { fill: var(--ok); } .meter--warn .meter-fill { fill: var(--warn); } .meter--critical .meter-fill { fill: var(--critical); }

.alerts { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.alert { padding: 8px 10px; border-left: 3px solid var(--warn); border-radius: 6px; background: #d9a65012; font-size: .88rem; }
.alert--critical { border-color: var(--critical); background: #d0534b1c; }
.bars { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.bars li { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; }
.bars .meter { grid-column: 1 / -1; }
.bar-label { text-transform: capitalize; } .bar-value { font-variant-numeric: tabular-nums; color: var(--h3ll-muted); }
.spend { margin-top: 10px; } .spend p { display: flex; justify-content: space-between; gap: 8px; margin: 0 0 6px; font-variant-numeric: tabular-nums; }
.pairs { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.pairs li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid #8e795c22; font-variant-numeric: tabular-nums; }
.pairs li:last-child { border-bottom: 0; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 7px 4px; border-bottom: 1px solid #8e795c22; text-align: right; white-space: nowrap; }
.table th:first-child, .table td:first-child { text-align: left; }
.table thead th { color: var(--h3ll-muted); font-weight: 400; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.table tbody th { font-weight: 400; }
.table .rail small { display: block; color: var(--h3ll-muted); font-size: .72rem; }
.table .na-cell { color: var(--h3ll-muted); font-style: italic; text-align: left; white-space: normal; }
.errors-trend { margin: 8px 0 4px; }
@media (max-width: 479px) { .table th, .table td { padding: 7px 3px; } .table thead th { letter-spacing: .02em; font-size: .66rem; } }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--touch); padding: 0 16px; border: 1px solid var(--h3ll-line-strong); border-radius: 999px; background: #16151c; color: var(--h3ll-paper); font-size: .88rem; }
.btn:hover:not(:disabled) { border-color: var(--h3ll-accent); }
.btn--small { min-height: 36px; padding: 0 12px; font-size: .8rem; }
.btn--primary { border-color: #a777c1aa; background: linear-gradient(#5b2f73, #3d1f4f); }
.btn--danger { border-color: #d0534b99; color: #f0b3ae; }
.btn--ghost { background: transparent; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; padding: 10px; border: 1px solid var(--warn); border-radius: 10px; background: #d9a65010; }
.confirm p { flex: 1 0 100%; margin: 0; font-size: .86rem; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .72rem; letter-spacing: .04em; border: 1px solid currentColor; }
.chip--active { color: var(--ok); } .chip--paused, .chip--full { color: var(--warn); } .chip--closed, .chip--expired { color: var(--h3ll-muted); }
.state-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }

.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; color: var(--h3ll-muted); font-size: .8rem; }
.form label small { font-size: .72rem; }
.form input { min-height: var(--touch); padding: 0 12px; border: 1px solid var(--h3ll-line-strong); border-radius: 10px; background: #0b0a0e; color: var(--h3ll-paper); font-size: 16px; }
.form input:focus { border-color: var(--h3ll-accent); }
.form--inline { grid-template-columns: 1fr auto auto; align-items: end; margin-top: 10px; }
.campaigns, .switches { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.campaign, .switch { padding: 12px; border: 1px solid var(--h3ll-line); border-radius: 12px; background: #131218; }
.campaign--closed, .campaign--expired { opacity: .7; }
.campaign-head, .switch-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.campaign-head h3 { overflow-wrap: anywhere; }
.campaign-figures { display: flex; justify-content: space-between; gap: 8px; margin: 8px 0 6px; font-variant-numeric: tabular-nums; font-size: .88rem; }
.campaign-joins { margin: 6px 0 0; color: var(--h3ll-muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.panel--once { border-color: var(--warn); }
.once-field { margin-top: 10px; }
.once-field label { display: block; margin-bottom: 4px; color: var(--h3ll-muted); font-size: .78rem; }
.once-row { display: flex; gap: 6px; }
.once-row input { flex: 1; min-width: 0; min-height: 36px; padding: 0 10px; border: 1px solid var(--h3ll-line-strong); border-radius: 8px; background: #0b0a0e; color: var(--h3ll-paper); font: .85rem ui-monospace, 'SF Mono', Menlo, monospace; }
.panel--once > .btn { margin-top: 12px; }

.notice { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; padding: 10px 40px 10px 12px; border: 1px solid var(--h3ll-line-strong); border-radius: 10px; background: #16151c; font-size: .88rem; }
.notice p { flex: 1 1 200px; margin: 0; }
.notice--ok { border-color: #7fb38a88; } .notice--error, .notice--refused { border-color: #d0534b99; }
.notice-close { position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border: 0; background: transparent; color: var(--h3ll-muted); font-size: 1.2rem; }

.connecting, .refusal { display: grid; justify-items: center; gap: 12px; padding: 18vh 12px 0; text-align: center; }
.refusal h2 { margin: 6px 0 0; font: 500 1.6rem/1.2 var(--h3ll-display); letter-spacing: .05em; }
.refusal p, .connecting p { margin: 0; max-width: 32ch; color: var(--h3ll-muted); }
.refusal-sigil { width: 26px; height: 26px; }
.spinner { width: 28px; height: 28px; border: 2px solid #a777c133; border-top-color: var(--h3ll-accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dot, .spinner { animation: none; } }
