:root {
  --purple: #7b4fb8;
  --purple-dark: #5b3690;
  --purple-light: #f1e9fb;
  --ink: #241f33;
  --muted: #6b6580;
  --bg: #f4f3f9;
  --card: #ffffff;
  --border: #eae7f2;
  --success: #2f9e63;
  --pending: #d69a1f;
  --danger: #d1483f;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

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

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 24px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-text strong { display: block; font-size: 15px; }
.brand-text span { display: block; font-size: 12px; color: var(--muted); }

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.nav-list a {
  display: block;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}
.nav-list a:hover { background: var(--purple-light); text-decoration: none; }
.nav-list a.active { background: var(--purple-light); color: var(--purple-dark); font-weight: 700; }

.main {
  flex: 1;
  min-width: 0;
  padding: 32px 40px;
}

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

.topbar h1 { margin: 0 0 4px; font-size: 26px; }
.topbar .subtitle { margin: 0; color: var(--muted); font-size: 14px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 8px 8px 18px;
  font-size: 13px;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; }
.btn-primary { background: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-dark); }
.btn-ghost { background: var(--purple-light); color: var(--purple-dark); }
.btn-sm { padding: 6px 14px; font-size: 12px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
}

.card h2 { margin: 0 0 18px; font-size: 17px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px 24px;
}
.stat-card .label { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.stat-card .value { font-size: 32px; font-weight: 800; }

.stack { display: flex; flex-direction: column; gap: 24px; margin-bottom: 24px; }

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -24px;
  padding: 0 24px;
}

table.data-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 14px;
}
table.data-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--border);
}
table.data-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table .empty-row td { text-align: center; color: var(--muted); padding: 32px 12px; }

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge-completed { background: #e3f6ea; color: var(--success); }
.badge-pending { background: #fbf0da; color: var(--pending); }
.badge-draft { background: #ece9f5; color: var(--muted); }

.badge-admin { background: #e3f6ea; color: var(--success); }
.badge-staff { background: var(--purple-light); color: var(--purple-dark); }

.bars { display: flex; align-items: flex-end; gap: 14px; height: 180px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 8px; }
.bar-col .bar { width: 100%; max-width: 34px; background: var(--purple); border-radius: 6px 6px 0 0; min-height: 3px; }
.bar-col .bar-label { font-size: 11px; color: var(--muted); }

.donut-legend { display: flex; flex-direction: column; gap: 12px; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-row .count { margin-left: auto; font-weight: 700; }

.empty-note { color: var(--muted); text-align: center; padding: 40px 0; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.form-field .hint { font-size: 12px; color: var(--muted); }
.form-field input,
.form-field select,
.form-field textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--purple);
}
.form-actions { display: flex; gap: 12px; margin-top: 24px; }

.flash { padding: 12px 18px; border-radius: 10px; margin-bottom: 20px; font-size: 14px; font-weight: 500; }
.flash-success { background: #e3f6ea; color: var(--success); }
.flash-error { background: #fcebe9; color: var(--danger); }

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #efe8fb, #f4f3f9 60%);
}
.auth-card {
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(91, 54, 144, 0.12);
}
.auth-card .brand { border-bottom: none; margin-bottom: 20px; justify-content: center; }
.auth-card h1 { font-size: 20px; text-align: center; margin: 0 0 6px; }
.auth-card p.sub { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.auth-card .form-field { margin-bottom: 16px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 11px; }
.auth-demo { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.section-header h1 { margin: 0; font-size: 24px; }

.pill-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.pill-tabs a { padding: 7px 16px; border-radius: 999px; background: #fff; border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--muted); }
.pill-tabs a.active { background: var(--purple); color: #fff; border-color: var(--purple); }

.detail-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
.detail-list dt { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 4px; }
.detail-list dd { margin: 0; font-size: 15px; font-weight: 600; }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .brand {
    padding: 0 16px 0 0;
    margin-bottom: 0;
    border-bottom: none;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
  }
  .brand-text { white-space: nowrap; }
  .nav-list {
    flex-direction: row;
    flex-shrink: 0;
    gap: 4px;
  }
  .nav-list a { white-space: nowrap; padding: 10px 14px; }
  .main { padding: 20px 16px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .user-chip { justify-content: space-between; }
  .section-header { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
  .stat-card .value { font-size: 26px; }
  .auth-card { padding: 28px 22px; }
}
