/* ============================================================
   StoreDesk Dashboard — Stylesheet
   ============================================================ */

/* ── Design Tokens ── */
:root {
    --bg-color: #f8fafc;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --accent-color: #03c75a;
    --accent-glow: rgba(3, 199, 90, 0.1);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success: #03c75a;
    --danger: #ff4d4f;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 76px;
    --transition-speed: 0.25s;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
}

/* ── Reset ── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
}

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

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    z-index: 1000;
    transition: width var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: 0 1.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-color);
}

.sidebar-header .logo-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sidebar-toggle-btn:hover { background: #f1f5f9; color: var(--text-primary); }

.sidebar.collapsed .sidebar-header {
    padding: 0;
    justify-content: center;
    margin-bottom: 2rem;
}

.sidebar.collapsed .logo-box { display: none; }
.sidebar.collapsed .sidebar-toggle-btn { margin-top: 5px; }

.sidebar-nav { flex: 1; padding: 0 0.75rem; transition: padding var(--transition-speed); }
.sidebar.collapsed .sidebar-nav { padding: 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    margin-bottom: 0.25rem;
}
.nav-item:hover { background: #f1f5f9; color: var(--text-primary); }
.nav-item.active { background: #e7f8ef; color: var(--accent-color); }

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.75rem 0;
    gap: 0;
}

.sidebar.collapsed .nav-item span { display: none; }

.sidebar-footer { padding: 1.5rem; border-top: 1px solid var(--border-color); transition: padding var(--transition-speed); }
.sidebar.collapsed .sidebar-footer { padding: 1rem 0; }

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    transition: all var(--transition-speed);
}

.sidebar.collapsed .user-profile {
    background: none;
    border: none;
    padding: 0;
    justify-content: center;
}

.user-info { overflow: hidden; }
.user-info div:first-child { font-weight: 600; font-size: 0.8rem; white-space: nowrap; text-overflow: ellipsis; }
.user-info div:last-child { font-size: 0.7rem; color: var(--text-secondary); }

.sidebar.collapsed .user-info { display: none; }

.avatar {
    width: 32px;
    height: 32px;
    background: var(--accent-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
    transition: all var(--transition-speed);
}

.sidebar.collapsed .avatar { width: 36px; height: 36px; font-size: 0.9rem; }

.sidebar.collapsed .btn-logout {
    justify-content: center;
    padding: 0.75rem 0;
}

.sidebar.collapsed .btn-logout span { display: none; }

/* ── Main content ── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

header {
    background: #ffffff;
    padding: 1rem 2.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 900;
}

main {
    padding: 2.5rem;
    max-width: 1600px;
    margin: 0;
}

/* ── Status badge (header indicators) ── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    background: #e7f8ef;
    color: var(--accent-color);
    border: 1px solid rgba(3, 199, 90, 0.3);
    cursor: default;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-color);
    box-shadow: 0 0 6px var(--accent-color);
    flex-shrink: 0;
}

/* ── Utility: Panels ── */
/* Standard white card */
.panel {
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

/* Compact panel (less padding) */
.panel-sm {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

/* ── Utility: Section header ── */
.section-header {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}
.section-header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    color: var(--text-primary);
}

/* ── Utility: Grids ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; }
.grid-2-fixed { display: grid; grid-template-columns: 400px 1fr; gap: 2rem; }
.span-2 { grid-column: span 2; }

/* ── Utility: Spacing ── */
.mb-section { margin-bottom: 2rem; }
.mb-lg { margin-bottom: 3rem; }

/* ── Utility: Animations ── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.animate-spin { animation: spin 1s linear infinite; display: inline-block; }
.animate-pulse { animation: pulse 2s ease-in-out infinite; }

/* ── Controls / Search bar ── */
.controls {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.search-wrapper { flex: 1; position: relative; }
.search-wrapper i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    width: 20px;
}

.search-input {
    width: 100%;
    background: #ffffff !important;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem 0.875rem 3rem;
    color: #1e293b !important;
    font-size: 1rem;
    transition: all 0.2s;
}
.search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px var(--accent-glow);
}
select.search-input {
    padding: 0.375rem 0.75rem;
    cursor: pointer;
    height: 36px;
}

/* ── Device Grid ── */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* ── Device Card ── */
.device-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}
.device-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 5px;
    background: linear-gradient(90deg, var(--accent-color), #3b82f6);
    opacity: 0;
    transition: opacity 0.3s;
}
.device-card:hover {
    transform: translateY(-6px);
    border-color: rgba(3, 199, 90, 0.2);
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}
.device-card:hover::before { opacity: 1; }

.device-card.is-dismissed {
    opacity: 0.5;
    filter: grayscale(0.5);
    background: #f1f5f9;
    box-shadow: none;
}
.device-card.is-dismissed:hover {
    opacity: 0.8;
    filter: none;
}
.device-card.is-dismissed .id-badge { background: #e2e8f0; color: #94a3b8; }
.device-card.is-dismissed .btn-connect { background: #94a3b8; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.id-badge {
    display: inline-block;
    background: rgba(0,0,0,0.06);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-family: 'Roboto Mono', monospace;
    font-size: 1.1rem;
    font-weight: 800;
    color: #5a6fd6;
    letter-spacing: 1.5px;
    margin-top: 8px;
}

.device-details {
    border: none !important;
    background: #f8fafc;
    border-radius: var(--radius-md);
    padding: 1.25rem !important;
    margin-top: 1.25rem !important;
    box-shadow: inset 0 2px 4px 0 rgba(0,0,0,0.05);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #edf2f7;
}
.detail-row:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.detail-label { display: flex; align-items: center; gap: 0.5rem; color: var(--text-secondary); font-weight: 500; }
.detail-value { color: var(--text-primary); font-weight: 600; }

/* ── Buttons ── */
.btn-dismiss {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.btn-dismiss:hover {
    background: #fff1f2;
    color: var(--danger);
    border-color: #fecaca;
}
.btn-secondary {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    margin-bottom: 0.75rem;
    width: 100%;
}
.btn-secondary:hover { background: #f1f5f9; border-color: #cbd5e1; }

.btn-connect {
    width: 100%;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}
.btn-connect:hover { filter: brightness(1.1); transform: scale(1.02); box-shadow: 0 8px 20px -5px var(--accent-glow); }
.btn-connect:active { transform: scale(0.98); }

.btn-logout {
    background: rgba(239,68,68,0.1);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,0.2);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}
.btn-logout:hover { background: rgba(239,68,68,0.2); transform: translateY(-1px); }

/* ── Loading / Empty state ── */
#loading { text-align: center; padding: 4rem; color: var(--text-secondary); }
#empty-state {
    display: none;
    grid-column: 1 / -1;
    text-align: center;
    padding: 6rem 2rem;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border-color);
}
#empty-state i { color: var(--text-secondary); margin-bottom: 1rem; }

/* ── Sub-Tabs ── */
.section-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}
.sub-tab {
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    border: 1px solid transparent;
    background: none;
}
.sub-tab:hover { color: var(--text-primary); background: rgba(0,0,0,0.05); }
.sub-tab.active { color: var(--accent-color); background: #e7f8ef; border-color: rgba(3,199,90,0.2); }

/* ── Input Group ── */
.input-group { text-align: left; }
.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── CRM Layout ── */
.crm-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
    height: calc(100vh - 250px);
}
.crm-list-area {
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.crm-list-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
}
.crm-list-scroll { flex: 1; overflow-y: auto; padding: 0.5rem; }
.crm-list-item {
    padding: 0.75rem 0.85rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    margin-bottom: 0.4rem;
    position: relative;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.crm-list-item:hover { background: #f8fafc; transform: translateX(4px); }
.crm-list-item.active { background: #f0fdf4 !important; border-color: var(--accent-color) !important; box-shadow: 0 4px 12px rgba(3,199,90,0.1) !important; }
.crm-list-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 4px;
    background: var(--accent-color);
    border-radius: 0 4px 4px 0;
}
.crm-detail-area {
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    overflow-y: auto;
}
.crm-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1rem;
}
.crm-form .full-width { grid-column: span 2; }
.crm-form textarea { min-height: 100px; resize: vertical; padding: 0.75rem !important; }
.crm-form .input-group label { margin-bottom: 0.25rem; font-size: 0.8rem; }
.crm-form .search-input { height: 34px; padding: 0.5rem 0.75rem; font-size: 0.875rem; }

/* ── Login overlay ── */
.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-color);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background-image: radial-gradient(circle at 50% 50%, rgba(59,130,246,0.15) 0%, transparent 60%);
}
.login-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 3rem;
    border-radius: 24px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.2);
    text-align: center;
}
.login-card h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}
.login-card p { color: var(--text-secondary); margin-bottom: 2rem; }
.login-form { display: flex; flex-direction: column; gap: 1.25rem; }
.login-input {
    width: 100%;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s;
}
.login-input:focus { outline: none; border-color: var(--accent-color); box-shadow: 0 0 0 4px var(--accent-glow); }
.login-error { color: var(--danger); font-size: 0.875rem; margin-top: 1rem; display: none; }

/* ── Notification Toast (legacy — top-right) ── */
#notification-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -150%);
    width: 420px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 2px solid var(--danger);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: 0 0 0 100vw rgba(0,0,0,0.4), 0 25px 50px -12px rgba(0,0,0,0.5);
    z-index: 11000;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(12px);
    visibility: hidden;
    opacity: 0;
}
#notification-toast.show { 
    transform: translate(-50%, -50%); 
    visibility: visible;
    opacity: 1;
}
.notif-header { 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
    margin-bottom: 1.25rem; 
    color: var(--danger); 
    font-weight: 800; 
    font-size: 1.25rem;
    font-family: 'Outfit', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.notif-body { 
    font-size: 1rem; 
    color: white; 
    margin-bottom: 1.5rem; 
    line-height: 1.6;
    padding: 1rem;
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius-md);
}
.notif-footer { 
    display: flex; 
    gap: 0.75rem; 
}
.notif-footer .btn-connect {
    background: var(--danger);
    height: 48px;
    font-size: 1rem;
}
.notif-footer .btn-connect:hover {
    background: #ff4d4f;
    box-shadow: 0 0 20px rgba(255,77,79,0.4);
}

/* ── Persistent Toast System (bottom-left) ── */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    left: calc(var(--sidebar-width) + 1.5rem);
    right: 1.5rem; /* Allow growing to the right */
    z-index: 10000;
    display: flex;
    flex-direction: row; /* Stack horizontally */
    flex-wrap: wrap-reverse; /* Wrap UPWARDS */
    align-items: flex-end;
    gap: 0.75rem;
    pointer-events: none;
}

@keyframes subtle-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
    70%  { box-shadow: 0 0 0 10px rgba(16,185,129,0); }
    100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
@keyframes subtle-pulse-blue {
    0%   { box-shadow: 0 0 0 0 rgba(59,130,246,0.4); }
    70%  { box-shadow: 0 0 0 10px rgba(59,130,246,0); }
    100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); }
}
@keyframes slide-up-toast {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.conn-toast {
    background: white;
    border-left: 4px solid #10b981;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 0.75rem 1rem;
    width: 280px; /* Slightly wider for horizontal layout */
    pointer-events: auto;
    position: relative;
    animation: slide-up-toast 0.4s ease-out forwards;
    transition: all 0.3s ease;
}
.conn-toast.is-support {
    border-left-color: #3b82f6; /* Blue for active support requests */
}
.conn-toast.pulsing { 
    animation: slide-up-toast 0.4s ease-out forwards, subtle-pulse 2.5s infinite; 
}
.conn-toast.is-support.pulsing { 
    animation: slide-up-toast 0.4s ease-out forwards, subtle-pulse-blue 2.5s infinite; 
}
.conn-toast.pulsing:hover, .conn-toast.is-support.pulsing:hover { 
    animation: slide-up-toast 0.4s ease-out forwards; 
}
.conn-toast-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.conn-toast-title { font-weight: 700; color: #10b981; display: flex; align-items: center; gap: 6px; }
.conn-toast.is-support .conn-toast-title { color: #3b82f6; }
.conn-toast.is-support .btn-connect { background: #3b82f6 !important; }
.btn-connect:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-complete { border-radius: 4px; transition: all 0.2s; cursor: pointer; }
.btn-complete:hover { background: #334155 !important; transform: translateY(-1px); }
.conn-toast-close { background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 2px; border-radius: 4px; transition: all 0.2s; }
.conn-toast-close:hover { background: #f1f5f9; color: var(--danger); }
.conn-toast-body { font-size: 0.85rem; color: var(--text-primary); margin-top: 4px; }

/* ── Highlight blink (device search result) ── */
@keyframes highlight-pulse {
    0%   { box-shadow: 0 0 0 0  rgba(3,199,90,0.6); border-color: #03c75a; transform: scale(1);    }
    50%  { box-shadow: 0 0 0 20px rgba(3,199,90,0);   border-color: #03c75a; transform: scale(1.02); }
    100% { box-shadow: 0 0 0 0  rgba(3,199,90,0);   border-color: #03c75a; transform: scale(1);    }
}
.highlight-blink {
    animation: highlight-pulse 0.8s ease-in-out 3;
    z-index: 1000 !important;
    border-width: 2px !important;
    scroll-margin-top: 100px;
}

/* ── Master Management 1:2 Ratio Layout ── */
.master-management-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
    align-items: start;
}

.master-form-container {
    background: #ffffff;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    padding: 1rem;
}

.master-form-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.banner-vertical-stack {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.master-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    align-items: start;
}

/* ────────────────────────────────────── */

.master-category-section {
    background: #ffffff;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
}

.master-category-header {
    padding: 0.5rem 0.875rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 0.82rem;
}

.count-badge {
    margin-left: auto;
    background: #f1f5f9;
    color: var(--text-secondary);
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 10px;
}

.master-items-container {
    padding: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-height: 700px;
    overflow-y: auto;
}

.master-item-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.6rem;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    transition: all 0.1s;
}

.master-item-card:last-child { border-bottom: none; }
.master-item-card:hover { background: #f0fdf4; }

.master-item-name {
    font-weight: 500;
    font-size: 0.82rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.master-item-sub {
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.action-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn i { width: 13px; height: 13px; }

/* ────────────────────────────────────── */

.input-group label {
    font-size: 0.72rem;
    margin-bottom: 3px;
    color: var(--text-secondary);
}

.search-input {
    height: 32px;
    font-size: 0.8rem;
    padding: 0 0.6rem;
    border-radius: 4px;
}

.btn-connect {
    height: 34px;
    font-size: 0.85rem;
    border-radius: 6px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg-color); }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Responsive ── */
@media (max-width: 768px) {
    header { padding: 1rem; }
    main { padding: 1.5rem 1rem; }
    .controls { flex-direction: column; padding: 1rem; }
    .crm-container { grid-template-columns: 1fr; height: auto; }
    .grid-2, .grid-2-fixed { grid-template-columns: 1fr; }
}

/* ── Support Summary Bar ── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.support-summary-bar {
    display: flex;
    gap: 12px;
    align-items: center;
}

.summary-item {
    display: flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.summary-item.past {
    background: #fff1f2;
    color: #e11d48;
    border: 1px solid #fecdd3;
}

.summary-item.today {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.summary-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.summary-item strong {
    font-weight: 700;
    margin: 0 2px;
}

@keyframes pulse-animation {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.4); }
    70% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(225, 29, 72, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); }
}

.pulse-animation {
    animation: pulse-animation 2s infinite;
}
/* ── Store-Device Hierarchy UI ── */
.store-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    overflow: hidden;
}

.store-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 20px -5px rgba(0,0,0,0.1);
    border-color: var(--accent-color);
}

.store-card-inner {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.store-status {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.device-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.device-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 6px 10px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    position: relative;
    padding-right: 24px;
}

.device-chip:hover {
    background: #ffffff;
    border-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.device-chip.online {
    color: var(--text-primary);
}

.device-chip.offline {
    opacity: 0.6;
    background: #f1f5f9;
}

.device-chip .status-dot {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    box-shadow: none;
}

.device-chip.online .status-dot {
    background: var(--accent-color);
    box-shadow: 0 0 6px var(--accent-color);
}

.device-chip i {
    color: var(--text-secondary);
}

.device-chip.online i {
    color: var(--accent-color);
}

.store-footer {
    padding: 0.75rem 1.5rem;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
}

/* Unassigned Store Card variant */
.store-card.unassigned {
    border-style: dashed;
    background: #fdfdfd;
}

.store-card.unassigned h3 {
    color: var(--text-secondary);
}
