:root {
  --brand-purple: #562a99;
  --brand-yellow: #f3b632;
  --brand-purple-strong: #3e1f73;
  --brand-purple-light: #f0eafc;
  --brand-yellow-soft: #ffe9bd;

  --bg: #f4f6fb;
  --bg-soft: #eef1f9;
  --surface: #ffffff;
  --surface-muted: #f8f9ff;
  --text: #131a3b;
  --text-muted: #5f6785;
  --line: #dde2f0;

  --success: #0f9f6f;
  --warning: #c67d00;
  --danger: #cf2e3a;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;

  --shadow-sm: 0 2px 10px rgba(14, 25, 52, 0.07), 0 1px 3px rgba(14, 25, 52, 0.04);
  --shadow-md: 0 8px 28px rgba(14, 25, 52, 0.13), 0 2px 8px rgba(14, 25, 52, 0.06);
  --shadow-purple: 0 8px 20px rgba(86, 42, 153, 0.28);

  --topbar-height: 64px;
  --sidebar-width: 240px;
  --sidebar-collapsed: 72px;

  --skeleton-base: #e5e9f5;
  --skeleton-highlight: #f2f5ff;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  font-family: "Ubuntu", "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(circle at 8% 12%, #fafbff 0%, #eef1fa 40%, #e8ebf6 100%);
  color: var(--text);
}

h1, h2, h3, h4, .display-font {
  margin: 0;
  font-family: "League Spartan", "Ubuntu", sans-serif;
  letter-spacing: 0.02em;
}

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

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

.hidden { display: none !important; }
.app-shell { min-height: 100vh; }
.view { animation: fadeIn 0.22s ease; }

/* ── Page header ── */
.page-title {
  font-size: 1.55rem;
  color: var(--text);
  line-height: 1.2;
}

.page-subtitle {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 0.91rem;
}

/* ── Panel ── */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

/* ── Inputs ── */
.input, .select, .textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  padding: 9px 12px;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-purple);
  box-shadow: 0 0 0 3px rgba(86, 42, 153, 0.13);
}

.input.error, .select.error, .textarea.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(207, 46, 58, 0.13);
}

.input::placeholder, .textarea::placeholder { color: #b0b8cf; }

.field-error { margin-top: 5px; color: var(--danger); font-size: 0.8rem; }

.label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-grid { display: grid; gap: 12px; }

/* ── Buttons ── */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.14s, box-shadow 0.14s, background 0.14s, opacity 0.14s;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  color: #fff;
  background: linear-gradient(130deg, var(--brand-purple) 0%, var(--brand-purple-strong) 100%);
  box-shadow: var(--shadow-purple);
}
.btn-primary:hover { box-shadow: 0 10px 24px rgba(86, 42, 153, 0.36); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 1px 3px rgba(14, 25, 52, 0.06);
}
.btn-secondary:hover {
  background: var(--brand-purple-light);
  border-color: #cdb8f0;
  color: var(--brand-purple);
}

.btn-accent {
  color: #1c1d26;
  background: linear-gradient(130deg, #ffd062 0%, var(--brand-yellow) 100%);
  box-shadow: 0 6px 16px rgba(243, 182, 50, 0.28);
}

.btn-danger {
  color: #fff;
  background: linear-gradient(130deg, #e8525f 0%, #c82c3a 100%);
  box-shadow: 0 6px 16px rgba(207, 46, 58, 0.22);
}
.btn-danger:hover { box-shadow: 0 8px 20px rgba(207, 46, 58, 0.36); }

/* Compact variant — used in table rows */
.btn-sm,
.table-wrap .btn {
  padding: 5px 11px;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-success { color: #0b7a56; background: #d4f5e8; }
.badge-warning { color: #8f5a00; background: #ffecbf; }
.badge-danger  { color: #9f2730; background: #ffd6da; }
.badge-muted   { color: #46527e; background: #e8ecf9; }

/* ── Table ── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

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

th, td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid #eaedfa;
  font-size: 0.87rem;
  vertical-align: middle;
}

th {
  background: linear-gradient(180deg, #f3effe 0%, #ebe4f8 100%);
  font-weight: 700;
  font-size: 0.76rem;
  color: var(--brand-purple-strong);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid #d4c4ef;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8f5ff; }

/* ── KPI Cards ── */
.kpi-grid { display: grid; gap: 14px; }

.kpi-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 16px 16px 14px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-purple), #9b6fe0);
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.kpi-card .kpi-title {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-card .kpi-value {
  display: block;
  margin-top: 8px;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text);
  font-family: "League Spartan", "Ubuntu", sans-serif;
  line-height: 1;
}

.kpi-card .kpi-trend {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.kpi-trend.up   { color: var(--success); }
.kpi-trend.down { color: var(--danger); }

/* ── Skeleton ── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--skeleton-base) 25%,
    var(--skeleton-highlight) 50%,
    var(--skeleton-base) 75%
  );
  background-size: 200% 100%;
  animation: skeletonPulse 1.5s linear infinite;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

/* ── Animations ── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes skeletonPulse {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .page-title { font-size: 1.38rem; }
}
