:root {
  --sidebar: #0f1b2d;
  --sidebar-hover: #162338;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --orange: #ea580c;
  --orange-soft: #fff7ed;
  --purple: #7c3aed;
  --purple-soft: #f3e8ff;
  --blue-soft: #dbeafe;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box }
html, body { margin: 0; min-height: 100% }
body {
  font-family: "Segoe UI", Montserrat, system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}
a { color: inherit; text-decoration: none }
button, input, select, textarea { font: inherit }

/* ── Shell ─────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh }
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--sidebar); color: #fff;
  display: flex; flex-direction: column; padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 8px 22px; border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 18px;
}
.sidebar-logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(145deg, #1d4ed8, #3b82f6);
  display: grid; place-items: center; font-size: 1.15rem;
  box-shadow: 0 8px 18px rgba(37, 99, 235, .35);
}
.sidebar-brand strong { display: block; font-size: 1.05rem; letter-spacing: -.02em }
.sidebar-brand small { display: block; color: #94a3b8; font-size: .72rem; margin-top: 2px }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1 }
.sidebar-nav a, .sidebar-nav button.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 10px; color: #cbd5e1;
  font-size: .9rem; font-weight: 600; border: 0; background: transparent;
  cursor: pointer; text-align: left; width: 100%;
}
.sidebar-nav a:hover, .sidebar-nav button.nav-link:hover { background: var(--sidebar-hover); color: #fff }
.sidebar-nav a.active {
  background: var(--accent); color: #fff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, .35);
}
.sidebar-nav .ico { width: 18px; text-align: center; opacity: .9 }
.sidebar-foot {
  border-top: 1px solid rgba(255,255,255,.08); padding-top: 14px; margin-top: 12px;
}
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border-radius: 10px; margin-bottom: 8px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #334155; color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: .9rem; flex-shrink: 0;
}
.user-chip .meta { min-width: 0 }
.user-chip .meta strong { display: block; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.user-chip .meta span { display: block; font-size: .68rem; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.logout-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 10px 12px; border: 0; border-radius: 10px;
  background: transparent; color: #94a3b8; font-weight: 600; font-size: .85rem; cursor: pointer;
}
.logout-btn:hover { background: var(--sidebar-hover); color: #fff }

.main { flex: 1; min-width: 0; padding: 28px 32px 48px }
.page-head { margin-bottom: 22px }
.page-head h1 { margin: 0; font-size: 1.75rem; letter-spacing: -.03em }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: .95rem }

/* ── Cards / KPI ───────────────────────────────────── */
.kpi-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px;
}
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.kpi .label { font-size: .78rem; color: var(--muted); font-weight: 600 }
.kpi .value { margin-top: 4px; font-size: 1.65rem; font-weight: 800; letter-spacing: -.03em }
.kpi-ico {
  width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-size: 1.15rem;
}
.kpi-ico.blue { background: var(--blue-soft); color: var(--accent) }
.kpi-ico.green { background: var(--green-soft); color: var(--green) }
.kpi-ico.orange { background: var(--orange-soft); color: var(--orange) }
.kpi-ico.purple { background: var(--purple-soft); color: var(--purple) }

.action-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px;
}
.action-card {
  position: relative; display: block; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; transition: border-color .15s, transform .15s;
}
.action-card:hover { border-color: #bfdbfe; transform: translateY(-1px) }
.action-card .arrow { position: absolute; top: 16px; right: 16px; color: #94a3b8 }
.action-ico {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center;
  font-size: 1.35rem; margin-bottom: 14px;
}
.action-ico.blue { background: var(--blue-soft); color: var(--accent) }
.action-ico.orange { background: var(--orange-soft); color: var(--orange) }
.action-card h3 { margin: 0 0 6px; font-size: 1.05rem }
.action-card p { margin: 0; color: var(--muted); font-size: .88rem; max-width: 36ch }

.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px;
}
.panel-head h2 { margin: 0; font-size: 1.05rem }
.panel-head a { color: var(--accent); font-size: .88rem; font-weight: 700 }

.recent-list { display: flex; flex-direction: column; gap: 8px }
.recent-item {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
  transition: background .15s, border-color .15s;
}
.recent-item:hover { background: #f8fafc; border-color: #cbd5e1 }
.recent-ico {
  width: 40px; height: 40px; border-radius: 10px; background: var(--blue-soft);
  color: var(--accent); display: grid; place-items: center; flex-shrink: 0;
}
.recent-body { flex: 1; min-width: 0 }
.recent-body .top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px }
.recent-body .id { font-weight: 700; font-size: .92rem }
.recent-body .sub { margin-top: 2px; color: var(--muted); font-size: .82rem }
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 700;
}
.badge.ok { background: var(--green-soft); color: var(--green) }
.badge.blue { background: var(--blue-soft); color: var(--accent) }
.badge.orange { background: var(--orange-soft); color: var(--orange) }
.chev { color: #94a3b8 }

/* ── Forms / tables ────────────────────────────────── */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 700; font-size: .88rem; cursor: pointer; background: #e2e8f0; color: var(--text);
}
.button.primary { background: var(--accent); color: #fff }
.button.primary:hover { background: #1d4ed8 }
.button.outline { background: #fff; border-color: var(--border) }
.button.outline:hover { border-color: #94a3b8 }
.button.danger { background: #fef2f2; color: var(--danger); border-color: #fecaca }
.button.small { min-height: 34px; padding: 0 12px; font-size: .8rem }

.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px;
}
label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
input, select, textarea {
  min-height: 40px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
}
textarea { min-height: 110px; resize: vertical }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px }
.form-grid .full { grid-column: 1 / -1 }
.actions-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px }

.table-scroll { overflow-x: auto }
table { width: 100%; border-collapse: collapse; font-size: .88rem }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top }
th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em }
tr:hover td { background: #f8fafc }
.num { text-align: right; font-variant-numeric: tabular-nums }
.empty { padding: 28px; text-align: center; color: var(--muted) }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .88rem }
.alert.error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b }
.alert.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534 }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px }
.muted { color: var(--muted) }

/* ── Login ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(37,99,235,.12), transparent 40%),
    radial-gradient(circle at 80% 0%, rgba(124,58,237,.08), transparent 35%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%); background: #fff; border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow); padding: 32px 28px;
}
.login-card .brand-line {
  display: flex; align-items: center; gap: 10px; margin-bottom: 18px;
}
.login-card h1 { margin: 0 0 6px; font-size: 1.45rem }
.login-card .lead { margin: 0 0 18px; color: var(--muted) }
.login-card form { display: grid; gap: 14px }
.login-card .button { width: 100% }

@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr) }
}
@media (max-width: 860px) {
  .app-shell { flex-direction: column }
  .sidebar { width: 100%; height: auto; position: relative }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap }
  .action-row, .grid-2, .form-grid { grid-template-columns: 1fr }
  .main { padding: 20px 16px 40px }
}
