:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --ink: #1e293b;
  --muted: #475569;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #b45309;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --font: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(239, 246, 255, 0.5), var(--bg));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 1.15rem 1rem;
  flex-shrink: 0;
}
.sidebar .brand {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f8fafc;
  margin-bottom: .25rem;
}
.sidebar .brand-accent,
.brand-accent {
  color: var(--accent);
}
.sidebar .tenant {
  font-size: .85rem;
  color: #94a3b8;
  margin-bottom: 1.25rem;
}
.sidebar nav a {
  display: block;
  color: var(--sidebar-text);
  padding: .65rem .75rem;
  border-radius: 10px;
  margin-bottom: .25rem;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.sidebar nav a:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
  text-decoration: none;
}
.sidebar nav a.active {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}
.sidebar .nav-section {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #64748b;
  margin: 1rem 0 .4rem;
  padding: 0 .75rem;
}
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #f1f5f9;
}
.topbar strong {
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #0f172a;
}
.content { padding: 1.25rem; flex: 1; }
.menu-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: .45rem .7rem;
  font: inherit;
  cursor: pointer;
  color: var(--ink);
}

.card {
  background: var(--surface);
  border: 1px solid #f1f5f9;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
}
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; color: #0f172a; }
.muted { color: var(--muted); }
.h1 {
  margin: 0 0 1rem;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0f172a;
}
.h2 {
  margin: 0 0 .75rem;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #0f172a;
}

table.data {
  width: 100%;
  border-collapse: collapse;
}
table.data th, table.data td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: .7rem .4rem;
  vertical-align: top;
}
table.data th {
  font-size: .85rem;
  color: var(--muted);
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  border: 0;
  border-radius: 10px;
  padding: .65rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn:hover {
  background: var(--accent-hover);
  text-decoration: none;
  color: #fff;
}
.btn-secondary {
  background: #0f172a;
}
.btn-secondary:hover {
  background: #1e293b;
}
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover {
  background: #f8fafc;
  color: var(--ink);
  border-color: #cbd5e1;
}
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }

label { display: block; font-size: .9rem; margin-bottom: .3rem; color: var(--muted); font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .7rem .75rem;
  font: inherit;
  background: #fff;
  margin-bottom: .85rem;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type=text]:focus, input[type=email]:focus, input[type=password]:focus,
input[type=number]:focus, input[type=date]:focus, input[type=datetime-local]:focus,
select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
textarea { min-height: 120px; resize: vertical; }
.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem .85rem;
  margin-bottom: .85rem;
}
.checkbox-row label {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: var(--ink);
  margin: 0;
}
.flash {
  padding: .8rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}
.flash-success { background: #ecfdf5; color: var(--ok); }
.flash-error { background: #fef2f2; color: var(--danger); }
.badge {
  display: inline-block;
  padding: .2rem .5rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 500;
  background: #f1f5f9;
  color: var(--muted);
}
.badge-ok { background: #ecfdf5; color: var(--ok); }
.badge-bad { background: #fef2f2; color: var(--danger); }
.badge-warn { background: #fffbeb; color: var(--warn); }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.auth-card { width: min(420px, 100%); }
.auth-card .h1 { margin-bottom: .35rem; }
.auth-version {
  margin: 1rem 0 0;
  font-size: .8rem;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  margin-top: auto;
  padding: .75rem 1.25rem 1rem;
  border-top: 1px solid #f1f5f9;
  color: var(--muted);
  font-size: .8rem;
  background: rgba(255, 255, 255, .55);
}
.app-footer .version {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.checklist-grid td, .checklist-grid th { text-align: center; }
.checklist-grid input[type=checkbox] { width: 22px; height: 22px; }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    display: none;
  }
  .sidebar.open { display: block; }
  .menu-toggle { display: inline-flex; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
}

@media print {
  .sidebar, .topbar, .no-print, .menu-toggle, .app-footer { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}
