/* Master Brush Accounts System */
:root {
    --blue: #1a73c7;
    --blue-dark: #1557a0;
    --red: #e53935;
    --yellow: #f9a825;
    --green: #2e7d32;
    --dark: #1a1a2e;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-500: #6c757d;
    --gray-700: #495057;
    --gray-900: #212529;
    --sidebar-width: 260px;
    --radius: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.6;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--dark) 0%, #16213e 50%, var(--blue-dark) 100%);
    padding: 24px;
    overflow-y: auto;
}

.login-container { width: 100%; max-width: 440px; }

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 36px 32px 32px;
    box-shadow: var(--shadow-lg);
    overflow: visible;
}

.login-header { text-align: center; margin-bottom: 28px; }

.login-logo {
    width: 140px;
    height: auto;
    margin-bottom: 12px;
    border-radius: 8px;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--dark);
}

.tagline {
    color: var(--blue);
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 4px;
}

.login-form .form-group { margin-bottom: 18px; }

.login-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.login-form input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
    background: #fff;
    color: var(--gray-900);
    display: block;
    -webkit-appearance: none;
    appearance: none;
}

.login-form input:focus {
    outline: none;
    border-color: var(--blue);
}

.login-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 0.78rem;
    color: var(--gray-500);
}

.login-footer .contact { margin-top: 6px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    color: #fff;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,115,199,0.4); }

.btn-block { width: 100%; padding: 14px; font-size: 1rem; }

.btn-outline {
    background: transparent;
    border: 2px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover { border-color: var(--blue); color: var(--blue); }

.btn-danger { background: var(--red); color: #fff; }

.btn-success { background: var(--green); color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-error { background: #fdecea; color: #c62828; border: 1px solid #ef9a9a; }
.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }

/* Layout */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand img {
    width: 44px;
    height: 44px;
    border-radius: 6px;
}

.sidebar-brand strong { display: block; font-size: 0.85rem; letter-spacing: 0.5px; }
.sidebar-brand small { color: rgba(255,255,255,0.5); font-size: 0.72rem; }

.sidebar-nav { list-style: none; padding: 12px 0; flex: 1; }

.sidebar-nav li a {
    display: block;
    padding: 10px 20px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.88rem;
    transition: all 0.2s;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left: 3px solid var(--yellow);
}

.nav-section {
    padding: 16px 20px 6px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.35);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info { font-size: 0.85rem; }
.logout-link { color: var(--red); text-decoration: none; font-size: 0.8rem; }

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.top-bar {
    background: #fff;
    padding: 20px 32px;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
}

.top-bar h1 { font-size: 1.4rem; font-weight: 600; }

.content-area { padding: 28px 32px; }

/* Dashboard */
.welcome-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    color: #fff;
    padding: 28px 32px;
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.welcome-banner h2 { font-size: 1.5rem; margin-bottom: 4px; }
.welcome-banner p { opacity: 0.85; font-size: 0.95rem; }
.welcome-logo { width: 80px; border-radius: 8px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}

.stat-icon { font-size: 2rem; }
.stat-label { display: block; font-size: 0.82rem; color: var(--gray-500); }
.stat-value { display: block; font-size: 1.3rem; font-weight: 700; }
.stat-value.positive { color: var(--green); }
.stat-value.negative { color: var(--red); }

.quick-actions { margin-bottom: 28px; }
.quick-actions h3 { margin-bottom: 14px; font-size: 1.1rem; }

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.action-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px 20px;
    text-align: center;
    text-decoration: none;
    color: var(--gray-900);
    box-shadow: var(--shadow);
    transition: all 0.2s;
    border-top: 4px solid transparent;
}

.action-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.action-invoice { border-top-color: var(--blue); }
.action-receipt { border-top-color: var(--green); }
.action-quotation { border-top-color: var(--yellow); }
.action-delivery { border-top-color: var(--red); }

.action-icon { display: block; font-size: 2rem; margin-bottom: 8px; }
.action-title { display: block; font-weight: 700; font-size: 1rem; }
.action-count { display: block; font-size: 0.78rem; color: var(--gray-500); margin-top: 4px; }

.dashboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.panel {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.panel h3 { font-size: 1.05rem; }

.panel-about p { font-size: 0.9rem; color: var(--gray-700); margin-bottom: 12px; }
.about-details { font-size: 0.85rem; color: var(--gray-500); }
.about-details p { margin-bottom: 4px; }

/* Tables */
.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-200);
}

.data-table .empty { text-align: center; color: var(--gray-500); padding: 24px; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-invoice { background: #e3f2fd; color: var(--blue); }
.badge-receipt { background: #e8f5e9; color: var(--green); }
.badge-quotation { background: #fff8e1; color: #f57f17; }
.badge-delivery { background: #fce4ec; color: var(--red); }

/* Forms */
.form-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.form-card h3 {
    font-size: 1.05rem;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--gray-200);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.form-group { margin-bottom: 14px; }

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--blue);
}

.form-group textarea { min-height: 80px; resize: vertical; }

.form-hint {
    font-size: 0.85rem;
    color: #666;
    margin: -6px 0 14px;
    line-height: 1.45;
}

.items-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.spacer-row td {
    background: #f5f5f5;
    text-align: center;
    padding: 10px !important;
}

.spacer-label {
    color: #888;
    font-style: italic;
    margin-right: 12px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

/* Line Items */
.items-table { width: 100%; border-collapse: collapse; margin-top: 10px; }

.items-table th {
    background: var(--gray-100);
    padding: 8px 10px;
    text-align: left;
    font-size: 0.82rem;
    border: 1px solid var(--gray-200);
}

.items-table td {
    padding: 4px;
    border: 1px solid var(--gray-200);
}

.items-table input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    font-size: 0.88rem;
}

.items-table input:focus { outline: none; border-color: var(--blue); }

.totals-row {
    display: flex;
    justify-content: flex-end;
    gap: 24px;
    margin-top: 16px;
    padding: 16px;
    background: var(--gray-100);
    border-radius: 8px;
}

.total-item { text-align: right; }
.total-item label { display: block; font-size: 0.78rem; color: var(--gray-500); }
.total-item span { font-size: 1.2rem; font-weight: 700; color: var(--blue); }

/* Signature */
.signature-preview {
    max-width: 200px;
    max-height: 80px;
    border: 1px dashed var(--gray-300);
    border-radius: 6px;
    padding: 8px;
    margin-top: 8px;
}

.signature-preview img { max-width: 100%; max-height: 60px; }

/* Filters */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.filters select, .filters input {
    padding: 8px 12px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.88rem;
}

/* P&L Report */
.pl-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.pl-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    text-align: center;
}

.pl-card h4 { font-size: 0.82rem; color: var(--gray-500); margin-bottom: 6px; }
.pl-card .amount { font-size: 1.4rem; font-weight: 700; }
.pl-card.revenue .amount { color: var(--blue); }
.pl-card.costs .amount { color: var(--orange, #ef6c00); }
.pl-card.expenses .amount { color: var(--red); }
.pl-card.profit .amount { color: var(--green); }
.pl-card.loss .amount { color: var(--red); }

/* Responsive — Mobile & Tablet */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.mobile-menu-btn {
    display: none;
    background: var(--dark);
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
    cursor: pointer;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.top-bar {
    display: flex;
    align-items: center;
    gap: 14px;
}

.top-bar h1 {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

/* Tablet */
@media (max-width: 1024px) {
    .content-area { padding: 20px; }
    .top-bar { padding: 16px 20px; }
    .form-card { padding: 20px; }
    .welcome-banner { padding: 22px 24px; }
    .dashboard-row { grid-template-columns: 1fr; }
}

/* Mobile */
@media (max-width: 768px) {
    .mobile-menu-btn { display: flex; }

    .sidebar {
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 200;
        box-shadow: 4px 0 20px rgba(0,0,0,0.2);
    }

    .sidebar.open { transform: translateX(0); }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .top-bar {
        padding: 14px 16px;
        position: sticky;
        top: 0;
        z-index: 50;
    }

    .top-bar h1 { font-size: 1.15rem; }

    .content-area { padding: 14px; }

    .welcome-banner {
        flex-direction: column;
        text-align: center;
        gap: 14px;
        padding: 20px 16px;
    }

    .welcome-banner h2 { font-size: 1.25rem; }
    .welcome-logo { width: 70px; }

    .stats-grid { grid-template-columns: 1fr; gap: 12px; }

    .stat-card { padding: 16px; }
    .stat-value { font-size: 1.15rem; }

    .action-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

    .action-card { padding: 18px 12px; }
    .action-icon { font-size: 1.6rem; }
    .action-title { font-size: 0.9rem; }

    .panel { padding: 16px; }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .form-card { padding: 16px; margin-bottom: 14px; }

    .form-grid { grid-template-columns: 1fr; gap: 0; }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
        padding: 12px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
    }

    .filters select,
    .filters input,
    .filters .btn {
        width: 100%;
    }

    .totals-row {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .total-item { text-align: left; }

    .pl-summary { grid-template-columns: 1fr 1fr; gap: 10px; }

    .pl-card { padding: 14px; }
    .pl-card .amount { font-size: 1.1rem; }

    /* Data tables — scroll + compact */
    .table-wrap {
        margin: 0 -4px;
        -webkit-overflow-scrolling: touch;
    }

    .data-table { font-size: 0.8rem; min-width: 520px; }

    .data-table th,
    .data-table td { padding: 8px 10px; }

    .btn-group { flex-direction: column; width: 100%; }
    .btn-group .btn { width: 100%; text-align: center; }

    /* Line items — card layout on mobile */
    .items-table-wrap {
        overflow: visible;
    }

    .items-table thead { display: none; }

    .items-table tbody tr.item-row {
        display: block;
        background: var(--gray-100);
        border: 1px solid var(--gray-200);
        border-radius: 10px;
        padding: 12px;
        margin-bottom: 12px;
    }

    .items-table tbody tr.item-row td {
        display: block;
        border: none;
        padding: 6px 0;
    }

    .items-table tbody tr.item-row td:last-child {
        text-align: right;
        padding-top: 8px;
    }

    .items-table tbody tr.item-row td:nth-child(1)::before { content: 'Units: '; font-weight: 600; font-size: 0.75rem; color: var(--gray-500); }
    .items-table tbody tr.item-row td:nth-child(2)::before { content: 'Description: '; font-weight: 600; font-size: 0.75rem; color: var(--gray-500); display: block; margin-bottom: 4px; }
    .items-table tbody tr.item-row td:nth-child(3)::before { content: 'Unit Price: '; font-weight: 600; font-size: 0.75rem; color: var(--gray-500); }
    .items-table tbody tr.item-row td:nth-child(4)::before { content: 'Unit Cost: '; font-weight: 600; font-size: 0.75rem; color: var(--gray-500); }
    .items-table tbody tr.item-row td:nth-child(5)::before { content: 'Total: '; font-weight: 600; font-size: 0.75rem; color: var(--gray-500); }

    .items-table tbody tr.item-row .item-total {
        font-weight: 700;
        color: var(--blue);
        font-size: 1rem;
    }

    .items-table input {
        padding: 10px;
        font-size: 16px; /* prevents iOS zoom */
    }

    .login-page { padding: 16px; }

    .login-card { padding: 28px 20px 24px; }

    .login-logo { width: 120px; }

    .login-header h1 { font-size: 1.3rem; }

    .login-footer { font-size: 0.72rem; }
}

@media (max-width: 400px) {
    .action-grid { grid-template-columns: 1fr; }

    .pl-summary { grid-template-columns: 1fr; }
}
