:root {
  --bg: #f8f9fc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --primary: #f59e0b;
  --primary-light: #fef3c7;
  --primary-dark: #b45309;
  --accent: #3b82f6;
  --danger: #ef4444;
  --success: #10b981;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);
  --sidebar-w: 220px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #334155;
  --primary: #f59e0b;
  --primary-light: rgba(245,158,11,0.15);
  --primary-dark: #fbbf24;
  --accent: #60a5fa;
  --danger: #f87171;
  --success: #34d399;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border: #334155;
  --border-light: #1e293b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
}
[data-theme="dark"] .status-active { background: rgba(16,185,129,0.15); color: #34d399; }
[data-theme="dark"] .status-pending { background: rgba(245,158,11,0.15); color: #fbbf24; }
[data-theme="dark"] .status-inactive { background: rgba(239,68,68,0.15); color: #f87171; }
[data-theme="dark"] .filter-tag { background: rgba(245,158,11,0.15); color: #fbbf24; }
[data-theme="dark"] .tag-close { color: #fbbf24; }
[data-theme="dark"] .del-btn { border-color: rgba(248,113,113,0.3); }
[data-theme="dark"] .del-btn:hover { background: rgba(248,113,113,0.1); }
[data-theme="dark"] .kpi-total .kpi-icon { background: rgba(37,99,235,0.15); }
[data-theme="dark"] .kpi-week .kpi-icon { background: rgba(5,150,105,0.15); }
[data-theme="dark"] .kpi-month .kpi-icon { background: rgba(79,70,229,0.15); }
[data-theme="dark"] .kpi-missing .kpi-icon { background: rgba(220,38,38,0.15); }

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border: none; background: none;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; width: 100%;
  transition: all .15s; text-align: right; font-family: inherit;
}
.theme-toggle svg { width: 20px; height: 20px; flex-shrink: 0; transition: transform .4s ease; }
.theme-toggle:hover { background: var(--surface-hover); color: var(--text); }
[data-theme="dark"] .theme-toggle svg { transform: rotate(360deg); }

/* ===== LANDING ===== */
.landing-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, #1e1b4b 0%, #312e81 30%, #4338ca 60%, #6366f1 100%);
  overflow: hidden;
  position: relative;
}
.landing-screen::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(251,191,36,0.2) 0%, transparent 70%);
  top: -100px; right: -100px;
  border-radius: 50%;
}
.landing-content { text-align: center; position: relative; z-index: 1; }
.landing-logo {
  width: 80px; height: 80px;
  background: var(--primary);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 800; color: #fff;
  margin: 0 auto 24px;
  box-shadow: 0 8px 32px rgba(245,158,11,0.3);
}
.landing-title {
  font-size: 56px; font-weight: 800; color: #fff;
  margin-bottom: 8px; letter-spacing: -1px;
}
.landing-subtitle {
  font-size: 20px; color: rgba(255,255,255,0.7);
  margin-bottom: 48px; font-weight: 400;
}
.sound-btn {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin: 0 auto 40px; padding: 28px 40px;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px; cursor: pointer;
  transition: all .3s; color: #fff;
}
.sound-btn:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.3);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.sound-icon { width: 52px; height: 52px; }
.sound-label { font-size: 15px; font-weight: 600; }
.landing-login-btn {
  padding: 16px 48px; font-size: 17px; border-radius: 12px;
  background: var(--primary); color: #fff; font-weight: 700;
  border: none; cursor: pointer;
  box-shadow: 0 8px 32px rgba(245,158,11,0.3);
  transition: all .25s;
}
.landing-login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(245,158,11,0.4);
}

/* ===== LOGIN ===== */
.error { color: var(--danger); margin-top: 10px; font-size: 13px; }

/* ===== LANDING INLINE LOGIN ===== */
.landing-login-form {
  display: none;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
  animation: landingFormIn .25s ease;
}
.landing-login-form.show { display: flex; }
@keyframes landingFormIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.landing-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 10px;
  font-size: 15px;
  direction: rtl;
  font-family: 'IBM Plex Sans', sans-serif;
  background: rgba(255,255,255,0.10);
  color: #fff;
  transition: border-color .2s, background .2s;
}
.landing-input::placeholder { color: rgba(255,255,255,0.6); }
.landing-input:focus {
  outline: none;
  border-color: #fff;
  background: rgba(255,255,255,0.16);
}
.landing-submit {
  width: 100%;
  background: #fff;
  color: #003366;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 16px;
  font-weight: 700;
  padding: 15px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  transition: transform .15s, box-shadow .15s;
  margin-top: 2px;
}
.landing-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.landing-error {
  color: #fecaca;
  font-size: 13px;
  text-align: center;
}
.landing-back {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  padding: 4px;
  transition: color .2s;
}
.landing-back:hover { color: #fff; }

/* ===== APP LAYOUT ===== */
.app-screen { display: flex; min-height: 100vh; zoom: 1; }
body.scale-small .app-screen { zoom: 0.92; }
body.scale-large .app-screen { zoom: 1.1; }

.sidebar {
  width: var(--sidebar-w); background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; right: 0; bottom: 0;
  z-index: 90;
  transition: background .3s, border-color .3s;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px; font-size: 18px; font-weight: 700;
  color: var(--text); border-bottom: 1px solid var(--border-light);
}
.sidebar-logo {
  width: 36px; height: 36px; background: var(--primary);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff; flex-shrink: 0;
}
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-bottom { padding: 12px 10px; border-top: 1px solid var(--border-light); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border: none; background: none;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; width: 100%;
  transition: all .15s; text-align: right; font-family: inherit;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.logout-btn:hover { color: var(--danger); }

.main-content {
  flex: 1;
  margin-right: var(--sidebar-w);
  padding: 28px 32px;
  min-height: 100vh;
}

/* ===== PAGE ELEMENTS ===== */
.page-title { font-size: 24px; font-weight: 700; margin-bottom: 24px; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-actions { display: flex; gap: 10px; align-items: center; }

/* ===== KPI CARDS ===== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.kpi-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  display: flex; flex-direction: column; gap: 4px;
  transition: all .3s;
}
.kpi-card:hover { box-shadow: var(--shadow); }
.kpi-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.kpi-icon svg { width: 22px; height: 22px; }
.kpi-total .kpi-icon { background: #dbeafe; color: #2563eb; }
.kpi-total .kpi-icon svg { stroke: #2563eb; }
.kpi-week .kpi-icon { background: #d1fae5; color: #059669; }
.kpi-week .kpi-icon svg { stroke: #059669; }
.kpi-month .kpi-icon { background: #e0e7ff; color: #4f46e5; }
.kpi-month .kpi-icon svg { stroke: #4f46e5; }
.kpi-missing .kpi-icon { background: #fee2e2; color: #dc2626; }
.kpi-missing .kpi-icon svg { stroke: #dc2626; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.kpi-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.clickable { cursor: pointer; }
.clickable:hover { border-color: var(--primary); }

/* ===== DASHBOARD BODY ===== */
.dashboard-body {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
}
.charts-area { min-width: 0; }
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
.chart-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: background .3s, border-color .3s;
}
.chart-box h3 { font-size: 15px; margin-bottom: 12px; color: var(--text); font-weight: 600; }

/* ===== ACTIVITY FEED ===== */
.activity-panel {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  height: fit-content; position: sticky; top: 28px;
}
.activity-panel h3 {
  font-size: 15px; margin-bottom: 16px; color: var(--text); font-weight: 600;
}
.activity-feed {
  display: flex; flex-direction: column; gap: 0;
  max-height: 480px; overflow-y: auto;
}
.activity-item {
  display: flex; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; margin-top: 5px;
}
.activity-dot.created { background: var(--success); }
.activity-dot.deleted { background: var(--danger); }
.activity-dot.updated { background: var(--accent); }
.activity-dot.upload { background: var(--primary); }
.activity-dot.status { background: #8b5cf6; }
.activity-text { color: var(--text-secondary); line-height: 1.4; }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.activity-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 20px 0; }

/* ===== BUTTONS ===== */
.btn-primary {
  padding: 9px 20px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .2s; font-family: inherit;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger {
  padding: 9px 20px; background: var(--danger); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-ghost {
  padding: 9px 18px; background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all .2s; font-family: inherit;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-light); }
.btn-icon {
  background: none; border: none; font-size: 24px;
  cursor: pointer; color: var(--text-muted); line-height: 1;
}
.upload-btn {
  padding: 9px 20px; background: var(--accent); color: #fff;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .2s; display: inline-flex; align-items: center;
}
.upload-btn:hover { background: #2563eb; }

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex; gap: 12px; align-items: center;
  flex-wrap: wrap; margin-bottom: 16px;
}
.search-box {
  flex: 1; min-width: 260px; position: relative;
}
.search-box input {
  width: 100%; padding: 10px 16px 10px 40px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; direction: rtl; background: var(--surface);
  transition: border-color .2s; font-family: inherit;
}
.search-box input:focus { outline: none; border-color: var(--primary); }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-muted); pointer-events: none;
}
.toolbar select {
  padding: 10px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px;
  background: var(--surface); direction: rtl; font-family: inherit;
}
.filter-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; background: #fef3c7; color: #92400e;
  border-radius: 20px; font-size: 13px; font-weight: 500;
}
.tag-close {
  background: none; border: none; font-size: 16px;
  cursor: pointer; color: #92400e; line-height: 1;
}

/* ===== TABLE ===== */
.table-wrap {
  overflow-x: auto; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: background .3s, border-color .3s;
}
#usersTable, #volunteersTable, #eventsTable { width: 100%; border-collapse: collapse; font-size: 14px; }
#usersTable th, #usersTable td,
#volunteersTable th, #volunteersTable td,
#eventsTable th, #eventsTable td {
  padding: 12px 16px; text-align: right;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap; transition: background .2s;
}
#usersTable th, #volunteersTable th, #eventsTable th {
  background: var(--bg); font-weight: 600;
  color: var(--text-secondary); font-size: 13px;
  position: sticky; top: 0; z-index: 1;
}
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--primary-dark); }
#usersTable tbody tr, #volunteersTable tbody tr, #eventsTable tbody tr {
  transition: background .15s;
  animation: rowFadeIn .35s ease both;
}
#usersTable tbody tr:nth-child(even), #volunteersTable tbody tr:nth-child(even), #eventsTable tbody tr:nth-child(even) { background: var(--bg); }
#usersTable tbody tr:nth-child(odd), #volunteersTable tbody tr:nth-child(odd), #eventsTable tbody tr:nth-child(odd) { background: var(--surface); }
#usersTable tbody tr:hover, #volunteersTable tbody tr:hover, #eventsTable tbody tr:hover { background: var(--surface-hover); }

@keyframes rowFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.status-badge {
  display: inline-block; padding: 4px 12px;
  border-radius: 20px; font-size: 12px; font-weight: 600;
}
.status-active { background: #d1fae5; color: #065f46; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-inactive { background: #fee2e2; color: #991b1b; }
.status-contact-only { background: #d1fae5; color: #065f46; font-style: italic; }
.contact-only-row { border-right: 3px solid #10b981; }
[data-theme="dark"] .status-contact-only { background: rgba(16,185,129,0.15); color: #34d399; }

.action-btn {
  padding: 5px 12px; border: 1px solid var(--border);
  background: var(--surface); border-radius: 6px;
  font-size: 13px; cursor: pointer; transition: all .15s; font-family: inherit;
}
.action-btn:hover { border-color: var(--primary); color: var(--primary-dark); }
.del-btn { color: var(--danger); border-color: #fecaca; }
.del-btn:hover { background: #fef2f2; border-color: var(--danger); }
.approve-btn:hover { background: #f0fdf4; border-color: var(--success); }
.role-select {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-family: inherit; background: var(--surface);
  color: var(--text); cursor: pointer; direction: rtl;
}
.role-select:focus { outline: none; border-color: var(--primary); }

/* ===== PAGINATION ===== */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; margin-top: 18px;
}
.pagination button {
  padding: 8px 18px; border: 1px solid var(--border);
  background: var(--surface); border-radius: var(--radius-sm);
  font-size: 14px; cursor: pointer; font-family: inherit; transition: all .15s;
}
.pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary-dark); }
.pagination button:disabled { opacity: .4; cursor: default; }
#pageInfo { font-size: 13px; color: var(--text-muted); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  animation: overlayFadeIn .2s ease both;
}
@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: var(--surface); border-radius: 16px;
  padding: 28px; width: 560px; max-width: 95vw;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border-light);
  animation: modalSlideUp .3s ease both;
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 20px; font-weight: 700; }
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.form-grid label {
  display: flex; flex-direction: column;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
}
.form-grid input,
.form-grid select {
  margin-top: 4px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; direction: rtl; font-family: inherit;
  background: var(--bg); transition: border-color .2s;
}
.form-grid input:focus,
.form-grid select:focus { outline: none; border-color: var(--primary); }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ===== NOTES ===== */
#notesSection {
  margin-top: 24px; border-top: 1px solid var(--border-light); padding-top: 18px;
}
#notesSection h3 { margin-bottom: 10px; font-size: 16px; font-weight: 600; }
#notesList { max-height: 200px; overflow-y: auto; margin-bottom: 10px; }
.note-item {
  padding: 10px 12px; background: var(--bg);
  border-radius: var(--radius-sm); margin-bottom: 6px;
  font-size: 13px; display: flex;
  justify-content: space-between; align-items: flex-start; gap: 8px;
}
.note-item .note-text { flex: 1; }
.note-item .note-date { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.note-item .note-del {
  background: none; border: none; color: var(--danger);
  cursor: pointer; font-size: 16px; line-height: 1;
}
.note-add { display: flex; gap: 8px; }
.note-add input {
  flex: 1; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; direction: rtl; font-family: inherit;
}

/* ===== TAB TRANSITIONS ===== */
.tab-content {
  animation: tabFade .3s ease both;
}
@keyframes tabFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== RESULT COUNT ===== */
.result-count {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  padding: 2px 0;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-state svg {
  width: 56px; height: 56px;
  color: var(--text-muted); opacity: .5;
  margin-bottom: 16px;
}
.empty-state-title {
  font-size: 18px; font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.empty-state-sub {
  font-size: 14px;
  color: var(--text-muted);
}

/* ===== VOLUNTEER MAP ===== */
.vol-map-section {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light); margin-bottom: 20px;
}
.map-legend {
  display: flex; gap: 16px; margin-bottom: 10px; font-size: 13px; color: var(--text-secondary);
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* ===== EVENT DETAIL GRID ===== */
.event-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.event-detail-item {
  font-size: 14px;
  color: var(--text);
}
.event-detail-item strong {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
}

/* ===== SPINNER ===== */
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== SMS TAB ===== */

/* Compose card */
.sms-compose-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}
.sms-compose-body { padding: 24px 28px; }
.sms-compose-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 16px 28px;
  background: var(--bg);
  border-top: 1px solid var(--border-light);
}

/* Section title inside card */
.sms-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-muted);
  margin: 0 0 16px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

/* Field groups */
.sms-field { margin-bottom: 18px; }
.sms-field:last-child { margin-bottom: 0; }
.sms-field-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 6px;
}
.sms-field input,
.sms-field textarea,
.sms-field select {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; direction: rtl; font-family: inherit;
  background: var(--bg); color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.sms-field input:focus,
.sms-field textarea:focus,
.sms-field select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.12);
}
.sms-field input { max-width: 300px; }
.sms-field textarea { resize: vertical; min-height: 96px; }
.sms-char-count { font-size: 12px; color: var(--text-muted); margin-top: 5px; text-align: left; }

/* Segmented audience selector */
.sms-audience-group {
  display: inline-flex; gap: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--bg);
}
.sms-audience-group input[type="radio"] { display: none; }
.sms-audience-pill {
  padding: 8px 18px; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  transition: background .15s, color .15s;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}
.sms-audience-pill:last-of-type { border-left: none; }
.sms-audience-group input[type="radio"]:checked + .sms-audience-pill {
  background: var(--primary-light); color: var(--primary-dark); font-weight: 600;
}
.sms-audience-pill:hover { background: var(--surface-hover); color: var(--text); }
.sms-pill-count { font-size: 12px; opacity: .7; font-weight: 600; }

/* Source group search + multi-select */
.sms-source-group-search {
  width: 100%; max-width: 320px;
  padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px;
  font-family: inherit; background: var(--bg); color: var(--text);
  direction: rtl;
}
.sms-source-group-selected {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 8px;
}
.sms-source-group-selected:empty { display: none; }
.sms-source-group-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; background: var(--primary-light);
  color: var(--primary-dark); border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.sms-source-group-chip button {
  border: none; background: transparent; cursor: pointer;
  padding: 0 2px; font-size: 14px; line-height: 1;
  color: inherit; opacity: .7;
}
.sms-source-group-chip button:hover { opacity: 1; }
.sms-source-group-list {
  display: flex; flex-direction: column; gap: 0;
  max-height: 200px; overflow-y: auto; margin-top: 8px;
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  background: var(--surface);
}
.sms-source-group-list:empty { display: none; }
.sms-source-group-option {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; font-size: 13px; cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background .12s;
}
.sms-source-group-option:last-child { border-bottom: none; }
.sms-source-group-option:hover { background: var(--surface-hover); }
.sms-source-group-hint {
  padding: 12px; font-size: 13px; color: var(--text-secondary); text-align: center;
}

/* Recipient count pill */
.sms-recipient-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; background: var(--primary-light);
  color: var(--primary-dark); border-radius: 20px;
  font-size: 13px; font-weight: 600;
  min-width: 120px;
}

/* Campaigns table shared th style */
.sms-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sms-table th {
  padding: 12px 16px; text-align: right;
  background: var(--bg); font-weight: 600;
  color: var(--text-secondary); font-size: 13px;
  border-bottom: 1px solid var(--border-light);
}
.sms-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.sms-table tbody tr:hover { background: var(--surface-hover); }

/* Campaign status badges */
.sms-badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 20px; font-size: 12px; font-weight: 600;
}
.sms-badge-pending  { background: #f1f5f9; color: #475569; }
.sms-badge-sending  { background: #fef3c7; color: #92400e; }
.sms-badge-done     { background: #d1fae5; color: #065f46; }
.sms-badge-partial  { background: #ffedd5; color: #9a3412; }
.sms-badge-failed   { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .sms-badge-pending  { background: rgba(71,85,105,.25); color: #94a3b8; }
[data-theme="dark"] .sms-badge-sending  { background: rgba(245,158,11,.15); color: #fbbf24; }
[data-theme="dark"] .sms-badge-done     { background: rgba(16,185,129,.15); color: #34d399; }
[data-theme="dark"] .sms-badge-partial  { background: rgba(249,115,22,.15);  color: #fb923c; }
[data-theme="dark"] .sms-badge-failed   { background: rgba(239,68,68,.15);  color: #f87171; }

/* History section header */
.sms-history-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.sms-history-header h3 { font-size: 16px; font-weight: 600; margin: 0; }

/* Form-link dropdown items */
#formLinkList .fld-item {
  padding: 9px 16px; cursor: pointer; font-size: 13px;
  transition: background .12s; color: var(--text);
}
#formLinkList .fld-item:hover { background: var(--surface-hover); }

/* ===== CUSTOMIZATION TAB ===== */
.cust-intro {
  font-size: 14px;
  color: var(--text-secondary);
  margin: -12px 0 24px;
}
.cust-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.cust-card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}
.cust-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.cust-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.cust-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform .15s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
}
.cust-swatch:hover { transform: scale(1.08); }
.cust-swatch.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary);
}
.cust-color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.cust-color-picker-wrap input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--bg);
}
.cust-segmented {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.cust-segmented input { display: none; }
.cust-segmented label {
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.cust-segmented input:checked + label {
  background: var(--primary);
  color: #fff;
}

/* Palette presets grid */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.palette-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  font-family: inherit;
  text-align: right;
}
.palette-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.palette-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.palette-preview {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 46px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  overflow: hidden;
}
.palette-preview .palette-bar {
  position: absolute;
  inset: 8px auto 8px 8px;
  width: 34px;
  border-radius: 4px;
}
.palette-preview .palette-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.palette-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* Custom palette builder */
.cust-mode-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.cust-field-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.cust-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.cust-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.cust-field input[type="color"] {
  width: 40px;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: var(--surface);
  flex-shrink: 0;
}
.cust-custom-actions { display: flex; gap: 10px; }

/* Density compact */
body.density-compact .main-content { padding: 20px 24px; }
body.density-compact .kpi-card { padding: 14px 16px; }
body.density-compact .kpi-value { font-size: 22px; }
body.density-compact th,
body.density-compact td { padding: 8px 12px !important; }
body.density-compact .toolbar { gap: 8px; margin-bottom: 12px; }
body.density-compact .nav-item { padding: 8px 12px; font-size: 13px; }
body.density-compact .page-title { margin-bottom: 16px; font-size: 22px; }
body.density-compact .cust-card { padding: 16px 18px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-content { margin-right: 0; padding: 16px; }
  .dashboard-body { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
