/* ═══════════════════════════════════════════════════════
   Sevee Tenant Portal — Professional Theme
   ═══════════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────────── */
:root {
    --sidebar-width:       260px;
    --sidebar-bg:          #0f172a;
    --sidebar-hover:       #1e293b;
    --sidebar-active:      #6366f1;
    --sidebar-text:        #94a3b8;
    --sidebar-text-active: #ffffff;
    --body-bg:             #f1f5f9;
    --card-bg:             #ffffff;
    --primary:             #6366f1;
    --primary-hover:       #4f46e5;
    --success:             #10b981;
    --warning:             #f59e0b;
    --danger:              #ef4444;
    --info:                #3b82f6;
    --text-main:           #0f172a;
    --text-muted:          #64748b;
    --border:              #e2e8f0;
    --radius:              12px;
    --radius-sm:           8px;
    --shadow:              0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md:           0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
    --shadow-lg:           0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
    --transition:          all .18s ease;
}

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

html, body {
    height: 100%;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text-main);
    background: var(--body-bg);
    margin: 0;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

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

/* ── Layout Shell ────────────────────────────────────── */
.shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
    transition: transform .25s ease;
    overflow: hidden;
}

/* Brand row */
.sidebar-brand-row {
    display: flex;
    align-items: center;
    width: 100%;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand-row .sidebar-brand { flex: 1; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px 16px 20px;
    text-decoration: none;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
}

.sidebar-brand-name {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
    letter-spacing: -.3px;
}

.sidebar-brand-sub {
    font-size: 11px;
    color: var(--sidebar-text);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-top: 1px;
}

/* Mobile close button inside brand row */
.sidebar-close-btn {
    display: none;
    width: 34px; height: 34px;
    background: rgba(255,255,255,.07);
    border: none;
    border-radius: 8px;
    color: #94a3b8;
    font-size: 15px;
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 12px;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.sidebar-close-btn:hover { background: rgba(255,255,255,.14); color: #fff; }

/* Nav — only this section scrolls; brand + user bottom stay pinned */
.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 0;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #475569;
    padding: 14px 20px 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
    margin: 1px 8px;
    border-radius: var(--radius-sm);
}

.sidebar-link:hover {
    color: var(--sidebar-text-active);
    background: var(--sidebar-hover);
    text-decoration: none;
}

.sidebar-link.active {
    color: var(--sidebar-text-active);
    background: var(--sidebar-active);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px;
    background: #818cf8;
    border-radius: 0 3px 3px 0;
}

.sidebar-icon {
    width: 18px; height: 18px;
    flex-shrink: 0;
    opacity: .75;
}
.sidebar-link.active .sidebar-icon,
.sidebar-link:hover .sidebar-icon { opacity: 1; }

/* Settings toggle button (looks like sidebar-link but is a <button>) */
.sidebar-link-toggle {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    justify-content: flex-start;
}
.sidebar-link-toggle.active {
    background: rgba(99,102,241,.12);
    color: var(--sidebar-text-active);
}

.sidebar-chevron {
    width: 14px; height: 14px;
    margin-left: auto;
    flex-shrink: 0;
    opacity: .45;
    transition: transform .2s;
}
.sidebar-chevron.open { transform: rotate(180deg); opacity: .75; }

/* Sub-menu */
.sidebar-submenu {
    padding: .2rem 0 .4rem 0;
    border-left: 2px solid rgba(99,102,241,.25);
    margin: 0 8px .25rem 28px;
}
.sidebar-submenu-group {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #475569;
    padding: .55rem 12px .2rem;
}
.sidebar-sublink {
    display: block;
    padding: .38rem 12px;
    font-size: 13px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 6px;
    margin: 1px 4px;
    transition: background .12s, color .12s;
}
.sidebar-sublink:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
    text-decoration: none;
}
.sidebar-sublink.active {
    color: #a5b4fc;
    font-weight: 600;
    background: rgba(99,102,241,.1);
}

/* Sidebar divider */
.sidebar-divider {
    border: none;
    border-top: 1px solid rgba(255,255,255,.06);
    margin: 6px 12px;
}

/* ── Sidebar bottom user section ─────────────────────── */
.sidebar-bottom {
    padding: 12px 8px;
    border-top: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.sidebar-user-wrap { position: relative; }

.sidebar-user {
    display: flex;
    align-items: center;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    transition: var(--transition);
    gap: 10px;
}
.sidebar-user:hover,
.sidebar-user-wrap.menu-open .sidebar-user { background: rgba(255,255,255,.07); }

.sidebar-user-avatar {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: var(--sidebar-text);
}

.sidebar-user-chevron {
    font-size: 10px;
    color: var(--sidebar-text);
    opacity: .6;
    margin-left: auto;
    flex-shrink: 0;
}

.sidebar-user-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0; right: 0;
    background: #1e2433;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 -8px 24px rgba(0,0,0,.35);
    z-index: 100;
}

.sidebar-user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}
.sidebar-user-menu-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-user-menu-danger:hover { background: rgba(239,68,68,.12); color: #f87171; }
.sidebar-user-menu-divider { height: 1px; background: rgba(255,255,255,.07); margin: 2px 0; }

/* ── Mobile top bar ──────────────────────────────────── */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--sidebar-bg);
    z-index: 200;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.mobile-menu-btn {
    width: 40px; height: 40px;
    background: none; border: none;
    color: #e2e8f0;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    transition: background .15s;
    flex-shrink: 0;
}
.mobile-menu-btn:hover { background: rgba(255,255,255,.08); }

.mobile-brand-link {
    display: flex; align-items: center; gap: 8px;
    text-decoration: none;
}
.mobile-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.mobile-brand-name { font-size: 14px; font-weight: 700; color: #fff; letter-spacing: -.3px; }
.mobile-brand-sub  { font-size: 10px; color: rgba(255,255,255,.5); letter-spacing: .08em; text-transform: uppercase; }

/* Sidebar overlay (mobile) */
.sidebar-overlay { display: none; }

/* ── Main area ───────────────────────────────────────── */
.main-area {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── Page content ────────────────────────────────────── */
.page-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 1.75rem 2rem 0;
    background: var(--body-bg);
    min-height: 0;
}

/* ── Page header ─────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; gap: 1rem; }
.page-header-text { flex: 1; min-width: 0; }
.page-title  { font-size: 1.2rem; font-weight: 800; color: var(--text-main); margin: 0; letter-spacing: -.3px; }
.page-subtitle { font-size: .83rem; color: var(--text-muted); margin: .2rem 0 0; }

/* ── Cards ───────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow) !important;
}
.card-header {
    background: transparent !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 16px 20px !important;
    font-weight: 600;
}
.card-body { padding: 20px !important; }

/* ── Stat cards ──────────────────────────────────────── */
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex; align-items: center; gap: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-body { flex: 1; min-width: 0; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text-main); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; }
.stat-change { font-size: 12px; font-weight: 600; margin-top: 6px; }

/* ── Tables ──────────────────────────────────────────── */
.table { font-size: 13.5px; margin-bottom: 0; }
.table thead th {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .6px;
    color: var(--text-muted); background: #f8fafc;
    border-bottom: 1px solid var(--border) !important;
    padding: 12px 16px; white-space: nowrap;
}
.table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: var(--text-main);
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover td { background: #f8fafc; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
    font-size: 13px; font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    transition: var(--transition);
    border: none;
}

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(99,102,241,.3); }
.btn-primary:hover { background: var(--primary-hover); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,.4); }

.btn-outline-primary { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

.btn-outline-secondary { background: transparent; color: var(--text-muted); border: 1.5px solid var(--border); }
.btn-outline-secondary:hover { background: #f1f5f9; color: var(--text-main); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #dc2626; color: #fff; }

.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ── Badges ──────────────────────────────────────────── */
.badge { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 20px; letter-spacing: .2px; }

/* ── Forms ───────────────────────────────────────────── */
.form-control, .form-select {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px; padding: 9px 14px;
    color: var(--text-main);
    transition: var(--transition);
    background: #fff;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.12);
    outline: none;
}
.form-label { font-size: 12.5px; font-weight: 600; color: var(--text-main); margin-bottom: 6px; }

/* ── Alerts ──────────────────────────────────────────── */
.alert { border: none; border-radius: var(--radius-sm); font-size: 13.5px; padding: 12px 16px; }
.alert-danger  { background: #fef2f2; color: #991b1b; border-left: 4px solid var(--danger)   !important; }
.alert-success { background: #f0fdf4; color: #166534; border-left: 4px solid var(--success)  !important; }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 4px solid var(--warning)  !important; }
.alert-info    { background: #eff6ff; color: #1e40af; border-left: 4px solid var(--info)     !important; }

/* ── Spinners ────────────────────────────────────────── */
.spinner-border { width: 28px; height: 28px; border-width: 3px; color: var(--primary); }

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Utilities ───────────────────────────────────────── */
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger  { color: var(--danger)  !important; }
.fw-500 { font-weight: 500 !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.fw-800 { font-weight: 800 !important; }
.rounded-xl { border-radius: var(--radius) !important; }

/* ── Login page ──────────────────────────────────────── */
.login-bg {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
}
.login-bg::before {
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(99,102,241,.15) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(129,140,248,.10) 0%, transparent 50%);
}
.login-card {
    width: 420px;
    background: rgba(255,255,255,.98);
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0,0,0,.4);
    overflow: hidden;
    position: relative; z-index: 1;
}
.login-header {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    padding: 32px 32px 28px;
    text-align: center;
    user-select: none;
}
.login-logo {
    width: 56px; height: 56px;
    margin: 0 auto 14px;
    display: flex; align-items: center; justify-content: center;
    filter: drop-shadow(0 8px 20px rgba(99,102,241,.45));
}
.login-title    { font-size: 22px; font-weight: 800; color: #fff; margin: 0 0 4px; }
.login-subtitle { font-size: 13px; color: #94a3b8; margin: 0; }
.login-tenant-badge {
    display: inline-block;
    background: rgba(99,102,241,.25); color: #a5b4fc;
    font-size: .75rem; font-weight: 600;
    padding: .2rem .65rem; border-radius: 20px; letter-spacing: .04em;
}
.login-body { padding: 28px 32px 32px; }
.login-body .form-control { padding: 11px 14px; font-size: 14px; }

/* ── Settings lookup tables ──────────────────────────── */
/* Card is now a transparent wrapper — toolbar acts as page header above the table card */
.lookup-card {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
    display: flex; flex-direction: column;
    flex: 1; min-height: 0;
}

/* Toolbar = page-level header (title left, controls right) — matches Admin Portal style */
.lookup-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0 0 1.1rem 0;
    gap: .75rem;
    flex-wrap: wrap;        /* wraps on mobile: title row 1, controls row 2 */
    flex-shrink: 0;
}
.lookup-title    { font-size: 1.3rem; font-weight: 800; color: var(--text-main); margin: 0; letter-spacing: -.4px; line-height: 1.2; }
.lookup-subtitle { font-size: .83rem; color: var(--text-muted); margin: .25rem 0 0; }
/* Controls strip — never wraps internally; buttons never break their text */
.lookup-toolbar-right {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: nowrap;
    flex-shrink: 0;
    margin-left: auto;      /* pushes to right on desktop */
    padding-top: 2px;
}
.lookup-toolbar-right .btn { white-space: nowrap; flex-shrink: 0; }
/* Mobile: controls go full-width on their own row */
@media (max-width: 640px) {
    .lookup-toolbar-right { width: 100%; margin-left: 0; flex-wrap: wrap; }
    .lookup-search { width: 100%; flex: 1 1 auto; }
}

/* Search box in toolbar */
.lookup-search {
    height: 32px; padding: 0 .65rem 0 2rem;
    border: 1px solid var(--border); border-radius: 6px;
    font-size: .82rem; color: var(--text-main); background: #fff;
    width: 190px; outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%2394a3b8' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: .55rem center;
    transition: border-color .15s, box-shadow .15s;
}
.lookup-search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.lookup-search::placeholder { color: var(--text-muted); }

/* "Show inactive" filter chip — hides native checkbox, entire pill is the toggle */
.lookup-toggle-inactive {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: 5px 13px;
    border: 1.5px solid #e2e8f0;
    border-radius: 20px;
    font-size: 12px; font-weight: 500;
    color: #64748b; background: #fff;
    cursor: pointer; white-space: nowrap; user-select: none; margin: 0;
    transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
}
.lookup-toggle-inactive:hover {
    border-color: var(--primary); color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.08);
}
.lookup-toggle-inactive:has(input:checked) {
    border-color: var(--primary);
    background: #eef2ff; color: var(--primary);
    font-weight: 600;
    box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.lookup-toggle-inactive input[type="checkbox"] {
    position: absolute; opacity: 0; width: 0; height: 0; margin: 0; pointer-events: none;
}

/* ── Service Location grid (inside Add/Edit slideover) ─────────────────── */
.svc-loc-grid {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    font-size: .82rem;
}
.svc-loc-header,
.svc-loc-row {
    display: grid;
    grid-template-columns: 1fr 110px 56px;
    align-items: center;
    gap: .5rem;
    padding: .45rem .75rem;
}
.svc-loc-header {
    background: var(--bg-light, #f8fafc);
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
}
.svc-loc-row { border-bottom: 1px solid var(--border); }
.svc-loc-row:last-child { border-bottom: none; }
.svc-loc-row:hover { background: #fafafa; }
.svc-loc-name { font-weight: 500; color: var(--text-main); }
.svc-loc-price { width: 100%; padding: .25rem .45rem; font-size: .82rem; }

/* ── PhoneInput component ───────────────────────────────────────────────── */
.phone-input-group { display: flex; gap: .3rem; }
.phone-input-group .phone-prefix {
    width: 70px; flex-shrink: 0;
    font-family: monospace; font-size: .82rem; text-align: center;
}
.phone-input-group .phone-number { flex: 1; }

/* Employee location checkboxes (single column — no price) */
.emp-loc-row {
    padding: .45rem .75rem;
    border-bottom: 1px solid var(--border);
}
.emp-loc-row:last-child { border-bottom: none; }
.emp-loc-row:hover { background: #fafafa; }

/* ── Employee View panel ──────────────────────────────────────── */
.emp-view-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}
.emp-view-avatar {
    width: 56px; height: 56px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; font-weight: 700;
    flex-shrink: 0;
    letter-spacing: .02em;
}
.emp-view-header-info { flex: 1; }
.emp-view-name       { font-size: 1.1rem; font-weight: 700; color: #111827; line-height: 1.3; }
.emp-view-fullname   { font-size: .8rem; color: #6b7280; margin-top: .1rem; }
.emp-view-loc        { font-size: .75rem; color: #6b7280; display: inline-flex; align-items: center; }

/* ── Profile photo upload ── */
.emp-photo-upload-wrap { position: relative; display: inline-block; }
.emp-photo-btn {
    position: absolute;
    bottom: 2px; right: 2px;
    width: 22px; height: 22px;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,.18);
    color: #374151;
    transition: background .15s, box-shadow .15s;
}
.emp-photo-btn:hover { background: #f3f4f6; box-shadow: 0 2px 6px rgba(0,0,0,.22); }

.emp-view-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: .5rem;
    overflow: hidden;
}
.emp-view-cell {
    padding: .6rem .85rem;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}
.emp-view-cell:nth-child(even) { border-right: none; }
.emp-view-cell:nth-last-child(-n+2) { border-bottom: none; }
.emp-view-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: #9ca3af; font-weight: 600; margin-bottom: .2rem; }
.emp-view-value { font-size: .85rem; color: #1f2937; font-weight: 500; }

.emp-view-notes {
    font-size: .85rem; color: #374151;
    background: #f9fafb; border: 1px solid var(--border);
    border-radius: .375rem; padding: .6rem .85rem;
    line-height: 1.5;
}

.emp-view-loc-pill {
    display: inline-flex; align-items: center;
    padding: .25rem .65rem;
    border-radius: 999px;
    font-size: .75rem; font-weight: 500;
    background: #f3f4f6; color: #374151;
    border: 1px solid #e5e7eb;
}
.emp-view-loc-pill.primary {
    background: #ede9fe; color: #6366f1; border-color: #c4b5fd;
}

/* Transfer history timeline */
.timeline-list { border-left: 2px solid #e5e7eb; margin-left: .5rem; padding-left: 1rem; }
.timeline-item {
    position: relative;
    padding: .5rem 0 .5rem 0;
    border-bottom: 1px solid #f3f4f6;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.375rem;
    top: .75rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #6366f1;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #e5e7eb;
}

/* Table wrap = the white card (border, shadow, scroll) */
.lookup-table-wrap {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.lookup-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.lookup-table thead th {
    position: sticky; top: 0; z-index: 1;
    padding: 12px 1.25rem;
    text-align: left;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .6px;
    color: var(--text-muted); background: #f8fafc;
    box-shadow: inset 0 -1px 0 var(--border);
    white-space: nowrap;
}
.lookup-table td {
    padding: 14px 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle; color: var(--text-main);
    font-size: 13.5px;
}
.lookup-table tr:last-child td { border-bottom: none; }
.lookup-table tr:hover td { background: #f8fafc; }
.lookup-table tr.editing td { background: #f0f4ff; }
.lookup-table thead th:last-child { text-align: right; }

.table-count-badge {
    display: inline-flex; align-items: center; justify-content: center;
    background: #e2e8f0; color: #475569;
    font-size: 11px; font-weight: 700;
    padding: 2px 9px; border-radius: 20px;
    letter-spacing: .3px; text-transform: none;
}

/* Row-level UI */
.color-dot {
    width: 18px; height: 18px; border-radius: 50%;
    display: inline-block; flex-shrink: 0;
    border: 2px solid rgba(0,0,0,.08);
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.color-swatch { display: flex; align-items: center; gap: .5rem; }

/* Status badges — clean solid pills, no washed-out Bootstrap subtle */
.lookup-table .badge {
    font-size: 11px !important; font-weight: 600;
    padding: 4px 11px; border-radius: 20px; letter-spacing: .2px;
    display: inline-block;
}
.lookup-table .bg-success-subtle  { background: #d1fae5 !important; }
.lookup-table .text-success        { color: #065f46 !important; }
.lookup-table .bg-secondary-subtle { background: #f1f5f9 !important; }
.lookup-table .text-secondary      { color: #64748b !important; }

.badge-system  { font-size: 11px; padding: 3px 8px; border-radius: 20px; background: #ede9fe; color: #7c3aed; font-weight: 600; }
.badge-default { font-size: 11px; padding: 3px 8px; border-radius: 20px; background: #dcfce7; color: #16a34a; font-weight: 600; }

.row-actions { display: flex; gap: .5rem; align-items: center; }

.btn-icon {
    width: 34px; height: 34px;
    border: none; border-radius: 8px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    background: transparent; color: #64748b;
    transition: background .15s, color .15s;
}
.btn-icon:hover        { background: #f1f5f9; color: var(--text-main); }
.btn-icon.danger:hover { background: #fee2e2; color: #dc2626; }
.btn-icon.save:hover   { background: #dcfce7; color: #16a34a; }
.btn-icon:disabled     { opacity: .4; cursor: not-allowed; }
.btn-icon.warning      { color: #d97706; }
.btn-icon.warning:hover { background: #fef3c7; color: #b45309; }
.btn-icon.success      { color: #16a34a; }
.btn-icon.success:hover { background: #dcfce7; color: #15803d; }

/* ── Confirm Modal ───────────────────────────────────── */
.confirm-backdrop {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(15,23,42,.5);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(3px);
    animation: confirmFadeIn .15s ease;
}
@keyframes confirmFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes confirmSlideUp { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }

.confirm-dialog {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(15,23,42,.22);
    padding: 2rem 2rem 1.6rem;
    max-width: 360px; width: 90%;
    text-align: center;
    animation: confirmSlideUp .2s ease;
}
.confirm-icon-wrap {
    width: 56px; height: 56px; border-radius: 50%;
    background: #fef9c3;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.15rem;
}
.confirm-icon-wrap.danger  { background: #fee2e2; }
.confirm-icon-wrap.success { background: #dcfce7; }

.confirm-dialog-title   { font-size: 1.1rem; font-weight: 700; color: #0f172a; margin: 0 0 .45rem; }
.confirm-dialog-message { font-size: .875rem; color: #64748b; margin: 0 0 1.6rem; line-height: 1.5; }

.confirm-actions { display: flex; gap: .75rem; justify-content: center; }

.confirm-btn {
    padding: .55rem 1.4rem; border-radius: 8px; font-size: .875rem;
    font-weight: 600; border: none; cursor: pointer;
    transition: opacity .15s, transform .1s;
    line-height: 1.4;
}
.confirm-btn:hover  { opacity: .9; }
.confirm-btn:active { transform: scale(.97); }
.confirm-btn:disabled { opacity: .6; cursor: not-allowed; }

.confirm-btn-danger   { background: #ef4444; color: #fff; }
.confirm-btn-warning  { background: #f59e0b; color: #fff; }
.confirm-btn-success  { background: #22c55e; color: #fff; }
.confirm-btn-cancel   { background: #fff; color: #374151; border: 1.5px solid #d1d5db; }
.confirm-btn-cancel:hover { background: #f8fafc; }

/* ── ColorPicker ─────────────────────────────────────── */
.cp-wrap    { position: relative; display: inline-block; }
.cp-trigger {
    width: 32px; height: 32px;
    border: 2px solid var(--border);
    border-radius: 6px; cursor: pointer; padding: 0;
    transition: border-color .15s;
}
.cp-trigger:hover { border-color: var(--primary); }
.cp-palette {
    position: absolute; z-index: 200; top: 36px; left: 0;
    display: grid; grid-template-columns: repeat(5, 24px);
    gap: 3px; padding: 8px;
    background: #fff; border: 1px solid var(--border);
    border-radius: 8px; box-shadow: var(--shadow-md);
}
.cp-swatch {
    width: 24px; height: 24px;
    border: 2px solid transparent; border-radius: 4px;
    cursor: pointer; padding: 0;
    transition: transform .1s, border-color .1s;
}
.cp-swatch:hover  { transform: scale(1.2); border-color: rgba(0,0,0,.25); }
.cp-selected      { border-color: #6366f1 !important; transform: scale(1.15); }

/* ── Inline inputs ───────────────────────────────────── */
.inline-input {
    border: 1.5px solid var(--border);
    border-radius: 6px; padding: .3rem .6rem;
    font-size: .875rem; width: 100%; outline: none;
    background: #fff; transition: border-color .15s, box-shadow .15s;
}
.inline-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }

/* ── Settings index page ─────────────────────────────── */
.settings-grid { display: flex; flex-direction: column; gap: 2rem; overflow-y: auto; padding-right: 4px; }
.settings-section-title {
    font-size: 10px; font-weight: 700;
    letter-spacing: .08em; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: .75rem;
}
.settings-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: .75rem;
}
.settings-card {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem 1.25rem;
    background: #fff; border: 1.5px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none; color: inherit;
    box-shadow: var(--shadow);
    transition: border-color .15s, box-shadow .15s, transform .1s;
}
.settings-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(99,102,241,.15);
    transform: translateY(-1px); color: inherit;
}
.settings-card-icon {
    width: 42px; height: 42px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.settings-card-title { font-size: .9rem; font-weight: 600; color: var(--text-main); }
.settings-card-sub   { font-size: .78rem; color: var(--text-muted); margin-top: 1px; }

/* ── Services / empty state ──────────────────────────── */
.service-group-header {
    display: flex; align-items: center;
    padding: .5rem 0; font-size: .9rem;
}
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--text-muted); }

/* ── Slide-over panel ────────────────────────────────── */
.slideover-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1040; }
.slideover {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 440px; max-width: 95vw;
    background: #fff; box-shadow: -4px 0 32px rgba(0,0,0,.15);
    z-index: 1050; display: flex; flex-direction: column;
    transform: translateX(100%); transition: transform .25s ease;
}
.slideover.open { transform: translateX(0); }
.slideover-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
}
.slideover-title { font-size: 1rem; font-weight: 600; margin: 0; }
.slideover-body  { flex: 1; min-height: 0; overflow-y: auto; padding: 1.5rem; }
.slideover-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

/* ── Client stats strip ──────────────────────────────── */
.client-stats-row {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: .5rem; background: #f9fafb; border-radius: 8px; padding: .75rem;
}
.client-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.client-stat .label { font-size: .68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.client-stat .value { font-size: .9rem; font-weight: 600; color: var(--text-main); }

/* ── Filter bar ──────────────────────────────────────── */
.filter-bar {
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
    box-shadow: var(--shadow);
}

/* ── Pagination ──────────────────────────────────────── */
.pagination-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.pagination-info { font-size: 13px; color: var(--text-muted); }

/* ── Validation ──────────────────────────────────────── */
.valid.modified:not([type=checkbox]) { border-color: var(--success) !important; }
.invalid { border-color: var(--danger) !important; }
.validation-message { color: var(--danger); font-size: 12px; margin-top: 4px; display: block; }

/* ── Blazor error UI ─────────────────────────────────── */
#blazor-error-ui {
    display: none;
    background: #fef2f2; border-top: 1px solid #fca5a5; color: #991b1b;
    padding: 12px 20px;
    position: fixed; bottom: 0; left: 0; right: 0;
    z-index: 9999; font-size: 13px;
}
#blazor-error-ui .reload  { color: var(--primary); font-weight: 600; }
#blazor-error-ui .dismiss { cursor: pointer; }

/* ── Mobile / Responsive ─────────────────────────────── */
@media (max-width: 991px) {
    .sidebar-close-btn { display: flex; }
    .mobile-topbar { display: flex; }

    .sidebar { transform: translateX(-100%); z-index: 150; }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.5); }

    .sidebar-overlay {
        display: block;
        position: fixed; inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 140;
        backdrop-filter: blur(2px);
    }

    /* ── Restore natural document scroll on mobile ──────────────────────────
       Desktop locks everything at 100vh with internal scroll containers.
       On mobile / touch devices that breaks completely — nothing scrolls.
       Switch to standard document flow: let the page grow and the browser
       handle touch-scroll natively.                                          */
    html, body {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        height: auto;
        min-height: 100%;
    }
    .shell {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }
    .main-area {
        overflow: visible;
        min-height: auto;
    }
    .page-content {
        overflow: visible;
        flex: none;
        padding-bottom: 2rem;   /* breathing room at page bottom */
    }
    /* Lookup table wrap: let it expand fully instead of internal scroll */
    .lookup-table-wrap {
        overflow: visible;
        flex: none;
        min-height: unset;
        max-height: none;
    }
    /* Settings grid: same */
    .settings-grid { overflow: visible; }

    .main-area { margin-left: 0; padding-top: 56px; }
    .page-content { padding: .75rem .75rem 2rem; }

    /* Slide-over: start below mobile top bar */
    .slideover { top: 56px; }

    /* Toolbar: allow wrapping on tablet too */
    .lookup-toolbar-right { flex-wrap: wrap; }

    .login-card { width: calc(100vw - 32px); max-width: 420px; }
    .login-header { padding: 24px 24px 20px; }
    .login-body   { padding: 20px 24px 24px; }

    .pagination-bar { flex-direction: column; gap: 8px; align-items: flex-start; }

    /* Employee detail grid: 1 column in narrow slideover */
    .emp-view-grid { grid-template-columns: 1fr; }
    .emp-view-cell { border-right: none !important; }
    .emp-view-cell:nth-last-child(-n+2) { border-bottom: 1px solid var(--border); }
    .emp-view-cell:last-child { border-bottom: none !important; }

    /* Client stats: 2×2 grid */
    .client-stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* Large screens: cap content width */
@media (min-width: 1600px) {
    .page-content { max-width: 1600px; margin: 0 auto; width: 100%; }
}

@media (max-width: 480px) {
    .page-title  { font-size: 1rem; }
    .stat-value  { font-size: 1.4rem; }
    .settings-cards { grid-template-columns: 1fr; }
    /* Toolbar filters full width on phone */
    .lookup-toolbar-right .form-select { flex: 1 1 auto; min-width: 110px; max-width: none !important; }
}

/* ── Slideover form adjustments for small phones (≤ 575px) ──────── */
@media (max-width: 575px) {
    /* Tighter padding — gives ~32px extra content width on 375px phones */
    .slideover-body   { padding: 1rem; }
    .slideover-header { padding: 1rem 1.25rem; }
    .slideover-footer { padding: .85rem 1.25rem; }

    /* Stack all Bootstrap column pairs inside slideover forms
       so PhoneInput (needs ≥220px) gets full row width instead of ~150px */
    .slideover-body .row > .col,
    .slideover-body .row > [class*="col-"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Service location grid: slightly tighter fixed columns */
    .svc-loc-header,
    .svc-loc-row { grid-template-columns: 1fr 88px 46px; gap: .3rem; }

    /* Client stats in form: ensure 2-column fits */
    .client-stats-row { gap: .4rem; }
    .client-stat { padding: .5rem .6rem; }
}

/* ── Table → Card transform (≤ 767px) ───────────────────────── */
@media (max-width: 767px) {

    /* Wrapper becomes transparent — cards provide their own border/shadow */
    .lookup-table-wrap {
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
        padding: .1rem 0;
    }

    /* Table + tbody: block flow */
    .lookup-table,
    .lookup-table tbody { display: block; width: 100%; }

    /* Hide column headers */
    .lookup-table thead { display: none; }

    /* Each <tr> becomes a card */
    .lookup-table tr {
        display: block;
        background: #fff;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: .65rem;
        box-shadow: var(--shadow);
        overflow: hidden;
        transition: border-color .15s, box-shadow .15s;
    }
    .lookup-table tr:hover { border-color: #c7d2fe; box-shadow: var(--shadow-md); }
    .lookup-table tr:hover td { background: transparent; }
    .lookup-table tr.editing { border-color: var(--primary); background: #f0f4ff; }

    /* Each <td> = label : value row */
    .lookup-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .5rem;
        padding: .5rem 1rem;
        border-bottom: 1px solid #f1f5f9;
        font-size: .875rem;
        min-height: 36px;
    }
    .lookup-table td:last-child { border-bottom: none; }
    .lookup-table tr:last-child td { border-bottom: 1px solid #f1f5f9; }
    .lookup-table tr:last-child td:last-child { border-bottom: none; }

    /* Label injected from data-label attribute */
    .lookup-table td[data-label]::before {
        content: attr(data-label);
        font-size: .68rem;
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: .05em;
        flex-shrink: 0;
        min-width: 76px;
    }

    /* Action cell — no label, right-aligned, subtle background */
    .lookup-table td[data-label=""] {
        justify-content: flex-end;
        padding: .35rem .65rem;
        background: #fafafa;
        border-top: 1px solid #f1f5f9;
        border-bottom: none !important;
    }
    .lookup-table td[data-label=""]::before { display: none; }

    /* Inline-edit rows — suppress labels, stack inputs vertically */
    .lookup-table tr.editing td {
        flex-direction: column;
        align-items: stretch;
        gap: .3rem;
        padding: .45rem .75rem;
        min-height: unset;
    }
    .lookup-table tr.editing td::before { display: none; }
    .lookup-table tr.editing .inline-input,
    .lookup-table tr.editing input:not([type=checkbox]),
    .lookup-table tr.editing select { width: 100%; max-width: 100%; }

    /* Action cell in editing row */
    .lookup-table tr.editing td[data-label=""] {
        flex-direction: row;
        justify-content: flex-end;
        padding: .4rem .65rem;
    }
}

/* ── ClientPickerInput ─────────────────────────────────────────────── */
.client-picker { position: relative; }

.client-picker-dropdown {
    position: absolute;
    top: calc(100% + 2px);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    z-index: 1050;
    max-height: 220px;
    overflow-y: auto;
}

.client-picker-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 12px;
    cursor: pointer;
    font-size: .85rem;
    gap: 8px;
}
.client-picker-item:hover { background: #f3f4f6; }

.client-picker-name  { font-weight: 500; color: #111827; }
.client-picker-phone { font-size: .78rem; color: #6b7280; white-space: nowrap; }
.client-picker-empty { padding: 8px 12px; font-size: .82rem; color: #9ca3af; }

/* ── Client Notes Timeline ─────────────────────────────────── */
.client-note-entry {
    border-bottom: 1px solid #f0f0f0;
    padding: .55rem 0;
}
.client-note-entry.editing {
    background: #f9fafb;
    border-radius: 6px;
    padding: .6rem .7rem;
    border-bottom: none;
    margin-bottom: .4rem;
}
.client-note-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
}
.client-note-date {
    font-size: .78rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}
.client-note-category {
    font-size: .70rem;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 20px;
    white-space: nowrap;
}
.client-note-text {
    font-size: .85rem;
    color: #374151;
    white-space: pre-wrap;
    line-height: 1.5;
}
