/* ============================================
   SEABUG Dashboard — IoT Theme
   ============================================ */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2332;
  --bg-card-hover: #1f2b3d;
  --border-color: #2a3a4f;
  --text-primary: #e8edf5;
  --text-secondary: #8b9cb3;
  --text-muted: #5a6a7f;
  --accent: #00d4aa;
  --accent-dim: #00a88a;
  --accent-glow: rgba(0, 212, 170, 0.25);
  --accent-blue: #00b4d8;
  --danger: #ff4757;
  --warning: #ffa502;
  --success: #2ed573;
  --sidebar-width: 260px;
  --header-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: 0.25s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Login Page ---- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(0, 180, 216, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(0, 212, 170, 0.06) 0%, transparent 50%),
    var(--bg-primary);
  position: relative;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 212, 170, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 212, 170, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo .logo-icon {
  width: 72px;
  height: 72px;
  background: transparent;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  box-shadow: none;
}

.logo-icon__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.login-logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-primary);
}

.login-logo p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: var(--bg-primary);
  margin-top: 0.5rem;
}

.btn-primary:hover {
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.login-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---- Dashboard Layout ---- */

.dashboard {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-header .logo-icon {
  width: 40px;
  height: 40px;
  background: transparent;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-header .brand {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.sidebar-header .brand-sub {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 0.25rem;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(0, 212, 170, 0.12);
  color: var(--accent);
  border-left: 3px solid var(--accent);
  padding-left: calc(1rem - 3px);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active svg {
  opacity: 1;
}

.sidebar-partner {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sidebar-partner__img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
}

.user-details .user-name {
  font-size: 0.875rem;
  font-weight: 600;
}

.user-details .user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-logout {
  margin-top: 0.75rem;
  width: 100%;
  padding: 0.5rem;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}

.menu-toggle:hover {
  background: var(--bg-card);
}

.menu-toggle svg {
  width: 24px;
  height: 24px;
}

.page-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Language switcher */
.lang-switch {
  display: inline-flex;
  background: var(--bg-elevated, rgba(26, 35, 50, 0.9));
  border: 1px solid var(--border-color, #2a3a4f);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.lang-switch__btn {
  border: none;
  background: transparent;
  color: var(--text-secondary, #8b9cb3);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
  line-height: 1;
}

.lang-switch__btn:hover {
  color: var(--text-primary, #e8edf5);
}

.lang-switch__btn--active {
  background: var(--accent, #00d4aa);
  color: #0a1628;
}

.login-lang {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 2;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  background: rgba(46, 213, 115, 0.1);
  border: 1px solid rgba(46, 213, 115, 0.3);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--success);
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.status-dot--offline {
  background: var(--danger, #ff6b81);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.page-content {
  flex: 1;
  padding: 1.5rem;
}

/* Blank Page Placeholder */
.blank-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-height) - 3rem);
  text-align: center;
  padding: 2rem;
}

.blank-page .blank-icon {
  width: 80px;
  height: 80px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.blank-page .blank-icon svg {
  width: 36px;
  height: 36px;
  color: var(--text-muted);
}

.blank-page h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.blank-page p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  max-width: 360px;
}

/* ---- Home Page ---- */

.home-page {
  width: 100%;
}

.home-intro__title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 36%);
  gap: 1rem;
  align-items: start;
}

.home-layout__main {
  min-width: 0;
  display: flex;
}

/* Zone Grid */
.zone-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  width: 100%;
  align-items: stretch;
}

.zone-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition);
}

.zone-section--sea {
  border-top: 3px solid var(--accent-blue);
}

.zone-section--filter {
  border-top: 3px solid var(--accent);
}

.zone-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.zone-header__icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.zone-header__icon svg {
  width: 22px;
  height: 22px;
}

.zone-header__icon--sea {
  background: rgba(0, 180, 216, 0.15);
  color: var(--accent-blue);
}

.zone-header__icon--filter {
  background: rgba(0, 212, 170, 0.15);
  color: var(--accent);
}

.zone-header__title {
  font-size: 0.9375rem;
  font-weight: 600;
}

/* Sensor Cards */
.sensor-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  align-items: stretch;
}

.sensor-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color var(--transition), transform var(--transition);
}

.sensor-card:hover {
  border-color: rgba(0, 212, 170, 0.3);
  transform: translateY(-1px);
}

.sensor-card__top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.sensor-card__icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sensor-card__icon svg {
  width: 18px;
  height: 18px;
}

.sensor-card--do .sensor-card__icon {
  background: rgba(0, 180, 216, 0.15);
  color: var(--accent-blue);
}

.sensor-card--turbidity .sensor-card__icon {
  background: rgba(255, 165, 2, 0.15);
  color: var(--warning);
}

.sensor-card--temp .sensor-card__icon {
  background: rgba(255, 71, 87, 0.15);
  color: var(--danger);
}

.sensor-card--ph .sensor-card__icon {
  background: rgba(0, 212, 170, 0.15);
  color: var(--accent);
}

.sensor-card__label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.sensor-card__value {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.sensor-card__number {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.sensor-card__unit {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Charts */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
}

.chart-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
}

.chart-card__title {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 0.25rem;
  flex-shrink: 0;
}

.chart-card__canvas {
  position: relative;
  height: 100px;
  max-height: 100px;
  min-height: 100px;
  overflow: hidden;
}

.chart-card__canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-height: 100px;
}

/* CCTV Section */
.cctv-section {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
  border-top: 3px solid var(--accent-blue);
  width: 100%;
  min-width: 0;
  align-self: start;
  position: sticky;
  top: 1rem;
}

.section-header__title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.cctv-feed {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.cctv-feed__screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #060a10;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.cctv-feed__placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--text-muted);
  padding: 1rem;
}

.cctv-feed__placeholder svg {
  width: 36px;
  height: 36px;
  opacity: 0.5;
}

.cctv-feed__rec {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--danger);
  background: rgba(0, 0, 0, 0.6);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.rec-dot {
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

.cctv-feed__screen video,
.cctv-feed__screen iframe,
.cctv-feed__screen img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #060a10;
  z-index: 0;
}

.cctv-feed__video {
  display: none;
  background: #060a10;
}

.cctv-feed__screen--live .cctv-feed__video {
  display: block;
}

.cctv-feed__screen--live .cctv-feed__placeholder {
  display: none;
}

.cctv-feed__idle {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 14rem;
  line-height: 1.4;
}

.cctv-feed__status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 16, 0.85);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  z-index: 2;
  padding: 1rem;
  text-align: center;
}

.cctv-feed__status[hidden] {
  display: none !important;
}

.cctv-feed__status--error {
  color: var(--danger);
}

.cctv-feed__status--rebuffer {
  inset: auto 0.75rem 0.75rem auto;
  top: auto;
  left: auto;
  width: auto;
  height: auto;
  background: rgba(6, 10, 16, 0.75);
  border-radius: 4px;
  padding: 0.35rem 0.65rem;
  font-size: 0.6875rem;
  pointer-events: none;
}

.cctv-feed__rec[hidden] {
  display: none !important;
}

.cctv-feed__controls {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  width: 100%;
}

.cctv-feed__btn {
  flex: 1;
  padding: 0.625rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), opacity var(--transition);
}

.cctv-feed__btn:hover:not(:disabled) {
  border-color: rgba(0, 212, 170, 0.4);
}

.cctv-feed__btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cctv-feed__btn--play:not(:disabled) {
  background: rgba(0, 212, 170, 0.12);
  border-color: rgba(0, 212, 170, 0.35);
  color: var(--accent);
}

.cctv-feed__btn--stop:not(:disabled) {
  background: rgba(255, 71, 87, 0.1);
  border-color: rgba(255, 71, 87, 0.35);
  color: var(--danger);
}

/* Control Row */
.home-control-row {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 1rem;
  margin-top: 1rem;
  width: 100%;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
}

.panel-card--mode {
  border-top: 3px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel-card--mode #homeMqttBadge {
  display: inline-block;
  margin-top: -0.5rem;
}

.panel-card--status .control-grid--status {
  margin-top: 0.75rem;
}

.panel-card--status .ctrl-btn {
  min-height: 64px;
  padding: 0.75rem;
}

.panel-card--status .ctrl-btn__label {
  font-size: 0.75rem;
}

.panel-card--status {
  border-top: 3px solid var(--accent-blue);
}

.panel-card__title {
  font-size: 0.9375rem;
  font-weight: 600;
}

.mode-toggle {
  display: flex;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.mode-toggle__btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.mode-toggle__btn:hover:not(.mode-toggle__btn--active) {
  color: var(--text-primary);
}

.mode-toggle__btn--active {
  background: var(--accent);
  color: var(--bg-primary);
}

.mode-toggle__btn--active[data-mode="manual"] {
  background: var(--warning);
  color: var(--bg-primary);
}

.btn-run {
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: var(--bg-primary);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-run:hover:not(:disabled) {
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-run:disabled {
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.625rem;
  margin-top: 0.75rem;
}

.status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.status-item__label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.3;
}

.status-item__badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.status-item__badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-item__badge--on {
  background: rgba(46, 213, 115, 0.12);
  color: var(--success);
  border: 1px solid rgba(46, 213, 115, 0.3);
}

.status-item__badge--on::before {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.status-item__badge--off {
  background: rgba(90, 106, 127, 0.12);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.status-item__badge--off::before {
  background: var(--text-muted);
}

/* System Log */
.panel-card--log {
  margin-top: 1rem;
  border-top: 3px solid var(--text-muted);
}

.system-log {
  margin-top: 0.75rem;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.75rem;
  line-height: 1.5;
}

.system-log::-webkit-scrollbar {
  width: 6px;
}

.system-log::-webkit-scrollbar-track {
  background: transparent;
}

.system-log::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.log-entry {
  display: grid;
  grid-template-columns: 4.5rem 3.5rem minmax(0, 1fr);
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: 4px;
  align-items: start;
}

.log-entry:hover {
  background: rgba(255, 255, 255, 0.03);
}

.log-entry__time {
  color: var(--text-muted);
  flex-shrink: 0;
}

.log-entry__level {
  font-weight: 700;
  flex-shrink: 0;
}

.log-entry__msg {
  color: var(--text-secondary);
  word-break: break-word;
}

.log-entry--info .log-entry__level { color: var(--accent-blue); }
.log-entry--success .log-entry__level { color: var(--success); }
.log-entry--warning .log-entry__level { color: var(--warning); }
.log-entry--error .log-entry__level { color: var(--danger); }

/* ---- Sensor Page ---- */

.sensor-page {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.sensor-page__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.zone-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px;
  flex: 1;
  min-width: 0;
}

.zone-tabs__btn {
  padding: 0.5rem 0.875rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  min-height: 40px;
  -webkit-tap-highlight-color: transparent;
}

.zone-tabs__btn:hover:not(.zone-tabs__btn--active) {
  color: var(--text-primary);
}

.zone-tabs__btn--active {
  background: var(--accent);
  color: var(--bg-primary);
  font-weight: 600;
}

.sensor-page__updated {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.sensor-page__updated span {
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sensor-zones {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sensor-zone {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem 1rem 1.25rem;
}

.sensor-zone--sea {
  border-left: 4px solid var(--accent-blue);
}

.sensor-zone--filter {
  border-left: 4px solid var(--accent);
}

.sensor-zone--hidden {
  display: none;
}

.sensor-zone__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.sensor-zone__title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  min-width: 0;
}

.sensor-zone__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.sensor-zone__badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
  white-space: nowrap;
}

.sensor-zone__badge--online {
  color: var(--accent);
  background: rgba(0, 212, 170, 0.12);
}

.sensor-zone__badge--offline {
  color: var(--text-muted);
  background: var(--bg-secondary);
}

.sensor-zone__count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.sensor-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.detail-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  transition: border-color var(--transition);
}

.detail-card:hover {
  border-color: rgba(0, 212, 170, 0.35);
}

.detail-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.detail-card__code {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 0.125rem;
}

.detail-card__name {
  font-size: 0.9375rem;
  font-weight: 600;
}

.detail-card__status {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.detail-card__status--ok {
  background: rgba(46, 213, 115, 0.12);
  color: var(--success);
  border: 1px solid rgba(46, 213, 115, 0.3);
}

.detail-card__status--warn {
  background: rgba(255, 165, 2, 0.12);
  color: var(--warning);
  border: 1px solid rgba(255, 165, 2, 0.3);
}

.detail-card__status--offline {
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.detail-card__body {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
}

.detail-card__reading {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.detail-card__value {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.detail-card--do .detail-card__value { color: var(--accent-blue); }
.detail-card--turbidity .detail-card__value { color: var(--warning); }
.detail-card--temp .detail-card__value { color: #ff6b81; }
.detail-card--ph .detail-card__value { color: var(--accent); }

.detail-card__unit {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.detail-card__range {
  min-width: 0;
}

.detail-card__range-track {
  position: relative;
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: visible;
  margin-bottom: 0.375rem;
}

.detail-card__range-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  opacity: 0.7;
  transition: width var(--transition);
}

.detail-card--do .detail-card__range-fill {
  background: linear-gradient(90deg, #0088aa, var(--accent-blue));
}

.detail-card--turbidity .detail-card__range-fill {
  background: linear-gradient(90deg, #cc8400, var(--warning));
}

.detail-card--temp .detail-card__range-fill {
  background: linear-gradient(90deg, #cc5566, #ff6b81);
}

.detail-card--ph .detail-card__range-fill {
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
}

.detail-card__range-marker {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  background: var(--text-primary);
  border: 2px solid var(--bg-card);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
}

.detail-card__range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.625rem;
  color: var(--text-muted);
}

.detail-card__chart {
  height: 72px;
  position: relative;
}

.detail-card__footer {
  padding-top: 0.625rem;
  border-top: 1px solid var(--border-color);
}

.detail-card__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.detail-card__stats strong {
  color: var(--text-secondary);
  font-weight: 600;
  margin-left: 0.25rem;
}

/* Sensor page — tablet */
@media (max-width: 900px) {
  .sensor-detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-card__body {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

/* Sensor page — mobile */
@media (max-width: 768px) {
  .sensor-page__toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .zone-tabs {
    flex-direction: column;
    flex-wrap: nowrap;
    width: 100%;
    padding: 6px;
    gap: 4px;
  }

  .zone-tabs__btn {
    width: 100%;
    flex: none;
    text-align: left;
    white-space: normal;
    line-height: 1.35;
    padding: 0.625rem 0.875rem;
    min-height: 44px;
  }

  .sensor-page__updated {
    text-align: right;
    width: 100%;
  }

  .sensor-zones {
    gap: 1rem;
  }

  .sensor-zone {
    padding: 0.875rem;
    border-radius: var(--radius-sm);
  }

  .sensor-zone__title {
    font-size: 0.9375rem;
  }

  .detail-card {
    padding: 0.875rem;
    gap: 0.75rem;
  }

  .detail-card__header {
    gap: 0.5rem;
  }

  .detail-card__name {
    font-size: 0.875rem;
  }

  .detail-card__value {
    font-size: 1.875rem;
  }

  .detail-card__chart {
    height: 64px;
  }

  .detail-card__stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    text-align: center;
    font-size: 0.6875rem;
  }

  .detail-card__stats span {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
  }

  .detail-card__stats strong {
    margin-left: 0;
    font-size: 0.8125rem;
  }
}

@media (max-width: 480px) {
  .page-content.sensor-page {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .sensor-zone__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .detail-card__value {
    font-size: 1.625rem;
  }

  .detail-card__status {
    font-size: 0.625rem;
    padding: 0.2rem 0.4rem;
  }

  .detail-card__stats {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .detail-card__stats span {
    flex-direction: row;
    justify-content: space-between;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-color);
  }

  .detail-card__stats span:last-child {
    border-bottom: none;
  }
}

/* ---- Kontrol Page ---- */

.kontrol-page {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.kontrol-layout {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.kontrol-mode__card {
  position: sticky;
  top: calc(var(--header-height) + 1rem);
}

.kontrol-mode__card .panel-card__title {
  margin-bottom: 0.5rem;
}

.kontrol-mode__card #kontrolMqttBadge {
  display: inline-block;
  margin-bottom: 0.875rem;
}

.kontrol-mode__hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  padding: 0.625rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.kontrol-devices {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.control-group {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem 1rem 1.25rem;
}

.control-group__title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.875rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--border-color);
}

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

.control-grid--single {
  grid-template-columns: minmax(0, 1fr);
  max-width: 320px;
}

.ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 1rem;
  min-height: 72px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.ctrl-btn:hover:not(:disabled) {
  border-color: rgba(0, 212, 170, 0.4);
}

.ctrl-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ctrl-btn--on {
  border-color: var(--success);
  background: rgba(46, 213, 115, 0.08);
  box-shadow: 0 0 0 1px rgba(46, 213, 115, 0.2);
}

.ctrl-btn--on:not(:disabled):hover {
  border-color: var(--success);
  box-shadow: 0 0 16px rgba(46, 213, 115, 0.15);
}

.ctrl-btn--pending {
  opacity: 0.75;
  pointer-events: none;
}

.ctrl-btn__label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}

.ctrl-btn__state {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  background: rgba(90, 106, 127, 0.15);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.ctrl-btn__state::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

.ctrl-btn--on .ctrl-btn__state {
  background: rgba(46, 213, 115, 0.12);
  color: var(--success);
  border-color: rgba(46, 213, 115, 0.3);
}

.ctrl-btn--on .ctrl-btn__state::before {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

@media (max-width: 1024px) {
  .kontrol-layout {
    grid-template-columns: 1fr;
  }

  .kontrol-mode__card {
    position: static;
  }

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

  .control-grid--single {
    max-width: none;
  }
}

@media (max-width: 768px) {
  .control-grid {
    grid-template-columns: 1fr;
  }

  .ctrl-btn {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: 0.875rem 1rem;
  }

  .kontrol-mode__card .mode-toggle {
    flex-direction: row;
  }
}

@media (max-width: 480px) {
  .page-content.kontrol-page {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .control-group {
    padding: 0.875rem;
  }
}

/* ---- Laporan Page ---- */

.laporan-page {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.report-filter {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  border-top: 3px solid var(--accent-blue);
}

.report-filter__grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.875rem;
  margin-bottom: 1rem;
}

.report-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
}

.report-field--hidden {
  display: none;
}

.report-field label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.report-input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 40px;
}

.report-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.report-input option {
  background: var(--bg-secondary);
}

.report-filter__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
}

.report-notice {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.report-notice--warn {
  background: rgba(255, 165, 2, 0.1);
  border-color: rgba(255, 165, 2, 0.35);
  color: var(--warning);
}

.report-notice--error {
  background: rgba(255, 107, 129, 0.1);
  border-color: rgba(255, 107, 129, 0.35);
  color: #ff6b81;
}

.report-table-wrap--loading {
  opacity: 0.55;
  pointer-events: none;
}

.btn-report {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.125rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 40px;
}

.btn-report--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: var(--bg-primary);
}

.btn-report--primary:hover {
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-report--export {
  background: var(--bg-secondary);
  color: var(--success);
  border: 1px solid rgba(46, 213, 115, 0.4);
}

.btn-report--export:hover {
  background: rgba(46, 213, 115, 0.1);
  border-color: var(--success);
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.report-stat {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.report-stat__label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.report-stat__value {
  font-size: 1.375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.report-stat__value--sm {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.4;
}

.report-stat__value--ok { color: var(--success); }
.report-stat__value--warn { color: var(--warning); }

.report-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

.report-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.report-table-title {
  font-size: 0.9375rem;
  font-weight: 600;
}

.report-table-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.report-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  min-width: 640px;
}

.report-table thead {
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}

.report-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.report-table td {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.report-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.report-table tbody tr:last-child td {
  border-bottom: none;
}

.report-table__value {
  font-weight: 600;
  color: var(--text-primary) !important;
  font-variant-numeric: tabular-nums;
}

.report-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.report-badge--ok {
  background: rgba(46, 213, 115, 0.12);
  color: var(--success);
  border: 1px solid rgba(46, 213, 115, 0.3);
}

.report-badge--warn {
  background: rgba(255, 165, 2, 0.12);
  color: var(--warning);
  border: 1px solid rgba(255, 165, 2, 0.3);
}

.report-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

.report-empty svg {
  opacity: 0.4;
}

.report-empty p {
  font-size: 0.875rem;
}

.report-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.875rem 1rem;
  border-top: 1px solid var(--border-color);
}

.page-btn {
  padding: 0.5rem 0.875rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 36px;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-info {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1024px) {
  .report-filter__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .report-filter {
    padding: 1rem;
  }

  .report-filter__grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .report-summary {
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
  }

  .report-stat {
    padding: 0.75rem;
  }

  .report-stat__value {
    font-size: 1.125rem;
  }

  .report-stat__value--sm {
    font-size: 0.75rem;
  }

  .report-filter__actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn-report {
    width: 100%;
    justify-content: center;
    min-height: 44px;
    font-size: 0.9375rem;
  }

  .report-input {
    min-height: 44px;
    font-size: 1rem;
  }

  .report-table-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
  }

  .page-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem 1rem;
  }

  .report-pagination {
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }
}

@media (max-width: 640px) {
  .report-table-scroll {
    overflow-x: visible;
  }

  .report-table {
    min-width: 0;
  }

  .report-table thead {
    display: none;
  }

  .report-table tbody {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    padding: 0.75rem;
  }

  .report-table tr {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding: 0.875rem;
    padding-top: 2.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    position: relative;
  }

  .report-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.25rem 0;
    border: none;
    width: 100%;
    word-break: break-word;
  }

  .report-table__param {
    position: absolute;
    top: 0.875rem;
    left: 0.875rem;
    right: 5.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0;
    margin: 0;
    border: none;
    justify-content: flex-start;
  }

  .report-table__param::before {
    display: none;
  }

  .report-table td[data-label="Status"] {
    position: absolute;
    top: 0.75rem;
    right: 0.875rem;
    width: auto;
    padding: 0;
    margin: 0;
    border: none;
    justify-content: flex-end;
  }

  .report-table td[data-label="Status"]::before {
    display: none;
  }

  .report-table td:not(.report-table__param):not([data-label="Status"])::before {
    content: attr(data-label);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    min-width: 4.5rem;
    padding-top: 0.125rem;
  }

  .report-table__no {
    display: none;
  }

  .report-table__value {
    font-size: 1rem;
    text-align: right;
  }

  .report-table__zone {
    text-align: right;
    max-width: 60%;
  }

  .report-table__time {
    text-align: right;
    font-size: 0.8125rem;
  }
}

@media (max-width: 480px) {
  .page-content.laporan-page {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .report-filter {
    padding: 0.875rem;
    margin-bottom: 0.875rem;
  }

  .report-summary {
    grid-template-columns: 1fr;
    margin-bottom: 0.875rem;
  }

  .report-stat__value {
    font-size: 1.25rem;
  }

  .report-table-title {
    font-size: 0.875rem;
  }

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

  .page-info {
    width: 100%;
    text-align: center;
    order: -1;
    margin-bottom: 0.25rem;
  }
}

/* ---- Pengaturan Page ---- */

.settings-page {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 1.25rem;
  align-items: start;
}

.settings-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.settings-panel--threshold {
  border-top: 3px solid var(--accent-blue);
}

.settings-panel--password {
  border-top: 3px solid var(--accent);
  margin-bottom: 1rem;
}

.settings-panel--lamp {
  border-top: 3px solid var(--warning);
}

.settings-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.settings-panel__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.settings-panel__head .settings-panel__title {
  margin-bottom: 0;
}

.settings-panel__badge {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
  background: rgba(0, 180, 216, 0.12);
  color: var(--accent-blue);
  border: 1px solid rgba(0, 180, 216, 0.3);
}

.settings-panel__head-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.settings-panel__sync {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.settings-panel__badge--mqtt-ok {
  background: rgba(0, 212, 170, 0.12);
  color: var(--accent);
  border-color: rgba(0, 212, 170, 0.35);
}

.settings-panel__badge--mqtt-warn {
  background: rgba(255, 165, 2, 0.12);
  color: var(--warning);
  border-color: rgba(255, 165, 2, 0.35);
}

.settings-panel__badge--mqtt-off {
  background: var(--bg-secondary);
  color: var(--text-muted);
  border-color: var(--border-color);
}

.settings-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}

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

.btn-settings--ghost:hover {
  color: var(--text-primary);
  border-color: var(--accent-blue);
}

.threshold-zones {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.threshold-zone {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.threshold-zone--sea {
  border-left: 3px solid var(--accent-blue);
}

.threshold-zone--filter {
  border-left: 3px solid var(--accent);
}

.threshold-zone__title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.875rem;
}

.threshold-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.threshold-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  min-width: 320px;
}

.threshold-table th {
  text-align: left;
  padding: 0.5rem 0.625rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border-color);
}

.threshold-table th:nth-child(2),
.threshold-table th:nth-child(3) {
  width: 100px;
}

.threshold-table td {
  padding: 0.5rem 0.625rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.threshold-table tbody tr:last-child td {
  border-bottom: none;
}

.threshold-table__param {
  font-weight: 500;
  color: var(--text-primary);
}

.threshold-table__unit {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.settings-aside {
  display: flex;
  flex-direction: column;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.settings-panel--password .settings-panel__title,
.settings-panel--lamp .settings-panel__title {
  margin-bottom: 0.25rem;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.settings-field--disabled {
  opacity: 0.45;
  pointer-events: none;
}

.settings-field label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.settings-input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 40px;
}

.settings-input--sm {
  padding: 0.5rem 0.625rem;
  min-height: 36px;
  font-size: 0.8125rem;
  max-width: 100px;
}

.settings-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.settings-input:disabled {
  cursor: not-allowed;
}

.settings-switch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.25rem 0;
  margin-bottom: 0.25rem;
}

.settings-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.settings-switch__slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  flex-shrink: 0;
  transition: background var(--transition);
}

.settings-switch__slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}

.settings-switch input:checked + .settings-switch__slider {
  background: rgba(0, 212, 170, 0.2);
  border-color: var(--accent);
}

.settings-switch input:checked + .settings-switch__slider::after {
  transform: translateX(20px);
  background: var(--accent);
}

.settings-switch__label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.btn-settings {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.125rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 40px;
  width: 100%;
}

.btn-settings--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: var(--bg-primary);
}

.btn-settings--primary:hover {
  box-shadow: 0 4px 16px var(--accent-glow);
}

.settings-panel--threshold .btn-settings {
  max-width: 240px;
}

.settings-msg {
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
}

.settings-msg--ok {
  background: rgba(46, 213, 115, 0.1);
  color: var(--success);
  border: 1px solid rgba(46, 213, 115, 0.3);
}

.settings-msg--error {
  background: rgba(255, 71, 87, 0.1);
  color: var(--danger);
  border: 1px solid rgba(255, 71, 87, 0.3);
}

@media (max-width: 1024px) {
  .settings-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .settings-aside {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }

  .settings-panel--password {
    margin-bottom: 0;
  }

  .settings-panel--threshold .btn-settings {
    max-width: none;
  }
}

@media (max-width: 768px) {
  .settings-aside {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    padding: 1rem;
  }

  .settings-panel__head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .threshold-zone {
    padding: 0.875rem;
  }

  .threshold-zone__title {
    font-size: 0.8125rem;
    line-height: 1.35;
  }

  .settings-input,
  .btn-settings {
    min-height: 44px;
    font-size: 1rem;
  }

  .settings-input--sm {
    max-width: none;
    width: 100%;
    min-height: 44px;
  }

  .settings-switch {
    min-height: 44px;
  }

  .settings-switch__slider {
    width: 48px;
    height: 28px;
  }

  .settings-switch__slider::after {
    width: 22px;
    height: 22px;
  }

  .settings-switch input:checked + .settings-switch__slider::after {
    transform: translateX(20px);
  }
}

@media (max-width: 640px) {
  .threshold-table-wrap {
    overflow-x: visible;
  }

  .threshold-table {
    min-width: 0;
  }

  .threshold-table thead {
    display: none;
  }

  .threshold-table tbody {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
  }

  .threshold-table tr {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.875rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
  }

  .threshold-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0;
    border: none;
    width: 100%;
  }

  .threshold-table__param {
    font-size: 0.9375rem;
    font-weight: 600;
    padding-bottom: 0.5rem;
    margin-bottom: 0.125rem;
    border-bottom: 1px solid var(--border-color);
    justify-content: flex-start;
  }

  .threshold-table__param::before {
    display: none;
  }

  .threshold-table td:not(.threshold-table__param)::before {
    content: attr(data-label);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    min-width: 3.5rem;
  }

  .threshold-table td .settings-input {
    flex: 1;
    max-width: 9rem;
    text-align: right;
  }

  .threshold-table__unit {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
  }
}

@media (max-width: 480px) {
  .page-content.settings-page {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .settings-layout {
    gap: 0.875rem;
  }

  .threshold-zones {
    gap: 1rem;
    margin-bottom: 1rem;
  }

  .settings-panel__title {
    font-size: 0.9375rem;
  }

  .settings-form {
    gap: 0.75rem;
  }
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}

/* ---- Responsive ---- */

@media (max-width: 1024px) {
  .home-layout {
    grid-template-columns: 1fr;
  }

  .home-layout__main {
    display: block;
  }

  .home-control-row {
    grid-template-columns: 1fr;
  }

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

  .cctv-section {
    max-width: 100%;
    position: static;
  }

  .cctv-feed__screen {
    aspect-ratio: 16 / 9;
  }

  .zone-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .sensor-grid {
    grid-template-columns: 1fr;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .log-entry {
    grid-template-columns: 4rem 3rem minmax(0, 1fr);
    gap: 0.375rem;
    font-size: 0.6875rem;
  }

  .system-log {
    max-height: 180px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: flex;
  }

  .status-badge span:last-child {
    display: none;
  }

  .page-content {
    padding: 1rem;
  }

  .login-card {
    padding: 2rem 1.5rem;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: 0 1rem;
  }

  .page-title {
    font-size: 1rem;
  }
}
