:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-alt: #eef3f9;
  --text: #0f172a;
  --muted: #5b6473;
  --line: #d7dfeb;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --good: #0f9f6e;
  --warn: #d97706;
  --danger: #dc2626;
  --track: #e2e8f0;
  --shadow: 0 16px 34px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244, 247, 251, 0.96);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(215, 223, 235, 0.85);
}

.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 16px 12px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
}

.nav-menu {
  margin-top: 10px;
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 600;
}

.nav-item.active {
  background: #e8f0ff;
  color: var(--primary-strong);
}

.nav-user {
  padding: 8px 12px 4px;
  color: var(--muted);
  font-size: 0.84rem;
}

.page {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 16px 28px;
}

.hero {
  margin-bottom: 18px;
}

.hero-title {
  margin: 0;
  font-size: 1.38rem;
  font-weight: 700;
}

.hero-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.surface {
  background: var(--surface);
  border: 1px solid rgba(215, 223, 235, 0.95);
  box-shadow: var(--shadow);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 420px);
  padding: 24px;
  border-radius: 8px;
}

.login-title {
  margin: 0 0 6px;
  font-size: 1.35rem;
}

.login-subtitle {
  margin: 0 0 18px;
  color: var(--muted);
}

.field-stack {
  display: grid;
  gap: 12px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

.input,
.select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  color: var(--text);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn,
.step-btn {
  height: 44px;
  padding: 0 14px;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.primary-btn:active {
  background: var(--primary-strong);
}

.secondary-btn {
  background: #e8f0ff;
  color: var(--primary-strong);
  font-weight: 600;
}

.ghost-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.icon-btn {
  min-width: 44px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}

.list {
  display: grid;
  gap: 12px;
}

.dvb-list {
  display: grid;
  gap: 10px;
}

.dvb-card {
  border-radius: 8px;
  padding: 12px 14px;
}

.dvb-main {
  display: grid;
  grid-template-columns: 14px minmax(80px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.status-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.14);
}

.status-led.ok {
  background: var(--good);
}

.status-led.error {
  background: var(--danger);
}

.status-led.idle {
  background: #94a3b8;
}

.dvb-id {
  min-width: 0;
}

.dvb-id strong {
  display: block;
  font-size: 0.98rem;
}

.dvb-id span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dvb-type,
.dvb-frequency {
  font-weight: 700;
  white-space: nowrap;
}

.dvb-frequency {
  color: var(--primary-strong);
}

.dvb-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin: 10px 0 0 24px;
  color: var(--muted);
  font-size: 0.8rem;
}

.mod-card {
  border-radius: 8px;
  overflow: hidden;
}

.mod-row {
  display: grid;
  grid-template-columns: minmax(66px, 0.8fr) 0.7fr 0.9fr auto;
  gap: 8px;
  padding: 14px 14px 8px;
  align-items: center;
}

.mod-head {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 12px 14px 0;
}

.mod-value {
  min-width: 0;
  font-weight: 600;
}

.mod-value small {
  display: block;
  margin-top: 3px;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.77rem;
}

.detail-btn {
  justify-self: end;
  background: #eff6ff;
  color: var(--primary-strong);
  font-weight: 600;
  padding: 0 12px;
  border-radius: 8px;
  height: 38px;
}

.progress-wrap {
  padding: 0 14px 14px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb 0%, #0891b2 100%);
}

.progress-bar.warn {
  background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}

.progress-bar.danger {
  background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

.alert-chip,
.muted-chip,
.ok-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.alert-chip {
  background: #fee2e2;
  color: var(--danger);
}

.muted-chip {
  background: #edf2f7;
  color: var(--muted);
}

.ok-chip {
  background: #def7ec;
  color: var(--good);
}

.detail-layout {
  display: grid;
  gap: 16px;
}

.section {
  border-radius: 8px;
  padding: 16px;
}

.section-title {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 700;
}

.kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.kv:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.kv-label {
  color: var(--muted);
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.kv-value {
  text-align: right;
  font-weight: 600;
}

.channel-panel {
  display: grid;
  gap: 10px;
}

.power-panel {
  display: grid;
  gap: 14px;
}

.power-main {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}

.step-btn {
  width: 52px;
  border-radius: 8px;
  background: #e8f0ff;
  color: var(--primary-strong);
  font-size: 1.25rem;
  font-weight: 700;
}

.power-reading {
  text-align: center;
}

.power-reading strong {
  display: block;
  font-size: 1.45rem;
}

.power-reading span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.range-note {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.82rem;
}

.danger-text {
  color: var(--danger);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.empty-state,
.loading-state {
  padding: 26px 18px;
  text-align: center;
  color: var(--muted);
  border-radius: 8px;
}

.error-banner {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fee2e2;
  color: #991b1b;
}

.warning-banner {
  padding: 12px 14px;
  border-radius: 8px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.9rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.56);
  display: grid;
  place-items: end center;
  padding: 14px;
  z-index: 40;
}

.modal-panel {
  width: min(100%, 720px);
  max-height: calc(100vh - 28px);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  flex: 0 0 auto;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.modal-body {
  min-height: 0;
  padding: 12px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fff;
}

.raw-output {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.35;
  color: #0f172a;
}

@media (min-width: 700px) {
  .page,
  .topbar-inner {
    max-width: 860px;
  }

  .detail-layout {
    grid-template-columns: 1.15fr 0.85fr;
  }

  .dvb-meta {
    grid-template-columns: 1.1fr 1.2fr auto;
  }
}
