:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --blue: #0f6bdc;
  --blue-dark: #0752b8;
  --blue-soft: #e8f1ff;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --orange: #ea580c;
  --orange-soft: #ffedd5;
  --purple: #6d28d9;
  --purple-soft: #ede9fe;
  --gray-soft: #eef2f7;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 18px;
  --sidebar-width: 304px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: rgba(255, 255, 255, 0.9);
  border-right: 1px solid var(--line);
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border: 3px solid var(--blue);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--blue);
  font-size: 23px;
  position: relative;
}

.brand-icon::before,
.brand-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 4px;
  background: var(--blue);
  border-radius: 999px;
}

.brand-icon::before { top: -8px; }
.brand-icon::after { bottom: -8px; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 16px;
  border-radius: 12px;
  text-align: left;
  transition: 120ms ease;
}

.nav-item:hover { background: #f1f5f9; }
.nav-item.active {
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 700;
}

.nav-icon {
  width: 28px;
  text-align: center;
  font-size: 19px;
}

.sidebar-status {
  margin-top: auto;
  padding: 20px 12px 4px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.sidebar-status strong {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334155;
  font-weight: 700;
  margin-bottom: 5px;
}

.status-dot {
  width: 10px;
  height: 10px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 0 4px var(--green-soft);
}

.main {
  padding: 34px 44px 44px;
  max-width: 1500px;
  width: 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
}

.page-title h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.055em;
}

.page-title p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #334155;
  white-space: nowrap;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: white;
  font-weight: 800;
}

.grid { display: grid; gap: 22px; }
.grid.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 22px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.main-grid { grid-template-columns: 1.05fr 1fr; }

.card, .panel {
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.summary-card {
  min-height: 118px;
  padding: 22px;
  display: flex;
  gap: 18px;
  align-items: center;
}

.summary-icon {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 30px;
  flex: 0 0 auto;
}

.summary-card .label { color: #334155; font-size: 16px; }
.summary-card .value {
  font-size: 38px;
  line-height: 1;
  font-weight: 800;
  margin-top: 6px;
  letter-spacing: -0.04em;
}
.summary-card .sub { color: #475569; margin-top: 6px; font-size: 14px; }
.summary-card .sub a, .link { color: var(--blue); text-decoration: none; font-weight: 700; }
.summary-card .sub a:hover, .link:hover { text-decoration: underline; }

.blue { color: var(--blue); }
.green { color: var(--green); }
.orange { color: var(--orange); }
.purple { color: var(--purple); }
.bg-blue { background: var(--blue-soft); }
.bg-green { background: var(--green-soft); }
.bg-orange { background: var(--orange-soft); }
.bg-purple { background: var(--purple-soft); }

.panel { padding: 0; overflow: hidden; }
.panel-header {
  padding: 20px 22px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.025em;
}
.panel-body { padding: 0 22px 20px; }
.panel-footer { padding: 0 22px 20px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: #334155; font-weight: 800; background: #f8fafc; }
tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.badge.green { background: var(--green-soft); color: #15803d; }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.gray { background: var(--gray-soft); color: #475569; }
.badge.orange { background: var(--orange-soft); color: #c2410c; }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.purple { background: var(--purple-soft); color: var(--purple); }

.actions-stack { display: grid; gap: 12px; }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #0f172a;
  border-radius: 12px;
  min-height: 44px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-weight: 800;
  text-decoration: none;
  transition: 120ms ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.outline { border-color: var(--blue); color: var(--blue); }
.btn.danger { border-color: var(--red-soft); color: var(--red); background: #fff7f7; }
.btn.small { min-height: 34px; padding: 7px 10px; font-size: 13px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--blue); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.form-row { display: grid; gap: 7px; }
.form-row.full { grid-column: 1 / -1; }
label { color: #334155; font-size: 13px; font-weight: 800; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--blue-soft);
  border-color: var(--blue);
}

.empty {
  padding: 28px;
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  color: var(--muted);
  background: #f8fafc;
  text-align: center;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.kpi {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: #fff;
}
.kpi span { color: var(--muted); font-size: 13px; font-weight: 800; }
.kpi strong { display: block; margin-top: 8px; font-size: 30px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  width: min(720px, 100%);
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
  border: 1px solid var(--line);
  overflow: hidden;
}
.modal-header {
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.modal-header h2 { margin: 0; font-size: 22px; }
.modal-body { padding: 22px; }
.modal-actions {
  padding: 0 22px 22px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 10px;
  z-index: 80;
}
.toast {
  min-width: 260px;
  max-width: 420px;
  background: #0f172a;
  color: white;
  padding: 13px 15px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-weight: 700;
}
.toast.error { background: #991b1b; }
.toast.success { background: #166534; }

.note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.mobile-menu { display: none; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }
  .nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sidebar-status { display: none; }
  .main { padding: 24px 18px 40px; }
  .grid.cards, .grid.main-grid, .grid.two, .kpi-row { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
}

@media (max-width: 650px) {
  .brand { font-size: 22px; }
  .nav { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .summary-card { align-items: flex-start; }
}

.actions-cell {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.72;
  cursor: not-allowed;
  background: #f8fafc;
}

.user-chip .btn {
  margin-left: 6px;
}

hr.soft {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

.badge.purple {
  background: var(--purple-soft);
  color: var(--purple);
}

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

.btn.ghost:hover {
  background: #f1f5f9;
  color: var(--text);
}

pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: 12px;
  overflow: auto;
}

.checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}
.checkline input { width: auto; }

.subsection-title {
  margin: 18px 0 10px;
  color: #334155;
  font-size: 15px;
  font-weight: 900;
}
