:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f9fbff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #1e3a8a;
  --primary-soft: #dbeafe;
  --success: #15803d;
  --success-soft: #dcfce7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: Inter, Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
.hidden { display: none !important; }

#app { min-height: 100vh; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(30, 58, 138, 0.16), transparent 30%),
    radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.12), transparent 25%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1e3a8a, #0ea5e9);
  color: white;
  font-weight: 700;
  font-size: 18px;
}

.brand-title { font-size: 28px; font-weight: 700; margin: 0; }
.brand-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.form-input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 14px;
  background: white;
  transition: 0.2s ease;
}
.form-input:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.button {
  border: none;
  border-radius: 14px;
  height: 48px;
  padding: 0 18px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background-color 0.15s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }
.button-primary { background: var(--primary); color: white; font-weight: 700; width: 100%; }
.button-secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.button-ghost { background: transparent; color: var(--muted); }
.button-small { height: 38px; border-radius: 12px; padding: 0 14px; }

.login-hint {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 13px;
}

.error-box,
.info-box,
.success-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
}
.error-box { background: var(--danger-soft); color: var(--danger); }
.info-box { background: #eff6ff; color: #1d4ed8; }
.success-box { background: var(--success-soft); color: var(--success); }

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

.sidebar {
  background: #0f172a;
  color: white;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar .brand-subtitle { color: #94a3b8; }
.nav-list { display: grid; gap: 10px; }
.nav-button {
  width: 100%;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 600;
}
.nav-button.active,
.nav-button:hover { background: rgba(255,255,255,0.08); color: white; }
.sidebar-footer { margin-top: auto; }

.main {
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.topbar h1 { margin: 0; font-size: 30px; }
.topbar p { margin: 6px 0 0; color: var(--muted); }
.topbar-actions { display: flex; gap: 12px; align-items: center; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 20px;
}
.stat-label { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.stat-value { font-size: 28px; font-weight: 800; }
.stat-subtext { margin-top: 8px; color: var(--muted); font-size: 13px; }

.content-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 18px;
}

.section { padding: 20px; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.section-title { margin: 0; font-size: 20px; }
.section-subtitle { color: var(--muted); font-size: 14px; margin-top: 4px; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
}
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}
.table th, .table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}
.table th { color: var(--muted); background: #fafcff; font-weight: 700; }
.table tr:last-child td { border-bottom: none; }
.table td strong { display: block; }
.table td small { color: var(--muted); }

.clickable-row { cursor: pointer; transition: background-color .15s ease; }
.clickable-row:hover { background: #f8fbff; }
.clickable-card { cursor: pointer; transition: border-color .15s ease, transform .15s ease; }
.clickable-card:hover { border-color: #bfdbfe; transform: translateY(-1px); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-muted { background: #e2e8f0; color: #475569; }
.badge-primary { background: var(--primary-soft); color: var(--primary); }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.switch {
  position: relative;
  width: 46px;
  height: 26px;
  display: inline-block;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: .2s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: white;
  transition: .2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background: #22c55e; }
.switch input:checked + .slider::before { transform: translateX(20px); }

.summary-list {
  display: grid;
  gap: 12px;
}
.summary-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fcfdff;
}
.summary-item h4 { margin: 0 0 6px; font-size: 15px; }
.summary-item p { margin: 0; color: var(--muted); font-size: 13px; }
.summary-price { font-size: 16px; font-weight: 800; white-space: nowrap; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.search-input {
  min-width: 220px;
  flex: 1;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0 12px;
  background: white;
}

.empty-state {
  padding: 32px 18px;
  text-align: center;
  color: var(--muted);
}
.compact-empty {
  padding: 18px 12px;
}

.loader {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: white;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  justify-content: flex-end;
  z-index: 1000;
  padding: 18px;
}

.detail-modal {
  width: min(920px, 100%);
  height: 100%;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
  padding: 24px;
  overflow: auto;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.detail-overline {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 700;
}
.detail-title {
  margin: 6px 0;
  font-size: 28px;
}
.detail-subtitle {
  color: var(--muted);
  font-size: 14px;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.detail-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  background: #fbfdff;
  margin-bottom: 16px;
}
.detail-card-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 14px;
}
.kv-list {
  display: grid;
  gap: 12px;
}
.kv-list > div {
  display: grid;
  gap: 4px;
}
.kv-list span {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.kv-list strong {
  font-size: 14px;
  font-weight: 700;
}
.person-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.person-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
}
.person-index {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}
.person-name {
  font-weight: 800;
  margin-bottom: 8px;
}
.person-meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}
.break-text {
  word-break: break-word;
}
.inner-table-wrap {
  background: #fff;
}
.payment-table {
  min-width: 720px;
}
.detail-footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.price-chip {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: #ecfeff;
  color: #0f766e;
  font-weight: 800;
}
.muted-chip {
  background: #eef2ff;
  color: #4338ca;
}

@media (max-width: 1120px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .detail-grid,
  .person-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .dashboard-shell { grid-template-columns: 1fr; }
  .sidebar { padding-bottom: 12px; }
  .main { padding: 18px; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .modal-backdrop { padding: 0; }
  .detail-modal { border-radius: 0; width: 100%; }
}

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 24px; border-radius: 22px; }
  .detail-header { flex-direction: column; }
  .detail-title { font-size: 22px; }
}
