/* ==========================================================================
   AIS Parent Portal theme (on top of AdminLTE 3 / Bootstrap 4)
   ========================================================================== */

:root {
  --brand: #1d4ed8;
  --brand-600: #2563eb;
  --brand-700: #1e40af;
  --brand-50: #eff4ff;
  --brand-100: #dbe6fe;
  --accent: #f7892a;
  --accent-50: #fff4ea;

  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #eef2f7;
  --bg: #f4f6fb;
  --card: #ffffff;

  --success: #15803d;
  --success-50: #ecfdf3;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --warning: #b45309;
  --warning-50: #fffbeb;
  --info: #0e7490;
  --info-50: #ecfeff;

  --sidebar: #0f1b3d;
  --sidebar-2: #16244d;
  --sidebar-text: #c7d2fe;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .14);
  --font: "Source Sans Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bottom-nav-h: 64px;
}

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
.content-wrapper { background: var(--bg); }
a { color: var(--brand); }
a:hover { color: var(--brand-700); }
h1, h2, h3, h4, h5, h6 { color: var(--ink); font-weight: 600; letter-spacing: -.01em; }
.text-muted { color: var(--muted) !important; }
:focus-visible { outline: 3px solid rgba(37, 99, 235, .45); outline-offset: 2px; }

/* ---------- Top bar ---------- */
.main-header.navbar {
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line) !important;
  min-height: 60px;
  padding: .35rem .75rem;
}
.main-header .nav-link { color: var(--ink-2); height: auto; padding: .5rem .7rem; border-radius: 10px; }
.main-header .nav-link:hover { background: var(--line-2); color: var(--ink); }
.main-header .navbar-badge {
  top: 4px; right: 2px; font-size: .65rem; font-weight: 700; padding: 3px 5px;
  border-radius: 999px; background: var(--danger); color: #fff;
}
.topbar-brand { display: flex; align-items: center; gap: .5rem; color: var(--ink) !important; font-weight: 700; padding: .25rem .25rem; text-decoration: none !important; }
.topbar-brand img { width: 30px; height: 30px; border-radius: 8px; object-fit: contain; }
.filter-toggle {
  display: none; width: 100%; align-items: center; justify-content: space-between; gap: .5rem;
  border: 0; background: transparent; padding: .85rem 1rem; font-weight: 600; color: var(--ink);
}
.filter-toggle .count { background: var(--brand-600); color: #fff; border-radius: 999px; font-size: .7rem; padding: .05rem .45rem; margin-left: .35rem; }
.filter-toggle .fa-chevron-down { transition: transform .2s; color: var(--muted); }
.filter-card:not(.is-collapsed) .filter-toggle .fa-chevron-down { transform: rotate(180deg); }
.filter-card:not(.is-collapsed) .filter-toggle { border-bottom: 1px solid var(--line); }
.topbar-title { font-weight: 600; font-size: 1rem; color: var(--ink); margin-left: .25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55vw; }
.user-chip { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem .25rem .25rem !important; }
.user-chip .avatar { width: 34px; height: 34px; }
.user-chip .user-meta { line-height: 1.1; text-align: left; }
.user-chip .user-meta small { color: var(--muted); font-size: .75rem; }
.dropdown-menu { border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: .4rem; }
.dropdown-item { border-radius: 8px; padding: .55rem .75rem; }
.dropdown-item i { width: 1.25rem; color: var(--muted); }

/* ---------- Avatars ---------- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  background: var(--brand-100); color: var(--brand-700);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
}
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }
.avatar-lg { width: 96px; height: 96px; font-size: 1.6rem; }
.avatar-xl { width: 128px; height: 128px; font-size: 2rem; border: 4px solid #fff; box-shadow: var(--shadow); }

/* ---------- Sidebar ---------- */
.main-sidebar { background: var(--sidebar) !important; }
.main-sidebar .brand-link {
  border-bottom: 1px solid rgba(255, 255, 255, .08) !important;
  display: flex; align-items: center; gap: .6rem; padding: .95rem 1rem; height: 60px;
}
.main-sidebar .brand-link .brand-image { float: none; margin: 0; max-height: 34px; width: 34px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; box-shadow: none; opacity: 1; }
.main-sidebar .brand-text { color: #fff; font-weight: 600 !important; font-size: .98rem; line-height: 1.1; }
.main-sidebar .brand-text small { display: block; color: var(--sidebar-text); font-weight: 400; font-size: .72rem; opacity: .8; }
.sidebar { padding: .5rem .6rem 1.5rem; }
.nav-sidebar .nav-header { color: rgba(199, 210, 254, .55); font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding: 1rem .75rem .4rem; }
.nav-sidebar .nav-link { color: var(--sidebar-text) !important; border-radius: 10px; padding: .6rem .75rem; margin-bottom: 2px; }
.nav-sidebar .nav-link p { font-weight: 600; }
.nav-sidebar .nav-link .nav-icon { color: rgba(199, 210, 254, .75); font-size: 1rem; width: 1.6rem; }
.nav-sidebar .nav-link:hover { background: var(--sidebar-2) !important; color: #fff !important; }
.nav-pills.nav-sidebar .nav-link.active,
.nav-sidebar > .nav-item.menu-open > .nav-link {
  background: var(--brand-600) !important; color: #fff !important; box-shadow: 0 6px 16px rgba(37, 99, 235, .35);
}
.nav-sidebar .nav-link.active .nav-icon { color: #fff; }
.nav-sidebar .btn.nav-link { display: flex; justify-content: flex-start; align-items: center; gap: 0; font-weight: 400; border: 0; box-shadow: none; }
.nav-treeview .nav-link.active { background: rgba(255, 255, 255, .12) !important; box-shadow: none !important; }
.nav-treeview > .nav-item > .nav-link { padding-left: 1.2rem; }
.sidebar-mini.sidebar-collapse .main-sidebar:not(.sidebar-focused):not(:hover) .nav-header { display: none; }

/* ---------- Page header ---------- */
.content-header { padding: 1.25rem .5rem .5rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem; }
.page-head h1 { font-size: 1.5rem; margin: 0; }
.page-head .page-sub { color: var(--muted); margin: .2rem 0 0; font-size: .92rem; }
.page-head .breadcrumb { background: none; padding: 0; margin: 0 0 .25rem; font-size: .8rem; }
.page-head .breadcrumb-item + .breadcrumb-item::before { color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.content { padding: 0 .5rem 1.5rem; }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card > .card-header { background: transparent; border-bottom: 1px solid var(--line); padding: .9rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.card > .card-header::after { display: none; }
.card-title { font-size: 1rem; font-weight: 600; margin: 0; float: none; }
.card-title i { color: var(--brand-600); margin-right: .4rem; }
.card-body { padding: 1.25rem; }
.card-footer { background: #fbfcfe; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius) !important; padding: .9rem 1.25rem; }
.card-outline-soft { border-top: 3px solid var(--brand-600); }

/* ---------- Stat tiles & quick links ---------- */
.stat {
  display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.2rem; height: calc(100% - 1.25rem);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  color: inherit; text-decoration: none !important; transition: transform .15s ease, box-shadow .15s ease; margin-bottom: 1.25rem;
}
a.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); color: inherit; }
.stat .stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; }
.stat .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--ink); }
.stat .stat-label { color: var(--muted); font-size: .85rem; margin-top: .3rem; }
.tone-blue   .stat-icon, .tone-blue.quick-icon   { background: var(--brand-50);  color: var(--brand-600); }
.tone-green  .stat-icon, .tone-green.quick-icon  { background: var(--success-50); color: var(--success); }
.tone-orange .stat-icon, .tone-orange.quick-icon { background: var(--accent-50);  color: #c2410c; }
.tone-red    .stat-icon, .tone-red.quick-icon    { background: var(--danger-50);  color: var(--danger); }
.tone-cyan   .stat-icon, .tone-cyan.quick-icon   { background: var(--info-50);    color: var(--info); }
.tone-violet .stat-icon, .tone-violet.quick-icon { background: #f3efff; color: #6d28d9; }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9rem; }
.quick-link {
  display: flex; flex-direction: column; align-items: flex-start; gap: .75rem; padding: 1rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  color: var(--ink) !important; font-weight: 600; text-decoration: none !important; transition: transform .15s, box-shadow .15s, border-color .15s;
}
.quick-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--brand-100); }
.quick-link small { color: var(--muted); font-weight: 400; display: block; margin-top: .15rem; }
.quick-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.15rem; }

.welcome {
  background: linear-gradient(120deg, var(--brand-700), var(--brand-600) 60%, #3b82f6);
  color: #fff; border: 0; border-radius: var(--radius); padding: 1.4rem 1.5rem; margin-bottom: 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; box-shadow: 0 10px 30px rgba(29, 78, 216, .25);
}
.welcome h2 { color: #fff; font-size: 1.35rem; margin: 0 0 .25rem; }
.welcome p { margin: 0; opacity: .88; }
.welcome .avatar { background: rgba(255, 255, 255, .2); color: #fff; }

/* ---------- Buttons ---------- */
.btn { border-radius: 10px; font-weight: 600; padding: .5rem 1rem; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; }
.btn-sm { padding: .35rem .7rem; border-radius: 8px; font-size: .85rem; }
.btn-lg { padding: .75rem 1.25rem; }
.btn-primary { background: var(--brand-600); border-color: var(--brand-600); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-700); border-color: var(--brand-700); }
.btn-light { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-light:hover { background: var(--line-2); border-color: var(--line); }
.btn-soft-primary { background: var(--brand-50); color: var(--brand-700); border: 1px solid transparent; }
.btn-soft-primary:hover { background: var(--brand-100); color: var(--brand-700); }
.btn-soft-danger { background: var(--danger-50); color: var(--danger); border: 1px solid transparent; }
.btn-soft-danger:hover { background: #fde2e2; color: #b91c1c; }
.btn-soft-success { background: var(--success-50); color: var(--success); border: 1px solid transparent; }
.btn-soft-success:hover { background: #d7f7e3; color: var(--success); }
.btn-icon { width: 38px; height: 38px; padding: 0; }
.btn-group-actions { display: flex; flex-wrap: wrap; gap: .4rem; }

/* ---------- Forms ---------- */
label, .form-label { font-weight: 600; font-size: .85rem; color: var(--ink-2); margin-bottom: .35rem; }
.form-control, .custom-select {
  border-radius: 10px; border-color: #d5dbe5; min-height: 42px; font-size: .95rem; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .custom-select:focus { border-color: var(--brand-600); box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .15); }
textarea.form-control { min-height: 110px; }
.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { display: block; font-size: .8rem; }
.form-text { color: var(--muted); font-size: .8rem; }
.req { color: var(--danger); margin-left: 2px; }
.form-section-title { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: .5rem 0 1rem; padding-bottom: .5rem; border-bottom: 1px dashed var(--line); }
.form-narrow { max-width: 760px; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; }
.filter-card .card-body { padding-bottom: .25rem; }
.filter-actions { display: flex; gap: .5rem; align-items: flex-end; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .5rem; }
.check-tile { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; margin: 0; font-weight: 600; background: #fff; }
.check-tile:hover { border-color: var(--brand-100); background: var(--brand-50); }
.check-tile input { width: 18px; height: 18px; accent-color: var(--brand-600); }
.file-drop { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 1rem; text-align: center; color: var(--muted); background: #fbfcfe; position: relative; }
.file-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-drop i { font-size: 1.4rem; color: var(--brand-600); display: block; margin-bottom: .35rem; }
.file-drop .file-name { color: var(--ink); font-weight: 600; margin-top: .35rem; word-break: break-all; }
.password-field { position: relative; }
.password-field .form-control { padding-right: 2.75rem; }
.password-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); width: 38px; height: 38px; border-radius: 8px; }
.password-toggle:hover { color: var(--ink); background: var(--line-2); }

/* ---------- Tables ---------- */
.table { color: var(--ink); margin-bottom: 0; }
.table thead th { border-top: 0; border-bottom: 1px solid var(--line); background: #f8fafc; color: var(--muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; padding: .75rem 1rem; }
.table td { vertical-align: middle; border-top: 1px solid var(--line-2); padding: .8rem 1rem; }
.table-hover tbody tr:hover { background: #f8fafe; }
.cell-user { display: flex; align-items: center; gap: .75rem; min-width: 180px; }
.cell-user .name { font-weight: 600; }
.cell-user small { color: var(--muted); display: block; }
.table-empty { text-align: center; padding: 2.5rem 1rem !important; color: var(--muted); }

/* Status pills */
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .22rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-success { background: var(--success-50); color: var(--success); }
.pill-danger { background: var(--danger-50); color: var(--danger); }
.pill-warning { background: var(--warning-50); color: var(--warning); }
.pill-muted { background: var(--line-2); color: var(--muted); }
.pill-info { background: var(--brand-50); color: var(--brand-700); }
.pill-plain::before { display: none; }

/* Pagination */
.pagination { margin: 0; flex-wrap: wrap; gap: .25rem; }
.page-link { border-radius: 8px !important; border: 1px solid var(--line); color: var(--ink-2); min-width: 38px; text-align: center; }
.page-item.active .page-link { background: var(--brand-600); border-color: var(--brand-600); }
.list-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .75rem; padding: .9rem 1.25rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }

/* Empty state */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.2rem; color: #cbd5e1; margin-bottom: .75rem; display: block; }
.empty-state h5 { color: var(--ink-2); font-size: 1rem; margin-bottom: .25rem; }

/* ---------- Alerts ---------- */
.alert { border: 1px solid transparent; border-radius: 12px; padding: .85rem 1rem; display: flex; gap: .75rem; align-items: flex-start; }
.alert i.alert-icon { margin-top: .15rem; }
.alert .close { margin-left: auto; padding: 0 .25rem; opacity: .6; text-shadow: none; }
.alert-success { background: var(--success-50); border-color: #bbf7d0; color: #14532d; }
.alert-danger { background: var(--danger-50); border-color: #fecaca; color: #7f1d1d; }
.alert-warning { background: var(--warning-50); border-color: #fde68a; color: #78350f; }
.alert-info { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }
.alert ul { margin: .35rem 0 0; padding-left: 1.1rem; }

/* ---------- Notices / feed cards ---------- */
.notice { padding: 1.1rem 1.25rem; }
.notice + .notice { border-top: 1px solid var(--line); }
.notice-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: .5rem; }
.notice-title { font-weight: 600; font-size: 1.02rem; margin: 0; }
.notice-date { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.notice-body { color: var(--ink-2); line-height: 1.6; overflow-wrap: anywhere; }
.notice-body img { max-width: 100%; height: auto; border-radius: 8px; }
.notice-body table { max-width: 100%; display: block; overflow-x: auto; }

.media-card { overflow: hidden; display: flex; flex-direction: column; height: calc(100% - 1.25rem); }
.media-card .media-thumb { aspect-ratio: 16 / 10; background: var(--line-2) center / cover no-repeat; display: block; }
.media-card .card-body { flex: 1; }
.meta-list { list-style: none; padding: 0; margin: .5rem 0 0; color: var(--ink-2); font-size: .9rem; }
.meta-list li { display: flex; gap: .5rem; padding: .2rem 0; }
.meta-list i { color: var(--muted); width: 1rem; margin-top: .2rem; }

.profile-list { list-style: none; margin: 0; padding: 0; }
.profile-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid var(--line-2); }
.profile-list li:last-child { border-bottom: 0; }
.profile-list .k { color: var(--muted); font-size: .88rem; }
.profile-list .v { font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* Attendance segmented control */
.seg { display: inline-flex; background: var(--line-2); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { white-space: nowrap; margin: 0; padding: .45rem .8rem; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: .85rem; color: var(--muted); min-width: 76px; text-align: center; }
.seg input:focus-visible + label { outline: 3px solid rgba(37, 99, 235, .45); }
.seg input.present:checked + label { background: var(--success); color: #fff; }
.seg input.absent:checked + label { background: var(--danger); color: #fff; }
.seg input.leave:checked + label { background: #f59e0b; color: #fff; }
.save-state { font-size: .78rem; color: var(--muted); margin-left: .5rem; }

/* ---------- Activity log ---------- */
.change-old { background: var(--danger-50); color: #991b1b; padding: .1rem .4rem; border-radius: 6px; text-decoration: line-through; text-decoration-color: rgba(153, 27, 27, .4); overflow-wrap: anywhere; }
.change-new { background: var(--success-50); color: #166534; padding: .1rem .4rem; border-radius: 6px; overflow-wrap: anywhere; }
.timeline-item { display: flex; gap: .75rem; padding: .7rem 1.25rem; align-items: flex-start; }
.timeline-item + .timeline-item { border-top: 1px solid var(--line-2); }
.timeline-dot { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: .8rem; }

/* ---------- Chat ---------- */
.chat-shell { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 170px); min-height: 500px; overflow: hidden; padding: 0; position: relative; }
.chat-people { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: #fff; }
.chat-people .people-head { padding: .9rem .9rem .6rem; border-bottom: 1px solid var(--line); }
.chat-people ul { list-style: none; margin: 0; padding: .4rem; overflow-y: auto; flex: 1; }
.chat-tabs { display: flex; gap: .35rem; }
.chat-tabs button { border: 0; background: var(--line-2); color: var(--muted); font-weight: 600; font-size: .82rem; padding: .3rem .8rem; border-radius: 999px; }
.chat-tabs button.active { background: var(--brand-50); color: var(--brand-700); }
.chat-person { display: flex; gap: .75rem; align-items: center; padding: .65rem .7rem; border-radius: 12px; cursor: pointer; position: relative; }
.chat-person:hover, .chat-person:focus-visible { background: var(--line-2); }
.chat-person.active { background: var(--brand-50); }
.chat-person.active::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--brand-600); }
.chat-person .who { flex: 1; min-width: 0; }
.chat-person .who .name { font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.chat-person .who .when { color: var(--muted); font-size: .72rem; font-weight: 400; white-space: nowrap; }
.chat-person .who .last { color: var(--muted); font-size: .85rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.chat-person .who .role-line { color: #94a3b8; font-size: .72rem; }
.chat-person.has-unread .who .last { color: var(--ink); font-weight: 600; }
.chat-person.has-unread .who .when { color: var(--brand-600); font-weight: 600; }
.chat-person .unread { background: var(--brand-600); color: #fff; border-radius: 999px; font-size: .7rem; padding: .05rem .45rem; font-weight: 700; flex-shrink: 0; }
.tick { font-size: .7rem; color: #94a3b8; margin-right: 2px; }
.tick.is-read { color: #38bdf8; }
.presence { position: relative; display: inline-flex; flex-shrink: 0; }
.presence::after { content: ""; position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #fff; background: #cbd5e1; }
.presence.online::after { background: #22c55e; }

.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.chat-main.drop-target::after { content: "Drop to attach"; position: absolute; inset: 8px; border: 2px dashed var(--brand-600); border-radius: 14px; background: rgba(239, 244, 255, .92); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--brand-700); z-index: 5; }
.chat-top { display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); background: #fff; }
.chat-top .status { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-top .status.online { color: var(--success); font-weight: 600; }
.chat-history {
  flex: 1; overflow-y: auto; padding: 1rem 1.25rem; overscroll-behavior: contain;
  background-color: #f5f7fb;
  background-image: radial-gradient(rgba(29, 78, 216, .05) 1px, transparent 1px);
  background-size: 18px 18px;
}
.chat-history ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.day-sep { text-align: center; margin: .75rem 0 .4rem; }
.day-sep span { display: inline-block; background: #fff; border: 1px solid var(--line); color: var(--muted); font-size: .75rem; font-weight: 600; padding: .15rem .7rem; border-radius: 999px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.bubble-row { display: flex; }
.bubble-row.mine { justify-content: flex-end; }
.bubble-row + .bubble-row.mine, .bubble-row.mine + .bubble-row:not(.mine) { margin-top: .35rem; }
.bubble {
  max-width: min(78%, 560px); padding: .5rem .75rem .35rem; border-radius: 16px; background: #fff;
  border: 1px solid var(--line); overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(15, 23, 42, .04);
}
.bubble .text { white-space: pre-line; line-height: 1.45; }
.bubble .text a { color: inherit; text-decoration: underline; }
.bubble-row.mine .bubble { background: var(--brand-600); color: #fff; border-color: var(--brand-600); border-bottom-right-radius: 6px; }
.bubble-row:not(.mine) .bubble { border-bottom-left-radius: 6px; }
.bubble .meta { display: flex; justify-content: flex-end; align-items: center; gap: .3rem; font-size: .7rem; opacity: .75; margin-top: .15rem; }
.bubble-row.mine .tick { color: rgba(255, 255, 255, .75); }
.bubble-row.mine .tick.is-read { color: #bae6fd; }
.bubble .attachment { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; margin: .1rem 0 .3rem; border-radius: 10px; background: rgba(15, 23, 42, .05); color: inherit; text-decoration: none; font-weight: 600; }
.bubble-row.mine .bubble .attachment { background: rgba(255, 255, 255, .16); }
.bubble .attachment small { font-weight: 400; opacity: .8; }
.bubble .attachment-icon { width: 36px; height: 36px; border-radius: 8px; background: rgba(255, 255, 255, .9); color: var(--brand-600); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.bubble .attachment-img { display: block; max-width: min(260px, 100%); max-height: 240px; border-radius: 10px; margin: .1rem 0 .3rem; object-fit: cover; }
.new-msg-pill { position: absolute; left: 50%; transform: translateX(-50%); bottom: 90px; z-index: 4; border: 0; background: var(--brand-600); color: #fff; border-radius: 999px; padding: .4rem .9rem; font-weight: 600; font-size: .82rem; box-shadow: var(--shadow-lg); }

.chat-compose { border-top: 1px solid var(--line); padding: .6rem .7rem; background: #fff; }
.chat-compose form { display: flex; align-items: flex-end; gap: .5rem; }
.chat-compose textarea { resize: none; min-height: 44px; max-height: 140px; border-radius: 22px; padding: .6rem 1rem; line-height: 1.4; }
.chat-compose .btn-icon { border-radius: 50%; width: 44px; height: 44px; flex-shrink: 0; }
.compose-hint { font-size: .72rem; color: #94a3b8; padding: .3rem .3rem 0 3.4rem; }
.attach-preview { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; margin-bottom: .5rem; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe; }
.attach-preview[hidden] { display: none; }
.attach-preview img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; }
.attach-preview .attach-icon { width: 44px; height: 44px; border-radius: 8px; background: var(--brand-50); color: var(--brand-600); display: inline-flex; align-items: center; justify-content: center; }
.attach-preview .attach-icon[hidden], .attach-preview img[hidden] { display: none; }
.attach-preview .attach-name { flex: 1; min-width: 0; font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-placeholder { flex: 1; display: flex; align-items: center; justify-content: center; background: #f5f7fb; }
.contact-list { list-style: none; margin: 0; padding: 0; }
.contact-group { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: .75rem .7rem .3rem; }
.chat-toast { position: fixed; left: 50%; bottom: calc(var(--bottom-nav-h) + 16px); transform: translate(-50%, 20px); opacity: 0; transition: all .25s ease; z-index: 2000; background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 10px; font-size: .9rem; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); }
.chat-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Footer & bottom nav ---------- */
.main-footer { background: transparent; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; padding: .9rem 1.25rem; }
.main-footer a { color: var(--ink-2); }
.bottom-nav { display: none; }

/* ---------- Auth pages ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; }
.auth-hero {
  position: relative; color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(160deg, rgba(15, 27, 61, .92), rgba(29, 78, 216, .82)), var(--auth-bg, none) center / cover no-repeat;
}
.auth-hero h1 { color: #fff; font-size: 2.2rem; line-height: 1.15; max-width: 460px; }
.auth-hero p { color: rgba(255, 255, 255, .85); max-width: 440px; font-size: 1.02rem; }
.auth-hero .features { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.auth-hero .features li { display: flex; gap: .7rem; align-items: center; margin-bottom: .8rem; color: rgba(255, 255, 255, .92); }
.auth-hero .features i { width: 32px; height: 32px; border-radius: 10px; background: rgba(255, 255, 255, .15); display: inline-flex; align-items: center; justify-content: center; }
.auth-brand { display: flex; align-items: center; gap: .75rem; font-weight: 600; }
.auth-brand img { width: 46px; height: 46px; border-radius: 12px; background: #fff; padding: 4px; object-fit: contain; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 1.6rem; margin-bottom: .35rem; }
.auth-card .lead { color: var(--muted); font-size: .98rem; margin-bottom: 1.5rem; }
.auth-card .form-control { min-height: 48px; }
.auth-card .btn-lg { width: 100%; min-height: 48px; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .form-control { padding-left: 2.6rem; }
.auth-foot { color: var(--muted); font-size: .82rem; text-align: center; margin-top: 2rem; }
.custom-control-label { font-weight: 600; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 991.98px) {
  .chat-shell { grid-template-columns: 1fr; height: calc(100vh - 190px); }
  .chat-shell.has-active .chat-people { display: none; }
  .chat-shell:not(.has-active) .chat-main { display: none; }
  .chat-back { display: inline-flex !important; }
}

@media (max-width: 767.98px) {
  body { font-size: 16px; }
  .content-header { padding: 1rem .25rem .25rem; }
  .content { padding: 0 .25rem 1rem; }
  .page-head h1 { font-size: 1.25rem; }
  .page-head .breadcrumb { display: none; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .card-body { padding: 1rem; }
  .card > .card-header { padding: .8rem 1rem; }
  .form-actions .btn { flex: 1; }
  .filter-actions { width: 100%; }
  .filter-actions .btn { flex: 1; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  .welcome { flex-direction: column; align-items: flex-start; }
  .welcome .avatar { display: none; }
  .user-chip .user-meta { display: none; }
  .main-footer { margin-bottom: var(--bottom-nav-h); text-align: center; }
  .main-footer .float-right { float: none !important; display: block !important; }
  .content-wrapper { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); }

  .page-head { margin-bottom: .5rem; }
  .page-sub { font-size: .88rem; }

  /* Full-screen chat on phones */
  .page-chat .content-header, .page-chat .main-footer { display: none; }
  .page-chat .content { padding: 0; }
  .page-chat .content > .container-fluid { padding: 0; }
  .page-chat .content-wrapper { padding-bottom: 0; }
  .page-chat .chat-shell { border-radius: 0; border: 0; margin: 0; box-shadow: none; min-height: 0;
    height: calc(100vh - 60px - var(--bottom-nav-h) - env(safe-area-inset-bottom)); }
  @supports (height: 100dvh) {
    .page-chat .chat-shell { height: calc(100dvh - 60px - var(--bottom-nav-h) - env(safe-area-inset-bottom)); }
  }
  .page-chat.chat-open .bottom-nav { display: none; }
  .page-chat.chat-open .chat-shell { height: calc(100vh - 60px); }
  @supports (height: 100dvh) { .page-chat.chat-open .chat-shell { height: calc(100dvh - 60px); } }
  .chat-history { padding: .75rem; }
  .bubble { max-width: 86%; }
  .chat-compose { padding-bottom: calc(.6rem + env(safe-area-inset-bottom)); }
  .new-msg-pill { bottom: 80px; }

  /* Filters collapse behind a button on phones */
  .filter-toggle { display: flex !important; }
  .filter-card.is-collapsed form > .card-body, .filter-card.is-collapsed > form > .card-body, .filter-card.is-collapsed .card-body { display: none; }

  /* Tables become stacked cards */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { border-bottom: 1px solid var(--line); padding: .75rem 1rem; }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack td { border: 0 !important; padding: .3rem 0 !important; display: flex; justify-content: space-between; align-items: center; gap: 1rem; text-align: right; }
  .table-stack td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; text-align: left; flex-shrink: 0; }
  .table-stack td.td-main { justify-content: flex-start; text-align: left; padding-bottom: .5rem !important; }
  .table-stack td.td-main::before, .table-stack td.td-actions::before, .table-stack td[data-label=""]::before { display: none; }
  .table-stack td.td-actions { justify-content: flex-start; padding-top: .6rem !important; }
  .table-stack td.td-actions .btn-group-actions { width: 100%; }
  .table-stack td.td-actions .btn-group-actions > * { flex: 1; }
  .table-stack td.td-actions .btn-group-actions form .btn { width: 100%; }
  .table-stack .table-empty { justify-content: center; }
  .table-stack .table-empty::before { display: none; }
  .table-stack tr:hover { background: transparent; }
  .seg { width: 100%; display: flex; }
  .att-cell { width: 100%; }
  .seg label { flex: 1; min-width: 0; }

  /* Bottom navigation */
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 20px rgba(15, 23, 42, .06);
  }
  .bottom-nav a, .bottom-nav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--muted); font-size: .7rem; font-weight: 600; text-decoration: none; border: 0; background: none; position: relative;
  }
  .bottom-nav i { font-size: 1.15rem; }
  .bottom-nav .active { color: var(--brand-600); }
  .bottom-nav .active::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand-600); }
  .bottom-nav .dot { position: absolute; top: 8px; left: calc(50% + 6px); background: var(--danger); color: #fff; font-size: .6rem; border-radius: 999px; padding: 0 5px; line-height: 16px; }

  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-panel { align-items: flex-start; padding-top: 3rem; }
  .auth-mobile-brand { display: flex !important; }
}

@media (min-width: 768px) { .auth-mobile-brand { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
  .main-sidebar, .main-header, .bottom-nav, .page-actions, .filter-card, .main-footer, .td-actions { display: none !important; }
  .content-wrapper { margin: 0 !important; }
  .card { box-shadow: none; }
}
