:root {
  --bg: #0b1120;
  --panel: #151f32;
  --panel-2: #1e293b;
  --border: #263449;
  --border-soft: rgba(148, 163, 184, 0.16);
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-soft: rgba(16, 185, 129, 0.12);
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #38bdf8;
  --radius: 18px;
  --radius-small: 13px;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  background: radial-gradient(circle at top left, rgba(18, 32, 58, 0.95), transparent 38%), var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
a { color: var(--info); font-weight: 700; }
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 290px;
  min-width: 290px;
  height: 100vh;
  position: sticky;
  top: 0;
  padding: 26px 22px;
  background: rgba(15, 23, 42, 0.97);
  border-right: 1px solid var(--border);
}
.sidebar > #menu { display: flex; flex-direction: column; min-height: calc(100vh - 52px); }
.brand { display: flex; align-items: center; gap: 13px; margin-bottom: 30px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 12px 26px rgba(16, 185, 129, 0.22);
  font-size: 23px;
}
.logo { font-size: 25px; font-weight: 900; letter-spacing: -0.6px; }
.logo span { color: var(--primary); }
.subtitle { margin-top: 4px; color: var(--muted); font-size: 12px; }
.menu { display: flex; flex-direction: column; gap: 8px; }
.menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border-radius: 14px;
  color: #cbd5e1;
  text-decoration: none;
  transition: 0.2s ease;
  font-weight: 700;
}
.menu a:hover { color: #fff; background: var(--panel-2); transform: translateX(3px); }
.menu a.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 10px 24px rgba(16, 185, 129, 0.22);
}
.menu-icon { width: 24px; text-align: center; font-size: 18px; }
.sidebar-footer { margin-top: auto; padding-top: 24px; }
.sidebar-version { margin-bottom: 12px; color: #64748b; font-size: 12px; text-align: center; }
.logout-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid rgba(239, 68, 68, 0.24);
  border-radius: 13px;
  color: #fecaca;
  background: rgba(127, 29, 29, 0.16);
  cursor: pointer;
  font-weight: 800;
  transition: 0.2s ease;
}
.logout-button:hover { background: rgba(239, 68, 68, 0.2); border-color: rgba(239, 68, 68, 0.45); transform: translateY(-2px); }
.content { flex: 1; min-width: 0; padding: 30px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.topbar h1 { margin: 0; font-size: clamp(27px, 4vw, 36px); letter-spacing: -1px; }
.topbar-description { max-width: 720px; margin: 8px 0 0; color: var(--muted); line-height: 1.55; }
.eyebrow { margin: 0 0 7px; color: var(--primary); font-size: 12px; font-weight: 900; letter-spacing: 1.2px; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.system-status, .user-block {
  min-height: 52px;
  padding: 11px 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(21, 31, 50, 0.92);
}
.system-status { display: flex; align-items: center; gap: 9px; white-space: nowrap; font-weight: 800; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.12); }
.status-loading .status-dot { background: var(--warning); box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.12); }
.status-error .status-dot { background: var(--danger); box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.12); }
.user-block { display: flex; flex-direction: column; justify-content: center; min-width: 165px; }
.user-role { margin-bottom: 2px; color: var(--muted); font-size: 12px; }
.dashboard-toolbar {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-bottom: 20px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(21, 31, 50, 0.72);
}
.dashboard-toolbar > div { display: flex; flex-direction: column; gap: 4px; }
.toolbar-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.dashboard-toolbar .btn { margin-left: auto; }
.stats-grid, .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card, .card, .panel { border: 1px solid var(--border); border-radius: var(--radius); background: rgba(21, 31, 50, 0.92); box-shadow: var(--shadow); }
.stat-card { display: flex; align-items: center; gap: 16px; min-height: 145px; padding: 22px; transition: 0.2s ease; }
.stat-card:hover, .card:hover { transform: translateY(-4px); border-color: rgba(16, 185, 129, 0.45); }
.stat-icon { display: grid; place-items: center; flex: 0 0 52px; width: 52px; height: 52px; border-radius: 16px; background: var(--primary-soft); font-size: 24px; }
.stat-card > div:last-child { display: flex; flex-direction: column; }
.stat-label, .card-title { color: var(--muted); font-size: 13px; font-weight: 800; }
.stat-value, .card-number { margin: 5px 0; color: var(--primary); font-size: 34px; font-weight: 900; line-height: 1; word-break: break-word; }
.stat-help { color: #64748b; font-size: 12px; line-height: 1.35; }
.card { padding: 24px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(270px, 0.8fr); gap: 18px; }
.panel { padding: 22px; }
.panel h2 { margin: 0; font-size: 21px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.table-container { width: 100%; overflow-x: auto; border: 1px solid var(--border-soft); border-radius: 14px; }
table { width: 100%; min-width: 860px; border-collapse: collapse; }
th { padding: 14px; color: var(--primary); background: rgba(15, 23, 42, 0.84); font-size: 12px; letter-spacing: 0.5px; text-align: left; text-transform: uppercase; }
td { padding: 14px; border-top: 1px solid var(--border); color: #dbe5f3; text-align: left; }
tbody tr { transition: 0.15s ease; }
tbody tr:hover { background: rgba(255, 255, 255, 0.035); }
.empty-state { padding: 30px; color: var(--muted); text-align: center; }
.table-link { display: inline-flex; padding: 7px 10px; border-radius: 9px; color: #bae6fd; background: rgba(56, 189, 248, 0.1); text-decoration: none; }
.quick-actions { display: flex; flex-direction: column; gap: 11px; }
.quick-action {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: rgba(15, 23, 42, 0.48);
  text-decoration: none;
  transition: 0.2s ease;
}
.quick-action:hover { border-color: rgba(16, 185, 129, 0.48); background: var(--primary-soft); transform: translateX(3px); }
.quick-action-icon { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border-radius: 12px; background: var(--panel-2); font-size: 20px; }
.quick-action span:last-child { display: flex; flex-direction: column; gap: 3px; }
.quick-action small { color: var(--muted); font-weight: 500; }
.latest-summary { display: grid; gap: 7px; margin-top: 20px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: rgba(15, 23, 42, 0.45); }
.latest-summary strong + .summary-label { margin-top: 10px; }
.summary-label { color: var(--muted); font-size: 12px; font-weight: 800; }
.btn, button, input, select, textarea { border-radius: var(--radius-small); }
input, select, textarea { width: 100%; padding: 13px 14px; border: 1px solid var(--border); color: var(--text); background: #0f172a; font-size: 15px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: rgba(16, 185, 129, 0.65); box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1); }
input::placeholder, textarea::placeholder { color: #64748b; }
.btn, button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 14px; border: none; color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); cursor: pointer; font-weight: 800; text-decoration: none; transition: 0.2s ease; }
.btn:hover, button:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(16, 185, 129, 0.25); }
button:disabled { opacity: 0.65; cursor: wait; transform: none; box-shadow: none; }
.btn-secondary { border: 1px solid var(--border); color: #dbeafe; background: var(--panel-2); box-shadow: none; }
.btn-secondary:hover { border-color: rgba(56, 189, 248, 0.4); box-shadow: none; }
.btn-danger, button[style*="d63031"] { background: linear-gradient(135deg, #ef4444, #b91c1c) !important; }
.ok { color: var(--primary); }
.error, .danger, .error-text { color: var(--danger); }
.muted { color: var(--muted); }
.notification { position: fixed; right: 24px; bottom: 24px; z-index: 1000; max-width: min(420px, calc(100vw - 48px)); padding: 14px 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(15px); transition: 0.22s ease; }
.notification.visible { opacity: 1; transform: translateY(0); }
.notification-error { border-color: rgba(239, 68, 68, 0.45); color: #fecaca; }
@media (max-width: 1120px) { .dashboard-grid { grid-template-columns: 1fr; } .quick-panel { order: -1; } }
@media (max-width: 850px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; min-width: 0; height: auto; position: relative; }
  .sidebar > #menu { min-height: 0; }
  .menu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar-footer { margin-top: 22px; }
  .content { padding: 18px; }
  .topbar { flex-direction: column; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .system-status, .user-block { flex: 1; }
  .dashboard-toolbar { align-items: stretch; flex-direction: column; gap: 14px; }
  .dashboard-toolbar .btn { width: 100%; margin-left: 0; }
}
@media (max-width: 560px) {
  .sidebar { padding: 20px 16px; }
  .menu { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar-actions { flex-direction: column; align-items: stretch; }
  .stats-grid, .cards { grid-template-columns: 1fr; }
  .stat-card { min-height: 125px; }
  .panel { padding: 17px; }
  .panel-header { align-items: flex-start; flex-direction: column; }
  .panel-header .btn { width: 100%; }
}
