:root {
  --bg: #080809;
  --panel: #121214;
  --panel-2: #17171a;
  --line: #ff4e33;
  --text: #f6f6f7;
  --muted: #a6a6ad;
  --border: rgba(255,255,255,0.08);
  --green: #2cd67f;
  --orange: #ff9f43;
  --gray: #7b7b86;
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top right, rgba(114,12,12,0.35), transparent 28%), var(--bg);
  color: var(--text);
}

body.page-home,
body.page-networks,
body.page-report,
body.page-blocked,
body.page-wifi-detail {
  padding-bottom: 0;
}

a { color: inherit; }

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

.topbar {
  width: min(1120px, calc(100vw - 24px));
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 0;
}

.brand-link {
  text-decoration: none;
  font-size: 1.8rem;
  font-weight: 800;
}

.brand-accent { color: var(--line); }
.brand { color: white; }

.topnav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.topnav a {
  text-decoration: none;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.topnav a.active,
.topnav a:hover {
  color: white;
  background: rgba(255,255,255,0.06);
}

.page-shell {
  width: min(1120px, calc(100vw - 24px));
  margin: 0 auto 48px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 12px 0 18px;
}

.page-head h1,
.section-head h2,
.panel h2,
.panel h3 {
  margin: 0;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat-box,
.panel,
.simple-card,
.wifi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-box {
  padding: 16px;
}

.stat-box strong {
  display: block;
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.stat-box span,
.subtle-text,
.helper-text {
  color: var(--muted);
}

.chart-panel,
.panel {
  padding: 18px;
}

.section-block {
  margin-top: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.link-button {
  color: var(--muted);
  text-decoration: none;
}

.link-button:hover { color: white; }

.search-bar {
  background: #34343b;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.search-bar input,
select,
textarea,
input[type="text"],
input[type="number"] {
  width: 100%;
  border: 0;
  outline: 0;
  font: inherit;
}

.search-bar input {
  background: transparent;
  color: white;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.wifi-grid,
.simple-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

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

.wifi-card {
  display: block;
  padding: 16px;
  text-decoration: none;
}

.wifi-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.wifi-card-head h3 {
  font-size: 1.15rem;
}

.wifi-card-chart {
  min-height: 84px;
  margin-bottom: 10px;
}

.wifi-card-metrics {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.status-pill::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.status-down { background: rgba(255,78,51,0.14); color: #ff4e33; }
.status-unstable { background: rgba(255,159,67,0.18); color: var(--orange); }
.status-great { background: rgba(0,200,83,0.18); color: #00c853; }
.status-healthy { background: rgba(44,214,127,0.15); color: var(--green); }
.status-quiet { background: rgba(123,123,134,0.15); color: var(--gray); }

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

label span,
fieldset legend {
  display: block;
  margin-bottom: 8px;
  font-size: 0.92rem;
  color: var(--muted);
}

select,
textarea,
input[type="text"],
input[type="number"] {
  background: #f6f6f8;
  color: #151519;
  border-radius: 14px;
  padding: 14px;
}

.inline-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.radio-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border: 0;
  padding: 0;
  margin: 0;
}

.radio-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f6f6f8;
  color: #151519;
  border-radius: 14px;
  padding: 14px;
}

.radio-card input { accent-color: var(--line); }
.radio-card span { color: #151519; }

.primary-button {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--line);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.secondary-button {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.sort-toggle {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sort-button {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}

.sort-button.active {
  color: white;
  background: rgba(255,255,255,0.08);
}

.form-feedback { min-height: 1.3em; margin: 0; }
.form-feedback.success { color: var(--green); }
.form-feedback.error { color: #ff7a64; }

.hidden { display: none !important; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.metric-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
}

.quick-vote-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.quick-vote-button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 16px;
  padding: 14px 12px;
  font-weight: 700;
  cursor: pointer;
}

.quick-vote-button.active {
  color: white;
  box-shadow: inset 0 0 0 999px rgba(255,255,255,0.08);
}

.quick-vote-excellent { border-color: rgba(44,214,127,0.32); }
.quick-vote-usable { border-color: rgba(255,255,255,0.14); }
.quick-vote-slow { border-color: rgba(255,159,67,0.32); }
.quick-vote-down { border-color: rgba(255,78,51,0.32); }

.quick-vote-excellent.active { background: rgba(44,214,127,0.2); }
.quick-vote-usable.active { background: rgba(255,255,255,0.12); }
.quick-vote-slow.active { background: rgba(255,159,67,0.22); }
.quick-vote-down.active { background: rgba(255,78,51,0.22); }

.quick-vote-extra {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin: 0;
}

.quick-vote-panel {
  margin-top: 18px;
}

.quick-vote-notice {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 0 0 12px;
}

.quick-vote-notice.success {
  color: var(--green);
  border-color: rgba(44,214,127,0.28);
  background: rgba(44,214,127,0.08);
}

.quick-vote-notice.error {
  color: #ff7a64;
  border-color: rgba(255,122,100,0.26);
  background: rgba(255,122,100,0.08);
}

.metric-chip strong {
  display: block;
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.chart-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.chart-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
}

.chart-meta-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.icon-button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 12px;
  min-width: 42px;
  min-height: 42px;
  font-size: 1.1rem;
  cursor: pointer;
}

.chart-summary-popover {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  margin: 0 0 12px;
}

.chart-summary-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 10px;
}

.chart-summary-item strong {
  display: block;
  margin-top: 4px;
}

.chart-summary-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.chart-summary-box strong {
  display: block;
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.detail-chart-frame {
  min-height: 260px;
  position: relative;
}

.chart-ticks {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.detail-line-chart {
  position: relative;
  min-height: 260px;
}

.detail-line-chart svg {
  display: block;
  width: 100%;
  height: 100%;
}

.detail-chart-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.detail-chart-hit {
  cursor: crosshair;
}

.detail-chart-guide {
  pointer-events: none;
}

.detail-chart-tooltip {
  position: absolute;
  min-width: 132px;
  max-width: 180px;
  background: rgba(0,0,0,0.92);
  color: white;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 14px;
  padding: 10px 12px;
  pointer-events: none;
  z-index: 3;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
}

.detail-chart-tooltip-time {
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.detail-chart-tooltip-value {
  font-size: 1rem;
  font-weight: 800;
  color: #ffb020;
}


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

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}

.ranking-row {
  text-decoration: none;
}

.comment-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}

.comment-row,
.comment-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.comment-box p { margin: 8px 0 0; }

.comment-votes {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.vote-button {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  min-width: 42px;
  min-height: 42px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 800;
}

.vote-button.active-up {
  color: var(--green);
  border-color: rgba(44,214,127,0.4);
  background: rgba(44,214,127,0.12);
}

.vote-button.active-down {
  color: var(--orange);
  border-color: rgba(255,159,67,0.4);
  background: rgba(255,159,67,0.12);
}

.comment-score {
  font-size: 1.05rem;
  line-height: 1;
}

.empty-state {
  color: var(--muted);
  padding: 10px 0;
}

.comments-sentinel {
  width: 100%;
  height: 1px;
}

.compact-submit-panel {
  margin-bottom: 18px;
}

.compact-submit-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.blocked-list .simple-card {
  padding: 14px 16px;
}

.pagination-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.mobile-tabbar {
  display: none;
}

@media (max-width: 900px) {
  .grid-2,
  .grid-3,
  .inline-fields,
  .radio-grid {
    grid-template-columns: 1fr;
  }

  .stats-row,
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar,
  .page-head,
  .section-head,
  .wifi-card-head,
  .list-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .wifi-card-metrics {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 768px) {
  .topbar,
  .page-shell {
    width: calc(100vw - 16px);
  }

  .topbar {
    gap: 12px;
    padding: 14px 0;
  }

  .brand-link {
    font-size: 1.45rem;
  }

  .topnav {
    display: none;
  }

  .page-head {
    margin: 8px 0 14px;
    gap: 10px;
  }

  .page-head h1,
  .section-head h2,
  .panel h2,
  .panel h3 {
    font-size: 1.1rem;
  }

  .chart-panel,
  .panel,
  .stat-box,
  .wifi-card,
  .simple-card {
    padding: 14px;
  }

  .search-bar {
    padding: 10px 14px;
    margin-bottom: 12px;
  }

  select,
  textarea,
  input[type="text"],
  input[type="number"] {
    padding: 12px;
    font-size: 16px;
  }

  .compact-submit-form {
    grid-template-columns: 1fr;
  }

  .quick-vote-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-vote-button {
    min-height: 54px;
    font-size: 0.98rem;
    line-height: 1.2;
  }

  .sort-toggle {
    width: 100%;
  }

  .sort-button {
    flex: 1 1 0;
    text-align: center;
  }

  .comment-votes {
    width: 100%;
    justify-content: flex-start;
  }

  .pagination-row {
    flex-wrap: wrap;
  }

  .pagination-row .secondary-button {
    flex: 1 1 calc(50% - 6px);
  }

  .pagination-row .subtle-text {
    width: 100%;
    text-align: center;
    order: -1;
  }

  .mobile-tabbar {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
    background: rgba(18,18,20,0.92);
    border: 1px solid var(--border);
    border-radius: 18px;
    backdrop-filter: blur(16px);
    z-index: 50;
  }

  .mobile-tabbar a {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
    color: var(--muted);
    min-height: 56px;
    padding: 8px 6px;
    border-radius: 12px;
    font-size: 0.76rem;
    font-weight: 700;
  }

  .mobile-tabbar a.active {
    color: white;
    background: rgba(255,255,255,0.08);
  }

  .tab-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
  }

  .tab-icon svg {
    width: 100%;
    height: 100%;
  }

  body.page-home,
  body.page-networks,
  body.page-report,
  body.page-blocked,
  body.page-wifi-detail {
    padding-bottom: 92px;
  }

  .page-wifi-detail .page-head {
    align-items: stretch;
  }

  .page-wifi-detail .page-head .primary-button {
    width: 100%;
  }

  .page-wifi-detail .panel h2,
  .page-home .panel h2 {
    font-size: 1rem;
  }

  .page-home .page-shell,
  .page-wifi-detail .page-shell {
    display: flex;
    flex-direction: column;
  }

  .page-home .mobile-order-1 { order: 1; }
  .page-home .mobile-order-2 { order: 2; }
  .page-home .mobile-order-3 { order: 3; }
  .page-home .mobile-order-4 { order: 4; }
  .page-home .mobile-order-5 { order: 5; }

  .page-wifi-detail .mobile-detail-order-1 { order: 1; }
  .page-wifi-detail .mobile-detail-order-2 { order: 2; }
  .page-wifi-detail .mobile-detail-order-3 { order: 3; }
  .page-wifi-detail .mobile-detail-order-4 { order: 4; }
}

@media (max-width: 520px) {
  .topbar,
  .page-shell {
    width: calc(100vw - 12px);
  }

  .brand-link {
    font-size: 1.28rem;
  }

  .stats-row,
  .metric-grid,
  .quick-vote-row {
    grid-template-columns: 1fr;
  }

  .chart-summary-grid,
  .chart-summary-popover {
    grid-template-columns: 1fr;
  }

  .detail-chart-frame,
  .detail-line-chart {
    min-height: 340px;
  }

  .wifi-card-head {
    gap: 8px;
  }

  .status-pill {
    font-size: 0.76rem;
    padding: 7px 10px;
  }

  .wifi-card-chart {
    min-height: 70px;
  }

  .wifi-card-metrics {
    gap: 6px;
    font-size: 0.85rem;
  }

  .comment-row,
  .comment-votes,
  .list-row {
    gap: 8px;
  }

  .chart-meta-row,
  .chart-meta-main {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-home .section-block:first-of-type .wifi-card:nth-child(n+4) {
    display: none;
  }

  .page-home #unstable-ranking .ranking-row:nth-child(n+4),
  .page-home #pleasant-ranking .ranking-row:nth-child(n+3),
  .page-home #blocked-grid .simple-card:nth-child(n+4) {
    display: none;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
    justify-content: center;
  }

  .chart-ticks {
    font-size: 0.75rem;
    overflow-x: auto;
    white-space: nowrap;
  }
}
