/* ═══════════════════════════════════════
   VOLDB — Design Tokens & Base
   South African Municipal DM Platform
   ═══════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg:        #f0f2f7;
  --bg2:       #ffffff;
  --bg3:       #e8ebf3;
  --bg4:       #dde1ed;
  --border:    #d4d9e8;
  --border2:   #bcc3d8;

  --text:      #1a2035;
  --text2:     #3d4966;
  --text3:     #6b7499;
  --text4:     #9ba3bf;

  --blue:      #1a4fa0;
  --blue-lt:   #edf2fc;
  --blue-mid:  #2d64c8;
  --green:     #1a7a40;
  --green-lt:  #eaf5ef;
  --red:       #c0392b;
  --red-lt:    #fdf1f0;
  --amber:     #b85c00;
  --amber-lt:  #fef6ec;
  --purple:    #5b3fa0;
  --purple-lt: #f0ecfd;

  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  --shadow-sm: 0 1px 3px rgba(26,32,53,.07);
  --shadow-md: 0 3px 12px rgba(26,32,53,.10);
  --shadow-lg: 0 8px 32px rgba(26,32,53,.14);
  --transition: .14s ease;

  --topbar-h:  56px;
  --sidebar-w: 232px;

  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'DM Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button { cursor: pointer; font-family: inherit; }
select, input, textarea { font-family: inherit; }
a { color: var(--blue); text-decoration: none; }
img { max-width: 100%; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text4); }

/* ── UTILITY ── */
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── STATUS BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  padding: 2px 8px; border-radius: 20px;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge-active   { background: var(--green-lt);  color: var(--green); }
.badge-inactive { background: var(--bg3);        color: var(--text3); }
.badge-suspended{ background: var(--red-lt);     color: var(--red);   }
.badge-admin    { background: var(--blue-lt);    color: var(--blue);  }
.badge-editor   { background: var(--purple-lt);  color: var(--purple);}
.badge-viewer   { background: var(--bg3);        color: var(--text3); }
.badge-expiring { background: var(--amber-lt);   color: var(--amber); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 600;
  border: 1px solid transparent;
  transition: all var(--transition); white-space: nowrap;
}
.btn-primary   { background: var(--blue);  color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-mid); border-color: var(--blue-mid); }
.btn-ghost     { background: transparent; color: var(--text2); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-danger    { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #a93226; }
.btn-sm        { padding: 5px 10px; font-size: 12px; }
.btn-icon      { padding: 6px; }
.btn:disabled  { opacity: .45; cursor: not-allowed; }

/* ── CARDS / PANELS ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-title { font-size: 13.5px; font-weight: 700; color: var(--text); }
.card-sub   { font-size: 11px; color: var(--text3); margin-top: 2px; }
.card-body  { padding: 16px 18px; }

/* ── FORM ── */
.field { margin-bottom: 16px; }
.field-label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text2); margin-bottom: 5px;
}
.field-label .req { color: var(--red); margin-left: 2px; }
.field-input, .field-select, .field-textarea {
  width: 100%; padding: 9px 12px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: 13.5px; color: var(--text);
  outline: none; transition: border var(--transition), background var(--transition);
}
.field-input:focus, .field-select:focus, .field-textarea:focus {
  border-color: var(--blue-mid); background: var(--bg2);
}
.field-input::placeholder { color: var(--text4); }
.field-textarea { resize: vertical; min-height: 80px; }
.field-hint { font-size: 11px; color: var(--text3); margin-top: 4px; }
.field-error { font-size: 11px; color: var(--red); margin-top: 4px; display: none; }
.field-error.show { display: block; }
.field-input.invalid { border-color: var(--red); background: var(--red-lt); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── TABLE ── */
.tbl-wrap { overflow-x: auto; }
.tbl {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.tbl thead tr { border-bottom: 2px solid var(--border); }
.tbl th {
  padding: 9px 12px; text-align: left;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text3);
  white-space: nowrap;
}
.tbl td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  color: var(--text2); vertical-align: middle;
}
.tbl tbody tr:hover td { background: var(--bg3); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .actions { display: flex; gap: 4px; }

/* ── TOAST ── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 9999;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--text); color: #fff;
  padding: 11px 16px; border-radius: var(--r-lg);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease; min-width: 260px; max-width: 380px;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red);   }
.toast.warn    { background: var(--amber);  }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-msg  { flex: 1; }

/* ── MODAL ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(26,32,53,.48); backdrop-filter: blur(3px);
  z-index: 800; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg2); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  animation: modalIn .18s ease;
}
.modal.modal-lg { max-width: 820px; }
.modal.modal-sm { max-width: 380px; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: scale(1); }
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text3);
  font-size: 18px; line-height: 1; padding: 4px;
  border-radius: var(--r-sm); transition: all var(--transition);
}
.modal-close:hover { background: var(--bg3); color: var(--text); }
.modal-body   { padding: 20px; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── SEARCH BAR ── */
.search-wrap {
  position: relative; flex: 1; min-width: 0; max-width: 340px;
}
.search-input {
  width: 100%; padding: 8px 12px 8px 36px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: 13px; color: var(--text);
  outline: none; transition: all var(--transition);
}
.search-input:focus { background: var(--bg2); border-color: var(--blue-mid); }
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text3); pointer-events: none;
}

/* ── STEP TABS ── */
.form-steps {
  display: flex; gap: 0; border-bottom: 2px solid var(--border);
  margin-bottom: 24px; overflow-x: auto;
}
.form-step {
  display: flex; align-items: center; gap: 7px;
  padding: 11px 16px; font-size: 13px; font-weight: 600;
  color: var(--text3); cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all var(--transition);
}
.form-step:hover { color: var(--text2); }
.form-step.active { color: var(--blue); border-bottom-color: var(--blue); }
.form-step.done   { color: var(--green); }
.step-num {
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; background: var(--bg3); color: var(--text3);
}
.form-step.active .step-num { background: var(--blue-lt); color: var(--blue); }
.form-step.done   .step-num { background: var(--green-lt); color: var(--green); }

/* ── SECTION DIVIDERS ── */
.section-title {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text3);
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

/* ── KPI CARDS ── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); margin-bottom: 8px; }
.kpi-value { font-size: 32px; font-weight: 700; letter-spacing: -.02em; line-height: 1; color: var(--text); }
.kpi-sub   { font-size: 11px; color: var(--text3); margin-top: 5px; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3   { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
