/* ═══════════════════════════════════════════════════════════════════
   Pah Property — Production SaaS Design System
   Modern · Clean · Professional · Mobile-first
   ═══════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────────────── */
:root {
    /* Brand — Indigo theme (modern SaaS) */
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --primary-ring: rgba(79, 70, 229, 0.2);
    --primary-dark: #3730A3;

    /* Surfaces */
    --bg-root: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-input: #FFFFFF;
    --bg-modal-overlay: rgba(15, 23, 42, 0.55);
    --bg-badge-neutral: #F1F5F9;
    --bg-glass: rgba(255, 255, 255, 0.85);
    --bg-nav: #FFFFFF;

    /* Gray scale — kept for JS inline references */
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;

    /* Borders */
    --border-card: #E2E8F0;
    --border-input: #CBD5E1;
    --border-table: #E2E8F0;
    --border-nav: rgba(226, 232, 240, 0.7);

    /* Text */
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --text-inverse: #FFFFFF;

    /* Semantic */
    --success: #059669;
    --success-bg: #ECFDF5;
    --success-text: #065F46;
    --warning: #D97706;
    --warning-bg: #FFFBEB;
    --warning-text: #92400E;
    --danger: #DC2626;
    --danger-bg: #FEF2F2;
    --danger-text: #991B1B;
    --info-bg: #EFF6FF;
    --info-text: #1E40AF;

    /* Spacing / Radii */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.09), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 0 1px rgba(79, 70, 229, 0.1), 0 4px 16px rgba(79, 70, 229, 0.08);

    /* Layout */
    --nav-h: 60px;

    /* Typography */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;

    /* Font */
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ── Reset & Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    height: 100%;
}

body {
    font-family: var(--font);
    font-size: var(--text-base);
    font-weight: 400;
    color: var(--text-primary);
    background: var(--bg-root);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
    min-height: 100%;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s ease;
}
a:hover { color: var(--primary-hover); }

img { max-width: 100%; display: block; }

/* ── Scrollbar Styling ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ═══════════════════════════════════════════════════════════════════
   TOP NAVIGATION BAR — Premium Glass Design
   ═══════════════════════════════════════════════════════════════════ */

/* ── .app-layout, .sidebar, .main — legacy/fallback selectors ── */
/* These are preserved in case any pages use a sidebar layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: #FFFFFF;
    border-right: 1px solid var(--border-card);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 50;
}

.main {
    flex: 1;
    min-width: 0;
}

/* ── .topbar — legacy alias for top nav ── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: var(--nav-h);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-nav);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding: 8px 20px;
    gap: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

/* ── Top Navigation (actual layout used) ── */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: var(--nav-h);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-nav);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding: 8px 20px;
    gap: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

/* ── Brand (icon stacked above "Pah" text) ── */
.nav-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-weight: 700;
    font-size: 11px;
    color: var(--text-primary);
    text-decoration: none;
    margin-right: 16px;
    flex-shrink: 0;
    text-align: center;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    transition: opacity 0.15s;
}
.nav-brand:hover {
    color: var(--text-primary);
    opacity: 0.85;
}
.nav-brand svg {
    flex-shrink: 0;
}

/* ── Nav Links Container ── */
.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    flex-wrap: wrap;
    padding: 0 4px;
}
.nav-links::-webkit-scrollbar { display: none; }

/* ── Individual Nav Link ── */
.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    white-space: nowrap;
    transition: all 0.15s ease;
    cursor: pointer;
    position: relative;
    text-decoration: none;
    flex-shrink: 0;
    border: 1px solid transparent;
}
.nav-link:hover {
    background: var(--gray-100);
    color: var(--text-primary);
    text-decoration: none;
}
.nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
    border-color: rgba(79, 70, 229, 0.15);
}

.nav-link .nav-icon {
    width: 16px;
    height: 16px;
    opacity: 0.55;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.nav-link:hover .nav-icon { opacity: 0.8; }
.nav-link.active .nav-icon { opacity: 1; }

/* ── Nav Badge (unread count) ── */
.nav-badge {
    background: var(--danger);
    color: #fff;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    letter-spacing: 0;
    margin-left: 4px;
    box-shadow: 0 1px 3px rgba(220, 38, 38, 0.25);
}

/* ── Dropdown Menu ── */
.nav-dropdown { position: relative; flex-shrink: 0; }

.nav-dropdown-toggle { cursor: pointer; }

.nav-dropdown-toggle::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") center / contain no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") center / contain no-repeat;
    opacity: 0.4;
    margin-left: 2px;
    transition: transform 0.2s ease, opacity 0.2s;
}

.nav-dropdown.open .nav-dropdown-toggle::after {
    transform: rotate(180deg);
    opacity: 0.7;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    min-width: 190px;
    background: #fff;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md), 0 0 0 1px rgba(0, 0, 0, 0.02);
    padding: 6px;
    z-index: 200;
    animation: dropdownIn 0.15s ease;
}
.nav-dropdown.open .dropdown-menu { display: block; }

.dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.12s ease;
    white-space: nowrap;
    font-weight: 450;
}
.dropdown-menu .dropdown-item:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}
.dropdown-menu .dropdown-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

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

/* ── Nav Right Section ── */
.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

.nav-user-info {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-align: right;
    line-height: 1.35;
    display: none;
}
.nav-user-info strong {
    display: block;
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

/* ═══════════════════════════════════════════════════════════════════
   LOGIN / AUTH PAGE — Clean & Focused
   ═══════════════════════════════════════════════════════════════════ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(ellipse 80% 55% at 50% -15%, rgba(79, 70, 229, 0.07), transparent),
        radial-gradient(ellipse 60% 45% at 80% 85%, rgba(79, 70, 229, 0.04), transparent),
        var(--bg-root);
    padding: 24px;
}

.login-container {
    width: 100%;
    max-width: 420px;
    animation: fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.login-card {
    background: #FFFFFF;
    border-radius: var(--radius-xl);
    padding: 44px 40px;
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow), 0 4px 24px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.3s ease;
}

.login-card:hover {
    box-shadow: var(--shadow-md), 0 8px 32px rgba(0, 0, 0, 0.05);
}

.login-card h1 {
    font-size: var(--text-3xl);
    font-weight: 700;
    text-align: center;
    margin-bottom: 6px;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 36px;
    font-size: var(--text-base);
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════════
   FORM ELEMENTS — Professional & Accessible
   ═══════════════════════════════════════════════════════════════════ */

.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    font-weight: 600;
    font-size: var(--text-sm);
    margin-bottom: 6px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 16px;
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius);
    font-size: var(--text-base);
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-height: 48px;
    letter-spacing: -0.01em;
    appearance: none;
    -webkit-appearance: none;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: var(--gray-400);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* ── .form-input (used in public pages inline styles) ── */
.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-family: inherit;
    background: #fff;
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

/* ── .form-select (used in dynamic JS modals) ── */
.form-select {
    padding: 9px 14px;
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-family: inherit;
    background: #fff;
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 42px;
    cursor: pointer;
    appearance: auto;
    -webkit-appearance: auto;
}
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

/* ── .fg (SMS compose form groups) ── */
.fg {
    margin-bottom: 16px;
}
.fg label {
    display: block;
    font-weight: 600;
    font-size: var(--text-sm);
    margin-bottom: 6px;
    color: var(--text-primary);
}
.fg input,
.fg select,
.fg textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-family: inherit;
    background: #fff;
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.fg input:focus,
.fg select:focus,
.fg textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

/* ── Error Message ── */
.error-message {
    color: var(--danger-text);
    font-size: var(--text-sm);
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--danger-bg);
    border-radius: var(--radius);
    border: 1px solid #FECACA;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════════
   BUTTONS — Polished & Consistent
   ═══════════════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    min-height: 40px;
    letter-spacing: -0.01em;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    line-height: 1.4;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: transparent;
    transition: background 0.2s;
    pointer-events: none;
}

.btn:hover::after { background: rgba(0, 0, 0, 0.04); }
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.3), 0 1px 2px rgba(79, 70, 229, 0.2);
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}
.btn-primary:hover::after { background: transparent; }
.btn-primary:active { background: var(--primary-dark); }

.btn-outline {
    background: #fff;
    color: var(--text-primary);
    border: 1.5px solid var(--border-input);
    box-shadow: var(--shadow-xs);
}
.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}
.btn-outline:active {
    background: var(--gray-100);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 1px 3px rgba(220, 38, 38, 0.25);
}
.btn-danger:hover { background: #B91C1C; }
.btn-danger:active { background: #991B1B; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    min-height: 36px;
    padding: 6px 12px;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--text-primary); }
.btn-ghost:hover::after { background: transparent; }

/* ── Semantic Button Variants ── */
.btn-green {
    background: var(--success);
    color: #fff;
    box-shadow: 0 1px 3px rgba(5, 150, 105, 0.25);
}
.btn-green:hover { background: #047857; }
.btn-green:active { background: #065F46; }

.btn-orange {
    background: var(--warning);
    color: #fff;
    box-shadow: 0 1px 3px rgba(217, 119, 6, 0.25);
}
.btn-orange:hover { background: #B45309; }
.btn-orange:active { background: #92400E; }

/* ── Button Sizes ── */
.btn-sm {
    padding: 6px 14px;
    font-size: var(--text-xs);
    min-height: 32px;
    border-radius: var(--radius-sm);
}
.btn-xs {
    padding: 4px 10px;
    font-size: 11px;
    min-height: 26px;
    border-radius: var(--radius-sm);
}
.btn-full { width: 100%; }
.btn-block {
    display: flex;
    width: 100%;
    justify-content: center;
}

/* ═══════════════════════════════════════════════════════════════════
   MAIN CONTENT AREA
   ═══════════════════════════════════════════════════════════════════ */

.main-content {
    min-height: calc(100vh - var(--nav-h));
    min-height: calc(100dvh - var(--nav-h));
}

.content-header {
    padding: 20px 32px;
    background: #FFFFFF;
    border-bottom: 1px solid var(--border-card);
    position: sticky;
    top: var(--nav-h);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.content-header h1 {
    font-size: var(--text-2xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.content-body {
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ── Phone Link ── */
.phone-link {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
}
.phone-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════════════
   HOME PAGE — Card Grid
   ═══════════════════════════════════════════════════════════════════ */

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.home-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #fff;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-xs);
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    position: relative;
}
.home-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
    transform: translateY(-2px);
    text-decoration: none;
    color: inherit;
}
.home-card.home-card-alert {
    border-left: 4px solid var(--warning);
}

.home-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.home-card-body { flex: 1; min-width: 0; }
.home-card-body h3 {
    font-size: var(--text-base);
    font-weight: 600;
    margin-bottom: 3px;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.home-card-body p {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

.home-card-arrow {
    flex-shrink: 0;
    color: var(--text-muted);
    opacity: 0;
    transform: translateX(-4px);
    transition: all 0.2s ease;
}
.home-card:hover .home-card-arrow {
    opacity: 1;
    transform: translateX(0);
    color: var(--primary);
}

/* ═══════════════════════════════════════════════════════════════════
   SMS — Clean Console Layout
   ═══════════════════════════════════════════════════════════════════ */

.sms-container { max-width: 900px; margin: 0 auto; }

/* ── SMS Layout (side-by-side or stacked) ── */
.sms-layout {
    display: flex;
    gap: 20px;
    min-height: 500px;
    align-items: flex-start;
}

.sms-sidebar {
    width: 200px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: sticky;
    top: calc(var(--nav-h) + 80px);
}

.sms-sidebar .sms-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 11px 16px;
    border: 1.5px solid var(--border-card);
    border-radius: var(--radius);
    background: #fff;
    text-align: left;
    cursor: pointer;
    font-size: var(--text-sm);
    font-family: inherit;
    position: relative;
    transition: all 0.15s ease;
    color: var(--text-secondary);
    font-weight: 500;
}
.sms-sidebar .sms-tab:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}
.sms-sidebar .sms-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(79, 70, 229, 0.2);
}

.sms-main {
    flex: 1;
    min-width: 0;
}

/* ── SMS Badge ── */
.sms-badge {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: #DC2626;
    color: #fff;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
}

/* ── SMS List (inbox/outbox items) ── */
.sms-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sms-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border-card);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
    background: #fff;
}
.sms-item:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    box-shadow: var(--shadow-xs);
}
.sms-item.unread {
    background: #FFFBEB;
    border-color: #FCD34D;
}

.sms-item .sms-dir {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
    width: 28px;
    text-align: center;
}

.sms-item .sms-body {
    flex: 1;
    min-width: 0;
}
.sms-item .sms-body strong {
    color: var(--text-primary);
    font-weight: 600;
}
.sms-item .sms-meta {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-top: 4px;
}
.sms-item .sms-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
    text-align: right;
    white-space: nowrap;
}

/* ── SMS Thread / Bubble Chat ── */
.sms-thread {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 500px;
    overflow-y: auto;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-card);
}

.sms-bubble {
    max-width: 75%;
    padding: 10px 16px;
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    line-height: 1.55;
    word-wrap: break-word;
    position: relative;
}
.sms-bubble.inbound {
    align-self: flex-start;
    background: #fff;
    border: 1px solid var(--border-card);
    border-bottom-left-radius: 4px;
}
.sms-bubble.outbound {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.sms-bubble .bubble-time {
    font-size: 10px;
    opacity: 0.65;
    margin-top: 4px;
    text-align: right;
}

/* ── SMS Compose ── */
.sms-compose {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 600px;
}
.sms-compose textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px 16px;
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.sms-compose textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}
.sms-compose .char-count {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-align: right;
    margin-top: -8px;
}

/* ── SMS Filter ── */
.sms-filter {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.sms-filter select,
.sms-filter input {
    padding: 8px 12px;
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-family: inherit;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.sms-filter select:focus,
.sms-filter input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

/* ── SMS Pager ── */
.sms-pager {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 16px;
    align-items: center;
}
.sms-pager button {
    padding: 6px 16px;
}
.sms-pager span {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* ── SMS Tab Variants (horizontal tabs) ── */
.sms-tabs {
    display: flex;
    gap: 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid var(--border-card);
    margin-bottom: 20px;
}
.sms-tabs::-webkit-scrollbar { display: none; }

.sms-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: none;
    border: none;
    font-size: var(--text-sm);
    font-weight: 500;
    font-family: inherit;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.sms-tab:hover { color: var(--text-primary); background: var(--gray-50); }
.sms-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.sms-count {
    background: var(--bg-badge-neutral);
    color: var(--text-secondary);
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 600;
}
.sms-tab.active .sms-count {
    background: var(--primary-light);
    color: var(--primary);
}

/* ── SMS Empty State ── */
.sms-empty {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}
.sms-empty p { margin-top: 12px; }
.sms-empty .sms-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ── SMS Conversation Thread (collapsible) ── */
.sms-thread {
    border: 1px solid var(--border-card);
    border-radius: var(--radius);
    margin-bottom: 4px;
    background: #fff;
    overflow: hidden;
    transition: box-shadow 0.15s ease;
}
.sms-thread:hover { box-shadow: var(--shadow-xs); }
.sms-thread.expanded {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.sms-thread-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
}
.sms-thread-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-base);
    flex-shrink: 0;
}
.sms-thread-info { flex: 1; min-width: 0; }
.sms-thread-name {
    font-weight: 600;
    font-size: var(--text-sm);
    margin-bottom: 2px;
}
.sms-thread-preview {
    font-size: var(--text-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sms-thread-meta {
    text-align: right;
    flex-shrink: 0;
}
.sms-thread-time {
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.sms-thread-count {
    display: inline-block;
    background: var(--bg-badge-neutral);
    color: var(--text-secondary);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
}

.sms-thread-messages {
    border-top: 1px solid var(--border-card);
    padding: 16px;
    background: var(--gray-50);
}

.sms-msg { margin-bottom: 12px; }
.sms-msg:last-child { margin-bottom: 0; }
.sms-msg-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: 4px;
    display: flex;
    gap: 8px;
}
.sms-msg-body {
    font-size: var(--text-sm);
    line-height: 1.6;
    padding: 10px 14px;
    border-radius: var(--radius);
    max-width: 75%;
}
.sms-msg-in .sms-msg-body {
    background: #fff;
    border: 1px solid var(--border-card);
}
.sms-msg-out .sms-msg-body {
    background: var(--primary);
    color: #fff;
    margin-left: auto;
}

/* ── SMS Reply Box ── */
.sms-thread-reply {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-card);
}

.sms-reply-input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.sms-reply-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-ring);
}

/* ═══════════════════════════════════════════════════════════════════
   DASHBOARD — Widget Grid
   ═══════════════════════════════════════════════════════════════════ */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.widget {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 28px 28px 24px;
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow-xs);
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.widget::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), #6366F1);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.widget:hover {
    box-shadow: var(--shadow), var(--shadow-glow);
    border-color: var(--primary);
    transform: translateY(-2px);
}
.widget:hover::before { opacity: 1; }

.widget-title {
    font-size: var(--text-xs);
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.widget-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.03em;
}

.widget-sub {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: 6px;
}

.widget-warn::before  { background: linear-gradient(90deg, var(--warning), #F59E0B); }
.widget-good::before  { background: linear-gradient(90deg, var(--success), #10B981); }
.widget-danger::before { background: linear-gradient(90deg, var(--danger), #F87171); }


/* ═══════════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════════ */

.card {
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow-xs);
    padding: 28px;
    margin-bottom: 20px;
    transition: box-shadow 0.2s ease;
}

.card:hover { box-shadow: var(--shadow-sm); }

.card-header {
    font-weight: 700;
    margin-bottom: 20px;
    font-size: var(--text-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════════
   TABLES — Clean & Readable
   ═══════════════════════════════════════════════════════════════════ */

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-card);
    background: #fff;
    box-shadow: var(--shadow-xs);
}

.table-wrapper::-webkit-scrollbar { height: 6px; }
.table-wrapper::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

/* ── .table-responsive (used in dynamic JS modals) ── */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
    font-size: var(--text-sm);
}

.data-table th {
    background: var(--gray-50);
    padding: 14px 18px;
    text-align: left;
    font-weight: 600;
    font-size: var(--text-xs);
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border-table);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.data-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--text-primary);
    line-height: 1.5;
}

.data-table tbody tr { transition: background 0.1s ease; }
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Generic table styling for .table class ── */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}
.table th {
    background: var(--gray-50);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: var(--text-xs);
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-table);
    white-space: nowrap;
}
.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--text-primary);
    line-height: 1.5;
}
.table tbody tr:hover { background: var(--gray-50); }
.table tbody tr:last-child td { border-bottom: none; }

/* ═══════════════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════════════ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    letter-spacing: 0;
}

/* Semantic badges */
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-text); }
.badge-info    { background: var(--info-bg);     color: var(--info-text); }
.badge-neutral { background: var(--bg-badge-neutral); color: var(--text-secondary); }

/* Color-based badges (used in JS dynamic rendering) */
.badge-green  { background: #D1FAE5; color: #065F46; }
.badge-blue   { background: #DBEAFE; color: #1E40AF; }
.badge-yellow { background: #FEF3C7; color: #92400E; }
.badge-gray   { background: #F1F5F9; color: #475569; }
.badge-red    { background: #FEE2E2; color: #991B1B; }
.badge-purple { background: #EDE9FE; color: #5B21B6; }

/* ═══════════════════════════════════════════════════════════════════
   ACTION BUTTONS (table inline actions)
   ═══════════════════════════════════════════════════════════════════ */

.action-btns {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════════ */

.toast-container {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    width: calc(100vw - 56px);
    pointer-events: none;
}

.toast {
    padding: 14px 22px;
    border-radius: var(--radius-lg);
    color: #fff;
    font-weight: 500;
    font-size: var(--text-sm);
    line-height: 1.5;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    letter-spacing: -0.01em;
    pointer-events: auto;
    transition: opacity 0.3s ease;
}

.toast-info    { background: rgba(79, 70, 229, 0.92); }
.toast-success { background: rgba(5, 150, 105, 0.92); }
.toast-error   { background: rgba(220, 38, 38, 0.92); }

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

/* ═══════════════════════════════════════════════════════════════════
   MODAL — Clean Overlay
   ═══════════════════════════════════════════════════════════════════ */

body.modal-open { overflow: hidden; }

/* ── .modal, .modal-overlay, .modal-content (fallback classes) ── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-modal-overlay);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.15s ease;
}

.modal-content {
    background: #fff;
    border-radius: var(--radius-xl);
    padding: 28px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg), 0 25px 50px rgba(0, 0, 0, 0.15);
    animation: modalSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal {
    /* Generic modal container — styles inherited from context */
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══════════════════════════════════════════════════════════════════
   PUBLIC PAGES — Prequalify & Calendar
   ═══════════════════════════════════════════════════════════════════ */

.public-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 24px 80px;
    background: var(--bg-root);
}

.public-container {
    width: 100%;
    max-width: 680px;
    margin-top: 28px;
    padding: 40px 36px;
    background: #fff;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow), 0 1px 2px rgba(0, 0, 0, 0.03);
}

.public-container h1 {
    margin-bottom: 8px;
    font-size: var(--text-2xl);
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ═══════════════════════════════════════════════════════════════════
   EMPTY STATES & PLACEHOLDERS
   ═══════════════════════════════════════════════════════════════════ */

.placeholder-note {
    padding: 56px 32px;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--text-base);
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border-card);
    line-height: 1.6;
}

/* ── tg-card (Telegram-style card, referenced in requirements) ── */
.tg-card {
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow-xs);
    padding: 24px;
    transition: box-shadow 0.2s ease;
}
.tg-card:hover {
    box-shadow: var(--shadow-sm);
}

/* ═══════════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════════ */

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }

.flex         { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-wrap    { flex-wrap: wrap; }
.flex-gap     { display: flex; gap: 8px; align-items: center; }

.gap-1 { gap: 8px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 16px; }

.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET (< 1024px)
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 1023px) {
    .dashboard-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
    .widget-value { font-size: 1.75rem; }
    .content-body { padding: 24px; }
    .content-header { padding: 16px 24px; }

    .sms-layout {
        flex-direction: column;
    }
    .sms-sidebar {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        position: static;
        padding-bottom: 4px;
        border-bottom: 1px solid var(--border-card);
        margin-bottom: 8px;
    }
    .sms-sidebar::-webkit-scrollbar { display: none; }
    .sms-sidebar .sms-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (< 768px)
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
    .top-nav {
        padding: 4px 12px;
        gap: 0;
    }

    .nav-brand {
        font-size: 10px;
        margin-right: 6px;
    }
    .nav-brand svg { width: 18px; height: 18px; }

    .nav-links {
        gap: 0;
        padding: 0;
        overflow-x: auto;
    }

    .nav-link {
        padding: 6px 10px;
        gap: 4px;
        font-size: var(--text-xs);
    }
    .nav-link .nav-icon { width: 14px; height: 14px; }

    .nav-user-info { display: none; }

    .dropdown-menu {
        left: auto;
        right: -8px;
        min-width: 160px;
    }

    .content-header {
        padding: 14px 20px;
        position: sticky;
        top: var(--nav-h);
    }
    .content-header h1 { font-size: var(--text-xl); }
    .content-body { padding: 16px; }

    .dashboard-grid { grid-template-columns: 1fr; gap: 14px; }
    .widget { padding: 22px 22px 20px; }
    .widget-value { font-size: 1.75rem; }

    .table-wrapper { border-radius: var(--radius); }
    .data-table { font-size: var(--text-xs); }
    .data-table th,
    .data-table td { padding: 12px 14px; }

    .card { padding: 20px; }
    .card-header { font-size: var(--text-base); }

    .toast-container {
        bottom: 20px;
        right: 20px;
        left: 20px;
        width: auto;
        max-width: none;
    }
    .toast { font-size: var(--text-xs); padding: 14px 18px; }

    .home-grid {
        grid-template-columns: 1fr;
    }

    .content-header .flex-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .content-header .flex-between .btn { width: 100%; justify-content: center; }

    .login-card { padding: 36px 24px; }
    .login-card h1 { font-size: var(--text-2xl); }

    .public-container {
        padding: 28px 20px;
        margin-top: 12px;
        border-radius: var(--radius-lg);
    }
    .public-container h1 { font-size: var(--text-xl); }

    .sms-layout {
        flex-direction: column;
    }
    .sms-sidebar {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        position: static;
        gap: 4px;
        padding-bottom: 4px;
        border-bottom: 1px solid var(--border-card);
        margin-bottom: 4px;
    }
    .sms-sidebar::-webkit-scrollbar { display: none; }
    .sms-sidebar .sms-tab {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 8px 14px;
        font-size: var(--text-xs);
    }

    #modal-overlay > div {
        width: 100% !important;
        max-width: 100% !important;
        height: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0 !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — SMALL MOBILE (< 400px)
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 399px) {
    .login-card { padding: 28px 18px; }
    .login-card h1 { font-size: var(--text-xl); }
    .content-header { padding: 12px 16px; }
    .content-body { padding: 12px; }
    .widget { padding: 18px 18px 16px; }

    .nav-link {
        padding: 5px 8px;
        font-size: 11px;
    }
}
