/* ============================================
   SUN TOWER RWA - BOM Dashboard Styles
   Flat Minimal Tile Design (Stripe/GA style)
   ============================================ */

/* ========== CSS VARIABLES ========== */
:root {
  --primary: #1a237e;
  --primary-light: #283593;
  --primary-dark: #0d1b4a;
  --secondary: #ff6f00;
  --secondary-light: #ff8f00;
  --accent: #00695c;
  --bg: #f5f5f5;
  --card: #fff;
  --text: #212121;
  --text-light: #666;
  --light: #e8eaf6;
  --success: #2e7d32;
  --warning: #f57f17;
  --danger: #c62828;
  --border: #e0e0e0;
  --shadow: none;
  --shadow-lg: none;
  --tile-radius: 4px;
  --sidebar-width: 250px;
  --sidebar-collapsed: 60px;
  --header-height: 56px;
}

/* ========== BASE RESET ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== DASHBOARD LAYOUT ========== */
.dashboard-layout {
  min-height: 100vh;
}

/* ========== HEADER BAR ========== */
.dash-header {
  background: var(--primary-dark);
  color: #fff;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  height: var(--header-height);
}
.dash-header .logo-sm {
  width: 38px; height: 38px;
  background: var(--secondary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer;
}
.dash-header .logo-sm svg { width: 26px; height: 26px; }
.dash-header .header-text { flex: 1; }
.dash-header .header-title { font-size: 0.95rem; font-weight: 700; letter-spacing: 1px; }
.dash-header .header-sub { font-size: 0.68rem; color: #90caf9; }
.header-right { display: flex; align-items: center; gap: 10px; }
.header-user { font-size: 0.78rem; color: #a5d6a7; }
.header-btn {
  background: rgba(255,255,255,0.15); color: #fff; border: none;
  padding: 6px 14px; border-radius: var(--tile-radius); font-size: 0.75rem;
  cursor: pointer; transition: 0.2s;
}
.header-btn:hover { background: rgba(255,255,255,0.3); }
.sidebar-toggle {
  background: none; border: none; color: #fff; font-size: 1.3rem;
  cursor: pointer; padding: 4px 8px; border-radius: var(--tile-radius);
  transition: 0.2s; display: flex; align-items: center;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.15); }

/* ========== SIDEBAR ========== */
.dash-sidebar {
  background: #fff;
  border-right: 1px solid var(--border);
  padding-top: var(--header-height);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.3s ease;
  display: flex;
  flex-direction: column;
}
.dash-sidebar::-webkit-scrollbar { width: 4px; }
.dash-sidebar::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

.sidebar-collapsed .dash-sidebar {
  width: var(--sidebar-collapsed);
}

/* Sidebar sections */
.sidebar-section {
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}
.sidebar-section:last-child { border-bottom: none; }

/* Sidebar group header */
.sidebar-group-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; cursor: pointer;
  font-size: 0.72rem; font-weight: 700;
  color: var(--text-light); text-transform: uppercase;
  letter-spacing: 0.8px; transition: 0.2s;
  user-select: none;
}
.sidebar-group-header:hover { color: var(--primary); background: #f9f9f9; }
.sidebar-group-header .group-icon { font-size: 1rem; width: 28px; text-align: center; flex-shrink: 0; }
.sidebar-group-header .group-label { flex: 1; white-space: nowrap; overflow: hidden; }
.sidebar-group-header .group-caret {
  font-size: 0.6rem; transition: transform 0.2s; flex-shrink: 0;
}
.sidebar-group.open .group-caret { transform: rotate(180deg); }

/* Sidebar menu items */
.sidebar-menu { display: none; padding: 0 0 4px; }
.sidebar-group.open .sidebar-menu { display: block; }

.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px 9px 28px; cursor: pointer;
  font-size: 0.82rem; font-weight: 500;
  color: var(--text); transition: 0.15s;
  text-decoration: none; border-left: 3px solid transparent;
  white-space: nowrap; overflow: hidden;
}
.sidebar-item:hover {
  background: #e8eaf6; color: var(--primary);
  text-decoration: none; border-left-color: var(--secondary);
}
.sidebar-item.active {
  background: #e8eaf6; color: var(--primary);
  font-weight: 700; border-left-color: var(--secondary);
}
.sidebar-item .item-icon { font-size: 0.95rem; width: 22px; text-align: center; flex-shrink: 0; }
.sidebar-item .item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sidebar-item .item-badge {
  background: #b71c1c; color: #fff; font-size: 0.6rem;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px; font-weight: 700; flex-shrink: 0;
}

/* Standalone sidebar items (no group) */
.sidebar-item.standalone {
  padding-left: 16px;
  font-weight: 600;
}
.sidebar-item.standalone .item-icon { font-size: 1rem; width: 28px; }

/* Admin item */
.sidebar-item.admin-item { color: #b71c1c; }
.sidebar-item.admin-item:hover { background: #fce4ec; }
.sidebar-item.admin-item.active { background: #fce4ec; border-left-color: #b71c1c; }

/* Collapsed sidebar */
.sidebar-collapsed .sidebar-group-header .group-label,
.sidebar-collapsed .sidebar-group-header .group-caret,
.sidebar-collapsed .sidebar-item .item-label,
.sidebar-collapsed .sidebar-item .item-badge,
.sidebar-collapsed .sidebar-footer-text { display: none; }

.sidebar-collapsed .sidebar-group-header {
  justify-content: center; padding: 10px 0;
}
.sidebar-collapsed .sidebar-item {
  justify-content: center; padding: 9px 0; border-left: none;
}
.sidebar-collapsed .sidebar-item.standalone { padding-left: 0; }

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto; padding: 12px 16px;
  border-top: 1px solid #f0f0f0;
  font-size: 0.75rem; color: var(--text-light);
}
.sidebar-footer a {
  color: var(--accent); font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
}

/* ========== MAIN CONTENT ========== */
.dash-main {
  margin-left: var(--sidebar-width);
  padding: calc(var(--header-height) + 20px) 24px 40px;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}
.sidebar-collapsed .dash-main {
  margin-left: var(--sidebar-collapsed);
}

/* ========== AUTH OVERLAY ========== */
.auth-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6); z-index: 2000;
  display: flex; align-items: center; justify-content: center;
}
.auth-overlay.hidden { display: none; }
.auth-card {
  background: #fff; border-radius: 8px; padding: 40px;
  width: 90%; max-width: 420px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.15);
}
.auth-card h2 { color: var(--primary); margin-bottom: 5px; text-align: center; }
.auth-card .auth-sub { color: var(--text-light); text-align: center; margin-bottom: 25px; font-size: 0.9rem; }
.auth-card .auth-logo { text-align: center; margin-bottom: 15px; }
.auth-error {
  background: #ffebee; color: var(--danger); padding: 10px;
  border-radius: var(--tile-radius); font-size: 0.85rem; margin-bottom: 15px; display: none;
}
.auth-success {
  background: #e8f5e9; color: var(--success); padding: 10px;
  border-radius: var(--tile-radius); font-size: 0.85rem; margin-bottom: 15px; display: none;
}
.auth-link { color: var(--primary); cursor: pointer; font-size: 0.85rem; text-align: center; margin-top: 15px; }
.auth-link:hover { text-decoration: underline; }

/* ========== PAGE CONTENT ========== */
.page-title {
  font-size: 1.6rem; color: var(--primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px; margin-bottom: 20px;
}
.page-subtitle { font-size: 0.95rem; color: var(--text-light); margin-bottom: 20px; }
.bom-sec { display: none; }
.bom-sec.active { display: block; }

/* ========== CARDS ========== */
.card {
  background: var(--card); border-radius: var(--tile-radius); padding: 20px;
  margin-bottom: 18px; border: 1px solid var(--border);
}
.card h3 { color: var(--primary); margin-bottom: 8px; }
.card ul { padding-left: 20px; }
.card li { margin-bottom: 5px; line-height: 1.5; }

/* ========== GRIDS ========== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ========== TABLES ========== */
table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.9rem; }
th { background: #f5f5f5; color: var(--text); padding: 10px 8px; text-align: left; font-weight: 600; border-bottom: 2px solid var(--border); }
td { padding: 8px; border-bottom: 1px solid var(--border); }
tr:nth-child(even) { background: #f9f9f9; }
tr:hover { background: #f0f4ff; }

/* ========== BADGES ========== */
.badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; color: #fff; }
.badge-president { background: #b71c1c; }
.badge-vp { background: #4a148c; }
.badge-gs { background: #1a237e; }
.badge-vgs { background: #01579b; }
.badge-treasurer { background: #004d40; }
.badge-vt { background: #1b5e20; }
.badge-member { background: #e65100; }
.badge-admin { background: #b71c1c; }
.badge-success { background: var(--success); }
.badge-warning { background: var(--warning); color: #333; }
.badge-danger { background: var(--danger); }
.badge-info { background: #0277bd; }

/* Frequency badges */
.freq-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.72rem; font-weight: 600; }
.freq-daily { background: #ffcdd2; color: #b71c1c; }
.freq-weekly { background: #c8e6c9; color: #1b5e20; }
.freq-monthly { background: #bbdefb; color: #0d47a1; }
.freq-quarterly { background: #e1bee7; color: #4a148c; }
.freq-once { background: #ffe0b2; color: #e65100; }

/* ========== BUTTONS ========== */
.btn {
  padding: 10px 24px; border: none; border-radius: var(--tile-radius);
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  transition: 0.2s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.action-bar { display: flex; gap: 10px; margin: 20px 0; flex-wrap: wrap; }

/* ========== FORMS ========== */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-weight: 600; color: var(--primary); margin-bottom: 4px; font-size: 0.85rem; }
.form-control {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: var(--tile-radius); font-size: 0.9rem; transition: 0.2s; font-family: inherit;
}
.form-control:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 2px rgba(26,35,126,0.1); }
textarea.form-control { min-height: 80px; resize: vertical; }
select.form-control { appearance: auto; }

/* ========== AUTH ROLE BADGE ========== */
.role-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.5px; }
.role-badge-admin { background: #fce4ec; color: #b71c1c; }
.role-badge-bom { background: #e8eaf6; color: #1a237e; }

/* ========== SECURE AUTH CARD ========== */
.auth-card .auth-mode-tabs {
  display: flex; gap: 0; margin-bottom: 20px; border-radius: var(--tile-radius);
  overflow: hidden; border: 1px solid var(--border);
}
.auth-mode-tab {
  flex: 1; padding: 10px; text-align: center; cursor: pointer;
  font-weight: 600; font-size: 0.85rem; transition: 0.2s;
  background: #f5f5f5; color: var(--text-light);
}
.auth-mode-tab.active { background: var(--primary); color: #fff; }

/* ========== SUPABASE STATUS ========== */
.supa-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.72rem; padding: 3px 10px; border-radius: 12px;
}
.supa-status-connected { background: #e8f5e9; color: #2e7d32; }
.supa-status-disconnected { background: #fce4ec; color: #b71c1c; }
.supa-status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.supa-status-connected .supa-status-dot { background: #2e7d32; animation: pulse 2s infinite; }
.supa-status-disconnected .supa-status-dot { background: #b71c1c; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ========== AUDIT LOG ========== */
.audit-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 15px; }
.audit-filters .form-control { font-size: 0.82rem; padding: 8px 10px; }
.audit-action-badge { display: inline-block; padding: 2px 8px; border-radius: var(--tile-radius); font-size: 0.7rem; font-weight: 600; color: #fff; }

/* ========== MEMBER CARDS ========== */
.member-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; margin: 20px 0; }
.member-card { background: #fff; border: 1px solid var(--border); border-radius: var(--tile-radius); padding: 15px; transition: 0.2s; }
.member-card:hover { border-color: var(--primary); }
.member-card label { font-weight: 600; color: var(--primary); display: block; margin-bottom: 4px; font-size: 0.85rem; }
.member-card input, .member-card select { width: 100%; padding: 7px 10px; border: 1px solid #ccc; border-radius: var(--tile-radius); font-size: 0.9rem; margin-bottom: 8px; }

/* ========== TASK ALLOCATION ========== */
.task-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #fff; border: 1px solid var(--border); border-radius: var(--tile-radius); margin-bottom: 6px; }
.task-row select { padding: 5px; border: 1px solid #ccc; border-radius: var(--tile-radius); min-width: 160px; }
.task-category { font-weight: 700; color: var(--primary); padding: 12px; background: var(--light); border-radius: var(--tile-radius); margin: 15px 0 8px; }

/* ========== COMMITTEE ========== */
.committee-card { background: #fff; border-radius: var(--tile-radius); padding: 18px; margin-bottom: 16px; border: 1px solid var(--border); transition: 0.2s; }
.committee-card:hover { background: #fafafa; }
.committee-card h3 { margin-bottom: 10px; display: flex; align-items: center; gap: 10px; }
.committee-icon { width: 40px; height: 40px; border-radius: var(--tile-radius); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.2rem; flex-shrink: 0; }
.comm-member-slot { display: flex; align-items: center; gap: 8px; padding: 6px 10px; margin: 4px 0; background: #f5f5f5; border-radius: var(--tile-radius); font-size: 0.88rem; }
.comm-member-slot .slot-type { font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; white-space: nowrap; }
.slot-bom { background: #e8eaf6; color: var(--primary); }
.slot-resident { background: #e8f5e9; color: var(--success); }
.comm-select, .comm-input { flex: 1; padding: 5px 8px; border: 1px solid #ccc; border-radius: var(--tile-radius); font-size: 0.85rem; }
.sop-box { background: #fffde7; border: 1px solid #fff9c4; border-radius: var(--tile-radius); padding: 10px; margin-top: 10px; font-size: 0.82rem; }
.sop-box strong { color: var(--secondary); }
.comm-detail-header { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.comm-detail-icon { width: 52px; height: 52px; border-radius: var(--tile-radius); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.6rem; flex-shrink: 0; }
.comm-detail-members { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.comm-detail-member { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #f5f5f5; border-radius: var(--tile-radius); font-size: 0.85rem; }
.comm-detail-role { font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; white-space: nowrap; }

/* Committee dynamic add/remove buttons */
.comm-add-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 8px; margin: 6px 0 2px; border: 1px dashed var(--border);
  border-radius: var(--tile-radius); background: transparent; color: var(--text-light);
  font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: 0.2s;
}
.comm-add-btn:hover { border-color: var(--primary); color: var(--primary); background: #f5f7ff; }
.comm-remove-btn {
  background: none; border: none; color: #bbb; font-size: 1.1rem;
  cursor: pointer; padding: 2px 6px; line-height: 1; transition: 0.2s; flex-shrink: 0;
}
.comm-remove-btn:hover { color: var(--danger); }

/* Add Committee card */
.comm-add-card {
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--border); cursor: pointer; min-height: 200px;
  transition: 0.2s;
}
.comm-add-card:hover { border-color: var(--primary); background: #f5f7ff; }
.comm-add-card-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text-light); font-weight: 600; }
.comm-add-card-icon { font-size: 2.5rem; line-height: 1; color: var(--primary); }

/* Edit committee button */
.comm-edit-btn {
  background: none; border: none; color: var(--text-light); font-size: 1rem;
  cursor: pointer; padding: 2px 8px; margin-left: auto; transition: 0.2s; opacity: 0.5;
}
.comm-edit-btn:hover { color: var(--primary); opacity: 1; }
.committee-card h3 { display: flex; align-items: center; }

/* Committee edit/add modal */
.comm-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.comm-modal {
  background: #fff; border-radius: 8px; width: 420px; max-width: 95vw;
  box-shadow: 0 2px 16px rgba(0,0,0,0.15);
}
.comm-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.comm-modal-header h3 { margin: 0; font-size: 1rem; }
.comm-modal-body { padding: 16px 20px; }
.comm-modal-body label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-light); margin: 10px 0 4px; }
.comm-modal-body label:first-child { margin-top: 0; }
.comm-modal-body .form-control { width: 100%; padding: 8px 10px; }
.comm-modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 12px 20px; border-top: 1px solid var(--border);
}

/* Color swatches */
.comm-color-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.comm-color-swatch {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: 0.15s;
}
.comm-color-swatch:hover { transform: scale(1.15); }
.comm-color-swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--text); }

/* ========== FORMULA / LEGAL ========== */
.formula-box { background: #f7f8fc; padding: 20px; border-radius: var(--tile-radius); border: 1px solid var(--border); margin: 15px 0; }
.formula-box h4 { color: var(--primary); margin-bottom: 8px; }
.formula-step { display: flex; align-items: flex-start; gap: 12px; margin: 10px 0; padding: 10px; background: #fff; border-radius: var(--tile-radius); }
.step-num { background: var(--primary); color: #fff; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; flex-shrink: 0; }
.legal-box { background: #fff8f0; border: 1px solid var(--border); border-radius: var(--tile-radius); padding: 20px; margin: 15px 0; }
.legal-box h4 { color: var(--danger); margin-bottom: 10px; }

/* ========== TIMELINE ========== */
.timeline { position: relative; padding-left: 30px; }
.timeline::before { content: ''; position: absolute; left: 10px; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-item::before { content: ''; position: absolute; left: -24px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--secondary); border: 2px solid var(--primary); }
.timeline-item h4 { color: var(--primary); }

/* ========== SUMMARY DASHBOARD ========== */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 15px; margin: 20px 0; }
.summary-card { background: #fff; border-radius: var(--tile-radius); padding: 15px; text-align: center; border: 1px solid var(--border); }
.summary-card .name { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.summary-card .position { margin: 5px 0; }
.summary-card .task-count { font-size: 2rem; font-weight: 700; color: var(--secondary); }
.summary-card .task-list { text-align: left; font-size: 0.82rem; margin-top: 8px; max-height: 120px; overflow-y: auto; }
.summary-card .task-list div { padding: 2px 0; border-bottom: 1px solid #f0f0f0; }

/* ========== MODAL ========== */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); z-index: 3000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.hidden { display: none; }
.modal-content { background: #fff; border-radius: 8px; width: 90%; max-width: 800px; max-height: 90vh; overflow: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { color: var(--primary); }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-light); padding: 5px; }
.modal-body { padding: 20px; }
.modal-body img { max-width: 100%; border-radius: var(--tile-radius); }
.modal-body iframe { width: 100%; min-height: 500px; border: none; border-radius: var(--tile-radius); }
.modal-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 15px; flex-wrap: wrap; gap: 0; }
.modal-tab { padding: 10px 18px; font-size: 0.85rem; font-weight: 600; cursor: pointer; border: none; background: none; color: var(--text-light); border-bottom: 2px solid transparent; transition: 0.2s; }
.modal-tab:hover { color: var(--primary); background: #f5f5f5; }
.modal-tab.active { color: var(--primary); border-bottom-color: var(--secondary); }
.modal-tab-panel { display: none; }
.modal-tab-panel.active { display: block; }

/* ========== KPI DASHBOARD ========== */
.kpi-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
  margin-bottom: 20px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--tile-radius);
}
.kpi-card {
  background: transparent; border-radius: 0; padding: 20px 16px; text-align: center;
  border: none; border-right: 1px solid var(--border);
  position: relative; overflow: hidden; transition: background 0.2s;
}
.kpi-card:last-child { border-right: none; }
.kpi-card:hover { background: #fafafa; }
.kpi-card::before { display: none; }
.kpi-icon {
  width: 48px; height: 48px; border-radius: var(--tile-radius); display: inline-flex;
  align-items: center; justify-content: center; color: #fff; font-size: 1.4rem;
  margin: 0 auto 10px;
}
.kpi-value { font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1.1; margin-bottom: 4px; }
.kpi-label { font-size: 0.8rem; color: var(--text-light); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-sub { font-size: 0.72rem; color: var(--text-light); margin-top: 4px; }
.kpi-trend { font-size: 0.78rem; font-weight: 600; margin-top: 4px; }
.kpi-trend-up { color: #2e7d32; }
.kpi-trend-down { color: #c62828; }
.kpi-trend-flat { color: #666; }
.kpi-critical { color: #c62828 !important; font-weight: 700; }

/* KPI Charts */
.kpi-charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.kpi-chart-card {
  background: #fff; border-radius: var(--tile-radius); padding: 20px;
  border: 1px solid var(--border);
}
.kpi-chart-card h3 { color: var(--primary); font-size: 1rem; margin-bottom: 16px; }

/* KPI Action Items */
.kpi-actions-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.kpi-action-card {
  background: #fff; border-radius: var(--tile-radius); padding: 18px;
  border: 1px solid var(--border);
  max-height: 320px; overflow-y: auto;
}
.kpi-action-card h3 { font-size: 0.9rem; color: var(--primary); margin-bottom: 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.kpi-action-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-bottom: 1px solid #f5f5f5; font-size: 0.82rem;
  transition: background 0.2s; cursor: pointer;
}
.kpi-action-item:hover { background: #f5f5f5; }
.kpi-action-item .kpi-ai-label { font-weight: 600; color: var(--text); flex: 1; }
.kpi-action-item .kpi-ai-badge { font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.kpi-empty { text-align: center; padding: 20px; color: var(--text-light); font-size: 0.85rem; }

/* AI Insights Card */
.kpi-ai-card {
  background: #f7f8fc; border-radius: var(--tile-radius);
  padding: 20px; margin-bottom: 20px; border: 1px solid var(--border);
}
.kpi-ai-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.kpi-ai-header span { font-size: 1.05rem; font-weight: 700; color: var(--primary); }
#kpiAiContent { font-size: 0.88rem; line-height: 1.6; }
#kpiAiContent ul { padding-left: 18px; margin: 6px 0; }
#kpiAiContent li { margin-bottom: 4px; }

/* ========== COMPLAINT CARD ========== */
.complaint-card {
  background: #fff; border-radius: var(--tile-radius); padding: 16px; margin-bottom: 12px;
  border: 1px solid var(--border); border-left: 3px solid var(--primary); transition: 0.2s;
}
.complaint-card:hover { background: #fafafa; }
.complaint-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.complaint-card-title { font-weight: 700; color: var(--text); font-size: 0.95rem; }
.complaint-card-meta { font-size: 0.78rem; color: var(--text-light); margin-bottom: 8px; }
.complaint-card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.complaint-card[data-priority="Critical"] { border-left-color: #b71c1c; }
.complaint-card[data-priority="High"] { border-left-color: #e65100; }
.complaint-card[data-priority="Medium"] { border-left-color: #f57f17; }
.complaint-card[data-priority="Low"] { border-left-color: #2e7d32; }

/* ========== MEETING CARD ========== */
.meeting-card {
  background: #fff; border-radius: var(--tile-radius); padding: 16px; margin-bottom: 12px;
  border: 1px solid var(--border); border-left: 3px solid var(--primary); cursor: pointer; transition: 0.2s;
}
.meeting-card:hover { background: #fafafa; }
.meeting-card-type { font-size: 0.7rem; padding: 2px 10px; border-radius: 10px; font-weight: 600; display: inline-block; margin-bottom: 6px; }
.meeting-type-bom { background: #e8eaf6; color: #1a237e; }
.meeting-type-gbm { background: #fff3e0; color: #e65100; }
.meeting-type-committee { background: #e0f2f1; color: #00695c; }
.meeting-type-emergency { background: #fce4ec; color: #b71c1c; }

/* ========== RESIDENT DIRECTORY ========== */
.directory-search-bar { background: #fff; border-radius: var(--tile-radius); padding: 16px; border: 1px solid var(--border); margin-bottom: 15px; }
.directory-search-bar input { font-size: 1rem; padding: 12px 16px; border: 1px solid #e0e0e0; border-radius: var(--tile-radius); width: 100%; box-sizing: border-box; transition: border-color 0.3s; }
.directory-search-bar input:focus { border-color: var(--primary); outline: none; }
.directory-filters { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.directory-filters select { padding: 8px 12px; border-radius: var(--tile-radius); border: 1px solid #ddd; font-size: 0.85rem; min-width: 130px; }
.directory-stats { display: flex; gap: 12px; flex-wrap: wrap; }
.dir-stat-card { background: #fff; border-radius: var(--tile-radius); padding: 12px 18px; border: 1px solid var(--border); flex: 1; min-width: 120px; text-align: center; }
.dir-stat-card .stat-num { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.dir-stat-card .stat-label { font-size: 0.75rem; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; }
.dir-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.dir-table th { background: #f5f5f5; color: var(--text); padding: 10px 12px; text-align: left; font-weight: 600; position: sticky; top: 0; border-bottom: 2px solid var(--border); }
.dir-table td { padding: 8px 12px; border-bottom: 1px solid #eee; }
.dir-table tr:hover { background: #f0f7ff; }
.dir-table-wrap { max-height: 500px; overflow-y: auto; background: #fff; border-radius: var(--tile-radius); border: 1px solid var(--border); }
.dir-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; font-weight: 600; }
.dir-badge-owner { background: #e3f2fd; color: #1565c0; }
.dir-badge-tenant { background: #fff3e0; color: #e65100; }
.dir-badge-family { background: #f3e5f5; color: #7b1fa2; }
.dir-badge-active { background: #e8f5e9; color: #2e7d32; }
.dir-badge-inactive { background: #fce4ec; color: #c62828; }
.dir-tower-tag { background: #263238; color: #fff; padding: 2px 6px; border-radius: var(--tile-radius); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.5px; margin-right: 4px; }

/* ========== AUTOCOMPLETE ========== */
.autocomplete-wrapper { position: relative; flex: 1; }
.autocomplete-wrapper input { width: 100%; box-sizing: border-box; }
.autocomplete-list { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid #ddd; border-top: none; border-radius: 0 0 var(--tile-radius) var(--tile-radius); max-height: 200px; overflow-y: auto; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.1); display: none; }
.autocomplete-list.show { display: block; }
.autocomplete-item { padding: 8px 12px; cursor: pointer; font-size: 0.82rem; border-bottom: 1px solid #f5f5f5; display: flex; justify-content: space-between; align-items: center; }
.autocomplete-item:hover, .autocomplete-item.active { background: #e3f2fd; }
.autocomplete-item .ac-name { font-weight: 600; color: #333; }
.autocomplete-item .ac-flat { font-size: 0.75rem; color: #666; background: #f5f5f5; padding: 1px 6px; border-radius: var(--tile-radius); }
.autocomplete-item .ac-type { font-size: 0.65rem; color: #999; }

/* ========== MANAGE RESIDENTS ========== */
.mgr-form-card { background: #fff; border: 1px solid var(--border); border-radius: var(--tile-radius); padding: 20px; margin-bottom: 15px; }
.mgr-form-card h4 { font-size: 1rem; margin-bottom: 12px; }
.mgr-form-card .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 4px; }

/* ========== PROJECT DASHBOARD ========== */
.proj-stats-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.proj-stat-card { background: #fff; border-radius: var(--tile-radius); padding: 16px; text-align: center; border: 1px solid var(--border); border-top: 2px solid var(--primary); }
.proj-stat-card .stat-value { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.proj-stat-card .stat-label { font-size: 0.8rem; color: var(--text-light); margin-top: 4px; }
.proj-filter-bar { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.proj-filter-btn { padding: 6px 16px; border-radius: 20px; border: 1px solid var(--border); background: #fff; font-size: 0.8rem; cursor: pointer; font-weight: 600; transition: 0.2s; }
.proj-filter-btn:hover { opacity: 0.85; }
.proj-filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.proj-summary-card { background: #fff; border-radius: var(--tile-radius); padding: 18px; border: 1px solid var(--border); border-left: 3px solid var(--primary); transition: 0.2s; margin-bottom: 12px; }
.proj-summary-card:hover { background: #fafafa; }
.proj-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.proj-card-title { font-size: 1.05rem; font-weight: 700; margin: 0; line-height: 1.3; }
.proj-card-committee { font-size: 0.8rem; font-weight: 600; margin-top: 3px; }
.proj-card-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-light); margin-bottom: 12px; }
.proj-card-meta strong { color: var(--text); }
.proj-card-progress { margin-bottom: 12px; }
.proj-card-progress-bar { background: #e0e0e0; border-radius: var(--tile-radius); height: 20px; position: relative; overflow: hidden; }
.proj-card-progress-fill { height: 100%; border-radius: var(--tile-radius); transition: width 0.3s; }
.proj-card-progress-text { position: absolute; top: 1px; width: 100%; text-align: center; font-size: 0.7rem; font-weight: 700; }
.proj-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.proj-action-btn { padding: 7px 14px; border-radius: var(--tile-radius); border: none; font-size: 0.78rem; font-weight: 600; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; gap: 5px; }
.proj-action-btn:hover { opacity: 0.85; }
.proj-action-btn-committee { background: #e8eaf6; color: var(--primary); border: 1px solid #c5cae9; }
.proj-action-btn-status { background: #fff3e0; color: #e65100; border: 1px solid #ffe0b2; }
.proj-action-btn-edit { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.proj-action-btn-view { background: #f5f5f5; color: #999; border: 1px solid #e0e0e0; cursor: default; }
.proj-action-btn-view:hover { opacity: 1; }
details summary { list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: '+ '; font-weight: 700; }
details[open] summary::before { content: '- '; }
details[open] summary { margin-bottom: 8px; }

/* ========== ADMIN PANEL ========== */
.admin-section { background: #fff8f0; border: 1px solid var(--border); border-radius: var(--tile-radius); padding: 20px; margin-bottom: 20px; }
.admin-section h3 { color: var(--secondary); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }

/* ========== ACCOUNT MANAGEMENT ========== */
.acct-success-card { background: #f0f9f1; border: 1px solid #c8e6c9; border-radius: var(--tile-radius); padding: 20px; margin: 16px 0; }
.acct-success-card h4 { color: #2e7d32; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; font-size: 1rem; }
.acct-success-detail { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 0.88rem; margin-bottom: 14px; }
.acct-success-detail dt { font-weight: 600; color: #37474f; }
.acct-success-detail dd { color: #212121; margin: 0; }
.acct-copy-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.acct-copy-btn { padding: 8px 16px; border-radius: var(--tile-radius); border: none; font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; gap: 5px; }
.acct-copy-btn:hover { opacity: 0.85; }
.acct-copy-btn-cred { background: #1a237e; color: #fff; }
.acct-copy-btn-wp { background: #25d366; color: #fff; }
.acct-copy-btn-dismiss { background: #e0e0e0; color: #616161; }
.acct-list-section { margin-top: 20px; }
.acct-list-section h4 { color: var(--primary); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; font-size: 1rem; }
.acct-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.acct-table th { background: #f5f5f5; color: var(--text); padding: 10px 8px; text-align: left; font-size: 0.8rem; font-weight: 600; border-bottom: 2px solid var(--border); }
.acct-table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.acct-table tr:nth-child(even) { background: #f9f9f9; }
.acct-table tr:hover { background: #f0f4ff; }
.acct-status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 12px; font-size: 0.72rem; font-weight: 600; }
.acct-status-active { background: #e8f5e9; color: #2e7d32; }
.acct-status-never { background: #fff3e0; color: #e65100; }
.acct-status-dot { width: 7px; height: 7px; border-radius: 50%; }
.acct-status-active .acct-status-dot { background: #2e7d32; }
.acct-status-never .acct-status-dot { background: #e65100; }
.acct-pw-reveal { background: #f5f5f5; padding: 3px 8px; border-radius: var(--tile-radius); font-family: 'Courier New', monospace; font-weight: 700; font-size: 0.82rem; color: var(--primary); cursor: pointer; border: 1px solid #e0e0e0; }
.acct-pw-reveal:hover { background: #e8eaf6; }
.acct-action-group { display: flex; gap: 4px; flex-wrap: nowrap; }
.acct-action-group .btn-sm { padding: 4px 8px; font-size: 0.72rem; min-width: 30px; min-height: 30px; display: inline-flex; align-items: center; justify-content: center; }
.acct-edit-form { display: grid; gap: 14px; }
.acct-edit-form .form-group { margin-bottom: 0; }
.acct-edit-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.acct-edit-actions { display: flex; gap: 10px; margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.acct-edit-meta { font-size: 0.78rem; color: var(--text-light); padding: 10px; background: #f5f5f5; border-radius: var(--tile-radius); margin-top: 4px; }
.acct-empty { text-align: center; padding: 30px 20px; color: var(--text-light); }
.acct-empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
.acct-summary-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.acct-summary-item { background: #fff; border-radius: var(--tile-radius); padding: 12px; text-align: center; border: 1px solid var(--border); border-top: 2px solid var(--primary); }
.acct-summary-item .acct-sum-val { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.acct-summary-item .acct-sum-lbl { font-size: 0.75rem; color: var(--text-light); margin-top: 2px; }

/* ========== NOTICE BOARD ========== */
.notice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.notice-card { background: #fff; border-radius: var(--tile-radius); overflow: hidden; border: 1px solid var(--border); cursor: pointer; transition: 0.2s; }
.notice-card:hover { background: #fafafa; }
.notice-card .notice-body { padding: 15px; }
.notice-card .notice-date { font-size: 0.75rem; color: var(--text-light); }
.notice-card .notice-title { font-size: 1rem; font-weight: 700; color: var(--primary); margin: 5px 0; }
.notice-card .notice-summary { font-size: 0.85rem; color: var(--text-light); line-height: 1.4; }
.notice-card .notice-cat { margin-top: 8px; }
.notice-filter { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.notice-filter-btn { padding: 6px 16px; border-radius: 20px; border: 1px solid var(--border); background: #fff; font-size: 0.8rem; cursor: pointer; font-weight: 600; transition: 0.2s; }
.notice-filter-btn.active, .notice-filter-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ========== SESSION EXPIRED ========== */
.session-expired-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 10000;
  background: rgba(13, 27, 74, 0.95); display: flex; align-items: center; justify-content: center;
  flex-direction: column; transition: opacity 0.4s, visibility 0.4s;
}
.session-expired-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.session-expired-card {
  background: #fff; border-radius: 8px; padding: 40px 30px; text-align: center;
  max-width: 380px; width: 90%; box-shadow: 0 2px 16px rgba(0,0,0,0.15);
}
.session-expired-icon { font-size: 3.5rem; margin-bottom: 15px; }
.session-expired-card h2 { color: var(--primary); margin-bottom: 8px; font-size: 1.3rem; }
.session-expired-card p { color: var(--text-light); font-size: 0.9rem; margin-bottom: 20px; }

/* ========== LOADING STATES ========== */
.loading-spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 3px solid #e0e0e0; border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.loading-spinner-lg { width: 40px; height: 40px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; padding: 30px; color: var(--text-light); font-size: 0.9rem;
}
.loading-overlay.hidden { display: none; }

/* ========== TOAST ========== */
.toast-container {
  position: fixed; top: 60px; right: 20px; z-index: 5000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: #333; color: #fff; padding: 12px 20px; border-radius: var(--tile-radius);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15); font-size: 0.85rem;
  animation: toastSlide 0.3s ease-out; max-width: 360px;
}
.toast-success { background: #2e7d32; }
.toast-error { background: #c62828; }
.toast-info { background: #1565c0; }
@keyframes toastSlide { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ========== PRINT ========== */
@media print {
  .dash-header, .dash-sidebar, .auth-overlay, .modal-overlay, .toast-container { display: none !important; }
  .dash-main { margin-left: 0 !important; padding-top: 20px; }
  .bom-sec { display: block !important; page-break-after: always; }
  .btn, .action-bar { display: none !important; }
}

/* ========== RESPONSIVE: TABLET ========== */
@media (max-width: 900px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .kpi-card { border-right: none; border-bottom: 1px solid var(--border); }
  .kpi-card:nth-child(odd) { border-right: 1px solid var(--border); }
  .kpi-card:nth-last-child(-n+2) { border-bottom: none; }
  .kpi-charts-row { grid-template-columns: 1fr; }
  .kpi-actions-row { grid-template-columns: 1fr; }
  .proj-stats-bar { grid-template-columns: 1fr 1fr; gap: 8px; }
  .acct-summary-bar { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .comm-detail-members { grid-template-columns: 1fr; }
}

/* ========== RESPONSIVE: MOBILE ========== */
@media (max-width: 768px) {
  /* Sidebar becomes overlay drawer */
  .dash-sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
    z-index: 1100;
    box-shadow: 4px 0 20px rgba(0,0,0,0.2);
  }
  .dash-sidebar.mobile-open { transform: translateX(0); }

  .sidebar-collapsed .dash-sidebar { width: var(--sidebar-width); }
  .sidebar-collapsed .dash-sidebar .sidebar-group-header .group-label,
  .sidebar-collapsed .dash-sidebar .sidebar-group-header .group-caret,
  .sidebar-collapsed .dash-sidebar .sidebar-item .item-label,
  .sidebar-collapsed .dash-sidebar .sidebar-item .item-badge,
  .sidebar-collapsed .dash-sidebar .sidebar-footer-text { display: initial; }
  .sidebar-collapsed .dash-sidebar .sidebar-group-header { justify-content: initial; padding: 10px 16px; }
  .sidebar-collapsed .dash-sidebar .sidebar-item { justify-content: initial; padding: 9px 16px 9px 28px; border-left: 3px solid transparent; }

  /* Backdrop */
  .sidebar-backdrop {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1099;
  }
  .sidebar-backdrop.active { display: block; }

  .dash-main { margin-left: 0; padding: 70px 12px 30px; }
  .sidebar-collapsed .dash-main { margin-left: 0; }

  .page-title { font-size: 1.2rem; }
  .page-subtitle { font-size: 0.82rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: 12px; }

  .card { padding: 14px; margin-bottom: 12px; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .form-control { min-height: 44px; }

  .member-form { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .task-row { flex-wrap: wrap; }
  .task-row select { width: 100%; min-height: 40px; }

  table { display: block; overflow-x: auto; font-size: 0.78rem; }
  th, td { padding: 6px 5px; white-space: nowrap; }

  .auth-card { padding: 25px 18px; width: 95%; }
  .modal-content { width: 97%; border-radius: 8px; }

  .directory-filters { flex-direction: column; }
  .directory-filters select { width: 100%; }
  .audit-filters { flex-direction: column; }

  .dash-header { padding: 0 12px; height: 50px; }
  .dash-header .header-title { font-size: 0.82rem; }
  .dash-header .header-sub { font-size: 0.6rem; }
  .header-user { font-size: 0.65rem; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .acct-table { display: block; overflow-x: auto; }
  .acct-edit-row { grid-template-columns: 1fr; }
  .acct-copy-bar { flex-direction: column; }
  .acct-copy-btn { width: 100%; justify-content: center; min-height: 44px; }

  .proj-card-header { flex-direction: column; gap: 6px; }
  .proj-card-actions { flex-direction: column; }
  .proj-action-btn { width: 100%; justify-content: center; min-height: 44px; }

  .comm-detail-header { flex-direction: column; text-align: center; }
  .comm-member-slot { flex-wrap: wrap; }

  .modal-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .modal-tab { white-space: nowrap; flex-shrink: 0; min-height: 44px; }
}

@media (max-width: 480px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .kpi-card { padding: 14px 10px; }
  .kpi-icon { width: 38px; height: 38px; font-size: 1.1rem; }
  .kpi-value { font-size: 1.3rem; }
  .kpi-label { font-size: 0.68rem; }

  .proj-stats-bar { grid-template-columns: 1fr 1fr; gap: 6px; }
  .proj-stat-card { padding: 10px 6px; }
  .proj-stat-card .stat-value { font-size: 1.2rem; }

  .card { padding: 12px 10px; }
  .card h3 { font-size: 0.92rem; }
  .page-title { font-size: 1.05rem; }

  .acct-summary-bar { grid-template-columns: 1fr; }
  .header-user { display: none; }

  .dir-stat-card { min-width: 70px; padding: 8px 10px; }
  .dir-stat-card .stat-num { font-size: 1.2rem; }

  .mgr-form-card .grid-2 { grid-template-columns: 1fr; }
}
