/* QWebPLC Stylesheet - Style A (Bright) with Dark Theme Support */

:root {
  --bg: #F5F7FA;
  --card: #FFFFFF;
  --line: #E3E8EF;
  --ink: #1D2330;
  --mute: #667085;
  --primary: #0B6BCB;
  --primary-hover: #0958A6;
  --primary-light: #EBF3FB;

  --ok: #1A7F4B;
  --warn: #E08A00;
  --alarm: #C62828;
  --idle: #98A2B3;

  --ok-tint: rgba(26, 127, 75, 0.12);
  --warn-tint: rgba(224, 138, 0, 0.12);
  --alarm-tint: rgba(198, 40, 40, 0.12);
  --idle-tint: rgba(152, 162, 179, 0.14);

  --radius: 12px;
  --radius-sm: 6px;
  --radius-full: 9999px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);

  --nav-width: 64px;
  --topbar-height: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151B;
    --card: #1B2029;
    --line: #2C3340;
    --ink: #E6E9EF;
    --mute: #9AA4B5;
    --primary: #5AA8FF;
    --primary-hover: #79B8FF;
    --primary-light: rgba(90, 168, 255, 0.15);

    --ok: #2E9E66;
    --warn: #F5A623;
    --alarm: #E05252;
    --idle: #8A94A6;

    --ok-tint: rgba(46, 158, 102, 0.2);
    --warn-tint: rgba(245, 166, 35, 0.2);
    --alarm-tint: rgba(224, 82, 82, 0.2);
    --idle-tint: rgba(138, 148, 166, 0.18);

    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  }
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Fixed Left Nav Rail (Desktop) */
.nav-rail {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--nav-width);
  background-color: #0B6BCB;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  z-index: 100;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
}

.nav-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  margin-bottom: 24px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  align-items: center;
  flex: 1;
}

.nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 10px;
  gap: 2px;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
  background: transparent;
}

.nav-link svg {
  width: 22px;
  height: 22px;
}

.nav-link:hover:not(.disabled) {
  background: rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.28);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.nav-link.disabled {
  opacity: 0.42;
  cursor: not-allowed;
  pointer-events: none;
}

.nav-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.nav-user {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* App Layout Wrapper (Desktop) */
.app-layout {
  margin-left: var(--nav-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top Status Bar */
.topbar {
  height: var(--topbar-height);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.pill-online {
  background: var(--ok-tint);
  color: var(--ok);
}

.pill-offline {
  background: var(--alarm-tint);
  color: var(--alarm);
}

.pill-unknown {
  background: var(--idle-tint);
  color: var(--idle);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-online {
  background-color: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}

.dot-offline {
  background-color: var(--alarm);
  box-shadow: 0 0 6px var(--alarm);
}

.dot-unknown {
  background-color: var(--idle);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.comm-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.comm-pill.comm-warn {
  background: var(--warn-tint);
  border-color: var(--warn);
  color: var(--warn);
  font-weight: 600;
}

.topbar-clock {
  font-size: 13px;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
  padding-left: 6px;
  white-space: nowrap;
}

/* Top Status Bar User Area */
.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
  flex-shrink: 0;
}

.topbar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-logout-btn {
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--mute);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1.4;
}

.topbar-logout-btn:hover {
  background: var(--alarm-tint);
  border-color: var(--alarm);
  color: var(--alarm);
}

/* Error Banner */
.error-banner {
  display: none;
  margin: 16px 24px 0 24px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--alarm-tint);
  border: 1px solid var(--alarm);
  color: var(--alarm);
  font-weight: 600;
  font-size: 13px;
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Page Container */
.page-container {
  padding: 20px 24px;
  flex: 1;
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.section-subtitle {
  font-size: 12px;
  color: var(--mute);
}

/* Overview Layout */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

.rooms-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Room Cards Grid: 5 cols desktop, 2 tablet, 1 mobile */
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.room-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
  position: relative;
}

.room-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.room-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.room-status-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.indicator-ok { background-color: var(--ok); }
.indicator-warn { background-color: var(--warn); }
.indicator-alarm { background-color: var(--alarm); }
.indicator-idle { background-color: var(--idle); }

/* Big colored temperature block */
.temp-block {
  border-radius: 8px;
  padding: 12px 6px;
  text-align: center;
  color: #FFFFFF;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.temp-block.status-ok { background-color: var(--ok); }
.temp-block.status-warn { background-color: var(--warn); }
.temp-block.status-alarm { background-color: var(--alarm); }
.temp-block.status-idle { background-color: var(--idle); }

.room-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.room-limits {
  font-size: 12px;
  color: var(--mute);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.room-tags {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.tag-class-on {
  background: var(--ok-tint);
  color: var(--ok);
}

.tag-class-off {
  background: var(--idle-tint);
  color: var(--idle);
}

.tag-auto-on {
  background: var(--primary-light);
  color: var(--primary);
}

.tag-auto-off {
  background: var(--warn-tint);
  color: var(--warn);
}

/* AC Mini Rows */
.ac-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.ac-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  padding: 5px 6px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  gap: 4px;
}

.ac-info {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.ac-power-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.ac-power-on {
  color: var(--ok);
}

.ac-power-off {
  color: var(--mute);
  opacity: 0.5;
}

.ac-name {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.ac-badges {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-unload {
  background: var(--warn-tint);
  color: var(--warn);
  border: 1px solid var(--warn);
}

.badge-rotating {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary);
}

.badge-rotate-done {
  background: var(--ok-tint);
  color: var(--ok);
}

.ac-sec {
  font-size: 10px;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Overview Right Column */
.overview-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.alarm-count-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--alarm-tint);
  color: var(--alarm);
  font-weight: 700;
}

.alarm-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
}

.alarm-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--line);
}

.alarm-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.alarm-dot.level-critical { background: var(--alarm); box-shadow: 0 0 5px var(--alarm); }
.alarm-dot.level-warn { background: var(--warn); box-shadow: 0 0 5px var(--warn); }
.alarm-dot.level-info { background: var(--primary); }

.alarm-content {
  flex: 1;
  min-width: 0;
}

.alarm-item-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.alarm-item-time {
  font-size: 11px;
  color: var(--mute);
  margin-top: 2px;
}

.empty-state {
  text-align: center;
  color: var(--mute);
  padding: 24px 12px;
  font-size: 13px;
}

.sparkline-container {
  width: 100%;
  height: 120px;
}

.sparkline-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Floor Plan Page */
.floor-plan-wrapper {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.floor-plan-svg {
  min-width: 760px;
  width: 100%;
  height: auto;
  display: block;
}

.floor-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink);
  font-weight: 500;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}

.floor-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: var(--shadow-md);
  font-size: 12px;
  z-index: 200;
  display: none;
  min-width: 200px;
  line-height: 1.4;
}

/* Hottest Rooms Grid */
.hottest-section {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hottest-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.hottest-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.hottest-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.hottest-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hottest-room-name {
  font-size: 13px;
  font-weight: 700;
}

.hottest-room-temp {
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* History Page */
.history-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.select-room {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  min-width: 140px;
}

.select-room:focus {
  border-color: var(--primary);
}

.range-btn-group {
  display: inline-flex;
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 3px;
  border: 1px solid var(--line);
}

.range-btn {
  border: none;
  background: transparent;
  color: var(--mute);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.range-btn:hover {
  color: var(--ink);
}

.range-btn.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* History Stats Bar */
.history-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--mute);
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* History Main Chart Card */
.chart-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  position: relative;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.chart-unit {
  font-size: 12px;
  color: var(--mute);
}

.chart-svg-wrapper {
  position: relative;
  width: 100%;
  height: 380px;
}

.chart-svg {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  box-shadow: var(--shadow-md);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  display: none;
  z-index: 20;
  white-space: nowrap;
}

/* Login Page (Style A: Centered White Card on --bg) */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg);
  padding: 16px;
}

.login-container {
  width: 100%;
  max-width: 380px;
  margin: auto;
}

.login-card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 28px;
  box-shadow: var(--shadow-md);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 28px;
}

.login-brand-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 4px 12px rgba(11, 107, 203, 0.25);
}

.login-brand-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.login-brand-subtitle {
  font-size: 13px;
  color: var(--mute);
  margin-top: 4px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.login-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-form .form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.login-form .form-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-form .form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.login-submit-btn {
  width: 100%;
  height: 42px;
  margin-top: 6px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-submit-btn:hover:not(:disabled) {
  background: var(--primary-hover);
}

.login-submit-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.login-error {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--alarm-tint);
  border: 1px solid var(--alarm);
  color: var(--alarm);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  animation: fadeIn 0.2s ease-in-out;
}

/* Responsive Breakpoints */
@media (max-width: 1280px) {
  .rooms-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .overview-grid {
    grid-template-columns: 1fr;
  }
  .hottest-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .history-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Below 768px: Mobile & Tablet layout rules */
@media (max-width: 768px) {
  /* Item 2: Nav rail becomes fixed bottom tab bar */
  .nav-rail {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 56px;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.12);
    z-index: 100;
  }

  .nav-brand, .nav-footer {
    display: none;
  }

  .nav-menu {
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    height: 100%;
    gap: 0;
  }

  .nav-link {
    width: auto;
    flex: 1;
    height: 100%;
    border-radius: 0;
    font-size: 11px;
    gap: 2px;
    padding: 4px 0;
  }

  .nav-link svg {
    width: 20px;
    height: 20px;
  }

  .nav-link.active {
    box-shadow: none;
    background: rgba(255, 255, 255, 0.2);
  }

  /* Main content full width with bottom padding */
  .app-layout {
    margin-left: 0;
    width: 100%;
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0) + 16px);
  }

  /* Item 1: Top status bar wraps into two rows */
  .topbar {
    height: auto;
    min-height: 52px;
    flex-direction: column;
    align-items: stretch;
    padding: 8px 16px;
    gap: 6px;
  }

  .topbar-left {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
  }

  .topbar-right {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 8px;
    justify-content: flex-start;
    flex-wrap: nowrap;
  }

  .topbar-user {
    margin-left: auto;
  }

  /* Item 6: Section headers on narrow screens */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 8px;
  }

  .section-title {
    font-size: 15px;
    white-space: nowrap;
  }

  .section-subtitle {
    font-size: 11px;
    color: var(--mute);
    line-height: 1.3;
  }

  .rooms-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-container {
    padding: 14px 16px;
  }

  .error-banner {
    margin: 12px 16px 0 16px;
  }
}

/* Below 480px: Phone specific rules */
@media (max-width: 480px) {
  /* Item 1: Hide clock below 480px */
  .topbar-clock {
    display: none;
  }

  .rooms-grid {
    grid-template-columns: 1fr;
  }

  .hottest-grid {
    grid-template-columns: 1fr;
  }

  .history-stats-grid {
    grid-template-columns: 1fr;
  }

  .topbar-title {
    font-size: 14px;
  }

  .comm-pill {
    padding: 2px 8px;
    font-size: 11px;
  }

  .topbar-user {
    gap: 6px;
    margin-left: auto;
  }

  .topbar-user-name {
    max-width: 70px;
    font-size: 11px;
  }

  .topbar-logout-btn {
    padding: 2px 6px;
    font-size: 11px;
  }

  .login-card {
    padding: 28px 20px;
  }
}
