:root {
  /* ΘΕΜΑ ΠΡΟΕΠΙΛΟΓΗΣ: Γραφίτης — επαγγελματικό, σταθερό, διαχρονικό (μπλε accent) */
  --bg: #171c26; --panel: #1e2530; --panel-2: #273040; --line: #333d4d;
  --text: #e8edf3; --muted: #93a0b3; --accent: #3b82f6;
  --green: #22c55e; --red: #ef4444; --amber: #f59e0b; --blue: #3b82f6;
  --led-off: #2b3542; --btn-text: #ffffff; --widget-off: #2b3542;
}

/* ============================================================
   Themes — 3 curated παλέτες. Εναλλαγή μέσω <select id="theme-select">
   (theme.js, localStorage). Προεπιλογή: Γραφίτης (:root παραπάνω).
   ============================================================ */

/* Αρκτικός — καθαρό, φωτεινό, minimal (μπλε accent) */
:root[data-theme="arctic"] {
  --bg: #f5f8fc; --panel: #ffffff; --panel-2: #eef3f9; --line: #dbe3ec;
  --text: #1e293b; --muted: #64748b; --accent: #2563eb;
  --green: #16a34a; --red: #dc2626; --amber: #d97706; --blue: #2563eb;
  --led-off: #dde5ee; --btn-text: #ffffff; --widget-off: #e3eaf2;
}

/* Aurora — premium, μοντέρνο, ξεχωριστό (βιολετί accent) */
:root[data-theme="aurora"] {
  --bg: #17131f; --panel: #1f1a2b; --panel-2: #2a2340; --line: #3a3152;
  --text: #ece8f5; --muted: #a99fc0; --accent: #8b5cf6;
  --green: #34d399; --red: #fb7185; --amber: #fbbf24; --blue: #818cf8;
  --led-off: #332a4a; --btn-text: #ffffff; --widget-off: #332a4a;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 18px; margin: 0; }
.subtitle { color: var(--muted); font-size: 12px; }
.logo-dot { width: 14px; height: 14px; border-radius: 3px; background: var(--accent); }
#brand-logo { height: 28px; border-radius: 4px; margin-right: 6px; display: none; }
.status { display: flex; align-items: center; gap: 10px; }
.clock { color: var(--muted); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

.pill { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pill-ok { background: rgba(46,204,113,.15); color: var(--green); }
.pill-off { background: rgba(231,76,60,.15); color: var(--red); }
.pill-warn { background: rgba(243,156,18,.18); color: var(--amber); }

/* Συμπτυσσόμενο μενού: κρυφό, ανοίγει ως κάθετο dropdown από το hamburger (☰) δεξιά */
.nav-toggle { background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; width: 40px; height: 32px; cursor: pointer; font-size: 17px; line-height: 1; }
.nav-toggle:hover { border-color: var(--accent); color: var(--accent); }
.tabs { display: none; position: absolute; top: 52px; right: 16px; z-index: 120;
  flex-direction: column; align-items: stretch; gap: 2px; padding: 6px; min-width: 200px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0,0,0,.45); }
.tabs.open { display: flex; }
.tab { background: none; border: none; color: var(--muted); padding: 10px 14px; cursor: pointer;
  font-size: 14px; text-align: left; border-radius: 6px; }
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active { color: var(--accent); background: var(--panel-2); font-weight: 600; }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
h2 { font-size: 15px; color: var(--muted); margin: 22px 0 10px; text-transform: uppercase; letter-spacing: .5px; }

.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.device-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.device-card.offline { opacity: .65; }
.dc-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; background: var(--panel-2); }
.dc-head .name { font-weight: 600; }
.dc-head .host { color: var(--muted); font-size: 12px; }
.dc-body { padding: 12px 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.off { background: var(--red); }

.io-section { margin-top: 10px; }
.io-title { color: var(--muted); font-size: 11px; text-transform: uppercase; margin-bottom: 5px; }
.io-row { display: flex; flex-wrap: wrap; gap: 6px; }
.io-led { display: flex; flex-direction: column; align-items: center; width: 34px; }
.io-led .lbl { font-size: 10px; color: var(--muted); }
.led { width: 22px; height: 22px; border-radius: 5px; background: var(--led-off); border: 1px solid var(--line); }
.led.on { background: var(--green); box-shadow: 0 0 8px rgba(46,204,113,.6); }
.led.in.on { background: var(--blue); box-shadow: 0 0 8px rgba(52,152,219,.6); }
.led.click { cursor: pointer; }
.led.click:hover { outline: 2px solid var(--accent); }

.analog-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.analog-row .av { font-variant-numeric: tabular-nums; font-weight: 600; }
.analog-row.alarm .av { color: var(--red); }

.table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 8px; overflow: hidden; }
.table th, .table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-size: 12px; text-transform: uppercase; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar label { color: var(--muted); display: flex; align-items: center; gap: 6px; }
input, select { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 6px 8px; border-radius: 5px; }
.btn { background: var(--accent); color: var(--btn-text); border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.btn:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }

.chart-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
#history-chart { width: 100%; height: auto; }
.stats { display: flex; gap: 24px; margin-top: 12px; color: var(--muted); }
.stats b { color: var(--text); }

.alarm-list { display: flex; flex-direction: column; gap: 8px; }
.alarm-item { display: flex; justify-content: space-between; padding: 10px 14px; border-radius: 8px; background: rgba(231,76,60,.12); border: 1px solid rgba(231,76,60,.3); }
.alarm-item .kind { font-weight: 700; color: var(--red); }
.alarm-item.acked { opacity: .6; }
.alarm-item.sev-critical { border-color: var(--red); background: rgba(231,76,60,.14); }
.alarm-item.sev-warning { border-color: var(--amber); background: rgba(243,156,18,.12); }
.alarm-item.sev-info { border-color: var(--blue); background: rgba(52,152,219,.12); }
.sev-badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 10px; font-weight: 700; text-transform: uppercase; color: #fff; }
.sev-badge.sev-critical { background: var(--red); }
.sev-badge.sev-warning { background: var(--amber); color: #3a2600; }
.sev-badge.sev-info { background: var(--blue); }
.ack-tag { color: var(--green); font-size: 12px; }
.pill.flash { animation: pillflash 0.6s ease-in-out 0s 6; }
@keyframes pillflash { 0%,100% { background: rgba(243,156,18,.18); } 50% { background: var(--red); color: #fff; } }
.empty { color: var(--muted); padding: 14px; }

/* ---- print (αναφορές -> PDF) ---- */
@media print {
  .topbar, .tabs, .no-print, #login, #modal { display: none !important; }
  body { background: #fff; color: #000; }
  main { padding: 0; max-width: none; }
  #report-printable, #report-printable * { color: #000 !important; }
  #report-printable .table { background: #fff; }
  #report-printable .table th, #report-printable .table td { border-bottom: 1px solid #ccc; }
}

/* ---- login overlay ---- */
.login-overlay { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 100; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 30px; width: 320px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-box h2 { color: var(--text); margin: 0; text-transform: none; letter-spacing: 0; }
.login-box input { padding: 10px; }
.login-err { color: var(--red); font-size: 13px; min-height: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid2 label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.msg { color: var(--green); align-self: center; }
.small-link { color: var(--accent); font-size: 12px; text-decoration: none; cursor: pointer; }
.small-link:hover { text-decoration: underline; }
body.authed .login-overlay { display: none; }

/* ---- badges / buttons ---- */
.pill-user { background: rgba(52,152,219,.18); color: var(--blue); }
.btn-sm { padding: 3px 8px; font-size: 12px; margin-left: 4px; }
.analog-row .av.editable { cursor: pointer; }
.analog-row .av.editable:hover { color: var(--accent); text-decoration: underline; }

/* ---- toast ---- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); padding: 10px 18px; border-radius: 8px; z-index: 200; color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.4); }

/* ---- modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 150; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px; width: 420px; max-width: 92vw; }
.modal-box h3 { margin: 0 0 14px; color: var(--text); }
.modal-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.modal-field .mf-label { color: var(--muted); }
.modal-field input, .modal-field select, .modal-field textarea { padding: 8px; }
.modal-field textarea { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 5px; font-family: ui-monospace, "Consolas", monospace; font-size: 12px; resize: vertical; }
.modal-field input[type=checkbox] { width: auto; align-self: flex-start; }
.modal-field input[type=hidden] { display: none; }
.checklist { display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow-y: auto; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.cl-item { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.cl-item input { width: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ---- dashboard builder ---- */
.bld-palette { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.bld-board { position: relative; min-height: 520px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.bld-board.editing { background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 10px 10px; }
.bld-widget { position: absolute; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; box-sizing: border-box; }
.bld-board.editing .bld-widget { cursor: move; }
.bw-content { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 8px; text-align: center; }
.bw-cap { font-size: 11px; color: var(--muted); }
.bw-label-big { font-size: 15px; font-weight: 600; color: var(--text); }
.bw-lamp { width: 30px; height: 30px; border-radius: 50%; background: var(--widget-off); }
.bw-switch { padding: 6px 16px; border-radius: 6px; font-weight: 700; background: var(--widget-off); color: var(--muted); cursor: pointer; }
.bw-switch.on { background: var(--green); color: #04231a; }
.bw-btn { width: 90%; }
.bw-value { font-size: 22px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.bw-value.sm { font-size: 14px; }
.bw-gauge { width: 90%; height: 12px; background: var(--widget-off); border-radius: 6px; overflow: hidden; }
.bw-gauge-fill { height: 100%; background: var(--accent); transition: width .3s; }
.bw-trend { width: 100%; flex: 1; }
.bw-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.bw-resize { position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, var(--accent) 50%); border-bottom-right-radius: 8px; }
.bld-board { background-size: cover; background-position: center; }

/* ---- hotel room board ---- */
.room-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.room-card { background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--muted); border-radius: 10px; padding: 12px; cursor: pointer; }
.room-card:hover { outline: 2px solid var(--accent); }
.room-card.offline { opacity: .5; }
.room-card.r-vacant { border-left-color: var(--green); }
.room-card.r-occ { border-left-color: var(--blue); }
.room-card.r-mur { border-left-color: var(--amber); }
.room-card.r-maint { border-left-color: var(--muted); }
.room-card.r-sos { border-left-color: var(--red); animation: roomsos 1s infinite; }
@keyframes roomsos { 0%,100% { box-shadow: 0 0 0 rgba(231,76,60,0); } 50% { box-shadow: 0 0 14px rgba(231,76,60,.7); } }
.rc-name { font-weight: 700; font-size: 15px; }
.rc-temp { font-size: 20px; font-variant-numeric: tabular-nums; margin: 4px 0; }
.rc-sp { font-size: 13px; color: var(--muted); }
.rc-icons { font-size: 14px; min-height: 18px; letter-spacing: 2px; }
.rc-guest { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.kpi-tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; text-align: center; }
.kpi-val { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }
/* ενεργές έξοδοι στην κάρτα δωματίου */
.rc-out { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.out-on { font-size: 10px; background: rgba(46,204,113,.18); color: var(--green); border: 1px solid rgba(46,204,113,.4); border-radius: 10px; padding: 1px 7px; }
/* δυναμικά σημεία στη λεπτομέρεια δωματίου */
.room-items { display: flex; flex-direction: column; gap: 6px; }
.room-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px dashed var(--line); padding: 4px 0; }
.ri-lbl { color: var(--text); }
.ri-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.ri-lamp { width: 16px; height: 16px; border-radius: 50%; background: var(--widget-off); display: inline-block; }
.ri-lamp.on { background: var(--green); box-shadow: 0 0 8px rgba(46,204,113,.6); }
/* δυναμικός editor template */
.item-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.item-row { display: flex; gap: 6px; align-items: center; }
.item-row input, .item-row select { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 6px; border-radius: 5px; }
.item-row input:first-child { flex: 1; }
.item-row select { min-width: 90px; }
.point-edit { display: flex; gap: 6px; }
.point-edit select { flex: 1; }
.point-edit input { width: 56px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 5px; padding: 6px; }
/* μεγάλα modals: scroll */
.modal-box { max-height: 86vh; overflow-y: auto; }
/* Πλατύ modal (π.χ. hotel template) — χωράει χωρίς scroll, responsive πολλαπλές στήλες */
.modal-box.wide { width: 860px; max-height: 94vh; }
.modal-box.wide .grid2 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.point-edit select { min-width: 0; }   /* να μπορεί να συρρικνωθεί, χωρίς οριζόντιο overflow */
.bw-tools { position: absolute; top: 2px; right: 2px; display: flex; gap: 2px; }
.bw-tool { width: 20px; height: 20px; border: none; border-radius: 4px; background: rgba(0,0,0,.4); color: #fff; cursor: pointer; font-size: 11px; line-height: 1; }
.bw-binding { position: absolute; bottom: 2px; left: 4px; font-size: 9px; color: var(--muted); }

/* ---- responsive / mobile ---- */
@media (max-width: 760px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
  .brand { flex-wrap: wrap; gap: 8px; }
  .brand h1 { font-size: 16px; }
  .subtitle { display: none; }
  .status { flex-wrap: wrap; gap: 8px; }
  .tabs { top: auto; right: 8px; left: 8px; min-width: 0; }   /* dropdown σε πλήρες πλάτος στο κινητό */
  main { padding: 12px; }
  .device-grid { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .toolbar { gap: 8px; }
  .toolbar label { flex: 1 1 auto; }
  .modal-box { width: 95vw; padding: 16px; }
  /* πίνακες: οριζόντια κύλιση αντί για στρίμωγμα */
  .table { display: block; overflow-x: auto; white-space: nowrap; }
  .site-select, #lang-select { max-width: 46vw; }
}
