:root {
  --maroon: #7a1220;
  --maroon-dark: #5c0d18;
  --maroon-light: #fbe9ea;
  --gold: #f2b705;
  --gold-dark: #d9a300;
  --ink: #211a1c;
  --muted: #8a7f81;
  --border: #ece3e4;
  --bg: #f7f5f5;
  --card: #ffffff;
  --green: #1fa855;
  --green-bg: #e7f7ee;
  --orange: #e08a1e;
  --orange-bg: #fdf0dd;
  --red: #d64545;
  --red-bg: #fbe9e9;
  --blue: #2f80ed;
  --blue-bg: #e8f0fd;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(33, 26, 28, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }

.btn, button, input[type="submit"] {
  touch-action: manipulation;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:disabled, button:disabled { cursor: wait; opacity: 0.7; }

.btn-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  opacity: 0.85;
  flex-shrink: 0;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.btn-primary { background: var(--gold); color: #3a2c00; }
.btn-primary:hover { background: var(--gold-dark); }

.btn-outline { background: #fff; color: var(--ink); border-color: var(--border); }
.btn-outline:hover { border-color: var(--maroon); color: var(--maroon); }

.btn-maroon { background: var(--maroon); color: #fff; }
.btn-maroon:hover { background: var(--maroon-dark); }

.btn-danger { background: var(--red-bg); color: var(--red); border-color: var(--red); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

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

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

table.data-table th {
  text-align: left;
  color: var(--maroon);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border);
}

table.data-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: #fcfafa; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-green { background: var(--green-bg); color: var(--green); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-gray { background: #eee; color: #666; }

.input, select.input, textarea.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  background: #fff;
  color: var(--ink);
}

.input:focus, select.input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--maroon);
}

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field .help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .errors { color: var(--red); font-size: 12px; margin-top: 4px; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}
.tab.active { background: var(--maroon); border-color: var(--maroon); color: #fff; }

.messages { list-style: none; margin: 0 0 16px; padding: 0; }
.messages li {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}
.messages li.success { background: var(--green-bg); color: var(--green); }
.messages li.error { background: var(--red-bg); color: var(--red); }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 20px; margin: 0; }

.filters-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: flex-end;
}
.filters-bar .field { margin-bottom: 0; min-width: 180px; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(33, 26, 28, 0.45);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px 26px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.modal-box.modal-wide { max-width: 820px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.form-grid .field.full { grid-column: 1 / -1; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  padding: 4px 6px;
}
.icon-btn:hover { color: var(--maroon); }
.icon-btn.danger:hover { color: var(--red); }

.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Custom select (replaces native <select> popups) */
.cs-wrap {
  position: relative;
  width: 100%;
}

.cs-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.cs-trigger:hover { border-color: var(--maroon); }
.cs-wrap.open .cs-trigger { border-color: var(--maroon); box-shadow: 0 0 0 3px var(--maroon-light); }
.cs-trigger .cs-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-trigger .cs-label.placeholder { color: #a99a9c; }
.cs-trigger .cs-chevron {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  margin-top: -4px;
  transition: transform 0.15s ease;
}
.cs-wrap.open .cs-trigger .cs-chevron { transform: rotate(-135deg); margin-top: 2px; }

.cs-menu {
  position: fixed;
  z-index: 1000;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(33, 26, 28, 0.18);
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
}

.cs-option {
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cs-option:hover, .cs-option.cs-active { background: var(--maroon-light); color: var(--maroon); }
.cs-option.cs-selected { font-weight: 700; color: var(--maroon); }

.cs-wrap.cs-compact .cs-trigger {
  padding: 3px 8px;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.92);
}
.cs-wrap.cs-compact .cs-trigger .cs-chevron {
  width: 6px;
  height: 6px;
  border-width: 1.5px;
}

/* Custom date picker (replaces native <input type="date"> popups) */
.cs-date-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.cs-date-trigger:hover { border-color: var(--maroon); }
.cs-wrap.open .cs-date-trigger { border-color: var(--maroon); box-shadow: 0 0 0 3px var(--maroon-light); }
.cs-date-trigger .cs-date-label.placeholder { color: #a99a9c; }
.cs-date-trigger .cs-date-icon { flex-shrink: 0; color: var(--muted); }

.cs-calendar {
  position: fixed;
  z-index: 1000;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(33, 26, 28, 0.18);
  padding: 12px;
  width: 260px;
}

.cs-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 700;
  font-size: 13px;
}
.cs-cal-nav {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--maroon);
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 6px;
}
.cs-cal-nav:hover { background: var(--maroon-light); }

.cs-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.cs-cal-weekday { font-size: 11px; color: var(--muted); padding: 4px 0; font-weight: 600; }
.cs-cal-day {
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px 0;
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink);
}
.cs-cal-day:hover { background: var(--maroon-light); }
.cs-cal-day.cs-cal-muted { color: #cbbfc1; }
.cs-cal-day.cs-cal-today { font-weight: 700; color: var(--maroon); }
.cs-cal-day.cs-cal-selected { background: var(--maroon); color: #fff; font-weight: 700; }

.cs-cal-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.cs-cal-footer button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--maroon);
}

/* Plain number inputs: hide native spin arrows, keep the same box as other fields */
input.input[type="number"]::-webkit-outer-spin-button,
input.input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.input[type="number"] { -moz-appearance: textfield; }
