/* ---- UI tweaks for chips and green buttons ---- */

/* make chips subtler */
.chip { display:inline-block; padding:4px 10px; border-radius:14px; font-weight:700; font-size:12px; color:#fff; background:#3a3f46; }
.chip.active-chip { background: rgba(47,160,116,0.16); color:#cfe9db; font-weight:700; }
.chip.maps-chip { background: rgba(52,95,160,0.12); color:#cfe6ff; }
.chip.arm-chip { background: rgba(153,43,43,0.12); color:#ffcccc; }

/* device row */
.user-device-row { background: linear-gradient(180deg, rgba(255,255,255,0.01), rgba(0,0,0,0.04)); }
.user-device-row:hover { transform: translateY(-1px); transition: transform .12s; box-shadow: 0 6px 20px rgba(0,0,0,0.25); }

/* green button */
.btn-success { background:#26a65b; color:#fff; border: none; padding:8px 12px; border-radius:8px; cursor:pointer; font-weight:700; }
.btn-success:disabled { opacity:0.6; cursor:not-allowed; }

/* generic btn */
.btn { background:#2c3e50; color:#fff; border: none; padding:8px 12px; border-radius:8px; cursor:pointer; font-weight:700; }

/* subtle input styling */
#sp_body input[type="text"], #sp_body input[type="email"], #sp_body input[type="password"] { background: rgba(0,0,0,0.12); border: 1px solid rgba(255,255,255,0.02); padding:10px; border-radius:6px; color:#fff; }

/* reduce prominence of status chips across app */
.status-chip, .arm-chip, .active-chip, .maps-chip { font-size:12px; padding:6px 10px; border-radius:12px; }

/* Dark Theme (Default) */
:root,
html.dark {
  --bg: #0f1724;
  --panel: #0b1220;
  --muted: #94a3b8;
  --text: #e6eef8;
  --accent: #4f46e5;
  --border: rgba(255, 255, 255, 0.03);
  --input-bg: #071029;
  --input-border: #122033;
  --shadow: rgba(0, 0, 0, 0.6);
  --hover-bg: rgba(255, 255, 255, 0.05);
}

/* Light Theme */
html.light {
  --bg: #f8fafc;
  --panel: #ffffff;
  --muted: #64748b;
  --text: #1e293b;
  --accent: #6366f1;
  --border: rgba(0, 0, 0, 0.08);
  --input-bg: #ffffff;
  --input-border: #e2e8f0;
  --shadow: rgba(0, 0, 0, 0.1);
  --hover-bg: rgba(0, 0, 0, 0.03);
}

/* Smooth theme transitions */
html {
  transition: background-color 0.3s ease, color 0.3s ease;
}

* {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
html, body { 
  height:100%; 
  background:var(--bg); 
  color:var(--text); 
  margin:0; 
  font-family: Inter, system-ui, -apple-system;
  transition: background-color 0.3s ease, color 0.3s ease;
}
a{ color:var(--accent); }
button{ cursor:pointer; }
.bg-slate-800{ background:var(--panel); }
.bg-slate-900{ background:var(--bg); }
.text-slate-400{ color: #94a3b8; }
.text-slate-200{ color: #cbd5e1; }
.rounded{ border-radius:8px; }
.shadow{ box-shadow: 0 6px 18px var(--shadow); }
input, textarea { 
  background:var(--input-bg); 
  border:1px solid var(--input-border); 
  color:var(--text); 
  padding:8px;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
.table { width:100%; border-collapse:collapse; }
.table th, .table td { padding:8px; border-bottom:1px solid var(--border); }
.modal { 
  position: fixed; 
  inset:0; 
  display:flex; 
  align-items:center; 
  justify-content:center; 
  background: var(--shadow);
  backdrop-filter: blur(4px);
}
.modal .panel { background: var(--panel); padding:16px; border-radius:8px; width: 90%; max-width: 640px; }

/* Centered login wrapper and card */
.login-wrapper { display:flex; align-items:center; justify-content:center; min-height:calc(100vh - 40px); padding:20px; }
.login-card { width:420px; background:var(--panel); padding:24px; border-radius:12px; box-shadow:0 12px 30px var(--shadow); }
.input { 
  width:100%; 
  padding:12px; 
  margin-bottom:10px; 
  border-radius:8px; 
  border:1px solid var(--input-border); 
  background:var(--input-bg); 
  color:var(--text); 
  font-size:14px; 
  box-sizing:border-box;
  transition: all 0.3s ease;
}
.btn-primary { width:100%; padding:12px; background:var(--accent); color:white; border:none; border-radius:8px; font-weight:600; margin-top:8px; }
.link { color:var(--muted); font-size:13px; text-decoration:none; }
.link:hover { color:var(--accent); }

/* Page padding for all pages content */
.page-content { padding: 10px; background: transparent; }

/* Sidebar open/close */
#sidebar { transition: transform 220ms ease, opacity 220ms ease; }
#sidebar.closed { transform: translateX(-280px); opacity:0; }
.icon-btn { 
  background:transparent; 
  border:1px solid var(--border); 
  padding:8px; 
  border-radius:8px; 
  color:var(--text);
  transition: all 0.3s ease;
}
.icon-btn:hover {
  background: var(--hover-bg);
  border-color: var(--accent);
}
.icon-btn i { font-size:16px; }

/* Make sure images don't overflow */
img { max-width:100%; height:auto; }

/* Animations */
@keyframes loginPop { from { opacity:0; transform: translateY(6px) scale(.98);} to { opacity:1; transform: none; } }
.login-card { animation: loginPop .28s ease both; }
/* Sidebar transition already exists; add smoother */
#sidebar { transition: transform .28s ease, opacity .28s ease; }
#sidebar.closed { transform: translateX(-320px); opacity:0; }
/* Device panel (slide-in from right) */
.device-panel { position:fixed; right:0; top:0; bottom:0; width:420px; max-width:95%; transform: translateX(110%); transition: transform .28s ease; z-index:80; display:flex; }
.device-panel[aria-hidden="false"] { transform: translateX(0); }
.device-panel-inner { background: var(--panel); box-shadow: -12px 0 30px rgba(0,0,0,0.6); width:100%; padding:16px; display:flex; flex-direction:column; }
.device-panel-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.device-panel-body { overflow:auto; flex:1; }
/* chips */
.chips { display:flex; flex-wrap:wrap; gap:8px; margin-top:8px; }
.chip { padding:8px 12px; border-radius:999px; font-weight:600; font-size:13px; }
.chip-ok { background: rgba(34,197,94,0.12); color:#22c55e; border:1px solid rgba(34,197,94,0.12); }
.chip-warn { background: rgba(250,204,21,0.08); color:#f59e0b; border:1px solid rgba(245,158,11,0.08); }
.chip-off { background: rgba(239,68,68,0.08); color:#ef4444; border:1px solid rgba(239,68,68,0.08); }
.chip-neutral { background: rgba(148,163,184,0.06); color:#94a3b8; border:1px solid rgba(148,163,184,0.04); }

/* Header Bar */
.header-bar { 
  height:56px; 
  background:var(--panel); 
  display:flex; 
  align-items:center; 
  justify-content:space-between; 
  padding:0 12px; 
  border-bottom:1px solid var(--border);
  box-shadow: 0 1px 3px var(--shadow);
}
.header-left { display:flex; align-items:center; gap:12px; }
.header-logo { border-radius:8px; }
.header-title { font-weight:700; color:var(--text); }
.header-right { display:flex; align-items:center; gap:12px; }

/* small hamburger toggle inside header (hidden on wide layouts via media) */
.header-toggle {
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.header-toggle i { font-size: 18px; }

/* Sidebar styles */
.sidebar { width:220px; background:var(--panel); border-right:1px solid var(--border); display:flex; flex-direction:column; }
.sidebar.closed { transform: translateX(-260px); opacity:0; transition:transform .28s ease, opacity .28s ease; }
.sidebar-top { display:flex; align-items:center; gap:8px; border-bottom:1px solid rgba(255,255,255,0.02); }
.sidebar-logo { border-radius:6px; }
.sidebar-nav { display:flex; flex-direction:column; gap:4px; padding:8px; }
.nav-item { display:flex; align-items:center; gap:10px; padding:10px 12px; border:0; background:transparent; color:var(--text); text-align:left; border-radius:8px; cursor:pointer; }
.nav-item:hover { background: rgba(255,255,255,0.02); }

/* Account dropdown */
.account { position:relative; }
.account-btn { background:transparent; border:0; color:var(--text); cursor:pointer; }
.account-dropdown { position:absolute; right:0; top:46px; background:var(--panel); border:1px solid rgba(255,255,255,0.03); border-radius:8px; padding:8px; min-width:160px; box-shadow:0 10px 30px rgba(0,0,0,0.6); z-index:90; }
.account-dropdown.hidden { display:none; }
.dropdown-item { display:block; width:100%; padding:8px 10px; text-align:left; background:transparent; border:0; color:var(--text); cursor:pointer; }
.dropdown-item:hover { background: rgba(255,255,255,0.02); }

/* Layout tweaks */
.content-area { padding:10px; display:flex; align-items:stretch; width:100%; }
.app-content { padding:0; }

/* ensure login centered when visible */
.login-wrapper { display:flex; align-items:center; justify-content:center; flex:1; }
.hidden { display:none !important; }

/* small responsive */
@media(max-width:900px){
  .sidebar { position:fixed; z-index:80; left:0; top:56px; bottom:0; transform:translateX(-260px); }
  .sidebar.open { transform:translateX(0); }
  .header-title { font-size:16px; }
}

/* header above sidebar fix */
.header-bar { position: sticky; top: 0; z-index: 110; }
.sidebar { z-index: 100; position: relative; }
@media (max-width: 900px) {
  .sidebar { top: 56px; position: fixed; left: 0; }
  .header-bar { z-index: 120; position: fixed; width: 100%; }
  .content-area { margin-top: 56px; }
}

/* Fixed header + fixed left sidebar layout (desktop) */
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 220px; z-index: 100; }
.header-bar { position: fixed; top: 0; height: 56px; right: 0; z-index: 110; display:flex; align-items:center; padding:0 12px; }
/* when sidebar visible, header shifts right */
body.sidebar-visible .header-bar { left: 220px; }
/* when sidebar hidden, header spans full width */
body.sidebar-hidden .header-bar { left: 0; }

/* Content area should sit below header and to the right of sidebar on desktop */
.app-content { margin-top: 56px; padding: 10px; }
body.sidebar-visible .app-content { margin-left: 220px; }
body.sidebar-hidden .app-content { margin-left: 0; }

/* ensure device panel sits above header */
.device-panel { z-index: 200; }

@media (max-width:900px){
  /* mobile: sidebar is overlayed below header */
  .sidebar { position: fixed; top: 56px; left: 0; transform: translateX(-260px); }
  body.sidebar-visible .sidebar { transform: translateX(0); }
  .header-bar { left: 0; right: 0; }
  .app-content { margin-left: 0; margin-top: 56px; }
}

/* Layout overrides to ensure fixed header and left sidebar */
:root{ --header-height:56px; --sidebar-width:220px; }
.header-bar{position:fixed; top:0; left:0; right:0; height:var(--header-height); z-index:120}
.sidebar{position:fixed; top:var(--header-height); left:0; bottom:0; width:var(--sidebar-width); z-index:110}
.app-content{margin-top:var(--header-height); margin-left:var(--sidebar-width)}
.login-wrapper{z-index:200}

.detail-panel{position:fixed;right:0;top:0;bottom:0;width:480px;background:var(--panel);box-shadow:-12px 0 30px rgba(0,0,0,0.6);transform:translateX(110%);transition:transform .28s;z-index:220;padding:12px;}
.detail-panel[aria-hidden='false']{transform:translateX(0);} .detail-panel-body{overflow:auto;max-height:calc(100vh - 100px);} .detail-panel-header{display:flex;justify-content:space-between;align-items:center;padding-bottom:8px;border-bottom:1px solid rgba(255,255,255,0.03);} 

/* Side panel layout & memo expansion */
.side-panel .inner { display:flex; flex-direction:column; height:100%; box-sizing:border-box; }
.side-panel #sp_body { flex:1; min-height:0; overflow:auto; }

/* Prominent big chips */
.big-chip {
  display:inline-block;
  padding:10px 14px;
  border-radius:16px;
  font-weight:800;
  font-size:14px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.04);
}
.arm-chip { background: linear-gradient(180deg,#4a1212,#6e1a1a); color:#ffdede; border-color: rgba(200,40,40,0.25); }
.status-chip { background: linear-gradient(180deg,#09364d,#0d4a68); color:#e6fbff; border-color: rgba(30,120,200,0.25); }

/* Controls buttons */
.control-btn { padding:8px 14px; border-radius:999px; border:none; color:#fff; font-weight:700; cursor:pointer; box-shadow:0 6px 18px rgba(0,0,0,0.45); }
.control-btn.arm { background:#c83030; }
.control-btn.disarm { background:#2ea263; }
.control-btn.restart { background:#6f7378; }

/* Toggle switch (simple CSS-only) */
.toggle-switch { position: relative; display:inline-block; width:44px; height:24px; }
.toggle-switch input { opacity:0; width:0; height:0; }
.toggle-switch .slider {
  position:absolute; cursor:pointer; top:0; left:0; right:0; bottom:0; background:#2f3940; transition:.2s; border-radius:24px; box-shadow: inset 0 -2px 6px rgba(0,0,0,0.4);
}
.toggle-switch .slider:before {
  content:""; position:absolute; height:18px; width:18px; left:3px; top:3px; background:white; border-radius:50%; transition:.2s; box-shadow:0 2px 6px rgba(0,0,0,0.45);
}
.toggle-switch input:checked + .slider { background: linear-gradient(90deg,#2ea263,#28a16a); }
.toggle-switch input:checked + .slider:before { transform: translateX(20px); }

/* Zone / Relay chip defaults for list items (if you use rows) */
.zone-row, .relay-row { overflow:visible; }

/* Make memo fill bottom (already ensured by panel layout); improve memo box visuals */
#sp_memo { background: linear-gradient(180deg, rgba(0,0,0,0.03), rgba(255,255,255,0.01)); border: 1px solid rgba(255,255,255,0.02); box-shadow: inset 0 6px 12px rgba(0,0,0,0.45); border-radius:8px; padding:12px; white-space:pre-wrap; }

/* Slight improvements for rows */
.zone-row, .relay-row { transition: background .12s ease; }
.zone-row:hover, .relay-row:hover { background: rgba(255,255,255,0.02); }
/* SIDE PANEL SIZE: significantly wider (uses viewport width) */
.side-panel {
  width: 68vw;                 /* ~70% of viewport width */
  max-width: 1100px;          /* safety cap so it doesn't get massive on huge monitors */
  min-width: 620px;           /* ensures usability on smaller screens */
  right: 0;
  top: 0;
  bottom: 0;
  position: fixed;
  z-index: 1200;
  box-shadow: -40px 0 80px rgba(0,0,0,0.6);
  transform: translateX(110%);
  transition: transform .32s cubic-bezier(.2,.9,.2,1);
  background: linear-gradient(180deg, #07121a, #071E2B);
}

/* open state */
.side-panel.open { transform: translateX(0); }

/* ensure panel content is flex-col so memo can flex:1 */
.side-panel .inner { display:flex; flex-direction:column; height:100vh; box-sizing:border-box; padding:20px; min-height:0; }
.side-panel .header { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; gap:12px; }
.side-panel #sp_body { overflow:auto; flex:1; min-height:0; }

/* Prominent chips (unchanged styling plus larger sizes) */
.big-chip { padding:10px 14px; border-radius:18px; font-weight:800; font-size:14px; display:inline-block; margin-right:8px; }
.arm-chip { background: linear-gradient(180deg,#6f1b1b,#8a2222); color:#ffdede; border: 1px solid rgba(200,40,40,0.18); }
.status-chip { background: linear-gradient(180deg,#0a4153,#0f556e); color:#e6fbff; border: 1px solid rgba(30,120,200,0.18); }

/* GRID LAYOUTS */
#sp_zones_grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* 3 columns */
  gap: 10px;
  margin-top: 8px;
  align-items: start;
}
#sp_relays_grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 2 columns */
  gap: 10px;
  margin-top: 8px;
}

/* item cards inside grids */
.zone-card, .relay-card {
  background: rgba(255,255,255,0.02);
  border-radius: 10px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 56px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.02);
}

/* header row within card (title + small status) */
.card-top { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; }
.card-title { font-weight:700; font-size:14px; color:#e6f6ff; }
.card-sub { font-size:12px; color:#9fb2c8; }

/* toggle alignment */
.card-tog { display:flex; align-items:center; justify-content:flex-end; }

/* control buttons */
.control-btn { padding:8px 14px; border-radius:999px; border:none; color:#fff; font-weight:700; cursor:pointer; box-shadow:0 6px 18px rgba(0,0,0,0.45); }
.control-btn.arm { background:#c83030; }
.control-btn.disarm { background:#2ea263; }
.control-btn.restart { background:#6f7378; }

/* toggle switch style (kept, but removed the duplicate pseudo thumb to avoid double-dot) */
.toggle-switch { position: relative; display:inline-block; width:44px; height:26px; }
.toggle-switch input { position:absolute; inset:0; margin:0; width:100%; height:100%; opacity:0; cursor:pointer; z-index:2; }
.visual-slider { position:relative; display:inline-block; width:44px; height:26px; background:rgba(255,255,255,0.04); border-radius:16px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.4); }
/* NOTE: removed `.visual-slider::after { ... }` and corresponding checked pseudo-element to avoid the second dot */
/* the remaining JS inserts a single .visual-slider > span element (thumb) and moves it via script */

/* checked visual hint retained (background only) */
.toggle-switch input:checked + .visual-slider { background: rgba(0,128,0,0.14); }

/* memo box stretch to bottom */
#sp_memo { flex:1; min-height:0; overflow:auto; background: linear-gradient(180deg, rgba(0,0,0,0.03), rgba(255,255,255,0.01)); border-radius:8px; padding:12px; border:1px solid rgba(255,255,255,0.02); color:#cfe6ff; white-space:pre-wrap; }

/* visual slider appearance (simple) */
.toggle-switch { position: relative; display:inline-block; width:44px; height:26px; }
.toggle-switch input { position:absolute; inset:0; margin:0; width:100%; height:100%; opacity:0; cursor:pointer; z-index:2; }
.visual-slider { position:relative; display:inline-block; width:44px; height:26px; background:rgba(255,255,255,0.04); border-radius:16px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.4); }
.toggle-switch input:checked + .visual-slider { background: rgba(0,128,0,0.14); }
/* after pseudo-element removed (JS-controlled thumb remains) */

/* memo box stretch to bottom */
#sp_memo { flex:1; min-height:0; overflow:auto; background: linear-gradient(180deg, rgba(0,0,0,0.03), rgba(255,255,255,0.01)); border-radius:8px; padding:12px; border:1px solid rgba(255,255,255,0.02); color:#cfe6ff; white-space:pre-wrap; }

/* Zone/Relay card tweaks repeated at end to ensure consistent visuals */
.zone-card, .relay-card { min-height:56px; }

/* ---------- Devices page layout & table alignment ---------- */
/* scope to .devices-page so other pages are unaffected */
.devices-page { width:100%; box-sizing:border-box; padding:0; }

/* center and limit the devices table area */
.devices-container {
  max-width: 1100px;
  margin: 0 auto;             /* center on page */
  padding: 6px 12px 32px;     /* breathing room below */
  box-sizing: border-box;
}

/* use fixed table layout for consistent column widths */
.devices-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: rgba(255,255,255,0.01);
}

/* column width suggestions — tweak percentages if you want more/less space */
.devices-table th:nth-child(1), .devices-table td:nth-child(1) { width: 6%; text-align: left; white-space:nowrap; }
.devices-table th:nth-child(2), .devices-table td:nth-child(2) { width: 44%; text-align: left; overflow:hidden; text-overflow:ellipsis; }
.devices-table th:nth-child(3), .devices-table td:nth-child(3) { width: 26%; text-align: center; white-space:nowrap; }
.devices-table th:nth-child(4), .devices-table td:nth-child(4) { width: 10%; text-align: center; white-space:nowrap; }
.devices-table th:nth-child(5), .devices-table td:nth-child(5) { width: 14%; text-align: right; white-space:nowrap; }

/* nicer padding and vertical spacing */
.devices-table th, .devices-table td {
  padding: 14px 12px;
  vertical-align: middle;
  color: var(--text);
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

/* header style */
.devices-table thead th {
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  text-transform: none;
}

/* Actions column: put buttons flush-right for tidy alignment */
.devices-table .actions-cell {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ensure chips don't collapse */
.devices-table .chip { display:inline-block; min-width:64px; text-align:center; padding:6px 10px; font-size:13px; }

/* responsive: allow horizontal scroll on small screens */
@media (max-width: 900px) {
  .devices-container { padding-left: 8px; padding-right: 8px; }
  .devices-table { display:block; width:100%; overflow-x:auto; white-space:nowrap; }
  .devices-table thead, .devices-table tbody, .devices-table tr { display:table; width:100%; table-layout:fixed; }
  .devices-table th, .devices-table td { padding: 12px 10px; }
}

/* devices page left-alignment helpers */
.devices-wrap {
  max-width: 1100px;    /* keep content reasonably wide but not full-bleed */
  margin: 0;            /* left align inside the app-content area */
  padding-right: 10px;
}

/* left-align table cells and ensure headers align left */
.bg-panel .table th,
.bg-panel .table td,
.bg-panel thead th {
  text-align: left;
  vertical-align: middle;
}

/* tighten the table layout a bit for neatness */
.bg-panel .table { border-collapse: separate; border-spacing: 0 6px; width: 100%; }
.bg-panel thead th { padding: 14px 16px; font-weight: 700; }
.bg-panel tbody td { padding: 14px 16px; background: transparent; }

/* ensure the table stays flush to the left inside .devices-wrap */
.bg-panel { padding: 8px 8px 10px 8px; }

/* keep the action column buttons aligned left-ish */
.btn.small { padding: 6px 10px; }

/* responsive fallback */
@media (max-width: 900px) {
  .devices-wrap { max-width: calc(100vw - 32px); padding-right: 0; }
  .bg-panel .table th, .bg-panel .table td { padding: 10px 12px; }
}

/* ---------- Devices page fixes (add at end of styles.css) ---------- */

/* Ensure devices area uses full available content width and aligns left */
.devices-wrap {
  width: 100%;
  max-width: none;
  margin: 0;                 /* left-aligned to the page content area */
  box-sizing: border-box;
}

/* Panel should fill the wrapper, and inner padding provides spacing */
.bg-panel {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border-radius: 10px;
}

/* Table layout & left alignment */
.table {
  width: 100%;
  table-layout: auto;       /* let columns size naturally */
  border-collapse: collapse;
}

/* Default left alignment for all table cells */
.table th, .table td {
  text-align: left;
  padding: 12px 16px;
  vertical-align: middle;
}

/* Keep ID column compact, Actions column narrow and centered */
.table th:nth-child(1), .table td:nth-child(1) { width: 80px; min-width: 60px; }
.table th:nth-child(4), .table td:nth-child(4) { width: 90px; text-align: left; }
.table th:nth-child(5), .table td:nth-child(5) { width: 110px; white-space: nowrap; text-align: right; }

/* Make rows clickable but keep button clicks separate */
.table tbody tr { cursor: pointer; transition: background .12s ease; }
.table tbody tr:hover { background: rgba(255,255,255,0.02); }

/* CHIP: small inline badge look (restores earlier visual) */
.chip {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  vertical-align: middle;
  border: 1px solid rgba(255,255,255,0.04);
  background: rgba(255,255,255,0.02);
  color: var(--text);
}

/* Chip variants */
.chip.arm { background: rgba(200,40,40,0.08); color: #ffdede; border-color: rgba(200,40,40,0.12); }
.chip.disarm { background: rgba(34,197,94,0.06); color: #e8fff1; border-color: rgba(34,197,94,0.10); }

/* Buttons: compact, consistent, and muted for the "View" button */
.btn {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.04);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

/* small modifier */
.btn.small { padding: 4px 8px; font-size: 13px; }

/* Ghost style (used for Export) */
.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.06);
}

/* Table-embedded buttons (keep them compact and vertically centered) */
.table td .btn {
  vertical-align: middle;
  box-shadow: none;
}

/* Ensure export button sits left of the heading (no weird centering) */
.devices-header { display:flex; align-items:center; gap:12px; justify-content:flex-start; margin-bottom:18px; }

/* Small responsive tweak so small screens still show table properly */
@media (max-width: 900px) {
  .table { font-size: 13px; }
  .table th:nth-child(5), .table td:nth-child(5) { text-align: left; }
}

/* add to styles.css */

/* Make the content column nicely left-aligned and not full width */
.page-content { max-width: 1200px; margin: 0 auto; padding-left: 18px; }

/* Ensure table doesn't expand awkwardly and the panel inside has correct width */
.bg-panel { width: 100%; box-sizing: border-box; }

/* Buttons appearance (consistent small white buttons like older look) */
.btn { background: #0f1724; border: 1px solid rgba(255,255,255,0.06); color: #e6eef8; padding:6px 10px; border-radius:6px; }
.btn-ghost { background: transparent; border: 1px solid rgba(255,255,255,0.06); color: #e6eef8; }

/* small control buttons */
.control-btn { padding:8px 12px; border-radius:8px; border:none; color:#fff; font-weight:700; cursor:pointer; }
.control-btn[style] { box-shadow: 0 8px 20px rgba(0,0,0,0.45); }

/* Chips */
.chip { padding:6px 10px; border-radius:999px; font-weight:700; display:inline-block; }

/* Keep table cells left-aligned unless specified */
.table td, .table th { text-align: left; vertical-align: middle; }
.table td:last-child, .table th:last-child { text-align: right; }

/* zones / relays — slightly slimmer */
.zone-card, .relay-card {
  padding: 8px !important;      /* was 10px */
  min-height: 44px;
}
.zone-card .card-top, .relay-card .card-top {
  padding: 6px 0 !important;
}
.visual-slider { height: 22px !important; width: 40px !important; }
.visual-slider > span { top: 3px !important; width: 16px !important; height: 16px !important; left: 4px; }
.side-panel .inner { padding: 14px !important; } /* more room for memo */
#sp_memo { max-height: calc(40vh); } /* keep memo visible */

/* slightly slimmer zone & relay cards so memo has room */
.zone-card, .relay-card {
  padding: 8px;              /* was 10px */
  min-height: 44px;          /* slightly smaller */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  font-size: 13px;
}

/* smaller slider/thumb to match thinner card */
.visual-slider { width: 40px; height: 22px; }
.visual-slider > span { width: 16px; height: 16px; top: 3px; transition: left .12s; }

/* dash settings small additions */
#dash-slide-panel input[disabled] { opacity:0.7; }
#dash-create-modal input, #dash-slide-panel input { background: rgba(255,255,255,0.01); color: #eaf6ff; }
#dash-create-modal .btn, #dash-slide-panel .btn { border: none; padding:6px 10px; border-radius:6px; cursor:pointer; }

/* Dash Settings modal + slide-panel styles (append to styles.css) */

/* modal */
.modal { position:fixed; left:0; top:0; right:0; bottom:0; display:flex; align-items:center; justify-content:center; z-index:2147483000; background:rgba(0,0,0,0.45); }
.modal.hidden { display:none; }
.modal-content { width:540px; max-width:94%; background:var(--panel-bg,#071021); border-radius:10px; padding:18px; color:var(--text,#e6f4ff); box-shadow:0 12px 32px rgba(0,0,0,0.6); }

/* slide panel */
.slide-panel { position:fixed; right:0; top:0; height:100%; width:420px; max-width:94%; background:var(--panel-bg,#071021); transform:translateX(110%); transition:transform .22s ease; box-shadow:-8px 0 24px rgba(0,0,0,0.6); z-index:2147483001; padding:18px; color:var(--text,#e6f4ff); }
.slide-panel.open { transform:translateX(0); }
.slide-panel .slide-panel-inner { height:100%; display:flex; flex-direction:column; }

/* inputs and buttons (match app style) */
.input { width:100%; padding:10px 12px; border-radius:8px; border:1px solid rgba(255,255,255,0.04); background:rgba(255,255,255,0.01); color:var(--text,#fff); margin:6px 0; }
.btn-primary { background:#6c5ce7; color:#fff; padding:8px 12px; border-radius:8px; border:0; cursor:pointer; }
.btn-secondary { background:transparent; color:#cfe6ff; padding:8px 12px; border-radius:8px; border:1px solid rgba(255,255,255,0.04); cursor:pointer; }
.btn { background:#333; color:#fff; padding:6px 10px; border-radius:6px; border:0; cursor:pointer; }
.btn.danger { background:#b03030; color:#fff; }

/* green Save/Update visual (make Save/Update clearly green) */
.btn-primary.save-green { background:#1f9a6d !important; }

/* messages */
#addDashUserMsg, #slideMsg { font-size:13px; }

/* small responsive */
@media (max-width:640px){
  .slide-panel { width:100%; }
  .modal-content { width:92%; }
}

/* ---------- FINAL RESPONSIVE LAYOUT RULES (shell, sidebar, panels, home) ---------- */

/* Ensure header spans full width; body classes control sidebar margin on desktop. */
body.sidebar-visible .header-bar,
body.sidebar-hidden .header-bar {
  left: 0;
}

/* Desktop / large tablet: persistent left sidebar */
@media (min-width: 900px) {
  .header-toggle {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 110;
    transform: translateX(0);
  }

  body.sidebar-visible .app-content {
    margin-top: var(--header-height);
    margin-left: var(--sidebar-width);
  }

  body.sidebar-hidden .sidebar {
    transform: translateX(-260px);
  }
}

/* Mobile / small tablet: sidebar becomes off-canvas overlay and layout stacks */
@media (max-width: 899px) {
  .header-bar {
    left: 0;
    right: 0;
  }

  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: 260px;
    max-width: 80vw;
    z-index: 110;
    transform: translateX(-260px);
  }

  .sidebar.closed {
    transform: translateX(-260px);
  }

  body.sidebar-visible .sidebar {
    transform: translateX(0);
  }

  .app-content {
    margin-top: var(--header-height);
    margin-left: 0;
    padding: 10px;
  }

  .content-area {
    flex-direction: column;
    padding: 10px;
  }
}

/* Side-panel (device / user details) behaviour */
/* Default: keep existing wide panel on desktop; override for small screens */
@media (max-width: 900px) {
  .side-panel {
    width: 100%;
    max-width: 100%;
    left: 0;
    right: 0;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
  }
}

/* Home dashboard: stack main + MQTT column on narrow screens */
.home-layout-row {
  display: flex;
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 900px) {
  .home-layout-row {
    flex-direction: column;
  }

  .home-layout-row > aside {
    width: 100% !important;
    max-width: none !important;
  }
}
