:root {
  --bg: #f8f6fc;
  --panel: #ffffff;
  --ink: #2b2440;
  --muted: #8a7fa3;
  --line: #e8e0f5;
  --brand: #8b5cf6;
  --brand-dark: #7c3aed;
  --brand-2: #f472b6;
  --danger: #f43f5e;
  --warn: #f59e0b;
  --good: #3b82f6;
  --sidebar-from: #35204f;
  --sidebar-to: #4a2a6b;
  --shadow: 0 18px 44px rgba(107, 66, 163, 0.13);
}

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

button, input, select, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.28);
}
button:hover { transform: translateY(-1px); opacity: 0.96; }
button:active { transform: translateY(0); }
button.secondary {
  background: #f3edfb;
  color: var(--brand-dark);
  box-shadow: none;
}
button.secondary:hover { background: #ece2f9; }
.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar-from), var(--sidebar-to));
  color: #fff;
  padding: 24px 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.brand img { width: 44px; height: 44px; }
.brand span { display: block; color: #d9c9f0; font-size: 13px; }

nav { display: grid; gap: 6px; }
.nav-button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #e4d9f5;
  border-radius: 10px;
  box-shadow: none;
}
.nav-button.active, .nav-button:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  transform: none;
  box-shadow: none;
}

.workspace { padding: 28px; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.eyebrow {
  color: var(--brand-2);
  font-weight: 700;
  margin: 0 0 4px;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.04em;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 30px; margin-bottom: 0; color: var(--ink); }

.month-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

.view { display: none; }
.view.active { display: block; }

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--brand);
}
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; font-size: 22px; margin-top: 8px; color: var(--ink); }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--muted); font-weight: 700; }

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}
.green { background: #dbeafe; color: #2563eb; }
.orange { background: #fef1d6; color: #b46a0c; }
.red { background: #ffe0e6; color: #c22a48; }
.gray { background: #f1ecf9; color: var(--muted); }

dialog {
  width: min(760px, calc(100vw - 24px));
  border: 0;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 30px 90px rgba(53, 32, 79, 0.28);
}
dialog::backdrop { background: rgba(43, 27, 66, 0.5); }
dialog header, dialog footer {
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
dialog header { border-bottom: 1px solid var(--line); }
dialog footer { border-top: 1px solid var(--line); justify-content: flex-end; }
.form-grid {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.field.full { grid-column: 1 / -1; }
.field label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
  font-weight: 700;
}

.empty {
  color: var(--muted);
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #faf8fd;
}
.demo-banner {
  background: #fde9f2;
  color: #b23070;
  border: 1px solid #f6c9de;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}
.login-panel {
  max-width: 460px;
}
.login-form {
  display: grid;
  gap: 12px;
}
.form-error {
  color: var(--danger);
  font-weight: 700;
  margin: 0;
}

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 3; padding: 14px; }
  .brand { margin-bottom: 12px; }
  nav { grid-template-columns: repeat(2, 1fr); }
  .workspace { padding: 18px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  nav { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}
