:root {
  --bg: #0c1116;
  --surface: #151c24;
  --surface-alt: #1c2530;
  --border: #263241;
  --text: #f3f6fa;
  --muted: #93a3b8;
  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.14);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.14);
  --blue: #3b82f6;
  --amber: #f59e0b;
  --radius: 16px;
}

[data-theme="light"] {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-alt: #f0f4f8;
  --border: #dce3ec;
  --text: #111827;
  --muted: #64748b;
  --emerald: #059669;
  --emerald-soft: rgba(5, 150, 105, 0.11);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.11);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--emerald); text-decoration: none; }
a:hover { text-decoration: underline; }

.emerald { color: var(--emerald); }
.danger { color: var(--red); }
.muted { color: var(--muted); }

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.brand:hover { text-decoration: none; }

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 10px;
  background: var(--emerald-soft);
  color: var(--emerald);
  font-size: 0.78rem;
  font-weight: 800;
  border: 1px solid var(--emerald);
}

.nav-links {
  display: flex;
  gap: 18px;
  align-items: center;
}

.nav-links a {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--emerald);
  text-decoration: none;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.main-root {
  flex: 1;
  padding: 36px 0 64px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.btn:hover { opacity: 0.92; text-decoration: none; }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--emerald);
  color: #ffffff;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--border);
}

.btn-danger {
  background: var(--red);
  color: #ffffff;
}

.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 32px;
  align-items: center;
  margin-bottom: 48px;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.12;
  margin: 0 0 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--emerald-soft);
  color: var(--emerald);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.kpi-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 1.35rem;
  font-weight: 800;
}

.hero-balance {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(16, 185, 129, 0.04));
  border: 1px solid rgba(16, 185, 129, 0.45);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
}

input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.95rem;
}

input:focus, select:focus {
  outline: 2px solid var(--emerald);
  border-color: var(--emerald);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.badge-in { background: var(--emerald-soft); color: var(--emerald); border-color: transparent; }
.badge-out { background: var(--red-soft); color: var(--red); border-color: transparent; }

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  font-weight: 500;
}

.alert-error { background: var(--red-soft); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.35); }
.alert-ok { background: var(--emerald-soft); color: var(--emerald); border: 1px solid rgba(16, 185, 129, 0.35); }

.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 24px 0;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.88rem;
}

.tabs-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.tab-btn {
  padding: 9px 14px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}

.tab-btn:hover { color: var(--text); background: var(--surface-alt); }
.tab-btn.active { background: var(--emerald); color: #ffffff; }

.btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: 8px;
}

.bar-track {
  width: 100%;
  height: 10px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.bar-fill {
  height: 100%;
  background: var(--emerald);
  border-radius: 999px;
}

.bar-fill-red { background: var(--red); }

.check-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
}

.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.88rem;
}

.check-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.badge-warn { background: rgba(245, 158, 11, 0.16); color: var(--amber); border-color: transparent; }
.badge-info { background: rgba(59, 130, 246, 0.16); color: var(--blue); border-color: transparent; }

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.strength-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-alt);
  overflow: hidden;
  margin-top: 6px;
}

.strength-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.2s ease, background 0.2s ease;
}

.admin-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: calc(100vh - 69px);
}

.admin-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.admin-nav-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.admin-nav-btn.active {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.admin-content {
  padding: 26px;
  min-width: 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--emerald);
}

@media (max-width: 900px) {
  .hero, .grid-4, .grid-3, .grid-2 {
    grid-template-columns: 1fr;
  }
  .admin-shell {
    grid-template-columns: 1fr;
  }
  .admin-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
  }
  .admin-nav-btn {
    width: auto;
  }
}

@media print {
  .topbar, .footer, .tabs-bar, .no-print, button, form {
    display: none !important;
  }
  body { background: #ffffff; color: #111827; }
  .card { border: 1px solid #cbd5e1; break-inside: avoid; }
}
