/* Sauna Builder — admin panel.
   Paleta vychádza zo sauny: teplé cédrové drevo, para a tmavé uhlie.
   Nadpisy: Fraunces (mäkký display serif), text a čísla: Inter. */

:root {
  /* povrchy */
  --paper: #f6f2ec;
  --surface: #ffffff;
  --surface-sunk: #faf7f2;
  --charcoal: #221d18;
  --charcoal-soft: #2e2822;

  /* text */
  --ink: #1f1a15;
  --ink-soft: #574d43;
  --muted: #8a7d70;
  --on-dark: #f0e9e0;
  --on-dark-muted: #a2958a;

  /* akcenty */
  --cedar: #b4622d;
  --cedar-dark: #97501f;
  --cedar-wash: #fbf0e6;
  --steam: #2e6f73;
  --steam-wash: #e6f1f1;
  --ok: #2f7a4f;
  --ok-wash: #e8f4ec;
  --warn: #a97314;
  --warn-wash: #fbf1de;
  --danger: #b23a3a;
  --danger-wash: #fbeaea;

  --line: #e6ded3;
  --line-strong: #d4c8ba;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(34, 29, 24, .05), 0 8px 24px rgba(34, 29, 24, .06);
  --shadow-lg: 0 24px 60px rgba(34, 29, 24, .18);

  --sans: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; font-family: var(--sans); font-weight: 600; }

.hidden { display: none !important; }
.mono { font-family: var(--mono); }

.eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--cedar);
}

.stamp { margin: 0; font-size: 12px; color: var(--muted); }

/* ---------------- layout ---------------- */

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px 18px;
  background: var(--charcoal);
  color: var(--on-dark);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 11px; }

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  flex: none;
  background: linear-gradient(150deg, var(--cedar) 0%, #d98a4e 55%, var(--steam) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-family: var(--display); font-size: 15px; font-weight: 600; }
.brand-text small { font-size: 11px; color: var(--on-dark-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--on-dark-muted);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--charcoal-soft); color: var(--on-dark); }
.nav-item.is-active { background: var(--charcoal-soft); color: var(--on-dark); }

.nav-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .45;
}
.nav-item.is-active .nav-dot { background: var(--cedar); opacity: 1; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

.admin-email {
  font-size: 11px;
  color: var(--on-dark-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main { padding: 30px 34px 48px; max-width: 1180px; }

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

/* ---------------- tlačidlá ---------------- */

.btn {
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-sunk); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }

.btn-primary { background: var(--cedar); border-color: var(--cedar-dark); color: #fff; }
.btn-primary:hover { background: var(--cedar-dark); border-color: var(--cedar-dark); }

.btn-danger { color: var(--danger); border-color: #e6c4c4; background: var(--danger-wash); }
.btn-danger:hover { background: #f6dcdc; border-color: var(--danger); }

.btn-ok { color: var(--ok); border-color: #bcdcc8; background: var(--ok-wash); }
.btn-ok:hover { background: #dcefe4; border-color: var(--ok); }

.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, .16); color: inherit; }
.btn-ghost:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .28); }
.main .btn-ghost { border-color: var(--line-strong); color: var(--ink-soft); }
.main .btn-ghost:hover { background: var(--surface); }

.btn-block { width: 100%; }
.btn-small { padding: 6px 10px; font-size: 12px; }

.icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-sunk); }

/* ---------------- banner a toast ---------------- */

.banner {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid #e6c4c4;
  background: var(--danger-wash);
  color: var(--danger);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: var(--charcoal);
  color: var(--on-dark);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: rise .18s ease-out;
}
.toast.is-error { background: var(--danger); }
.toast.is-ok { background: var(--ok); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------------- dlaždice ---------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.stat.accent { background: var(--cedar-wash); border-color: #eed8c3; }

.stat-label { margin: 0; font-size: 12px; color: var(--muted); }
.stat-value { margin: 6px 0 2px; font-family: var(--display); font-size: 32px; line-height: 1; }
.stat.accent .stat-value { color: var(--cedar-dark); }
.stat-note { margin: 0; font-size: 11px; color: var(--muted); }

/* ---------------- panely ---------------- */

.panel-grid { display: grid; grid-template-columns: 1.9fr 1fr; gap: 14px; margin-bottom: 14px; }

.panel {
  padding: 18px 20px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.pill {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--steam-wash);
  color: var(--steam);
  font-size: 11px;
  font-weight: 600;
}

/* graf */
.chart-wrap { position: relative; }
#chart { width: 100%; height: 200px; display: block; overflow: visible; }
.chart-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

/* mini zoznam */
.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.mini-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  cursor: pointer;
}
.mini-list li:last-child { border-bottom: 0; }
.mini-list li:hover .mini-mail { color: var(--cedar); }
.mini-empty { color: var(--muted); cursor: default !important; }

.mini-mail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-days { flex: none; font-size: 12px; font-weight: 600; color: var(--warn); }

/* pruhy stavov */
.status-bars { display: flex; flex-direction: column; gap: 10px; }

.status-row { display: grid; grid-template-columns: 110px 1fr 44px; align-items: center; gap: 12px; font-size: 13px; }
.status-track { display: block; height: 8px; border-radius: 999px; background: var(--surface-sunk); overflow: hidden; }
/* display: block je nutné — inline span by výšku 100 % ignoroval. */
.status-fill { display: block; height: 100%; border-radius: 999px; }
.status-count { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-soft); }

/* ---------------- filtre a tabuľka ---------------- */

.search input {
  width: 280px;
  padding: 9px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
  font-size: 13px;
  color: var(--ink);
}
.search input:focus { outline: 2px solid #ecd6c2; outline-offset: 1px; border-color: var(--cedar); }

.filters { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }

.chip {
  padding: 6px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { background: var(--surface); }
.chip.is-active { background: var(--charcoal); border-color: var(--charcoal); color: var(--on-dark); }

.table-wrap {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table { width: 100%; border-collapse: collapse; font-size: 13px; }

.table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-sunk);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--cedar); }
.table th.sorted-asc::after { content: " ↑"; color: var(--cedar); }
.table th.sorted-desc::after { content: " ↓"; color: var(--cedar); }

.table td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; transition: background .12s; }
.table tbody tr:hover { background: var(--cedar-wash); }

.table-empty { text-align: center; color: var(--muted); padding: 30px 0 !important; cursor: default; }

.cell-key { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.cell-dim { color: var(--muted); }
.cell-warn { color: var(--warn); font-weight: 500; }
.cell-danger { color: var(--danger); font-weight: 500; }

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}
.tag-trial { background: var(--steam-wash); color: var(--steam); }
.tag-beta { background: var(--cedar-wash); color: var(--cedar-dark); }
.tag-active { background: var(--ok-wash); color: var(--ok); }
.tag-revoked { background: var(--danger-wash); color: var(--danger); }
.tag-expired { background: var(--warn-wash); color: var(--warn); }

.dot-device {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: middle;
}
.dot-hardware { background: var(--ok); }
.dot-fallback { background: var(--warn); }
.dot-none { background: var(--line-strong); }

.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.pager-buttons { display: flex; gap: 8px; }

/* ---------------- detail (drawer) ---------------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(34, 29, 24, .38);
  backdrop-filter: blur(2px);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  width: min(520px, 100vw);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-left: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  animation: slide-in .2s ease-out;
}

@keyframes slide-in { from { transform: translateX(22px); opacity: .5; } }

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.drawer-head h2 { font-size: 17px; letter-spacing: .04em; }

.drawer-body { flex: 1; overflow: auto; padding: 20px 22px 40px; }

.detail-grid {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 9px 14px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
}
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; word-break: break-word; }

.drawer-section { margin-top: 22px; }
.drawer-section h3 { margin-bottom: 10px; color: var(--ink-soft); }

.action-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); }

.timeline li { position: relative; padding: 0 0 14px 14px; font-size: 12.5px; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  box-shadow: 0 0 0 3px var(--paper);
}
.timeline li.ev-ok::before { background: var(--ok); }
.timeline li.ev-bad::before { background: var(--danger); }
.timeline li.ev-admin::before { background: var(--cedar); }

.ev-title { font-weight: 500; }
.ev-meta { color: var(--muted); font-size: 11.5px; }
.timeline-empty { color: var(--muted); padding-left: 14px; font-size: 12.5px; }

/* ---------------- modál ---------------- */

.modal {
  position: fixed;
  z-index: 50;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, calc(100vw - 32px));
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-sunk);
}

.modal-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field input, .field select {
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 13px;
  color: var(--ink);
}
.field input:focus, .field select:focus { outline: 2px solid #ecd6c2; outline-offset: 1px; border-color: var(--cedar); }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }

.create-result {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--ok-wash);
  border: 1px solid #bcdcc8;
  text-align: center;
}
.create-result .key {
  font-family: var(--mono);
  font-size: 17px;
  letter-spacing: .06em;
  color: var(--ok);
  display: block;
  margin-bottom: 4px;
}
.create-result small { color: var(--ink-soft); font-size: 12px; }

.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 2px; }

/* ---------------- responzivita ---------------- */

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

@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .nav { flex-direction: row; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .btn-block { width: auto; }
  .main { padding: 22px 18px 40px; }
  .view-head { flex-direction: column; align-items: flex-start; }
  .search input { width: 100%; }
}
