/* ============================================
   SixBudzet — brand palette
   black  #000000   white #ffffff
   graphite #3b434f  gold #f7bd2c
   ============================================ */
:root {
    --black:    #000000;
    --white:    #ffffff;
    --graphite: #3b434f;
    --graphite-light: #4d5765;
    --gold:     #f7bd2c;
    --text-dim: #b8bec7;
    --danger:   #e05252;
    --tomek:    #b388ff;
    --border:   rgba(247, 189, 44, 0.25);
    --glass-border: rgba(247, 189, 44, 0.25);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--black);
    color: var(--white);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
}

/* ---------- Header / nav ---------- */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem 1.5rem;
    padding: 1rem 2rem;
    border-bottom: 2px solid var(--gold);
    background: var(--black);
}
header .logo a { color: var(--white); text-decoration: none; display: inline-flex; align-items: center; }
header .logo .site-logo { height: 44px; width: auto; display: block; }
nav { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: center; justify-content: flex-end; }
nav a {
    color: var(--white);
    text-decoration: none;
    padding: .45rem .9rem;
    border-radius: 6px;
    transition: color .15s, background .15s;
}
nav a:hover { color: var(--gold); background: var(--graphite); }

main { width: 100%; padding: 1.5rem 2rem; }
.main-content { width: 100%; padding: 1.5rem 2rem; }
.container { width: 100%; max-width: none; margin: 0; padding: 0; }

/* ---------- Panels ---------- */
.glass-panel {
    background: var(--graphite);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}
.glass-panel h2, .glass-panel h3 { color: var(--white); margin-top: 0; }

.dashboard-header h2 { color: var(--gold); }
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
    gap: 1.5rem;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: .5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    font-size: .95rem;
    transition: filter .15s, background .15s;
    background: var(--gold);
    color: var(--black);
    border: 1px solid var(--gold);
    font-weight: 700;
}
.btn:hover { filter: brightness(1.12); }
.btn-primary {
    background: var(--gold);
    color: var(--black);
    border: 1px solid var(--gold);
    font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.12); }
.btn-secondary {
    background: transparent;
    color: var(--white);
    border: 1px solid var(--graphite-light);
}
.btn-secondary:hover { background: var(--graphite); border-color: var(--gold); color: var(--gold); }

/* ---------- Alerts ---------- */
.flashes { margin-bottom: 1rem; }
.alert {
    padding: .75rem 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--gold);
    background: var(--graphite);
    color: var(--white);
}
.alert-danger  { border-left-color: var(--danger); }
.alert-warning { border-left-color: #e0a52c; }
.alert-success { border-left-color: var(--gold); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1rem; }
label { color: var(--text-dim); display: block; margin-bottom: .3rem; }
input, select, textarea {
    width: 100%;
    padding: .55rem .75rem;
    border-radius: 6px;
    border: 1px solid var(--graphite-light);
    background: var(--black);
    color: var(--white);
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
}
.forecast-input { max-width: 220px; }

.login-container {
    max-width: 380px;
    margin: 4rem auto;
    background: var(--graphite);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
}
.login-container input { margin-bottom: 1rem; }

/* ---------- Tables ---------- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
th {
    background: var(--graphite);
    color: var(--gold);
    text-align: left;
    padding: .6rem .7rem;
    border-bottom: 1px solid rgba(255,255,255,.09);
    white-space: nowrap;
}
td {
    padding: .55rem .7rem;
    border-bottom: 1px solid rgba(255,255,255,.055);
    color: var(--white);
}
tbody tr:hover td { background: rgba(59, 67, 79, .55); }

/* ---------- Detailed report tables ---------- */
.detailed-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .84rem;
}
.detailed-table th,
.detailed-table td {
    padding: .52rem .68rem;
    border-bottom: 1px solid rgba(255, 255, 255, .055);
    white-space: nowrap;
    vertical-align: middle;
}
.detailed-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #2f363f;
    color: var(--gold);
    font-size: .67rem;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255, 255, 255, .09);
}
.detailed-table th:not(:first-child),
.detailed-table td:not(:first-child) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.detailed-table th:first-child,
.detailed-table td:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--graphite);
}
.detailed-table thead th:first-child {
    z-index: 4;
    background: #2f363f;
}
.detailed-table tbody tr:hover td { background: rgba(255, 255, 255, .035); }
.detailed-table tbody tr:hover td:first-child { background: #424b58; }

.detailed-table td.numeric,
td[style*="font-weight: bold"] { font-variant-numeric: tabular-nums; }

/* Category / client rows in the detailed analysis */
.detailed-table .category-row.income td { background: rgba(247, 189, 44, .055); }
.detailed-table .category-row.expense td { background: rgba(224, 82, 82, .05); }
.detailed-table .category-row.income td:first-child {
    background: #474438;
    color: var(--gold);
    font-weight: 600;
}
.detailed-table .category-row.expense td:first-child {
    background: #463a3d;
    color: var(--danger);
    font-weight: 600;
}
.detailed-table .client-row td { color: var(--text-dim); }
.detailed-table .tomek-row td { color: var(--tomek) !important; }
.detailed-table .tomek-row td:first-child {
    background: #3f3a4d;
    box-shadow: inset 3px 0 0 var(--tomek);
}

.text-positive { color: var(--gold); }
.text-negative { color: var(--danger); }

/* Documents list: mixed text/number columns */
.documents-table-wrap { max-height: 72vh; overflow: auto; }
.documents-table th:not(:first-child),
.documents-table td:not(:first-child) { text-align: left; }
.documents-table th.num,
.documents-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.documents-table td.cat-cell { color: var(--text-dim); }
td.cat-cell.tomek { color: var(--tomek); font-weight: 600; }

/* Analysis: dense month grid */
.analysis-table { font-size: .8rem; }
.analysis-table th,
.analysis-table td { padding: .45rem .5rem; }

/* Detailed income/expense: compact, truncated client names with tooltip */
.clients-table th:first-child,
.clients-table td:first-child {
    width: 220px;
    min-width: 220px;
    max-width: 220px;
}
.clients-table .name-cell { overflow: hidden; }
.clients-table .cell-truncate {
    display: block;
    max-width: 195px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.clients-table .client-name .cell-truncate { max-width: 175px; }

@media (max-width: 768px) {
    .clients-table th:first-child,
    .clients-table td:first-child {
        width: 160px;
        min-width: 160px;
        max-width: 160px;
    }
    .clients-table .cell-truncate { max-width: 140px; }
    .clients-table .client-name .cell-truncate { max-width: 120px; }
}


/* Forecast tables */
.forecast-table .first-col {
    width: 240px;
    min-width: 240px;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.forecast-table .client-label { padding-left: 2rem; color: var(--text-dim); }
.forecast-table .forecast-input { text-align: right; }

/* ---------- Misc ---------- */
h1, h2, h3 { color: var(--white); }
a { color: var(--gold); }
canvas { max-width: 100%; }

/* ---------- Wide tables ---------- */
/* Panels that hold a wide table scroll horizontally instead of pushing the
   whole page off-screen. */
.glass-panel { max-width: 100%; }
.table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---------- Responsive ---------- */
html, body { max-width: 100%; overflow-x: hidden; }

@media (max-width: 1024px) {
    main { padding: 1rem; }
    .glass-panel { padding: 1rem; }
    .dashboard-grid > .glass-panel { grid-column: auto !important; }
}

@media (max-width: 768px) {
    header { flex-wrap: wrap; gap: .5rem 1rem; padding: 1rem; }
    header .logo .site-logo { height: 34px; }
    nav { flex-wrap: wrap; gap: .25rem .5rem; width: 100%; }
    nav a { font-size: .9rem; padding: .35rem .6rem; }
    nav a.btn { margin-left: 0 !important; }

    main { padding: .75rem; }
    .glass-panel { padding: .85rem; border-radius: 8px; }
    .dashboard-header { flex-direction: column; align-items: flex-start !important; gap: .75rem; }
    .dashboard-header > div { width: 100%; }
    .dashboard-header div { flex-wrap: wrap; }

    h2 { font-size: 1.2rem; }
    h3 { font-size: 1rem; }
    table { font-size: .8rem; }
    th, td { padding: .4rem .5rem; }
    .detailed-table thead th:first-child { min-width: 140px; }
}

@media (max-width: 480px) {
    table { font-size: .72rem; }
    th, td { padding: .3rem .4rem; }
    .detailed-table thead th:first-child { min-width: 110px; }
}
