/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --background: #ffffff;
  --foreground: #0a0a0a;
  --card: #ffffff;
  --card-foreground: #0a0a0a;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --secondary: #f4f4f5;
  --secondary-foreground: #18181b;
  --destructive: #ef4444;
  --destructive-foreground: #fafafa;
  --ring: #a1a1aa;
  --radius: 0.5rem;
  --sidebar-w: 220px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

body {
  font-family: var(--font);
  background: var(--background);
  color: var(--foreground);
  font-size: 0.9rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Layout ───────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--muted);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
}

.sidebar-brand-icon {
  width: 1.75rem;
  height: 1.75rem;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-nav a, .nav-link {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground);
  font-size: 0.85rem;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover, .nav-link:hover {
  background: var(--border);
  color: var(--foreground);
  text-decoration: none;
}

.sidebar-nav a.active, .nav-link.active {
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 500;
}

.sidebar-section-label {
  padding: 0.75rem 0.75rem 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
}

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted-foreground);
}

/* ── Main content ─────────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
  height: 100vh;
}

.topbar {
  height: 3.25rem;
  border-bottom: 1px solid var(--border);
  padding: 0 1.75rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  background: var(--background);
  font-size: 0.825rem;
  color: var(--muted-foreground);
}

.page-content {
  flex: 1;
  padding: 1rem 1.5rem;
  max-width: 1400px;
}

.page-header {
  margin-bottom: 0.75rem;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
}

/* ── Card ─────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.card-body {
  padding: 0.85rem 1rem;
}

/* ── Inputs ───────────────────────────────────────────────────── */
.input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="tel"],
input[type="url"],
select,
textarea {
  display: block;
  width: 100%;
  height: 2rem;
  padding: 0 0.6rem;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground);
  font-size: 0.825rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  height: auto;
  padding: 0.5rem 0.75rem;
  resize: vertical;
}

.input:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(161, 161, 170, 0.2);
}

.input:disabled,
input:disabled,
select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Form layout ──────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.6rem;
}

.form-row {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

label, .label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--foreground);
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  height: 2.25rem;
  padding: 0 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}
.btn-primary:hover { background: #27272a; }

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-outline {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--muted); }

.btn-ghost {
  background: transparent;
  color: var(--foreground);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--muted); }

.btn-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
  border-color: var(--destructive);
}
.btn-destructive:hover { background: #dc2626; }

.btn-sm {
  height: 1.875rem;
  padding: 0 0.625rem;
  font-size: 0.8rem;
}

/* ── Table ────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead tr {
  background: var(--muted);
  border-bottom: 1px solid var(--border);
}

thead th {
  padding: 0.625rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--muted); }

tbody td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

/* ── Alerts ───────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
}

.alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #b45309;
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #16a34a;
}

/* ── Misc helpers ─────────────────────────────────────────────── */
.text-muted { color: var(--muted-foreground); }
.text-sm { font-size: 0.825rem; }
.text-xs { font-size: 0.75rem; }
.font-semibold { font-weight: 600; }
.gap-2 { gap: 0.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.ml-2 { margin-left: 0.5rem; }
.ms-2 { margin-left: 0.5rem; }
.d-none { display: none; }
.w-full { width: 100%; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--muted);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
}
.badge-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge-warning  { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
.badge-error    { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge-info     { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
