/* Finance Allohaus — Accurate Online Pixel-Perfect Clone
   Colors remapped to Allohaus branding */

:root {
    /* Allohaus brand */
    --brand-dark: #281508;
    --brand-accent: #b2c7e4;
    --brand-cream: #fff9e9;
    --brand-warm: #3d2210;
    --brand-light: #f5efe8;

    /* Header — warm brown gradient */
    --header-gradient-start: #281508;
    --header-gradient-mid: #3d2210;
    --header-gradient-end: #5a3a24;
    --sidebar-bg: #281508;
    --sidebar-icon: #b2c7e4;
    --sidebar-icon-hover: #fff9e9;
    --sidebar-width: 48px;
    --sidebar-expanded: 220px;

    /* Tab bar */
    --tab-bar-bg: #f5efe8;
    --tab-active-bg: #ffffff;
    --tab-inactive-bg: #e8dfd6;
    --tab-close: #999;
    --tab-height: 32px;

    /* Content */
    --content-bg: #ffffff;
    --content-border: #ddd5cc;
    --text-primary: #281508;
    --text-secondary: #5a4a3a;
    --text-muted: #9a8a7a;

    /* Accent colors for module tabs — warm, muted palette */
    --tab-dashboard: #281508;
    --tab-sales: #6b8cae;
    --tab-purchases: #7a6b8a;
    --tab-inventory: #5a8a7a;
    --tab-cashbank: #4a7a9a;
    --tab-gl: #8a7a4a;
    --tab-reports: #5a6a7a;
    --tab-company: #8a6a4a;
    --tab-settings: #6a6a6a;

    /* Form */
    --input-border: #ccc5bb;
    --input-focus: #b2c7e4;
    --btn-primary: #281508;
    --btn-primary-hover: #3d2210;
    --btn-success: #5a8a5a;
    --btn-danger: #b54a4a;

    /* Table */
    --table-header-bg: #3d2210;
    --table-header-text: #fff9e9;
    --table-stripe: #faf7f3;
    --table-border: #e8dfd6;

    /* Right action bar */
    --action-bar-width: 48px;

    /* Fonts */
    --font-primary: 'Segoe UI', 'Roboto', -apple-system, sans-serif;
    --font-secondary: 'Georgia', 'Times New Roman', serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: var(--font-primary);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--brand-light);
    overflow: hidden;
    height: 100vh;
}

/* ===== HEADER BAR (top) ===== */
.app-header {
    height: 40px;
    background: linear-gradient(135deg, var(--header-gradient-start), var(--header-gradient-mid), var(--header-gradient-end));
    display: flex;
    align-items: center;
    padding: 0 12px;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
}
.app-header .logo {
    display: flex;
    align-items: center;
    gap: 8px;
}
.app-header .logo img {
    height: 32px;
    border-radius: 4px;
    background: var(--brand-dark);
    padding: 2px;
}
.app-header .logo-text {
    color: white;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.app-header .header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
}
.app-header .header-right .header-icon {
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    font-size: 16px;
}
.app-header .header-right .header-icon:hover {
    color: white;
}
.app-header .user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

/* ===== SIDEBAR (left icons) ===== */
.app-sidebar {
    position: fixed;
    top: 40px;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 8px;
    z-index: 999;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sidebar-icon);
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 2px;
    position: relative;
    transition: all 0.15s;
    font-size: 18px;
}
.sidebar-icon:hover {
    background: rgba(178, 199, 228, 0.15);
    color: var(--sidebar-icon-hover);
}
.sidebar-icon.active {
    background: rgba(178, 199, 228, 0.2);
    color: var(--sidebar-icon-hover);
}
.sidebar-icon .tooltip {
    position: absolute;
    left: 50px;
    top: 50%;
    transform: translateY(-50%);
    background: #333;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}
.sidebar-icon:hover .tooltip {
    opacity: 1;
}

/* Sidebar flyout menu */
.sidebar-flyout {
    position: fixed;
    top: 40px;
    left: var(--sidebar-width);
    bottom: 0;
    width: 240px;
    background: white;
    box-shadow: 4px 0 12px rgba(0,0,0,0.1);
    z-index: 998;
    display: none;
    overflow-y: auto;
    padding: 16px 0;
}
.sidebar-flyout.visible {
    display: block;
}
.sidebar-flyout .flyout-title {
    font-size: 16px;
    font-weight: 600;
    padding: 0 16px 12px;
    color: var(--text-primary);
}
.sidebar-flyout .flyout-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 0 12px;
}
.sidebar-flyout .flyout-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 4px;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
}
.sidebar-flyout .flyout-item:hover {
    background: var(--brand-light);
}
.sidebar-flyout .flyout-item .flyout-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 6px;
    color: white;
}
.flyout-icon.sales { background: var(--tab-sales); }
.flyout-icon.purchases { background: var(--tab-purchases); }
.flyout-icon.inventory { background: var(--tab-inventory); }
.flyout-icon.cashbank { background: var(--tab-cashbank); }
.flyout-icon.gl { background: var(--tab-gl); }
.flyout-icon.reports { background: var(--tab-reports); }
.flyout-icon.company { background: var(--tab-company); }
.flyout-icon.settings { background: var(--tab-settings); }

.sidebar-flyout .flyout-item .flyout-label {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* ===== TAB BAR ===== */
.tab-bar {
    position: fixed;
    top: 40px;
    left: var(--sidebar-width);
    right: 0;
    height: var(--tab-height);
    background: var(--tab-bar-bg);
    display: flex;
    align-items: end;
    overflow-x: auto;
    overflow-y: hidden;
    z-index: 997;
    border-bottom: 1px solid var(--content-border);
    scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab-item {
    display: flex;
    align-items: center;
    height: 28px;
    padding: 0 12px;
    gap: 6px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 12px;
    border-radius: 6px 6px 0 0;
    margin-left: 2px;
    transition: all 0.15s;
    flex-shrink: 0;
    position: relative;
    color: var(--text-secondary);
    background: var(--tab-inactive-bg);
}
.tab-item.active {
    background: var(--tab-active-bg);
    color: var(--text-primary);
    font-weight: 500;
    border: 1px solid var(--content-border);
    border-bottom: 1px solid white;
}
.tab-item .tab-color {
    width: 4px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
}
.tab-item .tab-close {
    font-size: 14px;
    color: var(--tab-close);
    cursor: pointer;
    margin-left: 4px;
    line-height: 1;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tab-item .tab-close:hover {
    background: rgba(0,0,0,0.1);
    color: var(--btn-danger);
}

/* ===== CONTENT AREA ===== */
.content-area {
    position: fixed;
    top: calc(40px + var(--tab-height));
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    overflow: hidden;
}
.tab-content {
    display: none;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background: var(--content-bg);
}
.tab-content.active {
    display: block;
}

/* ===== RIGHT ACTION BAR ===== */
.action-bar {
    position: fixed;
    top: calc(40px + var(--tab-height));
    right: 0;
    bottom: 0;
    width: var(--action-bar-width);
    background: var(--brand-light);
    border-left: 1px solid var(--content-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 8px;
    gap: 4px;
    z-index: 996;
}
.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-secondary);
    border: none;
    background: transparent;
    transition: all 0.15s;
}
.action-btn:hover {
    background: #e8dfd6;
    color: var(--text-primary);
}
.action-btn.primary {
    background: var(--brand-accent);
    color: white;
}
.action-btn.primary:hover {
    background: #9ab5d4;
}

/* ===== DASHBOARD ===== */
.dashboard {
    padding: 16px;
    padding-right: calc(var(--action-bar-width) + 16px);
    background: #1e1008;
    min-height: 100%;
}
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.dashboard-header h2 {
    color: white;
    font-size: 14px;
    font-weight: 500;
}
.widget-btn {
    background: var(--brand-accent);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.widget {
    background: #2a1a0e;
    border-radius: 8px;
    padding: 16px;
    color: white;
    min-height: 180px;
}
.widget-title {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.widget-title .expand-icon {
    cursor: pointer;
    font-size: 14px;
}
.widget-value {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}
.widget-chart {
    height: 80px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
}
.widget-chart .bar {
    flex: 1;
    background: var(--brand-accent);
    border-radius: 2px 2px 0 0;
    min-height: 4px;
}

/* Bottom stats row */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 12px;
}
.stat-card {
    background: #2a1a0e;
    border-radius: 8px;
    padding: 16px;
    color: white;
}
.stat-card h4 {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #aaa;
    margin-bottom: 4px;
}
.stat-row .value {
    color: white;
    font-weight: 500;
}

/* ===== FORM PAGES (Sales Invoice, etc.) ===== */
.page-form {
    padding: 0;
    padding-right: var(--action-bar-width);
}
.form-toolbar {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 8px;
    border-bottom: 1px solid var(--content-border);
    background: var(--brand-light);
}
.btn {
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid var(--content-border);
    background: white;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}
.btn:hover { background: #f0f0f0; }
.btn-new {
    background: var(--btn-success);
    color: white;
    border-color: var(--btn-success);
}
.btn-new:hover { background: #4a7a4a; }

.form-header {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    gap: 16px;
    border-bottom: 1px solid var(--content-border);
    flex-wrap: wrap;
}
.form-group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.form-group label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.form-group label .required {
    color: var(--btn-danger);
}
.form-control {
    padding: 5px 8px;
    border: 1px solid var(--input-border);
    border-radius: 3px;
    font-size: 12px;
    font-family: var(--font-primary);
    outline: none;
    transition: border-color 0.15s;
}
.form-control:focus {
    border-color: var(--input-focus);
}
.form-control-search {
    width: 220px;
    padding-right: 28px;
}

/* ===== DATA TABLE ===== */
.data-table-wrapper {
    padding: 0 16px 16px;
    flex: 1;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.data-table thead th {
    background: var(--table-header-bg);
    color: var(--table-header-text);
    padding: 8px 10px;
    text-align: left;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid #5a3a24;
}
.data-table tbody td {
    padding: 7px 10px;
    border: 1px solid var(--table-border);
}
.data-table tbody tr:nth-child(even) {
    background: var(--table-stripe);
}
.data-table tbody tr:hover {
    background: #eee8df;
}
.data-table .no-data {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-style: italic;
}
.data-table .sub-total-row td {
    font-weight: 600;
    background: #f5f5f5;
    text-align: right;
}

/* ===== LIST PAGE ===== */
.page-list {
    padding: 0;
    padding-right: var(--action-bar-width);
    display: flex;
    flex-direction: column;
    height: 100%;
}
.list-toolbar {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 8px;
    border-bottom: 1px solid var(--content-border);
    background: var(--brand-light);
}
.search-input {
    padding: 5px 8px;
    border: 1px solid var(--input-border);
    border-radius: 3px;
    font-size: 12px;
    width: 240px;
}

/* ===== DONUT CHART (CSS) ===== */
.donut-chart {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    position: relative;
}
.donut-center {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    color: #aaa;
    text-align: center;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    background: var(--brand-dark);
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.login-card .login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-card .login-logo img {
    height: 100px;
    border-radius: 12px;
}
.login-card h2 {
    text-align: center;
    margin-bottom: 24px;
    color: var(--brand-dark);
    font-size: 18px;
}
.login-card .form-group {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 16px;
}
.login-card .form-group label {
    margin-bottom: 4px;
    font-weight: 500;
    color: var(--text-primary);
}
.login-card .form-control {
    padding: 10px 12px;
    font-size: 14px;
    width: 100%;
}
.login-card .btn-login {
    width: 100%;
    padding: 12px;
    background: var(--brand-dark);
    color: var(--brand-cream);
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}
.login-card .btn-login:hover {
    background: #3d2210;
}

/* ===== USER MENU (header) ===== */
.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}
.user-menu:hover { background: rgba(255,255,255,0.15); }
.user-name {
    color: white;
    font-size: 12px;
    font-weight: 500;
}

/* User Dropdown */
.user-dropdown {
    position: fixed;
    top: 44px;
    right: 12px;
    width: 240px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 2000;
    display: none;
    overflow: hidden;
}
.user-dropdown.visible { display: block; }
.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
}
.user-dropdown-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--brand-accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
}
.user-dropdown-name { font-weight: 600; color: var(--text-primary); font-size: 14px; }
.user-dropdown-email { font-size: 12px; color: var(--text-muted); }
.user-dropdown-divider { height: 1px; background: var(--content-border); }
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.15s;
}
.user-dropdown-item:hover { background: var(--brand-light); }
.user-dropdown-item i { color: var(--text-muted); width: 16px; }

/* ===== NOTIFICATION PANEL ===== */
.notif-panel {
    position: fixed;
    top: 44px;
    right: 60px;
    width: 320px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 2000;
    display: none;
    overflow: hidden;
}
.notif-panel.visible { display: block; }
.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid var(--content-border);
    color: var(--text-primary);
}
.notif-close {
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
    line-height: 1;
}
.notif-close:hover { color: var(--text-primary); }
.notif-body { padding: 32px 16px; }
.notif-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ===== SEARCH MODAL ===== */
.search-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 3000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
}
.search-overlay.visible { display: flex; }
.search-modal {
    background: white;
    border-radius: 12px;
    width: 480px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    overflow: hidden;
}
.search-input-wrapper {
    padding: 16px;
    border-bottom: 1px solid var(--content-border);
}
.search-modal-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--brand-accent);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font-primary);
    outline: none;
}
.search-modal-input:focus { border-color: var(--brand-dark); }
.search-section-title {
    padding: 12px 16px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.search-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 0 12px 16px;
}
.search-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 4px;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
}
.search-item:hover { background: var(--brand-light); }
.search-item-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-bottom: 6px;
    color: white;
}
.search-item span {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* ===== UTILITIES ===== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
