/* ==========================================================================
   1. GLOBAL VARIABLES & SYSTEM THEMING
   ========================================================================== */
:root {
    --primary: #1e88e5;          /* Clean Water Blue */
    --primary-dark: #1565c0;     /* Deep Industrial Blue */
    --bg: #f4f6f9;               /* Light Gray Background */
    --surface: #ffffff;          /* Card Backgrounds */
    --text: #333333;             /* Sharp Text Content */
    --text-muted: #666666;       /* Subtext and Meta Tags */
    --border: #dddddd;           /* Standard Grid Borders */
    --success: #2e7d32;          /* Profit / Balance Paid Green */
    --danger: #c62828;           /* Loss / Expenses Red */
    --warning: #ef6c00;          /* Outstanding Debts Orange */
}

/* ==========================================================================
   2. CORE RESET & TYPOGRAPHY
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ==========================================================================
   3. SYSTEM HEADER & NAVIGATION
   ========================================================================== */
header {
    background-color: var(--surface);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.logo h2 {
    color: var(--primary);
}

.logo p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

nav {
    display: flex;
    align-items: center;
}

nav a {
    text-decoration: none;
    color: var(--text);
    margin: 0 1rem;
    font-weight: 600;
    padding: 0.5rem 0;
    transition: color 0.2s;
}

nav a.active, nav a:hover {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

nav button {
    background: var(--danger);
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    margin-left: 1rem;
}

nav button:hover {
    background: #b71c1c;
}

/* ==========================================================================
   4. LOGIN & REGISTRATION LAYOUT (1_index.html)
   ========================================================================== */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    padding: 2rem;
}

.auth-box {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 450px;
}

.auth-box h3 {
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--primary-dark);
}

.auth-box p {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-muted);
}

.auth-box a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* ==========================================================================
   5. CONTAINER GRIDS & STRUCTURAL PAGE LAYOUTS
   ========================================================================== */
.page-container {
    padding: 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    padding: 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.welcome-bar {
    grid-column: 1 / -1;
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 5px solid var(--primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Split Form vs Ledger Layout (Used heavily on Expenses, Sales & Production) */
.data-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* ==========================================================================
   6. CARDS, FORMS & COMPONENT STYLING
   ========================================================================== */
.card {
    background: var(--surface);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    margin-bottom: 1.5rem;
}

.wide-card {
    grid-column: 1 / -1;
    margin-top: 1rem;
}

.card h3 {
    margin-bottom: 1.5rem;
    color: var(--primary-dark);
    border-bottom: 2px solid var(--bg);
    padding-bottom: 0.5rem;
    font-size: 1.25rem;
}

.card h4 {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Metrics and Data Badges */
.metric {
    font-size: 2rem;
    font-weight: bold;
    margin-top: 0.5rem;
    color: var(--primary);
}

.summary-list p {
    padding: 0.8rem 0;
    border-bottom: 1px dashed var(--border);
    display: flex;
    justify-content: space-between;
}

/* Form Inputs Styling */
.input-group {
    margin-bottom: 1.2rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.input-group input, 
.input-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    background-color: #fafafa;
    transition: border-color 0.2s, background-color 0.2s;
}

.input-group input:focus, 
.input-group select:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #ffffff;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 0.8rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background: var(--primary-dark);
}

.btn-sm {
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

/* ==========================================================================
   7. DETAILED EXPENSE SECTIONS & VISUAL FEEDBACK BOARDS
   ========================================================================== */
/* Form box customization on 5_expenses.html */
#expense-form {
    display: flex;
    flex-direction: column;
}

/* Context/Information box styling on 5_expenses.html */
.visual-feedback {
    background: linear-gradient(135deg, #fff5f5 0%, #ffebee 100%);
    border-left: 5px solid var(--danger);
    display: flex;
    flex-direction: column;
    justify-content: center;
}



.visual-feedback h3 {
    color: var(--danger) !important;
    border-bottom: 1px solid rgba(198, 40, 40, 0.1);
}

.visual-feedback p {
    color: #5c3a3a;
    line-height: 1.6;
    font-size: 0.95rem;
}

/* ==========================================================================
   8. DATA TABLES DESIGN (Log Ledgers & Histories)
   ========================================================================== */
.table-wrapper {
    overflow-x: auto;
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background: var(--surface);
}

th, td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--border);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #fcfcfc;
}

/* ==========================================================================
   9. UTILITIES & STRUCTURAL MODIFIERS
   ========================================================================== */
.hidden {
    display: none !important;
}

/* Functional State Classes */
.text-success { color: var(--success) !important; font-weight: 600; }
.text-danger { color: var(--danger) !important; font-weight: 600; }
.text-warning { color: var(--warning) !important; font-weight: 600; }

/* Financial State Indicators */
.bg-loss { border-top: 5px solid var(--danger); }
.bg-profit { border-top: 5px solid var(--success); }

/* Yield Config Header Adjustment */
.config-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.config-section input {
    width: 90px;
    padding: 0.4rem;
    text-align: center;
}

/* ==========================================================================
   10. MOBILE RESPONSIVENESS & MEDIA QUERIES
   ========================================================================== */
@media (max-width: 900px) {
    .data-split {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    nav a {
        margin: 0.25rem 0.75rem;
    }
}
