/* ============================================================
   BASE & RESET
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

:root {
    --bg-dark:    #000000;
    --bg-panel:   #0A0A0A;
    --bg-card:    #141414;

    --primary:       #FFFFFF;
    --primary-hover: #E0E0E0;
    --accent:        #5D3FD3;

    --text-main:  #FFFFFF;
    --text-muted: #888888;

    --border-color: #222222;

    --success:    #2ECC71;
    --warning:    #F1C40F;
    --danger:     #E74C3C;
    --info:       #3498DB;

    --transition: all 0.3s ease;
}

body.dark-theme {
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-panel); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, strong { color: var(--text-main); font-weight: 600; }
p, span, td { color: var(--text-muted); }

.text-primary { color: var(--primary);  font-weight: 700; }
.text-warning  { color: var(--warning); font-weight: 700; }
.text-danger   { color: var(--danger);  font-weight: 700; }
.text-success  { color: var(--success); font-weight: 700; }
.text-muted    { color: var(--text-muted); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: 260px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    z-index: 100;
    overflow-y: auto;
    scrollbar-width: none;
    transition: left 0.3s ease, right 0.3s ease;
}
.sidebar::-webkit-scrollbar { display: none; }

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    margin-bottom: 30px;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}
.logo i { font-size: 28px; }

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 24px;
    border-bottom: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    margin-bottom: 20px;
    background: rgba(255,255,255,0.02);
}
.avatar { width: 45px; height: 45px; border-radius: 50%; border: 2px solid var(--primary); }
.user-details h4 { font-size: 15px; margin-bottom: 3px; }
.user-details p  { font-size: 12px; font-weight: 500; color: var(--primary); }

.nav-links { list-style: none; flex-grow: 1; }
.nav-links li {
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.nav-links li:hover  { background-color: var(--bg-card); color: var(--text-main); }
.nav-links li.active { background-color: rgba(255,255,255,0.05); color: var(--primary); border-left-color: var(--primary); }
.nav-links li i { font-size: 20px; }

.bottom-menu ul { list-style: none; }
.bottom-menu ul li {
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    font-size: 15px;
    color: var(--danger);
    transition: var(--transition);
}
.bottom-menu ul li:hover { background-color: rgba(231,76,60,0.1); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background-image:
        radial-gradient(circle at top right,   rgba(255,255,255,0.02) 0%, transparent 50%),
        radial-gradient(circle at bottom left, rgba(255,255,255,0.02) 0%, transparent 50%);
}

.top-header {
    height: 80px;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(20,24,34,0.6);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 16px;
    width: 350px;
    transition: var(--transition);
}
.search-bar:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,255,255,0.05); }
.search-bar i { color: var(--text-muted); font-size: 18px; }
.search-bar input { background: transparent; border: none; outline: none; color: var(--text-main); padding-left: 10px; width: 100%; }

.header-actions { display: flex; align-items: center; gap: 20px; }

.branch-selector select {
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 6px;
    outline: none;
    font-size: 14px;
}

.notifications { position: relative; cursor: pointer; }
.notifications i { font-size: 24px; color: var(--text-muted); }
.notifications .badge {
    position: absolute; top: -5px; right: -5px;
    background-color: var(--danger); color: white;
    font-size: 10px; font-weight: bold;
    border-radius: 50%; width: 16px; height: 16px;
    display: flex; align-items: center; justify-content: center;
}

.export-btn {
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    transition: var(--transition);
}
.export-btn:hover { background-color: var(--border-color); }

/* ============================================================
   BUTTONS
   ============================================================ */
.primary-btn {
    background-color: var(--primary);
    color: var(--bg-dark);
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    transition: var(--transition);
}
.primary-btn:hover { background-color: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(255,255,255,0.15); }

.secondary-btn {
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    transition: var(--transition);
}
.secondary-btn:hover { background-color: var(--border-color); }

.outline-btn {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.outline-btn:hover { background: rgba(255,255,255,0.1); }

.small { padding: 6px 12px; font-size: 12px; }

.export-btn-mini {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    transition: var(--transition);
}
.export-btn-mini:hover { border-color: var(--accent); color: var(--accent); }

/* ============================================================
   PAGES CONTAINER & SECTIONS
   ============================================================ */
.pages-container { padding: 40px; }

.page-section {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}
.page-section.active { display: block; }

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

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}
.section-header h2 { font-size: 26px; }
.header-buttons { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Date filter bar in section headers */
.date-filter-bar {
    display: flex; align-items: center; gap: 6px;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 8px; padding: 4px 10px;
    font-size: 13px; color: var(--text-muted);
}
.date-filter-bar i { font-size: 16px; color: var(--accent); }
.date-picker {
    background: transparent; border: none; outline: none;
    color: var(--text-main); font-size: 13px; cursor: pointer;
    width: 130px;
}
.date-picker::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }

/* Mini trend badge on KPI cards */
.mini-trend { font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 10px; }
.mini-trend.up   { background: rgba(46,204,113,.15); color: #2ecc71; }
.mini-trend.down { background: rgba(231,76,60,.15);  color: #e74c3c; }
.stat-trend { font-size: 13px; font-weight: 600; }
.stat-trend.up { color: #2ecc71; }
.stat-label    { font-size: 12px; color: rgba(255,255,255,0.6); }


.section-footer { display: flex; gap: 12px; margin-top: 20px; }

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.kpi-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex; align-items: center; gap: 20px;
    transition: var(--transition);
}
.kpi-card:hover { transform: translateY(-3px); border-color: var(--primary); box-shadow: 0 10px 25px rgba(0,0,0,0.5); }

.kpi-icon {
    width: 60px; height: 60px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 32px;
}
.kpi-icon.purchases { background: rgba(52,152,219,0.1);  color: var(--info); }
.kpi-icon.pending   { background: rgba(241,196,15,0.1);  color: var(--warning); }
.kpi-icon.inv       { background: rgba(255,255,255,0.1); color: var(--primary); }
.kpi-icon.prod      { background: rgba(46,204,113,0.1);  color: var(--success); }

.kpi-info h3 { font-size: 14px; color: var(--text-muted); font-weight: 500; margin-bottom: 8px; }
.kpi-info p  { font-size: 24px; color: var(--text-main); font-weight: 700; }
.kpi-info .currency, .kpi-info .subtitle { font-size: 14px; color: var(--text-muted); font-weight: 400; }

/* ============================================================
   PANELS & TABLES
   ============================================================ */
.custom-panel {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 30px;
}

.panel-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}
.toolbar-filters { display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar-filters select,
.search-input {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 6px;
    outline: none;
}
.search-input { width: 250px; }

.styled-table { width: 100%; border-collapse: collapse; }
.styled-table th {
    text-align: left;
    padding: 15px;
    color: var(--text-main);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-card);
    white-space: nowrap;
}
.styled-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
.styled-table tbody tr:hover { background-color: rgba(255,255,255,0.02); }

/* ============================================================
   STATUS BADGES
   ============================================================ */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    white-space: nowrap;
}
.status-badge.pending  { background: rgba(241,196,15,0.1);  color: var(--warning); }
.status-badge.approved { background: rgba(46,204,113,0.1);  color: var(--success); }
.status-badge.received { background: rgba(52,152,219,0.1);  color: var(--info); }

/* ============================================================
   ACTION BUTTONS
   ============================================================ */
.action-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 32px; height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: var(--transition);
    margin: 2px;
}
.action-btn:hover         { color: var(--primary);  border-color: var(--primary); }
.action-btn.approve:hover { color: var(--success);  border-color: var(--success); }
.action-btn.delete:hover  { color: var(--danger);   border-color: var(--danger); }

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
.dashboard-banner {
    background: linear-gradient(135deg, #4B2A8A 0%, #2D1B5E 100%);
    border-radius: 12px;
    padding: 30px 40px;
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}
.dashboard-banner::after {
    content: '';
    position: absolute; top: 0; right: 0;
    width: 300px; height: 100%;
    background: url('https://www.transparenttextures.com/patterns/cubes.png');
    opacity: 0.1;
}
.banner-content h1 { font-size: 32px; margin-bottom: 8px; color: white; }
.banner-content p  { color: rgba(255,255,255,0.8); font-size: 16px; }

.dashboard-tabs {
    display: flex;
    gap: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 25px;
    padding-bottom: 5px;
}
.dash-tab {
    background: transparent; border: none;
    color: var(--text-muted); font-size: 16px; font-weight: 500;
    padding: 10px 5px; cursor: pointer;
    position: relative; transition: var(--transition);
}
.dash-tab.active { color: var(--primary); }
.dash-tab.active::after {
    content: ''; position: absolute;
    bottom: -6px; left: 0; width: 100%; height: 3px;
    background: var(--primary); border-radius: 3px;
}

.dashboard-controls-row {
    display: flex; align-items: center; gap: 15px;
    margin-bottom: 30px; flex-wrap: wrap;
}
.toggle-group {
    display: flex;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 8px; padding: 4px;
}
.toggle-btn {
    background: transparent; border: none;
    padding: 6px 15px; border-radius: 6px;
    color: var(--text-muted); cursor: pointer; font-size: 14px;
    transition: var(--transition);
}
.toggle-btn.active { background: var(--accent); color: white; }

.date-picker-wrapper input {
    background: var(--bg-card); border: 1px solid var(--border-color);
    color: var(--text-main); padding: 8px 12px; border-radius: 8px; outline: none;
}
.compare-control { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 14px; }

.icon-filter-btn {
    margin-left: auto;
    background: var(--bg-card); border: 1px solid var(--border-color);
    color: var(--text-muted); width: 40px; height: 40px;
    border-radius: 8px; cursor: pointer;
}

/* Mini KPIs */
.mini-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px; margin-bottom: 30px;
}
.kpi-mini-card {
    background: var(--bg-panel); border: 1px solid var(--border-color);
    border-radius: 12px; padding: 15px;
}
.kpi-mini-card .card-header {
    display: flex; justify-content: space-between;
    font-size: 13px; margin-bottom: 10px;
}
.view-report { color: var(--accent); text-decoration: none; font-size: 11px; }
.kpi-mini-card h2 {
    font-size: 22px; margin-bottom: 10px;
    display: flex; align-items: center; gap: 5px;
}
.kpi-mini-card h2 i { font-size: 18px; }
.mini-chart-container { height: 40px; }

/* Charts */
.large-chart-card, .hourly-sales-card { margin-bottom: 30px; }
.chart-wrapper { height: 300px; }
.pie-charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.pie-card canvas { max-height: 250px; }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-container h3 {
    margin-bottom: 15px; font-size: 18px; color: var(--text-main);
    border-bottom: 1px solid var(--border-color); padding-bottom: 10px;
}

/* ============================================================
   COSTING / RECIPE CARDS
   ============================================================ */
.costing-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; }
.recipe-card {
    background-color: var(--bg-panel); border: 1px solid var(--border-color);
    border-radius: 12px; overflow: hidden; transition: var(--transition);
}
.recipe-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.4); border-color: var(--primary); }
.recipe-card img { width: 100%; height: 180px; object-fit: cover; border-bottom: 1px solid var(--border-color); }
.recipe-info { padding: 20px; }
.recipe-info h3 { margin-bottom: 15px; font-size: 18px; }
.recipe-meta { display: flex; justify-content: space-between; margin-bottom: 15px; font-size: 14px; }
.profit-margin {
    background: var(--bg-card); padding: 12px; border-radius: 8px;
    margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center;
}
.profit-margin span { color: var(--text-main); font-weight: 600; }
.margin-badge { background: rgba(46,204,113,0.1); color: var(--success) !important; padding: 4px 8px; border-radius: 4px; font-size: 12px; }
.recipe-info .outline-btn { width: 100%; }

/* ============================================================
   MODALS
   ============================================================ */
.modal {
    display: none;
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(11,14,20,0.85); backdrop-filter: blur(4px);
    z-index: 1000; justify-content: center; align-items: center;
}
.modal.show { display: flex; animation: fadeIn 0.3s; }

.modal-content {
    background: var(--bg-panel); border: 1px solid var(--border-color);
    border-radius: 12px; width: 650px; max-width: 95%;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.7);
}
.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 { font-size: 20px; }
.close-modal { font-size: 28px; color: var(--text-muted); cursor: pointer; transition: 0.2s; }
.close-modal:hover { color: var(--danger); }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 20px 24px; border-top: 1px solid var(--border-color);
    display: flex; justify-content: flex-end; gap: 12px;
    background: var(--bg-card); border-radius: 0 0 12px 12px;
}

/* Form Elements */
.form-row { display: flex; gap: 20px; margin-bottom: 20px; }
.input-group { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.input-group label { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.input-group input,
.input-group select,
.input-group textarea {
    background: var(--bg-card); border: 1px solid var(--border-color);
    color: var(--text-main); padding: 10px 14px;
    border-radius: 6px; font-size: 14px; width: 100%; outline: none;
    transition: var(--transition);
}
.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(255,255,255,0.05); }

.items-list h4, .ingredients-list h4, .yield-box h4 {
    margin-bottom: 12px; font-size: 14px;
    color: var(--accent); text-transform: uppercase;
}
.items-list, .ingredients-list, .yield-box {
    margin-top: 20px; padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.item-row {
    display: flex; gap: 10px; align-items: center; margin-bottom: 10px;
}
.item-row input, .item-row select {
    background: var(--bg-card); border: 1px solid var(--border-color);
    color: var(--text-main); padding: 8px; border-radius: 6px;
}
.item-row input[type="text"]   { flex: 2; }
.item-row input[type="number"] { width: 80px; }
.item-row select               { width: 90px; }
.item-row .item-total          { font-weight: 600; width: 110px; text-align: right; color: var(--primary); }
.item-row i                    { cursor: pointer; font-size: 20px; padding: 5px; }

/* PO Items */
.po-item-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.po-item-row input   { flex: 1; padding: 10px; background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-main); border-radius: 6px; }
.po-item-row input[type='number'] { flex: 0 0 80px; }
.po-item-row select  { flex: 0 0 100px; padding: 10px; background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-main); border-radius: 6px; }
.po-item-row .item-total  { flex: 0 0 120px; text-align: right; font-weight: 600; color: var(--primary); }
.po-item-row .delete-item { cursor: pointer; color: var(--danger); font-size: 20px; }

.form-footer-totals {
    margin-top: 20px; border-top: 1px dashed var(--border-color);
    padding-top: 15px; text-align: right;
}
.vat-field { display: flex; flex-direction: column; }
.vat-field label { font-size: 10px; color: var(--text-muted); margin-bottom: 4px; }

/* Permissions */
.access-settings { margin-top: 25px; padding-top: 20px; border-top: 1px solid var(--border-color); }
.access-settings h4 { margin-bottom: 15px; }
.permissions-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 15px; }
.check-item { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-muted); cursor: pointer; }
.check-item input { accent-color: var(--success); }

/* File Upload */
.file-upload-box { border: 1px dashed var(--border-color); padding: 15px; border-radius: 6px; text-align: center; background: rgba(0,0,0,0.1); }

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 30px; }
.setting-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 0; border-bottom: 1px solid var(--border-color);
}
.setting-item:last-child { border-bottom: none; }
.setting-info strong { display: block; margin-bottom: 4px; }
.setting-info p { font-size: 13px; color: var(--text-muted); }

/* Toggle Switch */
.switch { position: relative; display: inline-block; width: 46px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0;
    background-color: var(--bg-card); transition: .4s;
    border: 1px solid var(--border-color); border-radius: 20px;
}
.slider:before {
    position: absolute; content: "";
    height: 14px; width: 14px; left: 3px; bottom: 3px;
    background-color: var(--text-muted); transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--success); border-color: var(--success); }
input:checked + .slider:before { transform: translateX(24px); background-color: white; }

/* ============================================================
   FINANCE GRID
   ============================================================ */
.finance-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }

/* ============================================================
   AI ASSISTANT
   ============================================================ */
.ai-chat-container {
    max-width: 900px;
    margin: 20px auto;
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    padding: 30px;
    border: 1px solid var(--border-color);
}
.ai-input-area textarea {
    width: 100%;
    height: 100px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #fff;
    padding: 15px;
    font-family: inherit;
    font-size: 15px;
    margin-bottom: 15px;
    resize: none;
    outline: none;
    transition: var(--transition);
}
.ai-input-area textarea:focus { border-color: var(--accent); }
.ai-ask-btn {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white; border: none;
    padding: 12px 25px; border-radius: 8px;
    cursor: pointer; font-weight: 600;
    display: flex; align-items: center; gap: 10px;
    transition: var(--transition);
}
.ai-ask-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(46,204,113,0.4); }
.sql-code-box {
    margin-top: 25px;
    background: #1a1a1a; border-radius: 8px;
    overflow: hidden; border-left: 4px solid #f39c12;
}
.sql-header { background: #2d2d2d; padding: 8px 15px; font-size: 12px; color: #aaa; }
.sql-code-box pre {
    padding: 15px; color: #e0e0e0;
    font-family: 'Courier New', monospace;
    overflow-x: auto; white-space: pre-wrap; word-break: break-word;
    max-height: 400px; overflow-y: auto;
    font-size: 13px; line-height: 1.6;
}
.results-table-container { margin-top: 20px; max-height: 400px; overflow-y: auto; }

/* ============================================================
   AUTHENTICATION OVERLAY
   ============================================================ */
.auth-overlay {
    display: none; position: fixed; inset: 0;
    background: #000; z-index: 9999;
    justify-content: center; align-items: center; overflow: hidden;
}
.auth-overlay.active { display: flex; }
#auth-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }

.auth-box {
    position: relative; z-index: 1;
    background: rgba(8,8,12,0.82);
    border: 1px solid rgba(0,200,255,0.12);
    border-radius: 20px; padding: 44px 40px;
    width: 440px; max-width: 95vw;
    box-shadow: 0 0 80px rgba(0,120,255,0.12), 0 30px 80px rgba(0,0,0,0.95);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    animation: authSlideUp 0.55s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes authSlideUp {
    from { opacity: 0; transform: translateY(40px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.auth-box-logo { text-align: center; margin-bottom: 28px; }
.auth-box-logo .logo-icon { font-size: 48px; color: #00c8ff; display: block; }
.auth-box-logo h1 { font-size: 26px; font-weight: 700; color: #fff; letter-spacing: 4px; margin-top: 8px; }
.auth-box-logo p  { font-size: 10px; color: #555; margin-top: 4px; letter-spacing: 3px; text-transform: uppercase; }
.auth-box-inner h2 {
    font-size: 15px; margin-bottom: 24px; text-align: center; color: #666;
    letter-spacing: 1.5px; font-weight: 400;
    border-top: 1px solid rgba(255,255,255,0.06); padding-top: 20px; text-transform: uppercase;
}
#auth-submit-btn {
    background: linear-gradient(135deg, #00c8ff 0%, #0055ff 100%);
    color: #fff; border: none; font-weight: 700; letter-spacing: 1px;
    transition: all 0.3s ease; box-shadow: 0 0 24px rgba(0,150,255,0.35);
    text-transform: uppercase; font-size: 13px;
}
#auth-submit-btn:hover:not(:disabled) { box-shadow: 0 0 50px rgba(0,200,255,0.6); transform: translateY(-2px); }
#auth-submit-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.auth-links { display: flex; justify-content: space-between; margin-top: 20px; gap: 10px; flex-wrap: wrap; }
.auth-links span { font-size: 12px; color: #555; cursor: pointer; transition: color 0.25s; }
.auth-links span:hover { color: #00c8ff; }

/* ============================================================
   HAMBURGER
   ============================================================ */
.hamburger-btn {
    display: none;
    background: none; border: none;
    color: var(--text-main); font-size: 28px;
    cursor: pointer; padding: 0 10px;
}

/* ============================================================
   RTL SUPPORT
   ============================================================ */
body.rtl { direction: rtl; text-align: right; }
body.rtl .sidebar { border-right: none; border-left: 1px solid var(--border-color); }
body.rtl .nav-links li { border-left: none; border-right: 3px solid transparent; }
body.rtl .nav-links li.active { border-right-color: var(--primary); }
body.rtl .logo { flex-direction: row-reverse; }
body.rtl .kpi-card { flex-direction: row-reverse; }
body.rtl .section-header { flex-direction: row-reverse; }
body.rtl .header-actions { flex-direction: row-reverse; }
body.rtl .styled-table th,
body.rtl .styled-table td { text-align: right; }
body.rtl .close-modal { margin-right: auto; margin-left: 0; }
body.rtl .modal-footer { flex-direction: row-reverse; }

/* ============================================================
   COMPARISON BADGES
   ============================================================ */
.comparison-row { margin-top: -15px; margin-bottom: 25px; }
.comp-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 500; }
.comp-badge.up   { background: rgba(46,204,113,0.1);  color: var(--success); }
.comp-badge.down { background: rgba(231,76,60,0.1);   color: var(--danger); }

.badge { background: var(--accent); color: white; font-size: 11px; padding: 2px 8px; border-radius: 12px; font-weight: 600; }
.badge-new { background: var(--success); color: white; font-size: 10px; padding: 2px 6px; border-radius: 4px; margin-left: 5px; vertical-align: middle; }

/* ============================================================
   RESPONSIVE — TABLET (≤ 1024px)
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar { width: 220px; }
    .pages-container { padding: 20px; }
    .top-header { padding: 0 20px; }
    .search-bar { width: 220px; }
    .kpi-grid { grid-template-columns: repeat(2,1fr); }
    .charts-grid { grid-template-columns: 1fr; }
    .mini-kpi-grid { grid-template-columns: repeat(3,1fr); }
    .pie-charts-grid { grid-template-columns: 1fr; }
    .finance-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {
    body.dark-theme { flex-direction: column; overflow: hidden; }

    .hamburger-btn { display: block; }

    /* Sidebar hidden off-screen by default on mobile */
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        height: 100vh;
        z-index: 500;
        width: 260px;
    }
    .sidebar.open { left: 0; }

    body.rtl .sidebar { left: auto; right: -260px; }
    body.rtl .sidebar.open { left: auto; right: 0; }

    .main-content { width: 100%; }
    .top-header { padding: 0 16px; height: 64px; }
    .search-bar { width: 160px; }
    .pages-container { padding: 16px; }

    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .kpi-card { padding: 16px; gap: 12px; }
    .kpi-icon { width: 44px; height: 44px; font-size: 22px; }
    .kpi-info p { font-size: 18px; }

    .mini-kpi-grid { grid-template-columns: repeat(2,1fr); }
    .pie-charts-grid { grid-template-columns: 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
    .costing-cards { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .finance-grid { grid-template-columns: 1fr; }

    .section-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .header-buttons { flex-wrap: wrap; }
    .header-actions { gap: 10px; }

    .auth-box { padding: 28px 20px; }
    .ai-chat-container { padding: 16px; margin: 10px; }
}

/* ============================================================
   RESPONSIVE — SMALL PHONES (≤ 480px)
   ============================================================ */
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .modal-content { width: 95vw; }
    .section-header h2 { font-size: 20px; }
    .search-bar { width: 120px; }
    .permissions-grid { grid-template-columns: repeat(2,1fr); }
}


/* ============================================================
   INVOICE FILE LINK & UPLOAD
   ============================================================ */
.invoice-file-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #f39c12;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    padding: 4px 10px;
    background: rgba(243,156,18,0.1);
    border-radius: 6px;
    transition: var(--transition);
}
.invoice-file-link:hover {
    background: rgba(243,156,18,0.2);
}

#invoice-drop-zone:hover {
    border-color: #2ecc71 !important;
    background: rgba(46,204,113,0.04);
}

/* ============================================================
   DASHBOARD — 12-CARD KPI GRID
   ============================================================ */
.dashboard-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #0f0f0f 0%, #1a1200 50%, #0f0f0f 100%);
    border: 1px solid #2a2000;
    border-radius: 14px;
    padding: 28px 32px;
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
}
.dashboard-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(243,156,18,.15) 0%, transparent 70%);
    pointer-events: none;
}
.dashboard-banner h1 { font-size: 26px; font-weight: 700; color: #fff; margin: 0 0 4px; }
.dashboard-banner p  { color: #888; margin: 0; font-size: 14px; }
.banner-actions { display: flex; gap: 10px; flex-shrink: 0; }

.dash-kpi-section { margin: 28px 0; }
.dash-section-title {
    font-size: 15px;
    font-weight: 600;
    color: #aaa;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: .5px;
    text-transform: uppercase;
}
.dash-section-title i { color: #f39c12; font-size: 18px; }

.dash-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.dash-kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: border-color .2s, transform .2s, box-shadow .2s;
    cursor: default;
}
.dash-kpi-card:hover {
    border-color: #333;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,.3);
}

.dk-icon {
    width: 46px; height: 46px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.dk-icon i { font-size: 22px; }
.dk-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dk-val  { font-size: 20px; font-weight: 700; color: #fff; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dk-val.warn   { color: #f39c12; }
.dk-label { font-size: 12px; color: #777; font-weight: 500; }
.dk-sub   { font-size: 11px; color: #555; }
.dk-sub.warn   { color: #f39c12; }
.dk-sub.danger { color: #e74c3c; }
.dk-loading { color: #555; font-size: 13px; }

.charts-row {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}


/* ================================================================
   AUTH OVERLAY — FULL ORANGE BLOCKCHAIN LOGIN PAGE
   ================================================================ */

/* Body guard — hides app shell until logged in */
body.auth-active .main-content,
body.auth-active .sidebar { visibility: hidden; pointer-events: none; }

/* Full-screen overlay */
.auth-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: 99999 !important;
    display: none;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
}
.auth-overlay.active { display: flex !important; }

/* Canvas sits behind everything */
#auth-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* ── Floating watermark brand ─────────────────────────────────── */
.auth-brand-watermark {
    position: absolute;
    top: 28px;
    left: 36px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 3px;
    color: rgba(255,140,0,0.25);
    z-index: 1;
    pointer-events: none;
    font-family: 'Outfit', sans-serif;
    text-transform: uppercase;
}
.auth-brand-watermark .wm-3 { color: rgba(255,80,0,0.35); }

/* ── Bottom tagline ───────────────────────────────────────────── */
.auth-bottom-tag {
    position: absolute;
    bottom: 22px;
    left: 0; right: 0;
    text-align: center;
    font-size: 11px;
    color: rgba(255,140,0,0.3);
    z-index: 1;
    pointer-events: none;
    letter-spacing: 0.5px;
}

/* ── Auth card ────────────────────────────────────────────────── */
.auth-box {
    position: relative;
    z-index: 2;
    background: rgba(8,8,8,0.92);
    border: 1px solid rgba(255,120,0,0.22);
    border-radius: 20px;
    padding: 36px 40px 32px;
    width: 540px;
    max-width: 96vw;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow:
        0 0 0 1px rgba(255,100,0,0.08),
        0 0 60px rgba(255,90,0,0.08),
        0 30px 80px rgba(0,0,0,0.7);
    backdrop-filter: blur(16px);
    scrollbar-width: none;
}
.auth-box::-webkit-scrollbar { display: none; }

/* ── Logo row ─────────────────────────────────────────────────── */
.auth-logo-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255,120,0,0.1);
}
.auth-logo-icon {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, rgba(255,120,0,0.2), rgba(255,60,0,0.1));
    border: 1px solid rgba(255,120,0,0.3);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.auth-logo-icon i {
    font-size: 28px;
    color: #ff8c00;
    filter: drop-shadow(0 0 8px rgba(255,140,0,0.6));
}
.auth-logo-text h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 2px;
    margin: 0 0 3px;
    background: linear-gradient(135deg, #ff8c00 0%, #ffba00 60%, #ff6000 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.auth-logo-text h1 span { color: #ff4500; -webkit-text-fill-color: #ff5500; }
.auth-logo-text p {
    color: #666;
    font-size: 12px;
    margin: 0;
    letter-spacing: 0.5px;
}

/* ── Tabs ─────────────────────────────────────────────────────── */
.auth-tabs {
    display: flex;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,120,0,0.1);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 24px;
    gap: 4px;
}
.auth-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 12px;
    background: none;
    border: none;
    color: #555;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 7px;
    font-family: 'Outfit', sans-serif;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}
.auth-tab i { font-size: 16px; }
.auth-tab:hover { color: #888; background: rgba(255,255,255,0.04); }
.auth-tab.active {
    background: linear-gradient(135deg, rgba(255,140,0,0.2), rgba(255,80,0,0.12));
    color: #ff8c00;
    border: 1px solid rgba(255,140,0,0.25);
    box-shadow: 0 2px 12px rgba(255,100,0,0.1);
}

/* ── Panel ────────────────────────────────────────────────────── */
.auth-panel { animation: authFadeIn 0.25s ease; }
@keyframes authFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Two-column form row ──────────────────────────────────────── */
.auth-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ── Field ────────────────────────────────────────────────────── */
.auth-field {
    margin-bottom: 14px;
}
.auth-field label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #777;
    font-size: 11.5px;
    font-weight: 600;
    margin-bottom: 7px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}
.auth-field label i { font-size: 13px; color: #ff8c00; }
.auth-field label small { text-transform: none; color: #555; font-weight: 400; }

/* ── Input wrap ───────────────────────────────────────────────── */
.auth-input-wrap { position: relative; }
.auth-input-wrap input,
.auth-input-wrap .auth-select {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,120,0,0.15);
    color: #e8e8e8;
    padding: 11px 14px;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    box-sizing: border-box;
    -webkit-appearance: none;
}
.auth-input-wrap.has-eye input { padding-right: 42px; }
.auth-input-wrap input::placeholder { color: #444; }
.auth-input-wrap input:focus,
.auth-input-wrap .auth-select:focus {
    border-color: rgba(255,140,0,0.55);
    background: rgba(255,140,0,0.04);
    box-shadow: 0 0 0 3px rgba(255,140,0,0.1);
}
.auth-input-wrap input:hover,
.auth-input-wrap .auth-select:hover {
    border-color: rgba(255,120,0,0.3);
}

/* Select arrow */
.auth-select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ff8c00' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
.auth-select option { background: #111; color: #ddd; }

/* Eye toggle */
.auth-eye {
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: #444;
    font-size: 17px;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 2;
}
.auth-eye:hover { color: #ff8c00; }

/* ── Forgot password row ──────────────────────────────────────── */
.auth-forgot-row {
    display: flex;
    justify-content: flex-end;
    margin: -4px 0 16px;
}

/* ── Submit button ────────────────────────────────────────────── */
.auth-submit-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, #ff8c00 0%, #ff6200 50%, #e55a00 100%);
    color: #fff;
    border: none;
    padding: 13px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1.2px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    margin-top: 6px;
    position: relative;
    overflow: hidden;
    transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 4px 20px rgba(255,100,0,0.3);
}
.auth-submit-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.12), transparent);
    opacity: 0;
    transition: opacity 0.2s;
}
.auth-submit-btn:hover { opacity: 0.92; transform: translateY(-1px); box-shadow: 0 6px 24px rgba(255,100,0,0.4); }
.auth-submit-btn:hover::before { opacity: 1; }
.auth-submit-btn:active { transform: translateY(0); }
.auth-submit-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.auth-submit-btn i { font-size: 18px; }

/* ── Switch row ───────────────────────────────────────────────── */
.auth-switch-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
    font-size: 13px;
    color: #555;
}
.auth-link {
    color: #ff8c00;
    cursor: pointer;
    font-weight: 600;
    transition: color 0.2s;
}
.auth-link:hover { color: #ffba00; }
.auth-link-small {
    color: #ff8c00;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}
.auth-link-small:hover { color: #ffba00; }
.auth-link-small i { font-size: 14px; }

/* ── Forgot password header ───────────────────────────────────── */
.auth-forgot-header {
    text-align: center;
    margin-bottom: 24px;
}
.auth-forgot-icon {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, rgba(255,140,0,0.15), rgba(255,60,0,0.08));
    border: 1px solid rgba(255,120,0,0.25);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 14px;
}
.auth-forgot-icon i { font-size: 30px; color: #ff8c00; }
.auth-forgot-header h3 { color: #fff; font-size: 18px; margin: 0 0 8px; }
.auth-forgot-header p  { color: #666; font-size: 13px; margin: 0; }

/* ── Auth messages ────────────────────────────────────────────── */
.auth-msg {
    padding: 11px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-top: 12px;
    line-height: 1.5;
    display: none;
}
.auth-msg.error   {
    background: rgba(231,76,60,0.1);
    color: #e74c3c;
    border: 1px solid rgba(231,76,60,0.25);
    display: block;
}
.auth-msg.success {
    background: rgba(46,204,113,0.1);
    color: #2ecc71;
    border: 1px solid rgba(46,204,113,0.25);
    display: block;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 600px) {
    .auth-box { padding: 28px 22px 24px; }
    .auth-form-row { grid-template-columns: 1fr; gap: 0; }
    .auth-logo-row { gap: 12px; }
    .auth-logo-icon { width: 46px; height: 46px; }
    .auth-logo-text h1 { font-size: 18px; }
}

/* ================================================================
   INVOICE FILE LINK
   ================================================================ */
.invoice-file-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: #f39c12; font-size: 13px; font-weight: 500;
    text-decoration: none; padding: 4px 10px;
    background: rgba(243,156,18,.1); border-radius: 6px;
    transition: background .2s;
}
.invoice-file-link:hover { background: rgba(243,156,18,.2); }

/* Status badge extras */
.status-badge.received { background: rgba(52,152,219,.15); color: #3498db; border-color: #3498db44; }
.status-badge.danger   { background: rgba(231,76,60,.15);  color: #e74c3c; border-color: #e74c3c44; }

/* Toast fadeIn */
@keyframes fadeIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
