:root {
  --bg: #0A0C0F;
  --surface: #16191E;
  --surface-2: #1C2026;
  --blue: #0077C8;
  --blue-light: #3D9BE0;
  --maroon: #8E0F2A;
  --maroon-light: #C2233F;
  --text: #E6E7E8;
  --text-dim: #9AA0A8;
  --text-faint: #6b7280;
  --border: rgba(255,255,255,.08);
  --border-soft: rgba(255,255,255,.05);
  --green: #2E9E5B;
  --amber: #C8860B;
}

* { box-sizing: border-box; }

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

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

.mono { font-family: ui-monospace, Menlo, monospace; }

/* ---------- App Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: transform .2s ease;
  z-index: 50;
}
.sidebar .brand {
  padding: 14px 20px;
  font-weight: 700;
  font-size: 16px;
  color: var(--blue-light);
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-img { max-width: 160px; height: auto; display: block; }
.sidebar nav { padding: 10px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--text-dim); font-size: 13.5px; font-weight: 500;
  margin-bottom: 2px;
}
.sidebar nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--surface-2); color: var(--blue-light); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; position: sticky; top: 0; z-index: 40;
}
.topbar .menu-toggle { display: none; background: none; border: none; color: var(--text); font-size: 20px; cursor: pointer; }
.topbar .lang-switch { margin: 0; }
.topbar .lang-switch select {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font-size: 12.5px; cursor: pointer;
}
.topbar .user-menu { display: flex; align-items: center; gap: 12px; color: var(--text-dim); font-size: 13px; }
.topbar .user-menu strong { color: var(--text); }
.topbar .badge-role {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  background: var(--surface-2); color: var(--blue-light); padding: 2px 8px; border-radius: 99px;
}

.content { padding: 24px; flex: 1; }
.content-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px;
}
.content-header h1 { font-size: 22px; margin: 0; font-weight: 700; }
.breadcrumb { color: var(--text-faint); font-size: 12px; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #0089e6; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #232830; }
.btn-danger { background: var(--maroon); color: #fff; }
.btn-danger:hover { background: var(--maroon-light); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- Cards / Forms ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; margin-bottom: 20px;
}
.card h2 { font-size: 15px; margin: 0 0 16px; color: var(--blue-light); }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid.single { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.form-group .hint { font-size: 11.5px; color: var(--text-faint); }

input[type=text], input[type=password], input[type=number], input[type=date],
input[type=email], input[type=tel], select, textarea {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 9px 12px; border-radius: 8px; font-size: 13.5px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-light); outline-offset: 0; border-color: var(--blue-light); }
textarea { resize: vertical; min-height: 70px; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filter-bar input, .filter-bar select { min-width: 160px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-faint); border-bottom: 1px solid var(--border); padding: 10px 14px;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); color: var(--text-dim); font-size: 13.5px; }
tbody tr:hover { background: var(--surface-2); }
tbody td:first-child, thead th:first-child { padding-left: 20px; }
tbody td.strong { color: var(--text); font-weight: 600; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.table-wrap .table-actions { padding: 16px 20px 0; }

.pagination { display: flex; justify-content: flex-end; gap: 6px; padding: 16px 20px; }
.pagination a, .pagination span {
  padding: 6px 11px; border-radius: 6px; font-size: 12.5px; color: var(--text-dim); border: 1px solid var(--border);
}
.pagination a:hover { background: var(--surface-2); text-decoration: none; }
.pagination .current { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.badge-active, .badge-completed, .badge-published { background: rgba(46,158,91,.15); color: var(--green); }
.badge-inactive, .badge-draft { background: rgba(154,160,168,.15); color: var(--text-dim); }
.badge-in_progress { background: rgba(61,155,224,.15); color: var(--blue-light); }
.badge-cancelled, .badge-archived { background: rgba(194,35,63,.15); color: var(--maroon-light); }

/* ---------- KPI / Dashboard ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.kpi-card .label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin-bottom: 8px; }
.kpi-card .value { font-size: 22px; font-weight: 700; }
.chart-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 20px; }
.chart-grid canvas { max-height: 280px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal-box.wide { max-width: 920px; }
.attendance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.attendance-day { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.attendance-day.weekend { opacity: .75; }
.attendance-day label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; }
.attendance-day .day-num { font-weight: 700; color: var(--text); font-size: 13px; }
.attendance-day .day-name { color: var(--text-faint); font-size: 10px; }
.attendance-day select { width: 100%; font-size: 11px; padding: 4px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 15px; }
.modal-header .close { cursor: pointer; color: var(--text-faint); font-size: 18px; background: none; border: none; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Toast / Flash ---------- */
.toast-wrap { position: fixed; top: 70px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 12px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 18px rgba(0,0,0,.4); border: 1px solid var(--border); }
.toast-success { background: rgba(46,158,91,.15); color: #6fe39c; border-color: rgba(46,158,91,.3); }
.toast-error { background: rgba(194,35,63,.15); color: #f08fa0; border-color: rgba(194,35,63,.3); }

/* ---------- Pricing engine / breakdown ---------- */
.pricing-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.checklist-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.checklist-item input[type=checkbox] { width: 16px; height: 16px; }
.checklist-item .name { flex: 1; font-size: 13px; }
.checklist-item .qty { width: 70px; }
.checklist-item .subtotal { width: 110px; text-align: right; font-size: 12.5px; color: var(--text-faint); }
.breakdown-line { display: flex; justify-content: space-between; padding: 7px 0; font-size: 13.5px; color: var(--text-dim); }
.breakdown-line.total { border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 12px; font-size: 15px; font-weight: 700; color: var(--text); }
.breakdown-line.final { color: var(--blue-light); font-size: 18px; font-weight: 800; }

/* ---------- Auth ---------- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at top, #11141a 0%, var(--bg) 60%); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px; text-align: center; }
.auth-card .logo { color: var(--blue-light); font-weight: 800; font-size: 22px; margin-bottom: 4px; }
.auth-logo-img { max-width: 220px; height: auto; margin: 0 auto 4px; display: block; }
.auth-card .tagline { color: var(--text-faint); font-size: 12.5px; margin-bottom: 24px; }
.auth-card form { text-align: left; display: flex; flex-direction: column; gap: 14px; }
.auth-card .btn-primary { width: 100%; justify-content: center; padding: 11px; }
.lang-switch-login { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; font-size: 12.5px; color: var(--text-faint); }
.lang-switch-login a { color: var(--text-dim); text-decoration: none; }
.lang-switch-login a.active { color: var(--blue-light); font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.auth-error { background: rgba(194,35,63,.12); color: #f08fa0; border: 1px solid rgba(194,35,63,.3); padding: 10px 14px; border-radius: 8px; font-size: 13px; text-align: left; }
.auth-hint { margin-top: 18px; font-size: 11.5px; color: var(--text-faint); }

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  body { background: #fff; color: #111; }
  .content { padding: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .form-grid, .pricing-grid, .chart-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .topbar .menu-toggle { display: block; }
  .kpi-grid { grid-template-columns: 1fr; }
  table thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody tr { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; padding: 6px 0; }
  tbody td { display: flex; justify-content: space-between; gap: 10px; border-bottom: none; }
  tbody td::before { content: attr(data-label); color: var(--text-faint); font-weight: 600; font-size: 11px; text-transform: uppercase; }
}
