/* ===============================
   ElectroHub — Admin Dashboard
   =============================== */

:root {
    --primary: #1a56db;
    --primary-dark: #1541a8;
    --primary-light: #e8f0fe;
    --accent: #06b6d4;
    --purple: #7c3aed;
    --green: #16a34a;
    --amber: #f59e0b;
    --red: #ef4444;
    --pink: #ec4899;
    --dark: #0f172a;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --border: #e5e9f0;
    --bg: #f1f5f9;
    --card: #ffffff;
    --sidebar-w: 264px;
    --sidebar-collapsed: 80px;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(15,23,42,0.06);
    --shadow: 0 4px 20px rgba(15,23,42,0.06);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }

.material-icons-outlined {
    font-family: 'Material Icons Outlined';
    font-weight: normal; font-style: normal; line-height: 1;
    letter-spacing: normal; text-transform: none; display: inline-block;
    white-space: nowrap; word-wrap: normal; direction: ltr;
    -webkit-font-feature-settings: 'liga'; -webkit-font-smoothing: antialiased;
    vertical-align: middle; user-select: none;
}

.logo-icon {
    width: 42px; height: 42px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff;
}
.logo-icon .material-icons-outlined { font-size: 24px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px; border-radius: var(--radius-sm);
    font-weight: 600; font-size: 13px; cursor: pointer; border: none;
    transition: all 0.2s;
}
.btn .material-icons-outlined { font-size: 18px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: var(--sidebar-w);
    background: var(--dark); color: #cbd5e1;
    display: flex; flex-direction: column; z-index: 100;
    transition: width 0.25s ease;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .nav-text,
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .sidebar-logo { justify-content: center; }
.sidebar.collapsed .sidebar-nav a { justify-content: center; }

.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo { display: flex; align-items: center; gap: 12px; overflow: hidden; }
.sidebar-logo .logo-text h2 { color: #fff; font-size: 18px; font-weight: 800; white-space: nowrap; }
.sidebar-logo .logo-text span { font-size: 11px; color: var(--text-light); }
.sidebar-toggle { background: rgba(255,255,255,0.06); border: none; color: #cbd5e1; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; flex-shrink: 0; }
.sidebar-toggle:hover { background: rgba(255,255,255,0.14); color: #fff; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 12px; }
.sidebar-nav ul { display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 14px; border-radius: 10px;
    color: #cbd5e1; font-weight: 500; transition: all 0.2s; position: relative;
}
.sidebar-nav a .material-icons-outlined { font-size: 22px; flex-shrink: 0; }
.sidebar-nav li:hover a { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav li.active a { background: var(--primary); color: #fff; }
.nav-badge {
    margin-left: auto; background: var(--red); color: #fff;
    font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
}
.sidebar-nav li.active .nav-badge { background: rgba(255,255,255,0.25); }

.sidebar-footer { padding: 16px 12px; border-top: 1px solid rgba(255,255,255,0.08); display: flex; flex-direction: column; gap: 4px; }
.sidebar-footer a { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 10px; color: #cbd5e1; font-weight: 500; transition: all 0.2s; }
.sidebar-footer a .material-icons-outlined { font-size: 22px; }
.back-to-store:hover { background: rgba(6,182,212,0.15); color: var(--accent); }
.logout-btn:hover { background: rgba(239,68,68,0.15); color: var(--red); }

/* ---------- Main Content ---------- */
.main-content {
    margin-left: var(--sidebar-w);
    transition: margin-left 0.25s ease;
    min-height: 100vh;
}
.main-content.expanded { margin-left: var(--sidebar-collapsed); }

.dash-header {
    background: var(--card); border-bottom: 1px solid var(--border);
    padding: 16px 28px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
}
.dash-header-left { display: flex; align-items: center; gap: 16px; }
.mobile-menu-btn { display: none; background: none; border: none; cursor: pointer; color: var(--text); }
.mobile-menu-btn .material-icons-outlined { font-size: 26px; }
.dash-header h1 { font-size: 22px; font-weight: 800; color: var(--dark); }
.dash-header-right { display: flex; align-items: center; gap: 16px; }
.date-range-picker {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg); padding: 9px 14px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; cursor: pointer; color: var(--text-muted);
}
.date-range-picker .material-icons-outlined { font-size: 18px; }
.notif-btn { position: relative; background: var(--bg); border: none; width: 42px; height: 42px; border-radius: 10px; cursor: pointer; color: var(--text); }
.notif-btn .material-icons-outlined { font-size: 22px; }
.notif-badge { position: absolute; top: 6px; right: 7px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.header-profile { display: flex; align-items: center; gap: 10px; cursor: pointer; padding-left: 8px; }
.profile-avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--purple)); display: flex; align-items: center; justify-content: center; color: #fff; }
.profile-info strong { display: block; font-size: 13px; }
.profile-info span { font-size: 11px; color: var(--text-muted); }

.page-content { padding: 28px; }

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 18px; margin-bottom: 24px; }
.stat-card {
    background: var(--card); border-radius: var(--radius); padding: 22px;
    box-shadow: var(--shadow); display: flex; gap: 16px; align-items: flex-start;
    transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-4px); }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon .material-icons-outlined { font-size: 26px; }
.orders-icon { background: rgba(26,86,219,0.12); color: var(--primary); }
.sales-icon { background: rgba(22,163,74,0.12); color: var(--green); }
.customers-icon { background: rgba(124,58,237,0.12); color: var(--purple); }
.products-icon { background: rgba(6,182,212,0.12); color: var(--accent); }
.pending-icon { background: rgba(245,158,11,0.12); color: var(--amber); }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--dark); margin: 4px 0; letter-spacing: -0.5px; }
.stat-change { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; }
.stat-change .material-icons-outlined { font-size: 16px; }
.stat-change span { color: var(--text-muted); font-weight: 500; }
.stat-change.positive { color: var(--green); }
.stat-change.negative { color: var(--red); }

/* ---------- Charts Grid ---------- */
.charts-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; margin-bottom: 24px; }
.charts-grid-3 { grid-template-columns: 1fr 1.4fr; }
.chart-card { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.chart-header h3 { font-size: 16px; font-weight: 700; color: var(--dark); }
.chart-legend { display: flex; gap: 16px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.primary { background: var(--primary); }
.dot.secondary { background: var(--accent); }
.chart-body { position: relative; height: 280px; }
.chart-body canvas { width: 100% !important; height: 100% !important; }
.view-all-link { color: var(--primary); font-weight: 600; font-size: 13px; }

/* Donut */
.donut-chart-body { display: flex; align-items: center; justify-content: center; height: 200px; }
.donut-center { position: absolute; text-align: center; }
.donut-center strong { display: block; font-size: 24px; font-weight: 800; color: var(--dark); }
.donut-center span { font-size: 12px; color: var(--text-muted); }
.donut-legend { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.donut-legend-item { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.donut-legend-item .left { display: flex; align-items: center; gap: 8px; }
.donut-legend-item .swatch { width: 12px; height: 12px; border-radius: 3px; }
.donut-legend-item .value { font-weight: 700; }

/* Top products */
.top-products-list { display: flex; flex-direction: column; gap: 14px; }
.top-product-item { display: flex; align-items: center; gap: 12px; }
.top-product-rank { width: 26px; height: 26px; border-radius: 7px; background: var(--bg); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: var(--text-muted); flex-shrink: 0; }
.top-product-item:nth-child(1) .top-product-rank { background: var(--primary); color: #fff; }
.top-product-icon { width: 42px; height: 42px; border-radius: 10px; background: var(--primary-light); display: flex; align-items: center; justify-content: center; color: var(--primary); flex-shrink: 0; }
.top-product-info { flex: 1; min-width: 0; }
.top-product-info h4 { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-product-info span { font-size: 12px; color: var(--text-muted); }
.top-product-sales { text-align: right; }
.top-product-sales strong { display: block; font-size: 14px; color: var(--dark); }
.top-product-bar { height: 5px; background: var(--bg); border-radius: 3px; margin-top: 5px; overflow: hidden; width: 80px; }
.top-product-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 3px; }

/* Recent orders */
.recent-orders-list { display: flex; flex-direction: column; }
.recent-order-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--bg); }
.recent-order-item:last-child { border-bottom: none; }
.recent-order-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--bg); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--primary); flex-shrink: 0; }
.recent-order-info { flex: 1; min-width: 0; }
.recent-order-info h4 { font-size: 13px; font-weight: 600; }
.recent-order-info span { font-size: 12px; color: var(--text-muted); }
.recent-order-amount { font-weight: 700; font-size: 14px; }

/* Traffic sources */
.traffic-sources-list { display: flex; flex-direction: column; gap: 18px; }
.traffic-source-item h4 { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; margin-bottom: 7px; }
.traffic-source-item h4 span { color: var(--text-muted); font-weight: 500; }
.traffic-bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.traffic-bar span { display: block; height: 100%; border-radius: 4px; }

/* ---------- Status Badges ---------- */
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-delivered, .status-instock { background: rgba(22,163,74,0.12); color: var(--green); }
.status-pending, .status-lowstock { background: rgba(245,158,11,0.12); color: var(--amber); }
.status-processing { background: rgba(26,86,219,0.12); color: var(--primary); }
.status-cancelled, .status-outofstock { background: rgba(239,68,68,0.12); color: var(--red); }

/* ---------- Toolbar ---------- */
.page-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar-left { display: flex; gap: 12px; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 10px; }
.search-input { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 12px; }
.search-input .material-icons-outlined { color: var(--text-light); font-size: 20px; }
.search-input input { border: none; padding: 10px 4px; font-size: 13px; outline: none; background: none; width: 220px; }
.toolbar-select { border: 1px solid var(--border); background: var(--card); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; color: var(--text); cursor: pointer; outline: none; }

/* ---------- Data Table ---------- */
.data-table-container { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th { text-align: left; padding: 14px 18px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); background: var(--bg); white-space: nowrap; }
.data-table tbody td { padding: 14px 18px; font-size: 13px; border-bottom: 1px solid var(--bg); white-space: nowrap; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table tbody tr:last-child td { border-bottom: none; }
.table-product { display: flex; align-items: center; gap: 12px; }
.table-product-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--primary-light); display: flex; align-items: center; justify-content: center; color: var(--primary); flex-shrink: 0; }
.table-product-name { font-weight: 600; }
.table-customer { display: flex; align-items: center; gap: 10px; }
.table-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--bg); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: var(--primary); flex-shrink: 0; }
.row-actions { display: flex; gap: 6px; }
.action-btn { width: 32px; height: 32px; border-radius: 8px; border: none; background: var(--bg); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-muted); transition: all 0.2s; }
.action-btn .material-icons-outlined { font-size: 18px; }
.action-btn.edit:hover { background: var(--primary-light); color: var(--primary); }
.action-btn.view:hover { background: rgba(6,182,212,0.15); color: var(--accent); }
.action-btn.delete:hover { background: rgba(239,68,68,0.12); color: var(--red); }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }

/* ---------- Pagination ---------- */
.table-pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; flex-wrap: wrap; gap: 12px; }
.pagination-info { font-size: 13px; color: var(--text-muted); }
.pagination-controls { display: flex; align-items: center; gap: 6px; }
.page-btn { min-width: 36px; height: 36px; border: 1px solid var(--border); background: var(--card); border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.page-btn .material-icons-outlined { font-size: 18px; }
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.settings-card { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.settings-card h3 { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.settings-card h3 .material-icons-outlined { color: var(--primary); font-size: 22px; }
.settings-form .form-group { margin-bottom: 16px; }
.settings-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.settings-form input, .settings-form select, .settings-form textarea {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 13px; outline: none; font-family: inherit; resize: vertical;
    transition: border 0.2s;
}
.settings-form input:focus, .settings-form select:focus, .settings-form textarea:focus { border-color: var(--primary); }
.toggle-group { display: flex; align-items: center; justify-content: space-between; }
.toggle-group label:first-child { margin-bottom: 0; }
.toggle { position: relative; display: inline-block; width: 46px; height: 26px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 26px; transition: 0.25s; }
.toggle-slider::before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.25s; box-shadow: var(--shadow-sm); }
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ---------- Placeholder Pages ---------- */
.placeholder-page { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 80px 40px; text-align: center; color: var(--text-muted); }
.placeholder-page .material-icons-outlined { font-size: 72px; color: var(--border); margin-bottom: 16px; }
.placeholder-page h2 { font-size: 22px; color: var(--dark); margin-bottom: 8px; }

/* ---------- Extra buttons ---------- */
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c81e1e; }
.btn-text { background: none; border: none; color: var(--text-muted); cursor: pointer; font-weight: 600; font-size: 13px; }
.btn-text:hover { color: var(--red); }

/* ---------- Category Manage Grid ---------- */
.category-manage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.category-manage-card {
    background: var(--card); border-radius: var(--radius); padding: 22px;
    box-shadow: var(--shadow); text-align: center; position: relative; transition: transform 0.2s;
}
.category-manage-card:hover { transform: translateY(-4px); }
.category-manage-icon {
    width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 16px;
    background: var(--primary-light); display: flex; align-items: center; justify-content: center;
}
.category-manage-icon .material-icons-outlined { font-size: 30px; color: var(--primary); }
.category-manage-icon img { width: 100%; height: 100%; object-fit: contain; border-radius: 14px; }
.category-manage-card h4 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.category-manage-card .cat-count { font-size: 12px; color: var(--text-muted); }
.category-manage-actions { display: flex; gap: 6px; justify-content: center; margin-top: 14px; }

/* ---------- Admin Modals ---------- */
.admin-modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.55);
    display: flex; align-items: center; justify-content: center; padding: 20px;
    opacity: 0; visibility: hidden; transition: all 0.25s; z-index: 500;
}
.admin-modal-overlay.open { opacity: 1; visibility: visible; }
.admin-modal {
    background: var(--card); border-radius: var(--radius); width: 100%; max-width: 620px;
    max-height: 92vh; overflow-y: auto; transform: translateY(20px); transition: transform 0.25s;
}
.admin-modal-overlay.open .admin-modal { transform: translateY(0); }
.admin-modal-sm { max-width: 460px; }
.admin-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 24px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card); z-index: 2;
}
.admin-modal-header h2 { font-size: 18px; font-weight: 800; }
.admin-modal-close { background: var(--bg); border: none; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; color: var(--text); transition: all 0.2s; }
.admin-modal-close:hover { background: var(--red); color: #fff; }
.admin-form { padding: 24px; }
.admin-form .form-group { margin-bottom: 16px; }
.admin-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.admin-form input, .admin-form select, .admin-form textarea {
    width: 100%; padding: 11px 14px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 13px; outline: none; font-family: inherit;
    transition: border 0.2s; background: var(--card); color: var(--text);
}
.admin-form input:focus, .admin-form select:focus { border-color: var(--primary); }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.admin-modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.admin-modal-footer.center { justify-content: center; }

/* Image upload */
.image-upload { display: flex; gap: 20px; align-items: center; margin-bottom: 22px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.image-preview {
    width: 120px; height: 120px; border-radius: var(--radius); border: 2px dashed var(--border);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; background: var(--bg);
}
.image-preview .material-icons-outlined { font-size: 46px; color: var(--text-light); }
.image-preview img { width: 100%; height: 100%; object-fit: contain; }
.image-upload-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.image-upload-actions .btn { cursor: pointer; }
.upload-hint { font-size: 12px; color: var(--text-muted); }

/* Specifications rows */
.btn-sm { padding: 6px 12px; font-size: 12px; }
.specs-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.specs-rows { display: flex; flex-direction: column; gap: 8px; }
.spec-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.spec-row .spec-remove {
    width: 34px; height: 34px; flex-shrink: 0; border: 1px solid var(--border); background: var(--bg);
    border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-muted);
    transition: all 0.2s;
}
.spec-row .spec-remove:hover { background: rgba(239,68,68,0.12); color: var(--red); border-color: transparent; }
.spec-row .spec-remove .material-icons-outlined { font-size: 18px; }

/* Tag checkboxes */
.tag-checks { display: flex; gap: 18px; flex-wrap: wrap; }
.tag-check { display: flex !important; align-items: center; gap: 6px; font-weight: 500 !important; margin-bottom: 0 !important; cursor: pointer; }
.tag-check input { width: auto !important; }

/* Confirm dialog */
.confirm-dialog { text-align: center; padding: 32px 28px; }
.confirm-icon { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%; background: rgba(239,68,68,0.12); display: flex; align-items: center; justify-content: center; }
.confirm-icon .material-icons-outlined { font-size: 34px; color: var(--red); }
.confirm-dialog h2 { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.confirm-dialog p { color: var(--text-muted); margin-bottom: 8px; }
.confirm-dialog .admin-modal-footer { border-top: none; padding-top: 0; }

/* Product thumb in table */
.table-product-img { width: 40px; height: 40px; border-radius: 10px; object-fit: contain; background: #fff; border: 1px solid var(--border); flex-shrink: 0; }

/* Order detail modal */
.order-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.order-detail-grid .full { grid-column: 1 / -1; }
.order-detail-grid label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; margin-bottom: 3px; }
.order-detail-grid p { font-size: 14px; font-weight: 500; }
.order-lines { margin-top: 8px; }
.order-line { display: flex; justify-content: space-between; padding: 8px 0; font-size: 13px; border-bottom: 1px solid var(--bg); }
.order-totals { margin-top: 6px; border-top: 1px solid var(--border); padding-top: 6px; }
.order-line.grand { font-size: 16px; font-weight: 800; color: var(--dark); border-bottom: none; }

/* Courier (Steadfast) */
.action-btn.courier { background: rgba(245,158,11,0.16); color: var(--amber); }
.action-btn.courier:hover { background: var(--amber); color: #fff; }
.action-btn.courier-sent { background: rgba(22,163,74,0.16); color: var(--green); }
.courier-box { margin-top: 16px; border: 1px solid var(--green); border-radius: var(--radius-sm); padding: 14px 16px; background: rgba(22,163,74,0.06); }
.courier-head { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--green); margin-bottom: 8px; }
.courier-head .material-icons-outlined { font-size: 20px; }
.courier-box .order-line strong { font-family: monospace; font-size: 14px; color: var(--dark); }

/* Inline order status select */
.order-status-select {
    border: none; border-radius: 20px; padding: 5px 10px; font-size: 12px; font-weight: 600;
    cursor: pointer; outline: none; -webkit-appearance: none; appearance: none;
    background-image: none; text-align: center;
}
.order-status-select.status-delivered { background: rgba(22,163,74,0.12); color: var(--green); }
.order-status-select.status-pending { background: rgba(245,158,11,0.12); color: var(--amber); }
.order-status-select.status-processing { background: rgba(26,86,219,0.12); color: var(--primary); }
.order-status-select.status-cancelled { background: rgba(239,68,68,0.12); color: var(--red); }

/* ---------- Hero Slider Manager ---------- */
.hero-slider-card { grid-column: 1 / -1; }
.hero-slides-manage { display: flex; flex-direction: column; gap: 12px; }
.hero-slides-empty { font-size: 13px; color: var(--text-muted); padding: 12px; background: var(--bg); border-radius: var(--radius-sm); text-align: center; }
.hero-slide-row { display: flex; align-items: center; gap: 14px; background: var(--bg); border-radius: var(--radius-sm); padding: 10px 12px; }
.hero-slide-thumb { width: 90px; height: 56px; border-radius: 8px; overflow: hidden; flex-shrink: 0; background: #fff; border: 1px solid var(--border); }
.hero-slide-thumb img { width: 100%; height: 100%; object-fit: cover; }
.hero-slide-fields { flex: 1; min-width: 0; }
.hero-slide-fields label { display: block; font-size: 11px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.hero-slide-fields input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; outline: none; }
.hero-slide-fields input:focus { border-color: var(--primary); }
.hero-slide-order { display: flex; gap: 4px; flex-shrink: 0; }

/* Product images manager */
.product-images-manage { display: flex; flex-wrap: wrap; gap: 10px; }
.prod-img-thumb { position: relative; width: 84px; height: 84px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #fff; overflow: hidden; }
.prod-img-thumb img { width: 100%; height: 100%; object-fit: contain; }
.prod-img-main { position: absolute; bottom: 0; left: 0; right: 0; background: var(--primary); color: #fff; font-size: 10px; font-weight: 700; text-align: center; padding: 2px; }
.prod-img-remove { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(239,68,68,0.9); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.prod-img-remove .material-icons-outlined { font-size: 15px; }

/* Nav menu manager rows */
.nav-items-manage { display: flex; flex-direction: column; gap: 10px; }
.nav-item-row { display: flex; align-items: center; gap: 10px; background: var(--bg); border-radius: var(--radius-sm); padding: 8px 10px; }
.nav-item-row input { flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; outline: none; }
.nav-item-row input:focus { border-color: var(--primary); }
.nav-item-row .nav-label-input { max-width: 160px; }

/* Ad card manager rows */
.ad-cards-manage { display: flex; flex-direction: column; gap: 12px; }
.ad-card-row { display: flex; align-items: center; gap: 14px; background: var(--bg); border-radius: var(--radius-sm); padding: 10px 12px; }
.ad-card-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ad-card-fields input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; outline: none; }
.ad-card-fields input:focus { border-color: var(--primary); }

/* ---------- Dark Mode (admin) ---------- */
.dark {
    --bg: #0f172a;
    --card: #18233c;
    --text: #e5e9f2;
    --text-muted: #97a3b8;
    --text-light: #6b7a93;
    --border: #2a3a57;
    --primary-light: #1c2c4a;
}
.dark body { background: var(--bg); color: var(--text); }
.dark .dash-header,
.dark .stat-card,
.dark .chart-card,
.dark .settings-card,
.dark .data-table-container,
.dark .category-manage-card,
.dark .admin-modal,
.dark .page-btn,
.dark .toast,
.dark .notif-btn,
.dark .date-range-picker,
.dark .search-input,
.dark .toolbar-select,
.dark .hero-slide-row,
.dark .ad-card-row { background: var(--card); }
.dark .data-table thead th { background: #14203a; }
.dark .data-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.dark h1, .dark h2, .dark h3, .dark h4, .dark .stat-value,
.dark .table-product-name, .dark .font-bold { color: var(--text); }
.dark input, .dark textarea, .dark select { background: #14203a; color: var(--text); border-color: var(--border); }
.dark input::placeholder, .dark textarea::placeholder { color: var(--text-light); }
.dark .btn-outline { background: var(--card); color: var(--text); }
.dark .image-preview, .dark .hero-slide-thumb, .dark .prod-img-thumb { background: #0f172a; }
.dark .toggle-slider { background: #3a4a66; }

/* ---------- Admin password gate ---------- */
.admin-gate { position: fixed; inset: 0; z-index: 9999; background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%); display: flex; align-items: center; justify-content: center; padding: 20px; }
.admin-gate-box { background: #fff; border-radius: 18px; padding: 38px 32px; width: 100%; max-width: 360px; text-align: center; box-shadow: 0 24px 70px rgba(0,0,0,0.45); }
.admin-gate-logo { width: 62px; height: 62px; margin: 0 auto 16px; border-radius: 16px; background: linear-gradient(135deg, var(--primary), var(--accent)); display: flex; align-items: center; justify-content: center; }
.admin-gate-logo .material-icons-outlined { color: #fff; font-size: 30px; }
.admin-gate-box h2 { font-size: 22px; font-weight: 800; margin-bottom: 6px; color: #0f172a; }
.admin-gate-box p { color: #64748b; font-size: 14px; margin-bottom: 20px; }
.admin-gate-box input { width: 100%; padding: 12px 14px; border: 2px solid #e5e9f0; border-radius: 8px; font-size: 15px; outline: none; margin-bottom: 12px; }
.admin-gate-box input:focus { border-color: var(--primary); }
.admin-gate-box .btn { width: 100%; justify-content: center; }
.admin-gate-err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 16px; }

/* ---------- Toast ---------- */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 600; display: flex; flex-direction: column; gap: 12px; }
.toast { background: #fff; border-radius: var(--radius-sm); padding: 14px 18px; box-shadow: 0 12px 32px rgba(15,23,42,0.16); display: flex; align-items: center; gap: 12px; min-width: 280px; border-left: 4px solid var(--green); animation: slideIn 0.3s ease; font-size: 14px; font-weight: 500; }
.toast.hide { animation: slideOut 0.3s ease forwards; }
.toast .material-icons-outlined { color: var(--green); font-size: 22px; }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { to { transform: translateX(120%); opacity: 0; } }

/* ---------- Mobile overlay ---------- */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: 99; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .charts-grid, .charts-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.25s; width: var(--sidebar-w); }
    .sidebar.mobile-open { transform: translateX(0); }
    .sidebar.mobile-open + .sidebar-backdrop { display: block; }
    .main-content { margin-left: 0 !important; }
    .mobile-menu-btn { display: block; }
    .date-range-picker, .profile-info { display: none; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .settings-grid { grid-template-columns: 1fr; }
    .page-toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-left, .toolbar-right { flex-wrap: wrap; }
    .search-input input { width: 100%; }
    .search-input { flex: 1; }
}
@media (max-width: 560px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
    .dash-header { padding: 14px 16px; }
    .dash-header h1 { font-size: 18px; }

    /* Stack multi-column form rows in modals */
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .admin-modal-overlay { padding: 12px; }
    .admin-modal-header, .admin-form { padding-left: 18px; padding-right: 18px; }
    .image-upload { flex-direction: column; align-items: flex-start; }

    /* Hero slider manager rows stack */
    .hero-slide-row { flex-wrap: wrap; }
    .hero-slide-fields { flex-basis: 100%; order: 3; }

    /* Toolbar buttons full width */
    .toolbar-right { }
    .toolbar-right .btn { flex: 1; justify-content: center; }

    /* Settings & spec rows */
    .spec-row { grid-template-columns: 1fr 1fr auto; }
    .toolbar-select { flex: 1; }
}

/* =========================================================
   AI AGENTS PAGE
   ========================================================= */
.ai-status-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 22px; }
.ai-status { background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 12px; }
.ai-status .material-icons-outlined { font-size: 26px; color: var(--primary); }
.ai-status h4 { font-size: 13px; font-weight: 700; color: var(--dark); }
.ai-status p { font-size: 12px; color: var(--text-muted); }
.ai-pill { margin-left: auto; font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.ai-pill.live { background: #dcfce7; color: var(--green); }
.ai-pill.fallback { background: #fef3c7; color: #b45309; }

.ai-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; margin-bottom: 22px; }
.ai-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.ai-card-head { display: flex; gap: 14px; align-items: flex-start; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.ai-card-head .material-icons-outlined { font-size: 28px; color: var(--primary); }
.ai-card-head h3 { font-size: 16px; font-weight: 700; color: var(--dark); }
.ai-card-head p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ai-card-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.ai-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.ai-input { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; color: var(--text); background: #fff; }
.ai-input:focus { outline: none; border-color: var(--primary); }
.ai-btn { align-self: flex-start; }
.ai-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.ai-preview { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; background: #f8fafc; }
.ai-preview h4 { font-size: 15px; font-weight: 700; color: var(--dark); margin-bottom: 10px; }
.ai-preview pre { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 13px; line-height: 1.65; color: var(--text); }
.ai-tags { margin-top: 10px; font-size: 12px; color: var(--primary); font-weight: 600; }
.ai-preview-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.ai-chat { flex: 1; min-height: 240px; max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px; }
.ai-msg { max-width: 82%; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.ai-msg.customer { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 2px; }
.ai-msg.agent { align-self: flex-start; background: #f1f5f9; color: var(--text); border-bottom-left-radius: 2px; }
.ai-msg.typing { color: var(--text-muted); font-style: italic; }
.ai-chat-empty { margin: auto; color: var(--text-light); font-size: 13px; text-align: center; }
.ai-chat-form { display: flex; gap: 10px; }
.ai-chat-form .ai-input { flex: 1; }

.ai-table-card { margin-bottom: 22px; }
.ai-convo-list { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }
.ai-convo { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.ai-convo-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; background: #f8fafc; }
.ai-convo-head strong { font-size: 13px; color: var(--dark); }
.ai-convo-head small { color: var(--text-muted); font-size: 12px; }
.ai-convo-head .ai-pill { font-size: 10px; }
.ai-convo-body { padding: 14px 16px; display: none; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); }
.ai-convo.open .ai-convo-body { display: flex; }
.ai-empty-row { text-align: center; color: var(--text-light); padding: 26px; font-size: 13px; }
.ai-video-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.ai-video-name { font-size: 12px; color: var(--text-muted); word-break: break-all; }
.ai-video-name.attached { color: var(--green); font-weight: 600; }
.ai-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.ai-check input { accent-color: var(--primary); }
.ai-video-preview { width: 190px; max-height: 340px; border-radius: var(--radius-sm); margin-top: 12px; background: #000; }
.ai-video-name.rendering { color: var(--amber); font-weight: 600; }
.ai-video-name.failed { color: var(--red); font-weight: 600; }

/* ---- Marketing automation ---- */
.ai-switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; }
.ai-switch input { width: 18px; height: 18px; accent-color: var(--primary); }
.ai-auto-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 18px; }
.ai-auto-grid .ai-label { display: block; margin-bottom: 6px; }
.ai-auto-checks { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.ai-auto-sep { width: 1px; height: 20px; background: var(--border); }
.ai-plan { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.ai-plan-row { display: flex; align-items: baseline; gap: 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }
.ai-plan-row.top { border-color: var(--primary); background: var(--primary-light); }
.ai-plan-score { font-weight: 700; color: var(--primary); min-width: 46px; }
.ai-plan-name { font-weight: 600; color: var(--dark); }
.ai-plan-why { color: var(--text-muted); font-size: 12px; }
.ai-hint { margin-top: 16px; font-size: 12px; color: var(--text-muted); line-height: 1.7; }
.ai-hint code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 11px; }
.ai-pending { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
.ai-pending-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.ai-pending-head strong { font-size: 14px; color: var(--dark); }
.ai-pending-copy { font-size: 13px; color: var(--text); white-space: pre-wrap; max-height: 120px; overflow-y: auto; margin-bottom: 12px; }
.ai-pending-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ai-report-total { font-size: 13px; font-weight: 700; color: var(--green); }

/* ---- While you were away ---- */
.ai-digest-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ai-digest-controls .ai-input { width: auto; padding: 8px 12px; }
.ai-digest-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.ai-stat { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
.ai-stat b { display: block; font-size: 24px; font-weight: 800; color: var(--dark); line-height: 1.2; }
.ai-stat span { font-size: 12px; color: var(--text-muted); }
.ai-stat.alert { background: #fef2f2; border-color: #fecaca; }
.ai-stat.alert b { color: var(--red); }
.ai-stat.good { background: #f0fdf4; border-color: #bbf7d0; }
.ai-stat.good b { color: var(--green); }

.ai-digest-section { margin-bottom: 20px; }
.ai-digest-section h4 { font-size: 13px; font-weight: 700; color: var(--dark); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.ai-flag-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; }
.ai-flag-row.upset { border-left-color: var(--red); background: #fef2f2; }
.ai-flag-row.negotiating { border-left-color: var(--amber); background: #fffbeb; }
.ai-flag-row.unanswered { border-left-color: var(--purple); background: #faf5ff; }
.ai-flag-body { flex: 1; min-width: 0; }
.ai-flag-body strong { font-size: 13px; color: var(--dark); }
.ai-flag-quote { font-size: 13px; color: var(--text); margin: 4px 0; }
.ai-flag-why { font-size: 12px; color: var(--text-muted); }
.ai-q-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.ai-q-row:last-child { border-bottom: none; }
.ai-q-row b { color: var(--primary); }

.ai-convo.unseen { border-color: var(--primary); }
.ai-convo.unseen .ai-convo-head { background: var(--primary-light); }
.ai-convo.unseen .ai-convo-head strong::before { content: '●'; color: var(--primary); margin-right: 6px; font-size: 11px; }
.ai-pill.flag-upset { background: #fee2e2; color: #b91c1c; }
.ai-pill.flag-negotiating { background: #fef3c7; color: #b45309; }
.ai-pill.flag-unanswered { background: #f3e8ff; color: #7e22ce; }
.nav-badge.alert { background: var(--red); }

/* =========================================================
   INBOX — a messenger-style view of every AI conversation
   ========================================================= */
.inbox { display: grid; grid-template-columns: 330px 1fr; gap: 0; height: calc(100vh - 150px); min-height: 480px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }

/* ---- left column ---- */
.inbox-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.inbox-search { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.inbox-search .material-icons-outlined { font-size: 20px; color: var(--text-light); }
.inbox-search input { flex: 1; border: none; outline: none; font-family: inherit; font-size: 13px; color: var(--text); background: transparent; }
.inbox-filters { display: flex; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.inbox-chip { border: 1px solid var(--border); background: #fff; color: var(--text-muted); font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 20px; cursor: pointer; }
.inbox-chip:hover { border-color: var(--primary); color: var(--primary); }
.inbox-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.inbox-threads { flex: 1; overflow-y: auto; }

.inbox-row { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: flex-start; }
.inbox-row:hover { background: #f8fafc; }
.inbox-row.active { background: var(--primary-light); }
.inbox-row.unread .inbox-row-name { font-weight: 800; color: var(--dark); }
.inbox-row.unread .inbox-row-text { color: var(--text); font-weight: 600; }
.inbox-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0; text-transform: uppercase; }
.inbox-avatar.messenger { background: #0084ff; }
.inbox-avatar.instagram { background: #e1306c; }
.inbox-avatar.comment { background: var(--purple); }
.inbox-row-body { flex: 1; min-width: 0; }
.inbox-row-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.inbox-row-name { font-size: 13px; font-weight: 600; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-row-time { font-size: 11px; color: var(--text-light); white-space: nowrap; }
.inbox-row-text { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.inbox-row-tags { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.inbox-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 6px; }

/* ---- right column ---- */
/* min-height:0 on every link of the chain, or a flex item grows to fit its
   content instead of scrolling — which pushes the composer off screen. */
.inbox-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #f8fafc; }
.inbox-empty { margin: auto; text-align: center; color: var(--text-muted); padding: 40px; max-width: 380px; }
.inbox-empty .material-icons-outlined { font-size: 56px; color: var(--border); margin-bottom: 12px; }
.inbox-empty h3 { font-size: 17px; color: var(--dark); margin-bottom: 8px; }
.inbox-empty p { font-size: 13px; line-height: 1.7; }
.inbox-open { display: flex; flex-direction: column; flex: 1; min-height: 0; }
/* the rule above would otherwise beat the plain [hidden] attribute */
.inbox-open[hidden] { display: none; }
.inbox-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; background: #fff; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.inbox-who { flex: 1; min-width: 0; }
.inbox-who strong { display: block; font-size: 15px; color: var(--dark); }
.inbox-who small { font-size: 12px; color: var(--text-muted); }
.inbox-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.inbox-msg { max-width: 68%; padding: 10px 15px; border-radius: 16px; font-size: 13px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.inbox-msg.customer { align-self: flex-start; background: #fff; color: var(--text); border-bottom-left-radius: 4px; box-shadow: var(--shadow-sm); }
.inbox-msg.agent { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.inbox-msg-time { display: block; font-size: 10px; opacity: 0.7; margin-top: 5px; }
.inbox-day { align-self: center; font-size: 11px; color: var(--text-muted); background: #e2e8f0; padding: 3px 12px; border-radius: 20px; }
.inbox-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px; background: #fff; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
.inbox-foot .material-icons-outlined { font-size: 18px; color: var(--primary); }
.inbox-live { margin-left: auto; }

@media (max-width: 900px) {
    .inbox { grid-template-columns: 1fr; height: auto; }
    .inbox-list { border-right: none; border-bottom: 1px solid var(--border); max-height: 320px; }
    /* a fixed height, not a minimum: the messages need something to scroll in */
    .inbox-thread { height: 70vh; min-height: 380px; }
}

/* ---- Inbox: replying in person ---- */
.inbox-compose { background: #fff; border-top: 1px solid var(--border); flex-shrink: 0; }
.inbox-mode { display: flex; align-items: center; gap: 10px; padding: 10px 20px; font-size: 12px; color: var(--text-muted); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.inbox-mode .material-icons-outlined { font-size: 18px; color: var(--primary); }
.inbox-mode.human { background: #fffbeb; color: #92400e; }
.inbox-mode.human .material-icons-outlined { color: var(--amber); }
.inbox-form { display: flex; gap: 10px; padding: 12px 20px; align-items: flex-end; }
.inbox-form textarea { flex: 1; border: 1px solid var(--border); border-radius: 20px; padding: 11px 16px; font-family: inherit; font-size: 13px; color: var(--text); resize: none; max-height: 120px; outline: none; line-height: 1.5; }
.inbox-form textarea:focus { border-color: var(--primary); }
.inbox-form button { width: 42px; height: 42px; border-radius: 50%; padding: 0; justify-content: center; flex-shrink: 0; }

.inbox-msg.owner { align-self: flex-end; background: var(--green); color: #fff; border-bottom-right-radius: 4px; }
.inbox-msg.owner .inbox-msg-who { display: block; font-size: 10px; opacity: 0.85; margin-bottom: 3px; font-weight: 700; }
.inbox-msg.undelivered { background: #b45309; }
.inbox-msg-warn { display: block; font-size: 10px; margin-top: 5px; opacity: 0.9; font-style: italic; }
/* A credential the provider has rejected — posts are failing right now */
.ai-status.broken { background: #fef2f2; border: 1px solid #fecaca; }
.ai-status.broken .material-icons-outlined { color: var(--red); }
.ai-status.broken h4 { color: #b91c1c; }
.ai-pill.broken { background: #fee2e2; color: #b91c1c; }

/* ---- Watchlist ---- */
.ai-watch-form { display: grid; grid-template-columns: 1fr 1.6fr 90px auto; gap: 10px; margin-bottom: 16px; }
.ai-watch-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; flex-wrap: wrap; }
.ai-watch-row.off { opacity: 0.55; }
.ai-watch-key { font-weight: 700; color: var(--dark); font-size: 14px; }
.ai-watch-note { font-size: 12px; color: var(--text-muted); flex: 1; min-width: 140px; }
.ai-watch-hits { font-size: 12px; color: var(--green); }
.ai-watch-hits.none { color: var(--red); }
.ai-watch-boost { font-size: 12px; font-weight: 700; color: var(--primary); background: var(--primary-light); padding: 3px 10px; border-radius: 20px; }
@media (max-width: 700px) { .ai-watch-form { grid-template-columns: 1fr; } }

/* The voice picker sits beside its preview button. */
.ai-voice-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.ai-voice-row .ai-input { flex: 1; min-width: 0; }
.ai-voice-row .ai-btn { flex: none; white-space: nowrap; }

/* Style and colour pickers sit inline with the Make Short controls. */
.ai-video-pick {
    width: auto;
    min-width: 150px;
    padding: 6px 10px;
    font-size: 0.85rem;
}

/* Customer care agent */
.ai-care-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.ai-care-tile { background: var(--bg-secondary, #f1f5f9); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.ai-care-tile strong { font-size: 1.4rem; }
.ai-care-tile span { font-size: 0.78rem; color: var(--text-muted, #64748b); }
.ai-care-tile.good strong { color: #16a34a; }
.ai-care-tile.warn strong { color: #d97706; }
.ai-care-h { margin: 14px 0 6px; font-size: 0.9rem; }
.ai-plan-score.warn { background: #fef3c7; color: #b45309; }
.ai-help { font-size: 0.82rem; color: var(--text-muted, #64748b); margin: 4px 0 10px; }
