:root {
  --sidebar-bg: #1c1c1e;
  --sidebar-bg-2: #262628;
  --sidebar-border: rgba(255,255,255,.08);
  --sidebar-text: #9a9a9e;
  --sidebar-text-active: #ffffff;

  --bg: #f7f7f9;
  --panel: #ffffff;
  --panel-2: #f3f3f5;
  --border: #ececef;
  --text: #17171a;
  --muted: #6b7280;

  --accent: #f97316;
  --accent-hover: #e2620a;
  --success: #16a34a;
  --success-bg: #e8f8ee;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warn: #b45309;
  --warn-bg: #fef3d9;

  --gradient: linear-gradient(135deg, #fbbf24, #f97316);

  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 20px rgba(15,23,42,.06);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #202023 0%, #17171a 100%);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-shadow: inset -1px 0 0 rgba(255,255,255,.05);
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 10px 22px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  letter-spacing: .2px;
}
.sidebar .brand .dot {
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--gradient);
  box-shadow: 0 4px 14px rgba(249,115,22,.45);
  flex-shrink: 0;
}
.navlink {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
  transition: background .15s, color .15s;
}
.navlink:hover { color: #f0f0f2; background: rgba(255,255,255,.06); }
.navlink.active {
  color: var(--sidebar-text-active);
  background: rgba(249,115,22,.16);
  box-shadow: inset 0 0 0 1px rgba(249,115,22,.35);
  font-weight: 700;
}
.sidebar .spacer { flex: 1; }
.sidebar .logout {
  color: #ff9494;
  font-size: 13px;
  font-weight: 600;
  background: none;
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  border-top: 1px solid rgba(255,255,255,.07);
  margin-top: 8px;
  padding-top: 16px;
  transition: background .15s;
}
.sidebar .logout:hover { background: rgba(255,255,255,.05); }

.main { flex: 1; min-width: 0; padding: 28px 34px 60px; max-width: 1040px; }

.stats-row { display: flex; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.stat-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  min-width: 180px;
  flex: 1;
}
.stat-tile .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-tile .value { font-family: var(--mono); font-size: 24px; font-weight: 700; margin-top: 6px; color: var(--text); }
.stat-tile.on .value { color: var(--success); }
.stat-tile.off .value { color: var(--warn); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 18px;
}
.panel[hidden] { display: none; }
.panel h2 {
  margin: 0 0 4px;
  font-size: 15.5px;
  font-weight: 800;
  color: var(--text);
}
.panel .hint { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }

input, textarea, select {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: var(--mono);
  background: #fbfbfc;
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: #a8a8ae; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); background: #fff; }
textarea { font-family: var(--sans); }
select {
  font-family: var(--sans);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%236b7280'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
select:hover { border-color: #d4d4d9; }

.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.checkbox input { width: auto; accent-color: var(--accent); }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  margin-right: 8px;
  margin-bottom: 6px;
  transition: background .12s, box-shadow .12s, transform .08s;
}
button:hover { background: var(--accent-hover); box-shadow: 0 6px 18px rgba(249,115,22,.35); }
button:active { transform: translateY(1px); }
button.secondary { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); box-shadow: none; }
button.secondary:hover { background: #e9e9ec; box-shadow: none; }

table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 700; font-size: 11.5px; }
td { font-family: var(--mono); color: var(--text); }
td:first-child, th:first-child { padding-left: 0; }
tbody tr:hover { background: var(--panel-2); }

.ok { color: var(--success); margin-left: 10px; font-size: 13px; font-weight: 700; }
#logList { list-style: none; padding: 0; margin: 0; max-height: 340px; overflow-y: auto; font-size: 12.5px; font-family: var(--mono); }
#logList li { padding: 9px 0; border-bottom: 1px solid var(--border); color: var(--muted); }

.login-body {
  display: flex; align-items: center; justify-content: center;
  height: 100vh;
  background: var(--sidebar-bg);
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 34px 32px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
  width: 300px;
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
}
.login-card .sub { color: var(--muted); font-size: 12.5px; margin: -8px 0 6px; }
.error { color: var(--danger); font-size: 13px; min-height: 16px; }

.menu-wrap { max-width: 1040px; margin: 0 auto; padding: 40px 24px 60px; }
.menu-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.menu-top .who { color: var(--muted); font-size: 13px; }
.menu-top .who b { color: var(--text); }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.menu-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  display: block;
  box-shadow: var(--shadow);
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.menu-tile:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow), 0 10px 24px rgba(249,115,22,.18); }
.menu-tile .icon { font-size: 26px; margin-bottom: 10px; }
.menu-tile .name { font-weight: 800; font-size: 14.5px; margin-bottom: 4px; }
.menu-tile .desc { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.menu-tile.admin-tile { border: 1px solid transparent; background: linear-gradient(var(--panel), var(--panel)) padding-box, var(--gradient) border-box; }

.service-checks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.service-checks label {
  flex-direction: row; align-items: center; gap: 6px;
  background: var(--panel-2); border-radius: var(--radius-sm); padding: 6px 10px;
  font-size: 12.5px; color: var(--text); font-weight: 500;
}
.service-checks input { width: auto; accent-color: var(--accent); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge.admin { background: var(--gradient); color: #fff; }
.badge.user { background: var(--panel-2); color: var(--muted); }

/* ---------- єдина плаваюча кнопка "На головну" для всіх сервісів ---------- */
.back-home {
  position: fixed;
  left: 24px;
  bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 99px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  z-index: 50;
  transition: border-color .15s, color .15s;
}
.back-home:hover { border-color: var(--accent); color: var(--accent); }
