/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:         #C41E2E;
  --red-dark:    #9B1724;
  --red-light:   #F9E5E7;
  --navy:        #0D1B2A;
  --navy-mid:    #1A2C40;
  --navy-light:  #243449;
  --bg:          #F0F2F5;
  --card:        #FFFFFF;
  --border:      #D5DAE4;
  --text:        #0D1B2A;
  --muted:       #5E6E82;
  --green:       #16A34A;
  --green-light: #DCFCE7;
  --amber:       #D97706;
  --amber-light: #FEF3C7;
  --blue:        #1D4ED8;
  --blue-light:  #DBEAFE;
  --sidebar-w:   240px;
  --header-h:    60px;
  --radius:      8px;
  --shadow:      0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.05);
}

html, body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  height: 100%;
}

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

/* ── Admin Shell Layout ──────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 16px;
  border-bottom: 1px solid var(--navy-light);
}

.sidebar-logo .logo-mark {
  width: 36px; height: 36px;
  background: var(--red);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 900; color: #fff; letter-spacing: -1px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  line-height: 1.2;
}

.sidebar-logo .logo-text strong {
  display: block;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .3px;
}

.sidebar-logo .logo-text span {
  color: #8B9BB0;
  font-size: 11px;
}

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  color: #8B9BB0;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}

.sidebar-nav a:hover { background: var(--navy-light); color: #C8D3E0; text-decoration: none; }
.sidebar-nav a.active { background: var(--red); color: #fff; }

.sidebar-nav .nav-icon { width: 18px; text-align: center; font-size: 15px; }

.sidebar-section-label {
  color: #4A5C70;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 14px 10px 4px;
}

.sidebar-footer {
  border-top: 1px solid var(--navy-light);
  padding: 12px 14px;
  color: #5E7080;
  font-size: 12px;
}

.sidebar-footer strong { color: #8B9BB0; }

.sidebar-footer form button {
  background: none;
  border: none;
  color: var(--red);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  margin-top: 4px;
  display: block;
}

.sidebar-footer form button:hover { text-decoration: underline; }

/* Main content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-breadcrumb { color: var(--muted); font-size: 13px; }
.topbar-spacer { flex: 1; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
}

.search-bar input {
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  width: 200px;
  color: var(--text);
}

.search-bar button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  padding: 0;
  line-height: 1;
}

.page-body { padding: 28px; flex: 1; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title { font-size: 14px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--muted); margin-top: 1px; }
.card-header-actions { margin-left: auto; }
.card-body { padding: 20px; }

/* ── Stat Cards ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--navy); }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.amber .stat-value { color: var(--amber); }
.stat-card.green .stat-value { color: var(--green); }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  background: #F7F9FC;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid #F0F2F5;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFBFD; }

.table-link { color: var(--navy); font-weight: 500; }
.table-link:hover { color: var(--red); text-decoration: none; }

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-size: 13px;
}

/* ── Badges / Status Pills ───────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-pending          { background: var(--amber-light); color: var(--amber); }
.badge-pending_payment  { background: var(--amber-light); color: var(--amber); }
.badge-approved         { background: var(--green-light); color: var(--green); }
.badge-active           { background: var(--green-light); color: var(--green); }
.badge-overdue          { background: #FEE2E2; color: #DC2626; }
.badge-denied           { background: var(--red-light); color: var(--red); }
.badge-deleted          { background: #F1F3F5; color: #6B7280; }
.badge-info             { background: var(--blue-light); color: var(--blue); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { opacity: .88; text-decoration: none; }
.btn:active { transform: scale(.98); }

.btn-primary   { background: var(--red); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-success   { background: var(--green); color: #fff; }
.btn-danger    { background: #DC2626; color: #fff; }
.btn-sm        { padding: 5px 11px; font-size: 12px; }
.btn-ghost     { background: none; color: var(--muted); border: 1px solid var(--border); }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.label-optional { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 4px; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(196,30,46,.1);
}

textarea { resize: vertical; min-height: 80px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 16px; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }

.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 400;
}

.checkbox-label input[type="checkbox"] { width: auto; accent-color: var(--red); }

.field-error { color: #DC2626; font-size: 12px; margin-top: 4px; }

/* ── Section Dividers ────────────────────────────────────── */
.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 28px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.section-title:first-child { margin-top: 0; }

/* ── Alert ───────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 20px;
  border: 1px solid;
}

.alert-error   { background: var(--red-light); border-color: #F5C2C7; color: #842029; }
.alert-success { background: var(--green-light); border-color: #B8E0C4; color: #166534; }
.alert-warning { background: var(--amber-light); border-color: #FDD7A0; color: #92400E; }

/* ── Public Apply Form ───────────────────────────────────── */
.apply-shell {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.apply-header {
  background: var(--navy);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 3px solid var(--red);
}

.apply-header .logo-mark {
  width: 38px; height: 38px;
  background: var(--red);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 900; color: #fff;
}

.apply-header h1 { color: #fff; font-size: 18px; font-weight: 700; }
.apply-header p { color: #8B9BB0; font-size: 13px; margin-left: auto; }

.apply-body {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  width: 100%;
}

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

.apply-card-header {
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--border);
}

.apply-card-header h2 { font-size: 18px; font-weight: 700; }
.apply-card-header p { color: var(--muted); font-size: 13px; margin-top: 4px; }

.apply-card-body { padding: 28px; }

.apply-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 28px;
  border-top: 1px solid var(--border);
  background: #FAFBFD;
}

/* ── Login Page ──────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: 100%;
  max-width: 380px;
  overflow: hidden;
}

.login-header {
  background: var(--navy);
  padding: 28px 28px 24px;
  text-align: center;
  border-bottom: 3px solid var(--red);
}

.login-logo {
  width: 52px; height: 52px;
  background: var(--red);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 900; color: #fff;
  margin: 0 auto 12px;
}

.login-header h1 { color: #fff; font-size: 18px; font-weight: 700; }
.login-header p { color: #8B9BB0; font-size: 12px; margin-top: 4px; }
.login-body { padding: 28px; }

/* ── Profile ─────────────────────────────────────────────── */
.profile-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}

.profile-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.photo-thumb {
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 4/3;
  background: var(--bg);
}

.photo-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.photo-thumb a { display: block; height: 100%; }

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #F3F4F6;
  font-size: 13px;
}

.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--muted); font-weight: 500; }
.detail-value { font-weight: 500; flex: 1; text-align: right; font-size: 13px; }
.ef { flex: 1; text-align: right; font-size: 13px; font-weight: 500; font-family: inherit;
      border: none; background: transparent; color: var(--text);
      padding: 0; outline: none; min-width: 0; cursor: text; width: 100%; }

/* ── Upload zone ─────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--red);
  background: var(--red-light);
}

.upload-zone input[type="file"] { display: none; }
.upload-zone p { color: var(--muted); font-size: 13px; margin-top: 6px; }

.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* ── Renewal list ────────────────────────────────────────── */
.renewal-list { padding: 4px 0; }
.renewal-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.renewal-row:last-child { border-bottom: none; }
.renewal-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.renewal-form { display: flex; align-items: center; gap: 8px; }
.renewal-form input[type="date"] { width: auto; font-size: 13px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; }

/* ── Burger / close buttons ──────────────────────────────── */
.burger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
  border-radius: 6px;
}
.burger-btn:hover { background: var(--bg); }

.sidebar-close {
  display: none;
  position: absolute;
  top: 10px;
  right: 14px;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #8B9BB0;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  z-index: 10;
}
.sidebar-close:hover { background: var(--navy-light); color: #fff; }

body.sidebar-lock { overflow: hidden; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  html, body { overflow-x: hidden; }
  .shell { overflow-x: hidden; }
  .main-content { margin-left: 0; min-width: 0; overflow-x: hidden; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .28s ease;
    z-index: 200;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .sidebar-logo { justify-content: center; padding: 60px 20px 20px; }
  .sidebar-logo img { max-width: 180px; }
  .sidebar-nav { padding: 8px 16px; }
  .sidebar-nav a { font-size: 17px; padding: 16px 14px; }
  .sidebar-section-label { font-size: 11px; padding: 20px 14px 6px; }
  .sidebar-footer { padding: 16px; }

  .burger-btn { display: flex; }
  .topbar { padding: 0 14px; gap: 10px; height: 56px; }
  .mobile-hide { display: none !important; }
  .page-body { padding: 12px; }
  .settings-cols { grid-template-columns: 1fr !important; }
  .two-col-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .form-grid, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3, .col-span-4 { grid-column: span 1; }
  .profile-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .apply-header { padding: 0 14px; gap: 10px; }
  .apply-header h1 { font-size: 15px; }
  .apply-header p { display: none; }
  .apply-body { padding: 16px 12px 48px; }
  .apply-card-body { padding: 16px; }
  .apply-card-header { padding: 14px 16px 12px; }
  .apply-footer { padding: 14px 16px; }
  table { font-size: 12px; }
  th, td { padding: 9px 10px; }
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }
}

/* ── Utility ─────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
