/* EnerSync web – interní nástroj, střídmý technický vzhled */

:root {
  --bg: #f5f6f4;
  --panel: #ffffff;
  --ink: #23282d;
  --muted: #6b7280;
  --line: #dde1dc;
  --accent: #1f7a4d;        /* energetická zelená */
  --accent-ink: #ffffff;
  --warn: #b45309;
  --off: #9ca3af;
  --danger: #b91c1c;
  --mono: "JetBrains Mono", "Consolas", "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* --- horní lišta --------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.25rem;
  height: 52px;
  background: var(--panel);
  border-bottom: 2px solid var(--accent);
}

.brand {
  font-size: 1.1rem;
  letter-spacing: .02em;
  color: var(--ink);
  text-decoration: none;
}
.brand strong { color: var(--accent); }
/* Ikona je hotová dlaždice s vlastním tmavým podkladem, ne průhledný glyf -
   proto jen zaoblení rohů, žádné barvení. width/height jsou i v HTML, aby
   lišta neposkočila, než se obrázek načte. */
.brand-mark img {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  vertical-align: middle;
}

.topbar nav { display: flex; gap: .25rem; }
.topbar nav a {
  padding: .35rem .75rem;
  border-radius: 4px;
  color: var(--ink);
  text-decoration: none;
}
.topbar nav a:hover { background: var(--bg); }
.topbar nav a.active { background: var(--accent); color: var(--accent-ink); }

.userbox {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .9rem;
  font-size: .85rem;
  color: var(--muted);
}
.userbox a { color: var(--accent); text-decoration: none; }
.userbox a:hover { text-decoration: underline; }
.useremail { font-family: var(--mono); }

/* --- obsah ---------------------------------------------------------------- */
main { max-width: 1500px; margin: 1.5rem auto; padding: 0 1.25rem; }

.pagehead {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
}
.pagehead h1 { margin: 0; font-size: 1.35rem; }
.hint { color: var(--muted); font-size: 1.0rem; }

/* --- flash zprávy ---------------------------------------------------------- */
.flash {
  padding: .6rem .9rem;
  border-radius: 4px;
  margin-bottom: .75rem;
  font-size: .9rem;
}
.flash-ok      { background: #e3f2e9; color: #14532d; border: 1px solid #bbe3cb; }
.flash-error   { background: #fdecea; color: #7f1d1d; border: 1px solid #f6c9c5; }
.flash-info,
.flash-message { background: #eaf1fb; color: #1e3a8a; border: 1px solid #c9daf5; }

/* --- tabulky --------------------------------------------------------------- */
.datatable {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.datatable th, .datatable td {
  padding: .55rem .8rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.datatable thead th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  background: #fafbf9;
}
.datatable tbody tr:last-child td { border-bottom: none; }
.datatable tbody tr:hover { background: #f7faf7; }
.row-disabled td { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 2rem !important; }

.mono { font-family: var(--mono); font-size: .88rem; }
.num { text-align: right; }
.actions { display: flex; gap: .4rem; align-items: center; }
.actions form { margin: 0; }

/* --- odznaky --------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: .1rem .55rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-ok   { background: #e3f2e9; color: var(--accent); }
.badge-warn { background: #fef3e2; color: var(--warn); }
.badge-off  { background: #eceff1; color: var(--off); }
.badge-bad  { background: #fdecea; color: var(--danger); }
.badge-role-admin { background: #ede9fe; color: #5b21b6; }
.badge-role-user  { background: #eaf1fb; color: #1e40af; }

/* --- tlačítka -------------------------------------------------------------- */
.btn, button[type="submit"] {
  display: inline-block;
  padding: .45rem 1rem;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: .9rem;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover, button[type="submit"]:hover { filter: brightness(1.1); }
.btn-small { padding: .25rem .65rem; font-size: .8rem; }
.btn-danger { background: var(--danger); }

/* --- formuláře / auth karty ------------------------------------------------- */
.authcard {
  max-width: 420px;
  margin: 3rem auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 6px;
  padding: 1.75rem 2rem 1.5rem;
}
.authcard h1 { margin: 0 0 1rem; font-size: 1.25rem; }
.authcard label { display: block; margin: .9rem 0 .25rem; font-size: .85rem; color: var(--muted); }
.authcard input[type="text"],
.authcard input[type="email"],
.authcard input[type="password"],
.authcard select {
  width: 100%;
  padding: .5rem .65rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  background: #fff;
}
.authcard input:focus, .authcard select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}
.authcard button[type="submit"] { width: 100%; margin-top: 1.25rem; }
.checkline {
  display: flex !important;
  align-items: center;
  gap: .5rem;
  color: var(--ink) !important;
}
.checkline input { width: auto; }
.field-error { color: var(--danger); font-size: .8rem; margin: .25rem 0 0; }
.authlink { text-align: center; margin-top: 1rem; font-size: .85rem; }
.authlink a { color: var(--accent); }

/* --- detail místa --------------------------------------------------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  align-items: start;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem 1.25rem 1.25rem;
}
.card h2 { margin: 0 0 .75rem; font-size: .95rem; color: var(--muted); font-weight: 600; }
.card-wide { grid-column: 1 / -1; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .85rem; align-self: center; }
.kv dd { margin: 0; align-self: center; }
.big { font-size: 1.4rem; font-weight: 600; }

.inline-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0 .75rem .5rem 0; }
.inline-form label { color: var(--muted); font-size: .85rem; }
.inline-form input[type="number"] {
  width: 4rem;
  padding: .2rem .4rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  background: #fff;
}
.inline-form input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.inline-form br {
  flex-basis: 100%;
  height: 0;
}
.btn-secondary, button.btn-secondary { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: .5rem 1rem; }
  .userbox { margin-left: 0; width: 100%; }
  .datatable { display: block; overflow-x: auto; }
  .cards { grid-template-columns: 1fr; }
}

/* --- stránka Stav systému -------------------------------------------------- */
.sectionhead {
  margin: 1.75rem 0 .6rem;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
}
.autorefresh { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; }

/* Podřádek visí u svého modulu: bez horního rámečku a se světlejším pozadím,
   aby bylo poznat, že nejde o samostatnou položku tabulky. */
.subrow > td {
  background: #fafbf9;
  padding-top: .35rem;
  padding-bottom: .55rem;
}
.datatable tbody tr.subrow:hover { background: #fafbf9; }
.subnote { color: var(--muted); font-size: .82rem; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: .35rem;
  padding: .1rem .5rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  font-size: .78rem;
}
.chip-k { color: var(--muted); }
.chip-v { font-weight: 600; }

.subtable {
  width: 100%;
  border-collapse: collapse;
  margin-top: .45rem;
  font-size: .85rem;
}
.subtable th, .subtable td {
  padding: .3rem .5rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.subtable thead th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.subtable tbody tr:last-child td { border-bottom: none; }
.small { font-size: .8rem; }

/* Čistý export nad limitem skupiny. Barví se podle limitu, ne podle znaménka:
   kladný export sám o sobě není problém, jeho překročení ano. Barva je navíc
   jen doplněk - vedle čísla je i odznak "nad limitem". */
.over-limit { color: var(--danger); }
.strong { font-weight: 600; }

/* Tlačítka v úzkém sloupci akcí se nesmí lámat uprostřed popisku. */
.btn, .btn-small { white-space: nowrap; }
