/* =========================================================
   SK Committee Management System — Global Design System
   Civic / municipal dashboard style
   ========================================================= */

:root {
  --color-primary: #0b3a6e;
  --color-primary-hover: #0a2f58;
  --color-primary-soft: #e8f1fb;
  --color-secondary: #3b82c4;
  --color-secondary-soft: #eaf4fc;

  --color-bg: #eef2f6;
  --color-surface: #ffffff;
  --color-border: #d8e0ea;
  --color-border-strong: #c3cedc;

  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-text-inverse: #f8fafc;

  --color-success: #15803d;
  --color-success-soft: #dcfce7;
  --color-warning: #b45309;
  --color-warning-soft: #fef3c7;
  --color-danger: #b91c1c;
  --color-danger-soft: #fee2e2;
  --color-info: #1d4ed8;
  --color-info-soft: #dbeafe;

  --sidebar-width: 260px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  --focus-ring: 0 0 0 3px rgba(59, 130, 196, 0.35);

  --font-sans: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-secondary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---------- App shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--color-bg);
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(180deg, #0b3a6e 0%, #0a2f58 100%);
  color: var(--color-text-inverse);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 0.85rem;
}

.brand-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.brand-subtitle {
  margin: 0;
  font-size: 0.72rem;
  color: rgba(226, 232, 240, 0.75);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3);
}

.nav-group-label {
  margin: var(--space-4) var(--space-3) var(--space-2);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(191, 219, 254, 0.65);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.7rem 0.85rem;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: rgba(226, 232, 240, 0.9);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
}

.nav-link.is-active {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-secondary);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.user-name {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
}

.user-email {
  margin: 0;
  font-size: 0.72rem;
  color: rgba(226, 232, 240, 0.7);
  word-break: break-all;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.topbar-right {
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.page-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-text);
}

.page-desc {
  margin: 0.15rem 0 0;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.topbar-date {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.page-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.content {
  flex: 1;
  padding: var(--space-6);
}

.mobile-menu-btn {
  display: none;
}

.sidebar-overlay {
  display: none;
}

/* ---------- Typography helpers ---------- */

.section-title {
  margin: 0 0 var(--space-3);
  font-size: 1rem;
  font-weight: 700;
}

.helper-text {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ---------- Cards ---------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

.card-flush {
  padding: 0;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.card-header h3,
.card-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.card-body {
  padding: var(--space-5);
}

.card-accent {
  border-top: 3px solid var(--color-secondary);
}

.card-accent.is-success { border-top-color: var(--color-success); }
.card-accent.is-warning { border-top-color: var(--color-warning); }
.card-accent.is-danger { border-top-color: var(--color-danger); }

/* ---------- Grids ---------- */

.grid {
  display: grid;
  gap: var(--space-5);
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.row {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
}

.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }

/* ---------- Stat cards ---------- */

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  border-left: 4px solid var(--color-secondary);
}

.stat-card.is-success { border-left-color: var(--color-success); }
.stat-card.is-warning { border-left-color: var(--color-warning); }
.stat-card.is-danger { border-left-color: var(--color-danger); }
.stat-card.is-info { border-left-color: var(--color-info); }
.stat-card.is-primary { border-left-color: var(--color-primary); }

.stat-label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.stat-value {
  margin: 0.25rem 0 0;
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.1;
}

.stat-hint {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--color-secondary-soft);
  color: var(--color-primary);
  border-color: #bfd4ea;
}

.btn-secondary:hover:not(:disabled) {
  background: #d9ebf8;
}

.btn-success {
  background: var(--color-success);
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  background: #166534;
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #991b1b;
}

.btn-ghost {
  background: transparent;
  color: inherit;
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(15, 23, 42, 0.06);
}

.sidebar .btn-ghost {
  color: rgba(226, 232, 240, 0.9);
  justify-content: flex-start;
}

.sidebar .btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.btn-outline {
  background: #fff;
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.btn-outline:hover:not(:disabled) {
  background: var(--color-bg);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 32px;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}

.btn-icon {
  width: 40px;
  min-width: 40px;
  padding: 0;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-soft-primary {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.btn-soft-danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

/* ---------- Forms ---------- */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
}

.required {
  color: var(--color-danger);
}

.form-control,
.form-select,
.form-textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-text);
}

.form-textarea {
  min-height: 90px;
  resize: vertical;
}

.form-control:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-secondary);
  box-shadow: var(--focus-ring);
  outline: none;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.form-error {
  font-size: 0.75rem;
  color: var(--color-danger);
}

.form-control.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
  border-color: var(--color-danger);
}

.form-grid {
  display: grid;
  gap: var(--space-4);
}

.form-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ---------- Tables ---------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.table th,
.table td {
  padding: 0.85rem 1.1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.table th {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: #f8fafc;
}

.table td {
  font-size: 0.875rem;
  color: var(--color-text);
}

.table tbody tr:hover {
  background: #f8fbff;
}

.table .actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.3;
}

.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-info { background: var(--color-info-soft); color: var(--color-info); }
.badge-neutral { background: #e2e8f0; color: #475569; }

/* ---------- Progress ---------- */

.progress {
  width: 80px;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--color-secondary);
  border-radius: 999px;
}

.progress.is-success > span { background: var(--color-success); }
.progress.is-warning > span { background: var(--color-warning); }
.progress.is-danger > span { background: var(--color-danger); }

.member-cell {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ---------- States ---------- */

.state-box {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--color-text-muted);
}

.state-box.is-error {
  color: var(--color-danger);
}

.state-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto var(--space-3);
  opacity: 0.7;
}

.state-title {
  margin: 0 0 0.35rem;
  font-weight: 700;
  color: var(--color-text);
}

.state-text {
  margin: 0;
  font-size: 0.875rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #dbe3ee;
  border-top-color: var(--color-secondary);
  border-radius: 50%;
  margin: 0 auto var(--space-3);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.alert {
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  border: 1px solid transparent;
}

.alert-success {
  background: var(--color-success-soft);
  color: var(--color-success);
  border-color: #bbf7d0;
}

.alert-error {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border-color: #fecaca;
}

.alert-warning {
  background: var(--color-warning-soft);
  color: var(--color-warning);
  border-color: #fde68a;
}

.alert-info {
  background: var(--color-info-soft);
  color: var(--color-info);
  border-color: #bfdbfe;
}

.hidden {
  display: none !important;
}

/* ---------- Modals ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 80;
}

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.modal-lg {
  max-width: 640px;
}

.modal-header,
.modal-footer {
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.modal-header {
  border-bottom: 1px solid var(--color-border);
}

.modal-footer {
  border-top: 1px solid var(--color-border);
  justify-content: flex-end;
}

.modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-body {
  padding: var(--space-5);
}

.modal-center {
  text-align: center;
}

/* ---------- Toasts ---------- */

.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(360px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #fff;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-secondary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  color: var(--color-text);
  animation: toast-in 0.2s ease;
}

.toast.is-success { border-left-color: var(--color-success); }
.toast.is-error { border-left-color: var(--color-danger); }
.toast.is-warning { border-left-color: var(--color-warning); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Panels (AI / accent sections) ---------- */

.panel-ai {
  background: linear-gradient(135deg, #0b3a6e 0%, #1e5a96 100%);
  color: #fff;
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.panel-ai .form-label {
  color: rgba(226, 232, 240, 0.9);
}

.panel-ai .form-control,
.panel-ai .form-select {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.panel-ai .form-control::placeholder {
  color: rgba(191, 219, 254, 0.8);
}

.panel-ai option {
  color: var(--color-text);
}

.panel-ai-soft {
  background: var(--color-primary-soft);
  border: 1px solid #c5daf0;
  border-radius: var(--radius-md);
  padding: var(--space-5);
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: #f8fbff;
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.quick-action:hover {
  background: var(--color-primary-soft);
  border-color: #b7d0e8;
  text-decoration: none;
}

.quick-action .qa-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--color-border);
  display: grid;
  place-items: center;
  color: var(--color-primary);
}

.quick-action .qa-icon svg {
  width: 18px;
  height: 18px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--color-border);
}

.list-row:last-child {
  border-bottom: 0;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Login page ---------- */

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(11, 58, 110, 0.88), rgba(30, 90, 150, 0.78)),
    url("../cityhall.jpg") center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.login-layout {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  align-items: center;
}

.login-branding {
  color: #fff;
}

.login-seal {
  width: 240px;
  height: 240px;
  margin-bottom: var(--space-5);
  flex-shrink: 0;
  aspect-ratio: 1 / 1;
}

.login-seal-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.login-branding h1 {
  margin: 0 0 var(--space-3);
  font-size: 2.2rem;
  line-height: 1.15;
}

.login-branding p {
  margin: 0;
  color: rgba(226, 232, 240, 0.9);
  font-size: 0.95rem;
}

.login-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.login-metric {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
}

.login-metric strong {
  display: block;
  color: #fbbf24;
  font-size: 1.2rem;
}

.login-metric span {
  font-size: 0.72rem;
  color: rgba(226, 232, 240, 0.85);
}

.login-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-8) var(--space-6);
}

.login-card-header {
  text-align: center;
  margin-bottom: var(--space-5);
}

.login-sjdm-logo {
  display: block;
  width: 90px;
  height: auto;
  margin: 0 auto 0.75rem;
  object-fit: contain;
}

.login-card-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.login-card-header p {
  margin: 0.35rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.online-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-success);
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

.login-footer {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

/* ---------- Print ---------- */

@media print {
  .sidebar,
  .topbar,
  .page-actions,
  .toast-stack,
  .mobile-menu-btn {
    display: none !important;
  }

  .app-shell,
  .app-main,
  .content {
    display: block;
    padding: 0;
    min-height: auto;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .login-layout {
    grid-template-columns: 1fr;
  }

  .login-branding {
    text-align: center;
  }

  .login-seal {
    width: 168px;
    height: 168px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 35;
  }

  .sidebar-overlay[hidden] {
    display: none;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .form-grid-2,
  .form-grid-3,
  .form-grid-4 {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: var(--space-4);
  }

  .content {
    padding: var(--space-4);
  }

  .page-title {
    font-size: 1.15rem;
  }

  .topbar-date {
    display: none;
  }
}

@media (max-width: 480px) {
  .login-metrics {
    grid-template-columns: 1fr;
  }

  .login-seal {
    width: 148px;
    height: 148px;
  }

  .login-sjdm-logo {
    width: 72px;
  }

  .login-card {
    padding: var(--space-5) var(--space-4);
  }

  .modal {
    border-radius: var(--radius-md);
  }

  .btn {
    width: 100%;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1;
  }
}

/* ---------- Compatibility utilities for legacy dynamic markup ---------- */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.text-gray-800, .text-gray-700 { color: var(--color-text); }
.text-gray-600, .text-gray-500, .text-gray-400 { color: var(--color-text-muted); }
.text-blue-600, .text-blue-700 { color: var(--color-primary); }
.text-blue-200, .text-blue-100, .text-green-100, .text-green-200, .text-purple-200 { color: rgba(226,232,240,0.9); }
.text-green-600, .text-green-700 { color: var(--color-success); }
.text-red-500, .text-red-600, .text-red-700 { color: var(--color-danger); }
.text-yellow-600, .text-yellow-700 { color: var(--color-warning); }
.text-purple-600, .text-purple-700 { color: #6d28d9; }
.text-white { color: #fff; }
.bg-white { background: #fff; }
.bg-gray-50 { background: #f8fafc; }
.bg-gray-100 { background: var(--color-bg); }
.bg-gray-200 { background: #e2e8f0; }
.bg-blue-50 { background: var(--color-primary-soft); }
.bg-blue-100 { background: #dbeafe; }
.bg-blue-900 { background: var(--color-primary); }
.bg-green-50, .bg-green-100 { background: var(--color-success-soft); }
.bg-red-50, .bg-red-100 { background: var(--color-danger-soft); }
.bg-yellow-50, .bg-yellow-100 { background: var(--color-warning-soft); }
.bg-purple-50, .bg-purple-100 { background: #f3e8ff; }
.bg-white.bg-opacity-20, .bg-white.bg-opacity-15 { background: rgba(255,255,255,0.15); }
.bg-red-500.bg-opacity-50 { background: rgba(185,28,28,0.5); }
.rounded { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius-sm); }
.rounded-xl { border-radius: var(--radius-md); }
.rounded-full { border-radius: 999px; }
.shadow-sm { box-shadow: var(--shadow-sm); }
.border { border: 1px solid var(--color-border); }
.border-b { border-bottom: 1px solid var(--color-border); }
.border-t-4 { border-top: 4px solid var(--color-secondary); }
.border-blue-500 { border-color: var(--color-secondary); }
.border-gray-300 { border-color: var(--color-border-strong); }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.w-full { width: 100%; }
.w-8 { width: 2rem; } .h-8 { height: 2rem; }
.w-16 { width: 4rem; } .h-2 { height: 0.5rem; } .h-3 { height: 0.75rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.25rem; padding-right: 1.25rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.p-3 { padding: 0.75rem; }
.p-5 { padding: 1.25rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-3 { margin-top: 0.75rem; }
.ml-auto { margin-left: auto; }
.overflow-x-auto { overflow-x: auto; }
.col-span-2, .col-span-3 { grid-column: 1 / -1; }
.border-collapse { border-collapse: collapse; }
