:root {
  --bg: #eef5f7;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --text: #102033;
  --muted: #66768a;
  --line: rgba(16, 32, 51, 0.10);
  --brand: #0f766e;
  --brand-2: #14b8a6;
  --brand-3: #ecfeff;
  --danger: #dc2626;
  --warning: #b45309;
  --success: #047857;
  --shadow: 0 24px 70px rgba(15, 23, 42, 0.10);
  --soft-shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.24), transparent 30%),
    radial-gradient(circle at 85% 10%, rgba(59, 130, 246, 0.12), transparent 28%),
    linear-gradient(135deg, #f8fbfc 0%, var(--bg) 100%);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 290px;
  padding: 26px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  background: rgba(9, 19, 33, 0.94);
  color: white;
  border-right: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(18px);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 34px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand-2), #2563eb);
  font-weight: 900; font-size: 24px;
  box-shadow: 0 14px 40px rgba(20,184,166,0.34);
}
.brand-title { font-weight: 850; letter-spacing: -0.03em; font-size: 20px; }
.brand-subtitle { color: rgba(255,255,255,0.58); font-size: 13px; margin-top: 2px; }
.nav { display: grid; gap: 8px; }
.nav-item {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 13px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  color: rgba(255,255,255,0.72);
  background: transparent;
  text-align: left;
  transition: 180ms ease;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; transform: translateX(2px); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(20,184,166,0.28), rgba(37,99,235,0.18));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
}
.nav-item span { width: 22px; text-align: center; color: var(--brand-2); }
.sidebar-card {
  position: absolute;
  left: 20px; right: 20px; bottom: 24px;
  border-radius: 22px;
  padding: 18px;
  background: linear-gradient(150deg, rgba(255,255,255,0.12), rgba(255,255,255,0.05));
  border: 1px solid rgba(255,255,255,0.12);
}
.mini-label, .eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-weight: 800; font-size: 11px; color: var(--muted); }
.sidebar .mini-label { color: rgba(255,255,255,0.55); }
.mini-value { font-size: 26px; font-weight: 900; margin: 6px 0; letter-spacing: -0.04em; }
.mini-help { font-size: 12px; line-height: 1.45; color: rgba(255,255,255,0.58); }

.main { flex: 1; padding: 28px; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(30px, 4vw, 46px); line-height: 1; letter-spacing: -0.06em; margin-top: 4px; }
h2 { font-size: clamp(28px, 4vw, 54px); letter-spacing: -0.07em; line-height: 1.02; }
h3 { font-size: 18px; letter-spacing: -0.03em; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.primary-btn, .ghost-btn, .icon-btn, .menu-button {
  border: 0;
  border-radius: 14px;
  min-height: 42px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: 160ms ease;
}
.primary-btn { color: white; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 14px 30px rgba(15,118,110,0.22); }
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 18px 38px rgba(15,118,110,0.28); }
.ghost-btn { background: var(--panel-solid); color: var(--text); border: 1px solid var(--line); box-shadow: 0 8px 22px rgba(15,23,42,0.04); }
.ghost-btn:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(15,23,42,0.08); }
.icon-btn { width: 42px; padding: 0; font-size: 22px; background: #f3f7f8; color: var(--text); }
.menu-button { display: none; background: var(--panel-solid); border: 1px solid var(--line); }
.file-btn { cursor: pointer; }

.hero-card {
  border-radius: var(--radius-xl);
  padding: 30px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.86), rgba(255,255,255,0.62)),
    radial-gradient(circle at top right, rgba(20,184,166,0.24), transparent 32%);
  border: 1px solid rgba(255,255,255,0.80);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.hero-card::after {
  content: "";
  position: absolute;
  width: 220px; height: 220px;
  border-radius: 999px;
  background: rgba(20,184,166,0.10);
  right: -70px; top: -80px;
}
.hero-card > * { position: relative; z-index: 1; }
.hero-card p { color: var(--muted); margin-top: 10px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 12px; }
.hero-stats div {
  border-radius: 20px;
  padding: 16px;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(255,255,255,0.9);
  min-width: 132px;
}
.hero-stats span { display: block; font-weight: 900; font-size: 18px; letter-spacing: -0.04em; }
.hero-stats small { display: block; margin-top: 4px; color: var(--muted); }

.content-area { display: grid; gap: 20px; }
.grid { display: grid; gap: 18px; }
.grid.kpis { grid-template-columns: repeat(4, minmax(180px, 1fr)); }
.grid.two { grid-template-columns: 1.25fr 0.75fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.card {
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.78);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(20px);
  overflow: hidden;
}
.card-pad { padding: 22px; }
.card-header {
  padding: 20px 22px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}
.card-header p { color: var(--muted); margin-top: 4px; font-size: 13px; }
.kpi-card { padding: 20px; position: relative; min-height: 150px; }
.kpi-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.kpi-icon {
  width: 42px; height: 42px; border-radius: 15px;
  display: grid; place-items: center;
  background: var(--brand-3);
  color: var(--brand);
  font-weight: 900;
}
.kpi-card .label { color: var(--muted); font-size: 13px; font-weight: 700; }
.kpi-card .value { font-size: 30px; font-weight: 950; letter-spacing: -0.06em; margin-top: 14px; }
.kpi-card .note { color: var(--muted); font-size: 12px; margin-top: 8px; }
.trend { font-size: 12px; font-weight: 800; padding: 6px 9px; border-radius: 999px; background: #ecfdf5; color: var(--success); }
.trend.warn { background: #fff7ed; color: var(--warning); }
.trend.danger { background: #fef2f2; color: var(--danger); }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 840px; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); background: rgba(248,250,252,0.78); }
td { font-size: 14px; }
tbody tr:hover { background: rgba(20,184,166,0.05); }
.actions { display: flex; gap: 8px; }
.small-btn {
  border: 1px solid var(--line);
  background: white;
  min-height: 34px;
  border-radius: 10px;
  padding: 0 10px;
  color: var(--text);
}
.small-btn.delete { color: var(--danger); }
.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #ecfdf5;
  color: var(--success);
}
.status.closed, .status.inactive { background: #f1f5f9; color: #475569; }
.status.warning { background: #fff7ed; color: var(--warning); }

.chart-card { min-height: 360px; }
.chart-area { padding: 20px 22px 24px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 96px; align-items: center; gap: 12px; margin: 14px 0; }
.bar-label { font-weight: 750; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 12px; background: #e8f1f2; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.bar-value { color: var(--muted); text-align: right; font-size: 13px; }
.donut-layout { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: center; }
.donut {
  width: 170px; height: 170px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--brand) 0deg, var(--brand-2) 130deg, #2563eb 130deg, #8b5cf6 260deg, #cbd5e1 260deg);
  box-shadow: inset 0 0 0 18px rgba(255,255,255,0.72);
}
.donut span { background: white; border-radius: 999px; width: 96px; height: 96px; display: grid; place-items: center; text-align: center; font-weight: 900; font-size: 14px; box-shadow: 0 10px 28px rgba(15,23,42,0.08); }
.legend { display: grid; gap: 10px; }
.legend-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: 13px; }
.legend-left { display: flex; gap: 9px; align-items: center; min-width: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.svg-chart { width: 100%; height: 230px; display: block; }
.empty-state { padding: 28px; color: var(--muted); text-align: center; }
.progress {
  width: 100%; height: 10px; border-radius: 999px; background: #e8f1f2; overflow: hidden;
}
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: inherit; }

.modal { border: 0; padding: 0; background: transparent; width: min(820px, calc(100vw - 28px)); }
.modal::backdrop { background: rgba(15, 23, 42, 0.52); backdrop-filter: blur(5px); }
.modal-card {
  border-radius: 28px;
  background: rgba(255,255,255,0.96);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
  border: 1px solid rgba(255,255,255,0.86);
  overflow: hidden;
}
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding: 24px 24px 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 14px; padding: 16px 24px 24px; }
.field { display: grid; gap: 7px; }
.field label { font-size: 12px; font-weight: 850; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #f8fbfc;
  min-height: 46px;
  border-radius: 14px;
  padding: 0 13px;
  outline: none;
  color: var(--text);
}
.field textarea { padding-top: 12px; min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: rgba(20,184,166,0.7); box-shadow: 0 0 0 4px rgba(20,184,166,0.12); }
.modal-actions { padding: 16px 24px 24px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); }

@media (max-width: 1100px) {
  .grid.kpis { grid-template-columns: repeat(2, 1fr); }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .hero-card { align-items: stretch; flex-direction: column; }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; transform: translateX(-110%); transition: 220ms ease; }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 18px; }
  .menu-button { display: inline-flex; }
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .hero-stats, .grid.kpis { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .donut-layout { grid-template-columns: 1fr; justify-items: center; }
  .bar-row { grid-template-columns: 120px 1fr; }
  .bar-value { display: none; }
}


.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: #0f172a;
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.22);
  border-radius: 16px;
  padding: 12px 16px;
  font-weight: 700;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.error {
  background: #7f1d1d;
}

dialog[open] {
  display: block;
}
