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

:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --secondary: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --bg: #f5f6fa;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #dcdde1;
    --sidebar-width: 240px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.sidebar-header h2 { font-size: 1.5rem; }
.sidebar-subtitle { font-size: 0.75rem; opacity: 0.7; }

.nav-links {
    list-style: none;
    padding: 10px 0;
    flex: 1;
}

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

.nav-links li a:hover, .nav-links li a.active {
    background: rgba(255,255,255,0.1);
    color: white;
}

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

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.content {
    margin-left: var(--sidebar-width);
    padding: 30px;
    flex: 1;
    min-width: 0;
}

.content-full {
    padding: 30px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

h1 { font-size: 1.8rem; margin-bottom: 20px; color: var(--primary); }
h2 { font-size: 1.4rem; margin-bottom: 15px; color: var(--primary); }
h3 { font-size: 1.1rem; margin-bottom: 10px; }

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

.card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

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

.stat-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 5px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
}

tr:hover { background: #f8f9fa; }

.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-success { background: var(--secondary); color: white; }
.btn-success:hover { background: #219a52; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c0392b; }
.btn-warning { background: var(--warning); color: white; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.9rem;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(41,128,185,0.2);
}

select.form-control { appearance: auto; }
textarea.form-control { min-height: 80px; resize: vertical; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.alert {
    padding: 12px 16px;
    border-radius: 5px;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeaa8; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

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

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-danger { background: #f8d7da; color: #721c24; }

.tree { list-style: none; padding-left: 0; }
.tree ul { list-style: none; padding-left: 25px; border-left: 1px dashed var(--border); margin-left: 10px; }
.tree li { padding: 5px 0; }
.tree-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
}
.tree-item:hover { background: var(--bg); }

.login-container {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    text-align: center;
    margin-bottom: 30px;
}

.report-filters {
    display: flex;
    gap: 15px;
    align-items: end;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.report-filters .form-group { margin-bottom: 0; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.summary-item {
    background: var(--bg);
    padding: 15px;
    border-radius: 6px;
    text-align: center;
}

.summary-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

.summary-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 3px;
}

.profit { color: var(--secondary); font-weight: 600; }
.loss { color: var(--danger); font-weight: 600; }

.dashboard-filters {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    align-items: end;
}

.dashboard-filters .form-group { margin-bottom: 0; }

.dashboard-section { margin-bottom: 10px; }

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

.kpi-grid-small {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.kpi-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    border-left: 4px solid var(--primary);
}

.kpi-card.kpi-revenue { border-left-color: var(--primary); }
.kpi-card.kpi-cost { border-left-color: var(--warning); }
.kpi-card.kpi-profit { border-left-color: var(--secondary); }
.kpi-card.kpi-loss { border-left-color: var(--danger); }

.kpi-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.kpi-card.kpi-profit .kpi-value { color: var(--secondary); }
.kpi-card.kpi-loss .kpi-value { color: var(--danger); }

.kpi-sub {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 4px;
}

.kpi-card-sm {
    background: var(--bg);
    border-radius: 6px;
    padding: 12px 15px;
    border-left: 3px solid var(--primary);
}

.kpi-card-sm.kpi-profit { border-left-color: var(--secondary); }
.kpi-card-sm.kpi-loss { border-left-color: var(--danger); }

.kpi-value-sm {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.kpi-card-sm.kpi-profit .kpi-value-sm { color: var(--secondary); }
.kpi-card-sm.kpi-loss .kpi-value-sm { color: var(--danger); }

.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 4px;
    font-size: 0.85rem;
}

.breakdown-label { color: var(--text-light); }
.breakdown-value { font-weight: 600; }

.yield-bars { margin-top: 10px; }

.yield-bar-row {
    display: grid;
    grid-template-columns: 180px 1fr 160px;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
}

.yield-bar-label {
    font-size: 0.85rem;
    font-weight: 500;
    text-align: right;
}

.yield-bar-track {
    height: 26px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}

.yield-bar-fill {
    height: 100%;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    min-width: 50px;
    transition: width 0.3s ease;
}

.bar-good { background: var(--secondary); }
.bar-warn { background: var(--warning); }
.bar-bad { background: var(--danger); }

.yield-bar-detail {
    font-size: 0.8rem;
    color: var(--text-light);
}

.print-only { display: none; }

@media print {
    .sidebar, .no-print, .flash-messages { display: none !important; }
    .content { margin-left: 0; padding: 0; }
    .print-only { display: block; }
    body { background: white; }
}

.search-filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.search-filter-bar input[type="text"],
.search-filter-bar input[type="search"] {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-filter-bar input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(41, 128, 185, 0.15);
}

.search-filter-bar select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    min-width: 150px;
}

.search-filter-bar .filter-label {
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-filter-bar .result-count {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-left: auto;
    white-space: nowrap;
}

.search-filter-bar .btn-clear {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-light);
    transition: all 0.2s;
}

.search-filter-bar .btn-clear:hover {
    background: var(--bg);
    color: var(--text);
}

tr.filter-hidden {
    display: none;
}

@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-header h2 { font-size: 1rem; }
    .sidebar-subtitle, .nav-section, .sidebar-footer span { display: none; }
    .nav-links li a { padding: 10px; font-size: 0.75rem; text-align: center; }
    .content { margin-left: 60px; padding: 15px; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-filters { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: 1fr; }
    .yield-bar-row { grid-template-columns: 1fr; gap: 4px; }
    .yield-bar-label { text-align: left; }
}
