/* NKP Project Accounting - NK Partners Brand */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600;700&family=Manrope:wght@300;400;500;600;700&display=swap');

:root {
    /* NK Partners Brand Palette */
    --midnight: #162840;
    --midnight-light: #1E3550;
    --copper: #8B6E4E;
    --copper-light: rgba(139, 110, 78, 0.08);
    --parchment: #FDFBF7;
    --verdigris: #5B7B6D;
    --verdigris-light: rgba(91, 123, 109, 0.08);
    --sandstone: #D4C5B2;

    /* Functional */
    --navy: #162840;
    --navy-light: #1E3550;
    --slate: #4A5568;
    --gray-100: #FDFBF7;
    --gray-200: #F0EBE3;
    --gray-300: #D4C5B2;
    --gray-400: #A89B8C;
    --gray-600: #7A8A9A;
    --white: #FFFFFF;
    --green: #5B7B6D;
    --green-light: rgba(91, 123, 109, 0.08);
    --red: #A8432A;
    --red-light: rgba(168, 67, 42, 0.06);
    --yellow: #8B6E4E;
    --yellow-light: rgba(139, 110, 78, 0.06);
    --blue: #3B6B8A;
    --blue-light: rgba(59, 107, 138, 0.06);
}

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

body {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--parchment);
    color: var(--midnight);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 240px;
    height: 100vh;
    background: var(--midnight);
    color: var(--white);
    padding: 20px 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-logo {
    padding: 16px 20px 12px;
}

.sidebar-logo img {
    width: 140px;
    height: auto;
    display: block;
}

.project-selector {
    display: flex;
    padding: 0 10px;
    gap: 4px;
    margin-bottom: 8px;
}

.project-option {
    flex: 1;
    padding: 6px 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-400);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.15s;
}

.project-option.active {
    background: var(--midnight-light);
    color: var(--parchment);
}

.project-option:hover {
    color: var(--parchment);
}

.sidebar .project-name {
    font-family: 'Cormorant Garamond', serif;
    font-size: 16px;
    font-weight: 500;
    padding: 0 20px 16px;
    color: var(--copper);
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--midnight-light);
    margin-bottom: 15px;
}

.sidebar nav a {
    display: block;
    padding: 10px 20px;
    color: var(--gray-400);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
}

.sidebar nav a:hover, .sidebar nav a.active {
    background: var(--midnight-light);
    color: var(--parchment);
}

.sidebar nav .section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--copper);
    padding: 15px 20px 5px;
    font-weight: 600;
}

.sidebar-user {
    margin-top: 20px;
    padding: 16px 20px;
    border-top: 1px solid var(--midnight-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-username {
    font-size: 13px;
    color: var(--gray-400);
    font-weight: 500;
}

.sidebar-logout {
    font-size: 12px;
    color: var(--gray-600);
    text-decoration: none;
    transition: color 0.15s;
}

.sidebar-logout:hover {
    color: var(--white);
}

.main {
    margin-left: 240px;
    padding: 30px 40px;
    min-height: 100vh;
}

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

.page-header h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 28px;
    font-weight: 500;
    color: var(--midnight);
}

/* Cards */
.card {
    background: var(--white);
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    padding: 24px;
    margin-bottom: 20px;
}

.card h3 {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--copper);
    margin-bottom: 15px;
    font-weight: 600;
}

/* KPI row */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi {
    background: var(--white);
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    padding: 20px;
}

.kpi .label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--slate);
    margin-bottom: 4px;
    font-weight: 600;
}

.kpi .value {
    font-family: 'Cormorant Garamond', serif;
    font-size: 30px;
    font-weight: 600;
    color: var(--midnight);
}

.kpi .value.positive { color: var(--green); }
.kpi .value.negative { color: var(--red); }
.kpi .value.warning { color: var(--yellow); }
.kpi .value.muted { color: var(--gray-600); font-size: 22px; }

.kpi-detail {
    font-size: 11px;
    color: var(--gray-600);
    margin-top: 4px;
    font-weight: 400;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: fixed;
}

table.aligned {
    table-layout: auto;
}

thead th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--sandstone);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--slate);
    white-space: nowrap;
    font-weight: 600;
}

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

tbody td:last-child {
    white-space: normal;
    word-break: break-word;
    max-width: 400px;
}

tbody tr:hover { background: var(--gray-100); }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-mono { font-family: "SF Mono", "Fira Code", monospace; font-size: 13px; }

.total-row td {
    font-weight: 700;
    border-top: 2px solid var(--midnight);
    border-bottom: none;
    padding-top: 12px;
}

/* Budget bar */
.budget-bar {
    width: 100%;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

.budget-bar .fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.budget-bar .fill.ok { background: var(--verdigris); }
.budget-bar .fill.warn { background: var(--copper); }
.budget-bar .fill.over { background: var(--red); }

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--slate);
    margin-bottom: 4px;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

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

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--midnight);
    color: var(--parchment);
}

.btn-primary:hover { background: var(--midnight-light); }

.btn-secondary {
    background: var(--white);
    color: var(--slate);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover { background: var(--gray-100); }

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

.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

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

/* Flash messages */
.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
}

.flash.success { background: var(--green-light); color: var(--green); border: 1px solid var(--green); }
.flash.warning { background: var(--yellow-light); color: var(--yellow); border: 1px solid var(--yellow); }
.flash.error { background: var(--red-light); color: var(--red); border: 1px solid var(--red); }

/* Status badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-pending { background: var(--yellow-light); color: var(--yellow); }
.badge-approved { background: var(--blue-light); color: var(--blue); }
.badge-funded { background: var(--green-light); color: var(--green); }
.badge-rejected { background: var(--red-light); color: var(--red); }

/* Journal entry lines table */
.lines-table { margin-top: 10px; }
.lines-table input, .lines-table select {
    padding: 6px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 13px;
}
.lines-table select { min-width: 200px; }
.lines-table .money-input { width: 120px; text-align: right; font-family: "SF Mono", monospace; }

/* Pagination */
.pagination {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    justify-content: center;
}

.pagination a, .pagination span {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    text-decoration: none;
}

.pagination a { color: var(--navy); border: 1px solid var(--gray-300); }
.pagination a:hover { background: var(--gray-100); }
.pagination .current { background: var(--navy); color: var(--white); }

/* Print */
@media print {
    .sidebar { display: none !important; }
    .main { margin-left: 0 !important; padding: 20px !important; }
    .no-print { display: none !important; }
    .flash { display: none !important; }
    body { background: white; }
    .card { border: 1px solid #ddd; break-inside: avoid; }
    .kpi { border: 1px solid #ddd; }
    a { color: inherit !important; text-decoration: none !important; }
    @page { margin: 0.5in; }
}

/* Responsive */
@media (max-width: 1024px) {
    .main { padding: 24px 20px; }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

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

    .kpi .value {
        font-size: 24px;
    }

    .kpi .value.muted {
        font-size: 18px;
    }

    /* Horizontal scroll for tables */
    .card {
        overflow-x: auto;
    }

    table.aligned {
        min-width: 600px;
    }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main { margin-left: 0; padding: 16px; }

    .kpi-row {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .kpi {
        padding: 14px;
    }

    .kpi .value {
        font-size: 20px;
    }

    .kpi .value.muted {
        font-size: 16px;
    }

    .kpi-detail {
        font-size: 10px;
    }

    .btn-group {
        flex-wrap: wrap;
    }

    table {
        font-size: 13px;
    }

    table.aligned {
        min-width: 500px;
    }

    tbody td {
        padding: 8px 10px;
    }
}
