/* KSS Panel · Karagiannis Security Systems. Mobile-first, σκοτεινό/φωτεινό θέμα (prefers-color-scheme + data-theme),
   μεγάλα κουμπιά (>= 44px), χωρίς inline styles (CSP). Χρώματα/μεγέθη ως tokens στο :root. */

:root {
  --bg: #0b1220; --surface: #121a2b; --surface-2: #182236; --text: #e6ebf5; --muted: #93a0b8; --border: #223049;
  --primary: #2f7df6; --primary-text: #ffffff; --ok: #22c55e; --warn: #f59e0b; --crit: #ef4444; --unknown: #64748b;
  --info: #38bdf8; --shadow: 0 6px 24px rgba(0,0,0,.35); --radius: 14px; --topbar-h: 56px; --drawer-w: 260px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] {
    --bg: #f4f6fa; --surface: #ffffff; --surface-2: #eef2f8; --text: #0f172a; --muted: #5b6578; --border: #d9e0ec;
    --shadow: 0 6px 24px rgba(15,23,42,.12); color-scheme: light;
  }
}
html[data-theme="light"] {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #eef2f8; --text: #0f172a; --muted: #5b6578; --border: #d9e0ec;
  --shadow: 0 6px 24px rgba(15,23,42,.12); color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.45; background: var(--bg); color: var(--text);
  min-height: 100dvh; display: flex; flex-direction: column; padding-top: var(--topbar-h); }
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: .2rem 0 .6rem; } h2 { font-size: 1.2rem; margin: .4rem 0 .5rem; } h3 { font-size: 1.02rem; margin: 0; }
p { margin: .4rem 0 .8rem; }
code, pre, .mono { font-family: var(--mono); font-size: .92em; }
pre.pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .6rem; overflow: auto; white-space: pre-wrap; word-break: break-word; }
svg { width: 1.25em; height: 1.25em; vertical-align: -.25em; fill: none; }
.sprite { display: none; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 0; background: var(--primary); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; } .right { text-align: right; }
.narrow { max-width: 520px; margin: 0 auto; }
.linklike { background: none; border: 0; color: var(--primary); padding: .5rem 0; font: inherit; cursor: pointer; text-align: left; }

/* Topbar */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); display: flex; align-items: center; gap: .4rem;
  padding: 0 .6rem; background: var(--surface); border-bottom: 1px solid var(--border); z-index: 50; }
.brand { display: flex; align-items: center; gap: .5rem; color: var(--text); text-decoration: none; font-weight: 700; }
.brand-logo { width: 32px; height: 32px; object-fit: contain; }
.brand-fallback { width: 32px; height: 32px; color: var(--primary); }
.clock { margin-left: auto; font-variant-numeric: tabular-nums; font-size: .95rem; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 48vw; }
.clock-ntp { color: var(--warn); }
.topbar-actions { display: flex; align-items: center; gap: .2rem; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px;
  border: 0; background: transparent; color: var(--text); cursor: pointer; }
.iconbtn:hover, .iconbtn:focus-visible { background: var(--surface-2); }
.iconbtn svg { width: 1.5em; height: 1.5em; }
.usermenu { position: relative; } .usermenu > summary { list-style: none; } .usermenu > summary::-webkit-details-marker { display: none; }
.usermenu-panel { position: absolute; right: 0; top: 48px; min-width: 240px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); padding: .5rem .8rem; display: flex; flex-direction: column; gap: .2rem; z-index: 60; }
.usermenu-panel a { padding: .5rem 0; text-decoration: none; color: var(--text); }
.usermenu-name { font-weight: 600; padding: .3rem 0 .5rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }

/* Drawer / μενού */
.drawer { position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--drawer-w); background: var(--surface);
  border-right: 1px solid var(--border); transform: translateX(-100%); transition: transform .2s ease; z-index: 45; overflow-y: auto;
  display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer ul { list-style: none; margin: 0; padding: .5rem; flex: 1; }
.drawer a { display: flex; align-items: center; gap: .7rem; padding: .8rem .8rem; border-radius: 10px; color: var(--text);
  text-decoration: none; font-size: 1.02rem; min-height: 48px; }
.drawer a:hover { background: var(--surface-2); } .drawer a.active { background: var(--primary); color: var(--primary-text); }
.drawer-foot { padding: .8rem; font-size: .8rem; color: var(--muted); border-top: 1px solid var(--border); }
.backdrop { position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0,0,0,.45); z-index: 40; }
@media (min-width: 960px) {
  .drawer { transform: none; } .backdrop { display: none !important; } #menu-toggle { display: none; }
  body:not(.no-user) .content, body:not(.no-user) .footer { margin-left: var(--drawer-w); }
}

/* Περιεχόμενο */
.content { flex: 1; padding: 1rem; max-width: 1200px; width: 100%; }
@media (min-width: 960px) { .content { padding: 1.4rem 2rem; } }
.footer { padding: 1rem; color: var(--muted); font-size: .8rem; text-align: center; border-top: 1px solid var(--border); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .6rem; margin-bottom: .8rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: .8rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: .8rem; }
.card.tight { padding: .6rem .8rem; }
.status-card { display: block; color: inherit; text-decoration: none; margin: 0; border-left: 5px solid var(--unknown); }
.status-card.level-ok { border-left-color: var(--ok); } .status-card.level-warn { border-left-color: var(--warn); }
.status-card.level-crit { border-left-color: var(--crit); }
.card-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .3rem; }
.card-head h3 { flex: 1; }
.card-headline { font-size: 1.05rem; font-weight: 600; } .card-details { margin-top: .3rem; font-size: .9rem; }
.count { background: var(--surface-2); border-radius: 999px; padding: .1rem .6rem; font-size: .85rem; font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--unknown); flex: none; }
.dot-ok { background: var(--ok); } .dot-warn { background: var(--warn); } .dot-crit { background: var(--crit); }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.badge-ok { background: rgba(34,197,94,.18); color: var(--ok); } .badge-warn { background: rgba(245,158,11,.18); color: var(--warn); }
.badge-crit { background: rgba(239,68,68,.18); color: var(--crit); } .badge-info { background: rgba(56,189,248,.18); color: var(--info); }
.badge-unknown { background: rgba(100,116,139,.2); color: var(--muted); }
.empty { padding: 1.2rem; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }

/* Κουμπιά, φόρμες */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: .55rem 1rem;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.1); } .btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn-block { width: 100%; } .btn-sm { min-height: 36px; padding: .3rem .7rem; font-size: .9rem; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row > .input { flex: 1; min-width: 120px; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field-label { font-weight: 600; font-size: .92rem; } .req { color: var(--crit); }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: .55rem .7rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; }
textarea.input { min-height: 120px; resize: vertical; }
.input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.input-code { font-family: var(--mono); font-size: 1.4rem; letter-spacing: .25em; text-align: center; }
.check { display: flex; align-items: center; gap: .6rem; min-height: 44px; }
.check input { width: 22px; height: 22px; }
.or { text-align: center; color: var(--muted); margin: .9rem 0; font-size: .9rem; }
.or::before, .or::after { content: ""; display: inline-block; width: 30%; height: 1px; background: var(--border); vertical-align: middle; margin: 0 .6rem; }
.flashes { margin-bottom: .8rem; }
.flash { padding: .7rem .9rem; border-radius: 10px; margin-bottom: .5rem; border: 1px solid var(--border); background: var(--surface-2); }
.flash-ok { border-color: var(--ok); } .flash-warn { border-color: var(--warn); } .flash-error { border-color: var(--crit); }
.steps { padding-left: 1.2rem; } .steps li { margin-bottom: .4rem; }

/* Auth */
.auth-box { padding: 1rem 0; } .auth-logo { text-align: center; margin: .5rem 0 1rem; } .auth-logo img, .auth-logo svg { width: 72px; height: 72px; }
.qr { background: #fff; border-radius: 12px; padding: 10px; width: min(100%, 280px); margin: .8rem auto; }
.qr svg { width: 100%; height: auto; }
.manual-key { font-size: 1.05rem; letter-spacing: .08em; word-break: break-all; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.codes code { display: block; padding: .5rem; background: var(--surface-2); border-radius: 8px; text-align: center; font-size: 1.05rem; }
.error-code { font-size: 4rem; font-weight: 800; color: var(--muted); line-height: 1; }

/* Πίνακες */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.sev-warn td:first-child { box-shadow: inset 4px 0 0 var(--warn); } tr.sev-error td:first-child, tr.sev-critical td:first-child { box-shadow: inset 4px 0 0 var(--crit); }
.nowrap { white-space: nowrap; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .time { color: var(--muted); font-size: .82rem; white-space: nowrap; min-width: 7.5em; }

/* Help tooltip «τι σημαίνει αυτό» */
.help { position: relative; display: inline-block; }
.help-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 .2rem; min-width: 32px; min-height: 32px; }
.help-text { display: none; position: absolute; left: 0; top: 110%; z-index: 30; width: min(320px, 80vw); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem; box-shadow: var(--shadow); font-size: .88rem; font-weight: 400; color: var(--text); }
.help.open .help-text, .help:focus-within .help-text { display: block; }

/* Toasts, modal */
.toasts { position: fixed; left: 0; right: 0; bottom: 1rem; display: flex; flex-direction: column; align-items: center; gap: .4rem; z-index: 90; pointer-events: none; padding: 0 1rem; }
.toast { pointer-events: auto; background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--info); border-radius: 10px;
  padding: .6rem .9rem; box-shadow: var(--shadow); max-width: 560px; width: 100%; }
.toast-ok { border-left-color: var(--ok); } .toast-warn { border-left-color: var(--warn); } .toast-error, .toast-crit, .toast-critical { border-left-color: var(--crit); }
.modal { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; width: min(92vw, 460px); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(0,0,0,.5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: .6rem .6rem .6rem 1rem; border-bottom: 1px solid var(--border); margin: 0; }
.modal-body { padding: 1rem; }
.modal-wide { width: min(96vw, 760px); }

/* API docs */
.method { display: inline-block; min-width: 4.5em; text-align: center; font-size: .75rem; font-weight: 700; border-radius: 6px; padding: .15rem .4rem; background: var(--surface-2); }
.method-get { color: var(--ok); } .method-post { color: var(--info); } .method-delete { color: var(--crit); } .method-put, .method-patch { color: var(--warn); }
.apiop { padding: .4rem 0; border-bottom: 1px solid var(--border); } .apiop summary { cursor: pointer; }

/* HTMX δείκτες (includeIndicatorStyles=false λόγω CSP) */
.htmx-indicator { opacity: 0; transition: opacity .2s; } .htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Σελίδες: dashboard / logs / comms */
.problems-list .problem { border-left: 5px solid var(--warn); padding: .6rem .8rem; margin-bottom: .5rem; background: var(--surface-2); border-radius: 8px; }
.problems-list .problem.level-crit { border-left-color: var(--crit); }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; align-items: end; margin-bottom: .8rem; }
.filters .field { gap: .2rem; } .filters .input { min-height: 40px; }
.live-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); margin-right: .3rem; }
.live-dot.on { background: var(--ok); }
.sms-count { font-size: .85rem; color: var(--muted); } .sms-count.over { color: var(--crit); }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tabs a { padding: .5rem .8rem; border-radius: 999px; background: var(--surface-2); color: var(--text); text-decoration: none; min-height: 40px; display: inline-flex; align-items: center; }
.tabs a.active { background: var(--primary); color: var(--primary-text); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: .4rem; } }
.inline-form { display: inline; }
.wrap { white-space: pre-wrap; word-break: break-word; }
