/* ============================================================
   MediSMS theme — calm clinical teal/blue, light + dark
   Base component contract shared with the CRM / Inventory apps.
   ============================================================ */
:root {
    --bg:          #f2f5fb;
    --surface:     #ffffff;
    --surface-2:   #f8fafd;
    --border:      #e4e9f4;
    --text:        #17203a;
    --text-2:      #5a6479;
    --text-3:      #97a0b5;
    --primary:     #0f8b8d;
    --primary-600: #0b6f71;
    --primary-50:  #e6f6f6;
    --accent:      #7c3aed;
    --grad:        linear-gradient(135deg, #0ea5a4 0%, #2f6fed 100%);
    --green:       #16a34a;
    --green-bg:    #e8f9f0;
    --red:         #dc2626;
    --red-bg:      #feeeee;
    --amber:       #d97706;
    --amber-bg:    #fff6e4;
    --blue:        #2563eb;
    --blue-bg:     #eaf2ff;
    --purple:      #7c3aed;
    --purple-bg:   #f3edff;
    --gray:        #64748b;
    --gray-bg:     #eef2f7;
    --radius:      14px;
    --shadow:      0 1px 3px rgba(23, 32, 58, .06), 0 1px 2px rgba(23, 32, 58, .04);
    --shadow-md:   0 6px 18px rgba(23, 32, 58, .09);
    --shadow-lg:   0 16px 40px rgba(23, 32, 58, .16);
    --sidebar-w:   250px;
    --sidebar-bg:  linear-gradient(180deg, #0b1b2b 0%, #0f2438 60%, #10283f 100%);
    --ring:        0 0 0 3px rgba(15, 139, 141, .2);
}

[data-theme="dark"] {
    --bg:          #0b1120;
    --surface:     #121a30;
    --surface-2:   #16203a;
    --border:      #23304f;
    --text:        #e7ecf7;
    --text-2:      #a7b1c8;
    --text-3:      #6d7891;
    --primary:     #3ed0cf;
    --primary-600: #2ab9b8;
    --primary-50:  #10343a;
    --grad:        linear-gradient(135deg, #14b8a6 0%, #3b82f6 100%);
    --green:       #4ade80;
    --green-bg:    #10301f;
    --red:         #f87171;
    --red-bg:      #3a1620;
    --amber:       #fbbf24;
    --amber-bg:    #382a10;
    --blue:        #7aa5ff;
    --blue-bg:     #14224a;
    --purple:      #b195ff;
    --purple-bg:   #251b44;
    --gray:        #94a3b8;
    --gray-bg:     #1b2440;
    --shadow:      0 1px 3px rgba(0, 0, 0, .4);
    --shadow-md:   0 6px 18px rgba(0, 0, 0, .45);
    --shadow-lg:   0 16px 40px rgba(0, 0, 0, .6);
    --sidebar-bg:  linear-gradient(180deg, #08131d 0%, #0b1a28 100%);
    --ring:        0 0 0 3px rgba(62, 208, 207, .25);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14.5px;
    color: var(--text);
    background: var(--bg);
}
body { transition: background .25s ease, color .25s ease; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: rgba(15,139,141,.25); }

/* slim, theme-aware scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--text-3) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-brand img {
    width: 38px; height: 38px; border-radius: 10px;
    box-shadow: 0 4px 14px rgba(15, 139, 141, .45);
    transition: transform .25s ease;
}
.sidebar-brand:hover img { transform: rotate(-6deg) scale(1.06); }
.brand-name { font-weight: 700; color: #fff; font-size: 14px; line-height: 1.2; }
.brand-sub { font-size: 11.5px; color: #7d8aa5; }

.sidebar-nav { flex: 1; padding: 10px 10px 20px; }
.nav-section {
    font-size: 10.5px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #5d6b8c;
    margin: 18px 8px 6px;
    font-weight: 700;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    color: #b5c0d4;
    padding: 9px 12px;
    border-radius: 10px;
    margin-bottom: 2px;
    font-weight: 500;
    position: relative;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav-link svg { width: 18px; height: 18px; flex: none; transition: transform .18s ease; }
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; transform: translateX(3px); }
.nav-link:hover svg { transform: scale(1.12); }
.nav-link.active {
    background: var(--grad);
    color: #fff;
    box-shadow: 0 6px 16px rgba(15, 139, 141, .35);
}
.nav-link.active::before {
    content: "";
    position: absolute;
    left: -10px; top: 20%;
    height: 60%; width: 4px;
    border-radius: 99px;
    background: #8ab4ff;
}
.sidebar-foot { padding: 14px 16px; font-size: 11.5px; color: #5d6b8c; }

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 26px;
    height: 62px;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}
.page-title { font-size: 18px; font-weight: 700; margin: 0; flex: 1; letter-spacing: -.01em; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-2);
    width: 38px; height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, transform .15s ease;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--gray-bg); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.menu-toggle { display: none; }

/* theme toggle: sun/moon swap */
#themeToggle .moon { display: none; }
[data-theme="dark"] #themeToggle .sun { display: none; }
[data-theme="dark"] #themeToggle .moon { display: block; }

.user-menu { position: relative; }
.user-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    background: none;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 5px 8px;
    cursor: pointer;
    font: inherit;
    color: var(--text);
    transition: background .15s ease;
}
.user-btn:hover { background: var(--gray-bg); }
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--grad);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 3px 10px rgba(15, 139, 141, .35);
}
.user-name { font-weight: 600; }
.chev { width: 15px; height: 15px; color: var(--text-3); transition: transform .2s ease; }
.user-menu:hover .chev { transform: translateY(1px); }

.dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 210px;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-6px) scale(.98);
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}
.dropdown.open { opacity: 1; transform: none; pointer-events: auto; }
.dropdown-head {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.dropdown a { display: block; padding: 10px 14px; color: var(--text); transition: background .12s ease, padding-left .12s ease; }
.dropdown a:hover { background: var(--gray-bg); text-decoration: none; padding-left: 18px; }

/* ---------- Content ---------- */
.content { padding: 26px; max-width: 1500px; width: 100%; }

/* gentle entry animation for each page */
@keyframes rise-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}
.content > * { animation: rise-in .35s ease both; }
.content > *:nth-child(2) { animation-delay: .04s; }
.content > *:nth-child(3) { animation-delay: .08s; }
.content > *:nth-child(4) { animation-delay: .12s; }
.content > *:nth-child(5) { animation-delay: .16s; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.page-head h2 { margin: 0; font-size: 17px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    transition: box-shadow .2s ease, border-color .2s ease, background .25s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.card-head h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }

/* ---------- Stat tiles ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    display: flex;
    gap: 13px;
    align-items: flex-start;
    position: relative;
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.stat::after {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--grad);
    opacity: 0;
    transition: opacity .18s ease;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat:hover::after { opacity: 1; }
.stat-icon {
    width: 42px; height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    transition: transform .2s ease;
}
.stat:hover .stat-icon { transform: scale(1.1) rotate(-4deg); }
.stat-icon svg { width: 20px; height: 20px; }
.stat-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.stat-value { font-size: 21px; font-weight: 800; margin-top: 2px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.tone-blue   { background: var(--blue-bg);   color: var(--blue); }
.tone-green  { background: var(--green-bg);  color: var(--green); }
.tone-red    { background: var(--red-bg);    color: var(--red); }
.tone-amber  { background: var(--amber-bg);  color: var(--amber); }
.tone-purple { background: var(--purple-bg); color: var(--purple); }
.tone-gray   { background: var(--gray-bg);   color: var(--gray); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table.data th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-2);
    font-weight: 700;
    padding: 11px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.data td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .12s ease; }
table.data tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-empty {
    padding: 42px 20px;
    text-align: center;
    color: var(--text-3);
}
.row-danger td { background: var(--red-bg) !important; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    padding: 3px 10px;
    white-space: nowrap;
    transition: transform .12s ease;
}
tr:hover .badge { transform: scale(1.04); }
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-gray   { background: var(--gray-bg);   color: var(--gray); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font: inherit;
    font-weight: 600;
    font-size: 13.5px;
    padding: 8px 15px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .12s ease, box-shadow .15s ease;
    white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: scale(.96); }
.btn-primary {
    background: var(--grad);
    color: #fff;
    box-shadow: 0 4px 12px rgba(15, 139, 141, .3);
}
.btn-primary:hover { box-shadow: 0 6px 18px rgba(15, 139, 141, .4); filter: brightness(1.05); }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-ghost { background: none; color: var(--primary); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ---------- Forms ---------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 15px 18px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .req { color: var(--red); }
input[type=text], input[type=number], input[type=email], input[type=password],
input[type=date], input[type=month], input[type=search], input[type=time], input[type=datetime-local], input[type=tel], select, textarea {
    font: inherit;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    width: 100%;
    transition: border-color .15s ease, box-shadow .15s ease, background .25s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 74px; }
.field-help { font-size: 12px; color: var(--text-3); }
.form-actions {
    display: flex;
    gap: 9px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox-row input { width: auto; accent-color: var(--primary); }
input[type=checkbox] { accent-color: var(--primary); }

/* ---------- Filter bar ---------- */
.filter-bar {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    align-items: center;
}
.filter-bar input[type=search], .filter-bar input[type=text] { width: 230px; }
.filter-bar select { width: auto; min-width: 140px; }
.filter-bar input[type=date] { width: auto; }

/* ---------- Alerts → animated toasts ---------- */
.toasts {
    position: fixed;
    top: 74px;
    right: 22px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: none; }
}
.toasts .alert {
    animation: toast-in .3s ease both;
    box-shadow: var(--shadow-lg);
    margin: 0;
    padding-right: 38px;
    position: relative;
    overflow: hidden;
}
.toasts .alert.hide { opacity: 0; transform: translateX(30px); transition: all .3s ease; }
.toast-close {
    position: absolute;
    top: 8px; right: 8px;
    background: none; border: none;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    color: inherit;
    opacity: .6;
}
.toast-close:hover { opacity: 1; }
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-weight: 500;
    border: 1px solid transparent;
}
.alert-success { background: var(--green-bg); color: var(--green); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.alert-error   { background: var(--red-bg);   color: var(--red);   border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.alert-info    { background: var(--blue-bg);  color: var(--blue);  border-color: color-mix(in srgb, var(--blue) 30%, transparent); }
.alert-warning { background: var(--amber-bg); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 30%, transparent); }

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    gap: 5px;
    padding: 14px 16px;
    flex-wrap: wrap;
}
.page-link {
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    border-radius: 9px;
    border: 1px solid var(--border);
    color: var(--text-2);
    font-weight: 600;
    font-size: 13px;
    transition: all .15s ease;
}
.page-link:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.page-link.active { background: var(--grad); color: #fff; border-color: transparent; }
.page-gap { align-self: center; color: var(--text-3); }

/* ---------- Misc ---------- */
.muted { color: var(--text-3); font-size: 12.5px; }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.mono { font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.mb-0 { margin-bottom: 0; }
.stock-pill { font-weight: 700; font-variant-numeric: tabular-nums; }
.progress {
    height: 7px;
    border-radius: 99px;
    background: var(--gray-bg);
    overflow: hidden;
    min-width: 70px;
}
.progress > span {
    display: block; height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, #22c55e, #16a34a);
    transition: width .6s cubic-bezier(.22, 1, .36, 1);
}
.progress > span.warn { background: linear-gradient(90deg, #fbbf24, #d97706); }
.progress > span.danger { background: linear-gradient(90deg, #f87171, #dc2626); }

.cat-toggle { transition: transform .15s ease; }
.cat-toggle:hover { transform: scale(1.3); color: var(--primary) !important; }

details summary { transition: opacity .15s ease; }

/* ---------- Document (invoice/quote) view ---------- */
.doc-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.doc-title {
    font-size: 24px;
    font-weight: 800;
    margin: 0 0 4px;
    letter-spacing: -.02em;
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.doc-meta { color: var(--text-2); font-size: 13.5px; line-height: 1.65; }
.doc-totals { margin-left: auto; width: 300px; max-width: 100%; }
.doc-totals table { width: 100%; border-collapse: collapse; }
.doc-totals td { padding: 6px 0; }
.doc-totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.doc-totals tr.grand td {
    font-size: 17px;
    font-weight: 800;
    border-top: 2px solid var(--text);
    padding-top: 10px;
}

/* ---------- Login ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(900px 500px at 15% 10%, rgba(79, 70, 229, .35), transparent 60%),
        radial-gradient(800px 500px at 85% 90%, rgba(59, 130, 246, .3), transparent 60%),
        #0d1330;
    padding: 20px;
}
.login-card {
    width: 400px;
    max-width: 100%;
    background: var(--surface);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 36px;
    animation: rise-in .45s ease both;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-brand img { width: 46px; height: 46px; border-radius: 12px; box-shadow: 0 6px 18px rgba(15, 139, 141, .4); }
.login-brand h1 { font-size: 19px; margin: 0; }
.login-brand span { color: var(--text-3); font-size: 13px; }
.login-card .field { margin-bottom: 15px; }

/* ---------- Line-item editor ---------- */
.items-editor th { background: var(--surface-2); }
.items-editor input, .items-editor select { min-width: 70px; }
.items-editor .remove-row,
.remove-row {
    color: var(--red);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 7px;
    transition: background .12s ease, transform .12s ease;
}
.items-editor .remove-row:hover, .remove-row:hover { background: var(--red-bg); transform: scale(1.15); }

/* ---------- Print ---------- */
@media print {
    .sidebar, .topbar, .page-actions, .no-print, .alert, .toasts { display: none !important; }
    .main { margin-left: 0; }
    .content { padding: 0; max-width: none; }
    .content > * { animation: none !important; }
    .card { border: none; box-shadow: none; }
    body { background: #fff; color: #000; }
    .doc-title { color: #17203a; background: none; -webkit-background-clip: unset; background-clip: unset; }
}

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

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .sidebar-overlay {
        display: none;
        position: fixed; inset: 0;
        background: rgba(10, 14, 30, .55);
        backdrop-filter: blur(2px);
        z-index: 35;
    }
    .sidebar-overlay.show { display: block; }
    .main { margin-left: 0; }
    .icon-btn.menu-toggle { display: inline-flex; }
    .user-name, .chev { display: none; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .content { padding: 16px; }
    .filter-bar input[type=search] { width: 100%; }
    .toasts { left: 16px; right: 16px; max-width: none; }
}


/* ============================================================
   MediSMS components
   ============================================================ */

/* ---- Sidebar extras ---- */
.nav-count {
    margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 800;
    border-radius: 99px; min-width: 20px; height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center;
}
.credit-pill {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 12px;
    background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; color: #dbe4f0;
}
.credit-pill svg { width: 22px; height: 22px; color: #5eead4; flex: none; }
.credit-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #7d8aa5; }
.credit-value { font-size: 17px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.credit-value.low { color: #fca5a5; }

/* ---- Topbar extras ---- */
.hospital-switch { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 4px 8px; }
.hospital-switch svg { width: 16px; height: 16px; color: var(--text-3); }
.hospital-switch select { border: none; background: transparent; padding: 4px 4px; width: auto; max-width: 220px; font-weight: 600; }
.hospital-switch select:focus { box-shadow: none; }
.notif-dropdown { min-width: 320px; max-width: 360px; }
.notif-item { display: flex !important; flex-direction: column; gap: 2px; border-bottom: 1px solid var(--border); }
.notif-item strong { font-size: 13.5px; }
.notif-item span { font-size: 12.5px; color: var(--text-2); }
.notif-item em { font-size: 11px; color: var(--text-3); font-style: normal; }
.notif-empty { padding: 20px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ---- Login split layout ---- */
.login-wrap { gap: 40px; }
.login-side { display: none; color: #fff; max-width: 440px; }
.login-hero-logo { width: 56px; height: 56px; border-radius: 16px; margin-bottom: 20px; box-shadow: 0 10px 30px rgba(14,165,164,.4); }
.login-hero h2 { font-size: 34px; margin: 0 0 12px; letter-spacing: -.02em; line-height: 1.15; }
.login-hero p { color: #b7c3d6; font-size: 15px; line-height: 1.6; }
.login-points { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-direction: column; gap: 10px; }
.login-points li { display: flex; align-items: center; gap: 10px; color: #dbe4f0; font-size: 14px; }
.login-points li::before { content: "✓"; display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: rgba(94,234,212,.15); color: #5eead4; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; }
@media (min-width: 960px) { .login-side { display: block; } }
.login-wrap { background: radial-gradient(900px 500px at 15% 10%, rgba(14,165,164,.35), transparent 60%), radial-gradient(800px 500px at 85% 90%, rgba(47,111,237,.3), transparent 60%), #0b1b2b; }

/* ---- Chips / tags ---- */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--gray-bg); color: var(--text-2); margin: 2px 3px 2px 0; }
.chip.chip-primary { background: var(--primary-50); color: var(--primary-600); }
.chip .chip-x { cursor: pointer; opacity: .6; font-size: 14px; line-height: 1; }
.chip .chip-x:hover { opacity: 1; color: var(--red); }

/* ---- Segmented control / tabs ---- */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 3px; }
.seg label, .seg a { padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text-2); position: relative; transition: .15s; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked), .seg a.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.seg a:hover { text-decoration: none; color: var(--primary); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; font-weight: 600; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--primary); border-color: var(--primary); }

/* ---- Compose layout ---- */
.compose-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .compose-grid { grid-template-columns: 1fr; } }
.compose-sticky { position: sticky; top: 80px; }
.recipient-box { border: 1px dashed var(--border); border-radius: 12px; padding: 12px; min-height: 60px; background: var(--surface-2); }
.recipient-summary { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--primary-50); color: var(--primary-600); font-weight: 600; margin-top: 12px; }
.recipient-summary strong { font-size: 22px; font-weight: 800; }
.placeholders { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.placeholders button { font: inherit; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; transition: .12s; }
.placeholders button:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.sms-meta { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--text-3); margin-top: 6px; }
.sms-meta b { color: var(--text-2); }
.sms-meta .warn { color: var(--amber); font-weight: 600; }
.sms-meta .danger { color: var(--red); font-weight: 600; }
textarea.sms-body { min-height: 140px; font-size: 15px; line-height: 1.5; }

/* ---- Phone preview ---- */
.phone { width: 280px; margin: 0 auto; background: #0f172a; border-radius: 36px; padding: 14px; box-shadow: var(--shadow-lg), inset 0 0 0 2px #1e293b; }
.phone-screen { background: var(--surface); border-radius: 26px; min-height: 380px; padding: 18px 14px; display: flex; flex-direction: column; }
.phone-notch { width: 90px; height: 22px; background: #0f172a; border-radius: 0 0 14px 14px; margin: -18px auto 14px; }
.phone-sender { text-align: center; font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.phone-time { text-align: center; font-size: 11px; color: var(--text-3); margin-bottom: 14px; }
.bubble { background: var(--gray-bg); color: var(--text); border-radius: 18px 18px 18px 4px; padding: 10px 13px; font-size: 13.5px; line-height: 1.45; max-width: 92%; white-space: pre-wrap; word-wrap: break-word; animation: rise-in .3s ease both; }
.bubble.empty { color: var(--text-3); font-style: italic; }
.bubble-in { background: var(--grad); color: #fff; border-radius: 18px 18px 4px 18px; align-self: flex-end; margin-top: 10px; }

/* ---- Big stat with progress (campaign) ---- */
.progress-lg { height: 12px; }
.status-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--gray-bg); }
.status-bar span { display: block; height: 100%; transition: width .6s ease; }
.status-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-top: 8px; }
.status-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.c-delivered { background: #16a34a; } .c-sent { background: #2563eb; } .c-failed { background: #dc2626; } .c-queued { background: #94a3b8; } .c-blocked { background: #d97706; }

/* ---- Timeline ---- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.tl-item:last-child { border-bottom: none; }
.tl-icon { width: 32px; height: 32px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tl-icon svg { width: 16px; height: 16px; }
.tl-body { flex: 1; min-width: 0; }
.tl-body .tl-text { white-space: pre-wrap; word-wrap: break-word; }
.tl-body .muted { display: block; margin-top: 2px; }

/* ---- Modal ---- */
.modal { position: fixed; inset: 0; background: rgba(10,14,30,.55); backdrop-filter: blur(3px); z-index: 90; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-box { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: 560px; max-width: 100%; max-height: 92vh; overflow: auto; animation: rise-in .25s ease both; }
.modal-box.wide { width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-3); line-height: 1; }
.modal-close:hover { color: var(--red); }

/* ---- Detail lists ---- */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 14px; }
.dl dt { color: var(--text-3); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; padding-top: 2px; }
.dl dd { margin: 0; }

/* ---- Import stepper ---- */
.stepper { display: flex; gap: 0; margin-bottom: 22px; }
.step { flex: 1; display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; color: var(--text-3); font-size: 13.5px; }
.step:first-child { border-radius: 12px 0 0 12px; } .step:last-child { border-radius: 0 12px 12px 0; }
.step b { width: 26px; height: 26px; border-radius: 50%; background: var(--border); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex: none; }
.step.active { color: var(--primary); background: var(--primary-50); border-color: var(--primary); }
.step.active b { background: var(--grad); color: #fff; }
.step.done { color: var(--green); } .step.done b { background: var(--green); color: #fff; }
.dropzone { border: 2px dashed var(--border); border-radius: 14px; padding: 36px 20px; text-align: center; background: var(--surface-2); transition: .15s; cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-50); }
.dropzone input { display: none; }
.dropzone svg { width: 38px; height: 38px; color: var(--primary); margin-bottom: 8px; }
.map-row { display: grid; grid-template-columns: 1fr 24px 1fr 1.4fr; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.map-row .arrow { color: var(--text-3); text-align: center; }
.map-row .sample { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Quick-reply / inbox thread ---- */
.thread { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding: 6px 2px; }
.thread .bubble { max-width: 78%; }
.thread .bubble small { display: block; font-size: 10.5px; opacity: .7; margin-top: 4px; }
.inbox-list a { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: inherit; }
.inbox-list a:hover { background: var(--surface-2); text-decoration: none; }
.inbox-list a.unread strong { color: var(--primary); }
.inbox-list a.active { background: var(--primary-50); }
.inbox-list .preview { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-grid { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
@media (max-width: 960px) { .inbox-grid { grid-template-columns: 1fr; } }

/* ---- Toggle switch ---- */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(18px); }

/* ---- Charts ---- */
.chart-box { position: relative; height: 260px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; }
.bars .bar { flex: 1; background: var(--grad); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; opacity: .9; transition: opacity .15s; }
.bars .bar:hover { opacity: 1; }
.bars .bar[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); font-size: 11px; padding: 3px 7px; border-radius: 6px; white-space: nowrap; margin-bottom: 4px; z-index: 5; }
.bar-labels { display: flex; gap: 4px; font-size: 10px; color: var(--text-3); margin-top: 4px; }
.bar-labels span { flex: 1; text-align: center; overflow: hidden; }

/* ---- Empty state ---- */
.empty { text-align: center; padding: 50px 20px; color: var(--text-3); }
.empty svg { width: 46px; height: 46px; margin-bottom: 10px; color: var(--border); }
.empty h4 { margin: 0 0 4px; color: var(--text-2); }

/* ---- Misc ---- */
.kbd { font-family: ui-monospace, monospace; font-size: 11.5px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2); }
code.inline { font-family: ui-monospace, monospace; font-size: 12.5px; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border); word-break: break-all; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 960px) { .grid-4, .two-col { grid-template-columns: 1fr; } }
.truncate { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
.text-amber { color: var(--amber); }
.mt-0 { margin-top: 0; } .mb-10 { margin-bottom: 10px; } .mt-16 { margin-top: 16px; }
.bulk-bar { display: none; align-items: center; gap: 10px; padding: 10px 16px; background: var(--primary-50); border-bottom: 1px solid var(--border); font-weight: 600; color: var(--primary-600); }
.bulk-bar.show { display: flex; }
.topbar-compose { display: inline-flex; }
@media (max-width: 700px) { .topbar-compose span, .hospital-switch { display: none; } }
.help-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--text-2); line-height: 1.6; }
.consent-warn { background: var(--amber-bg); color: var(--amber); padding: 10px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-day { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px; min-height: 84px; font-size: 12px; }
.cal-day.today { border-color: var(--primary); }
.cal-day .d { font-weight: 700; color: var(--text-2); }
.cal-day .n { display: block; margin-top: 4px; font-weight: 700; color: var(--primary); }

/* inline icons inside text containers */
.card-head svg, .muted svg, .recipient-summary svg, .page-head p svg, .help-box svg { width: 16px; height: 16px; vertical-align: -3px; }
.recipient-summary svg { width: 22px; height: 22px; }
