/* ============ Somc — shared theme ============ */
:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-light: #14b8a6;
  --primary-50: #f0fdfa;
  --primary-100: #ccfbf1;
  --secondary: #0891b2;
  --accent: #2563eb;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #ea580c;
  --warning-light: #fed7aa;
  --error: #dc2626;
  --error-light: #fee2e2;
  --neutral-900: #0f172a;
  --neutral-800: #1e293b;
  --neutral-700: #334155;
  --neutral-600: #475569;
  --neutral-500: #64748b;
  --neutral-400: #94a3b8;
  --neutral-300: #cbd5e1;
  --neutral-200: #e2e8f0;
  --neutral-100: #f1f5f9;
  --neutral-50: #f8fafc;
  --white: #ffffff;
  --bg: #f0f4f8;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow: 0 4px 12px rgba(15,23,42,.08);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.14);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --header-h: 58px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--neutral-800);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
input, select, textarea { font-family: inherit; font-size: 15px; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------- App shell ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff; height: var(--header-h);
  box-shadow: var(--shadow);
}
.app-header-inner {
  max-width: 1100px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
}
.app-header-titles { flex: 1; min-width: 0; }
.app-header-title { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-header-sub { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: rgba(255,255,255,.14); border: none; color: #fff;
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  transition: background .2s;
}
.icon-btn:hover { background: rgba(255,255,255,.28); }

/* ---------- Drawer ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.app-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 84vw;
  background: #fff; z-index: 70; transform: translateX(-100%); transition: transform .28s;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.app-drawer.open { transform: translateX(0); }
.drawer-head {
  padding: 22px 18px 16px; background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.drawer-name { font-weight: 700; font-size: 16px; }
.drawer-role { font-size: 12px; opacity: .9; text-transform: capitalize; }
.drawer-nav { flex: 1; overflow-y: auto; padding: 10px; }
.drawer-link {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: var(--radius-sm); color: var(--neutral-700); font-weight: 500; text-decoration: none;
  margin-bottom: 2px; transition: background .15s, color .15s;
}
.drawer-link:hover { background: var(--primary-50); text-decoration: none; color: var(--primary-dark); }
.drawer-link.active { background: var(--primary-50); color: var(--primary-dark); font-weight: 600; }
.drawer-ic { width: 22px; display: grid; place-items: center; }
.drawer-logout {
  margin: 12px; padding: 12px; border: none; border-radius: var(--radius-sm);
  background: var(--error-light); color: var(--error); font-weight: 600;
}

/* ---------- Avatars ---------- */
.avatar-img, .avatar-initials {
  border-radius: 50%; object-fit: cover; display: inline-grid; place-items: center;
  color: #fff; font-weight: 700; flex-shrink: 0; line-height: 1;
}
.avatar-initials { letter-spacing: .5px; }

/* ---------- Main container ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 16px 14px 90px; }
.page-grid { display: grid; gap: 14px; }

/* ---------- Cards ---------- */
.card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 16px; border: 1px solid var(--neutral-200);
}
.card-title { font-size: 16px; font-weight: 700; color: var(--neutral-900); margin-bottom: 4px; }
.card-sub { font-size: 13px; color: var(--neutral-500); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border: none; border-radius: var(--radius-sm);
  background: var(--primary); color: #fff; font-weight: 600; font-size: 15px;
  transition: background .15s, transform .05s; text-decoration: none;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-secondary { background: var(--neutral-200); color: var(--neutral-800); }
.btn-secondary:hover { background: var(--neutral-300); }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary-dark); }
.btn-outline:hover { background: var(--primary-50); }
.btn-danger { background: var(--error); }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--neutral-700); margin-bottom: 6px; }
.field .req { color: var(--error); }
.input, .select, .textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--neutral-300);
  border-radius: var(--radius-sm); background: #fff; color: var(--neutral-900);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100);
}
.textarea { resize: vertical; min-height: 90px; }
.field-hint { font-size: 12px; color: var(--neutral-500); margin-top: 4px; }
.field-error { font-size: 12px; color: var(--error); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-error { background: var(--error-light); color: var(--error); }
.badge-info { background: var(--primary-100); color: var(--primary-dark); }
.badge-neutral { background: var(--neutral-100); color: var(--neutral-600); }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Lists ---------- */
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border-radius: var(--radius-sm); background: #fff; border: 1px solid var(--neutral-200);
  text-decoration: none; color: inherit; transition: box-shadow .15s, transform .05s;
}
.list-item:hover { box-shadow: var(--shadow); text-decoration: none; transform: translateY(-1px); }
.list-item:active { transform: scale(.99); }
.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; color: var(--neutral-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 13px; color: var(--neutral-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 4px; background: #fff; border-radius: var(--radius-sm);
  padding: 4px; border: 1px solid var(--neutral-200); margin-bottom: 14px; overflow-x: auto;
}
.tab {
  flex: 1; min-width: max-content; padding: 10px 14px; border: none; background: transparent;
  border-radius: 8px; color: var(--neutral-600); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.tab.active { background: var(--primary); color: #fff; }

/* ---------- Empty states ---------- */
.empty {
  text-align: center; padding: 40px 20px; color: var(--neutral-500);
}
.empty-icon { font-size: 40px; margin-bottom: 10px; opacity: .5; }
.empty-text { font-size: 14px; }

/* ---------- Toast ---------- */
#toast-host {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.toast {
  background: var(--neutral-900); color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0;
  transform: translateY(10px); transition: opacity .25s, transform .25s; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--error); }
.toast-info { background: var(--accent); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 200;
  display: grid; place-items: center; padding: 16px; opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); transform: scale(.95);
  transition: transform .2s;
}
.modal-backdrop.open .modal { transform: scale(1); }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--neutral-200); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-weight: 700; font-size: 17px; color: var(--neutral-900); }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--neutral-200); display: flex; gap: 10px; justify-content: flex-end; }
.modal-close { background: var(--neutral-100); border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 18px; color: var(--neutral-600); }

/* ---------- Section heading ---------- */
.section-title {
  font-size: 18px; font-weight: 700; color: var(--neutral-900); margin: 18px 0 10px;
  display: flex; align-items: center; gap: 8px;
}
.section-title:first-child { margin-top: 0; }

/* ---------- Stat tiles ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.stat-tile {
  background: #fff; border-radius: var(--radius); padding: 16px; border: 1px solid var(--neutral-200);
  box-shadow: var(--shadow-sm);
}
.stat-value { font-size: 26px; font-weight: 800; color: var(--primary-dark); }
.stat-label { font-size: 13px; color: var(--neutral-500); margin-top: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--neutral-200); }
table.data th { font-weight: 700; color: var(--neutral-700); background: var(--neutral-50); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
table.data tr:hover td { background: var(--neutral-50); }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: #fff; border-top: 1px solid var(--neutral-200); display: flex;
  justify-content: space-around; padding: 6px 0; max-width: 600px; margin: 0 auto;
  box-shadow: 0 -2px 10px rgba(15,23,42,.06);
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px; color: var(--neutral-500); font-size: 11px; font-weight: 600;
  text-decoration: none; border: none; background: transparent; position: relative;
}
.bottom-nav-item.active { color: var(--primary-dark); }
.bottom-nav-item .nav-badge {
  position: absolute; top: 2px; right: 50%; margin-right: -22px;
  background: var(--error); color: #fff; font-size: 9px; font-weight: 700;
  border-radius: 999px; min-width: 16px; height: 16px; padding: 0 4px; display: grid; place-items: center;
}

/* ---------- Loader ---------- */
.loader { display: inline-block; width: 22px; height: 22px; border: 2.5px solid var(--neutral-200); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-loader { display: grid; place-items: center; padding: 80px 20px; color: var(--neutral-500); }
.full-loader { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 999; }

/* ---------- Chat (WhatsApp-style) ---------- */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - var(--header-h)); max-width: 900px; margin: 0 auto; background: #e5ddd5; }
@media (max-width: 600px) { .chat-wrap { height: calc(100vh - var(--header-h)); } }
.chat-bg {
  flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 6px;
  background:
    linear-gradient(rgba(229,221,213,.85), rgba(229,221,213,.85)),
    radial-gradient(circle at 30% 20%, #dcd3cc 0, transparent 40%),
    radial-gradient(circle at 70% 80%, #cfc6bf 0, transparent 40%);
  background-attachment: fixed;
}
.chat-bubble {
  max-width: 78%; padding: 7px 11px 18px; border-radius: 10px; position: relative;
  font-size: 14.5px; line-height: 1.4; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.08);
  animation: bubbleIn .18s ease-out;
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.chat-bubble.in { background: #fff; align-self: flex-start; border-top-left-radius: 2px; }
.chat-bubble.out { background: #d9fdd3; align-self: flex-end; border-top-right-radius: 2px; }
.chat-bubble .bubble-text { white-space: pre-wrap; word-break: break-word; }
.chat-meta { position: absolute; bottom: 3px; right: 8px; font-size: 10px; color: var(--neutral-500); display: flex; align-items: center; gap: 3px; }
.chat-bubble.out .chat-meta { color: #5d7a6b; }
.chat-read { color: #53bdeb; font-weight: 700; }
.chat-day-divider {
  align-self: center; background: #e1f2fa; color: #3a6b7a; font-size: 11px; font-weight: 600;
  padding: 4px 12px; border-radius: 8px; box-shadow: 0 1px 1px rgba(0,0,0,.1); margin: 8px 0;
}
.chat-input-bar {
  display: flex; gap: 8px; padding: 8px 10px; background: #f0f2f5; align-items: flex-end;
}
.chat-input {
  flex: 1; border: none; background: #fff; border-radius: 22px; padding: 10px 14px;
  font-size: 15px; resize: none; max-height: 120px; line-height: 1.4;
}
.chat-send-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--primary);
  color: #fff; display: grid; place-items: center; flex-shrink: 0;
}
.chat-send-btn:disabled { opacity: .5; }
.chat-presence { font-size: 12px; color: #128c7e; font-weight: 500; }
.chat-presence.offline { color: var(--neutral-500); }
.chat-empty { text-align: center; padding: 40px 20px; color: var(--neutral-600); align-self: center; margin: auto; }
.chat-call-bar { display: flex; gap: 8px; padding: 8px 12px; background: var(--primary-50); border-bottom: 1px solid var(--neutral-200); }

/* ---------- Video call modal ---------- */
.call-modal { max-width: 720px; }
.call-stage { background: #1e293b; border-radius: var(--radius); aspect-ratio: 16/9; position: relative; overflow: hidden; }
.call-local { position: absolute; bottom: 10px; right: 10px; width: 25%; max-width: 150px; aspect-ratio: 4/3; background: #334155; border-radius: 10px; overflow: hidden; border: 2px solid #fff; }
.call-remote { position: absolute; inset: 0; display: grid; place-items: center; color: #cbd5e1; }
.call-controls { display: flex; justify-content: center; gap: 12px; padding: 16px; }
.call-btn { width: 50px; height: 50px; border-radius: 50%; border: none; display: grid; place-items: center; color: #fff; }
.call-btn.end { background: var(--error); }
.call-btn.mic { background: var(--neutral-700); }
.call-btn.cam { background: var(--neutral-700); }
.call-status { text-align: center; color: #cbd5e1; font-size: 13px; padding: 8px; }

/* ---------- Switch ---------- */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--neutral-300); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ---------- Helpers ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.center { text-align: center; }
.muted { color: var(--neutral-500); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 700; }
.cap { text-transform: capitalize; }
.gap-6 { gap: 6px; }
.mt-6 { margin-top: 6px; }
.mt-12 { margin-top: 12px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.flex { display: flex; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.aic { align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }
.full-screen-min { min-height: calc(100vh - var(--header-h)); }

/* ---------- Desktop tweaks ---------- */
@media (min-width: 768px) {
  .container { padding: 22px 20px 100px; }
  .app-header-inner { padding: 0 20px; }
}
