/* ==========================================================================
   TDC Accounts
   Built around dense, printable accounting tables. Brand red #e20c0c and
   near-black #1e1d1d are carried over from thedailycampus.com.
   ========================================================================== */

:root {
    --brand:        #e20c0c;
    --brand-dark:   #b80a0a;
    --brand-soft:   #fdecec;

    --ink:          #1e1d1d;
    --ink-2:        #4a4747;
    --ink-3:        #746f6f;
    --ink-4:        #9c9797;

    --bg:           #f4f5f7;
    --surface:      #ffffff;
    --surface-2:    #fafafa;
    --line:         #e3e4e8;
    --line-strong:  #c9ccd3;

    --in:           #0b7a4b;
    --in-soft:      #e8f5ef;
    --out:          #c62828;
    --out-soft:     #fdeaea;
    --warn:         #b26a00;
    --warn-soft:    #fdf2e2;
    --info:         #1d4ed8;
    --info-soft:    #e8eeff;

    --radius:       8px;
    --radius-sm:    5px;
    --shadow:       0 1px 2px rgba(30, 29, 29, .06), 0 1px 3px rgba(30, 29, 29, .04);
    --shadow-lg:    0 4px 14px rgba(30, 29, 29, .10);

    --sidebar-w:    228px;
    --topbar-h:     56px;

    --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
    --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

/* ---------------------------------------------------------------- shell */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--ink);
    color: #d8d5d5;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar__mark {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    display: grid;
    place-items: center;
    letter-spacing: -.5px;
}

.sidebar__name { font-size: 13px; font-weight: 600; color: #fff; line-height: 1.2; }
.sidebar__sub  { font-size: 11px; color: var(--ink-4); }

.nav { padding: 10px 0 24px; }
.nav__group { margin-top: 14px; }
.nav__label {
    padding: 0 18px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #6f6a6a;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 18px;
    color: #cfcbcb;
    font-size: 13px;
    border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; text-decoration: none; }
.nav a.is-active {
    background: rgba(226, 12, 12, .14);
    border-left-color: var(--brand);
    color: #fff;
    font-weight: 500;
}
.nav .ico { width: 16px; text-align: center; opacity: .85; font-size: 13px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar__title { font-size: 15px; font-weight: 600; }
.topbar__spacer { flex: 1; }
.topbar__user { font-size: 12px; color: var(--ink-3); }
.topbar__user strong { color: var(--ink); font-weight: 600; }

.content { padding: 20px; flex: 1; }
.content > * + * { margin-top: 16px; }

/* ---------------------------------------------------------------- cards */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
}
.card__head h2 { font-size: 14px; }
.card__head .spacer { flex: 1; }
.card__body { padding: 16px; }
.card__foot {
    padding: 10px 16px;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    font-size: 12px;
    color: var(--ink-3);
}

/* ---------------------------------------------------------------- tiles */

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}
.tile__label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--ink-3);
}
.tile__value {
    font-family: var(--mono);
    font-size: 22px;
    font-weight: 600;
    margin-top: 5px;
    letter-spacing: -.4px;
}
.tile__note { font-size: 11px; color: var(--ink-4); margin-top: 3px; }
.tile--in  .tile__value { color: var(--in); }
.tile--out .tile__value { color: var(--out); }
.tile--brand .tile__value { color: var(--brand); }

/* --------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.data th,
table.data td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

table.data thead th {
    background: var(--surface-2);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink-3);
    white-space: nowrap;
    border-bottom: 1px solid var(--line-strong);
    position: sticky;
    top: 0;
    z-index: 1;
}

table.data tbody tr:hover { background: #fbfbfc; }
table.data tbody tr:last-child td { border-bottom: none; }

table.data td.num,
table.data th.num {
    text-align: right;
    font-family: var(--mono);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
table.data td.mid, table.data th.mid { text-align: center; }
table.data td.tight { white-space: nowrap; }
table.data .sl { color: var(--ink-4); width: 1%; font-family: var(--mono); font-size: 12px; }

table.data tfoot td {
    font-weight: 700;
    background: var(--surface-2);
    border-top: 2px solid var(--line-strong);
    border-bottom: none;
}

table.data tr.group td {
    background: #f0f1f4;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-2);
}

table.data tr.total td {
    font-weight: 700;
    background: var(--surface-2);
}

.amount-in  { color: var(--in);  font-weight: 600; }
.amount-out { color: var(--out); font-weight: 600; }
.amount-zero { color: var(--ink-4); }

.empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--ink-3);
}
.empty__icon { font-size: 26px; opacity: .35; }
.empty p { margin: 8px 0 0; }

/* --------------------------------------------------------------- badges */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}
.badge--good  { background: var(--in-soft);   color: var(--in); }
.badge--bad   { background: var(--out-soft);  color: var(--out); }
.badge--warn  { background: var(--warn-soft); color: var(--warn); }
.badge--info  { background: var(--info-soft); color: var(--info); }
.badge--muted { background: #eeeff2;          color: var(--ink-3); }

/* -------------------------------------------------------------- buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 13px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-4); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.btn--primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn--dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn--dark:hover { background: #000; border-color: #000; }

.btn--danger { color: var(--out); border-color: #eab8b8; }
.btn--danger:hover { background: var(--out-soft); border-color: var(--out); }

.btn--sm { padding: 4px 9px; font-size: 12px; }
.btn--icon { padding: 5px 8px; }

.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------------------------------------------------------------- forms */

.field { margin-bottom: 14px; }
.field > label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 5px;
}
.field .hint { font-size: 11px; color: var(--ink-4); margin-top: 4px; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="email"], input[type="search"], select, textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: inherit;
    font-size: 13px;
    color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(226, 12, 12, .10);
}
input[readonly], input:disabled, select:disabled {
    background: var(--surface-2);
    color: var(--ink-3);
}
textarea { resize: vertical; min-height: 70px; line-height: 1.5; }

input.num, td input.num { text-align: right; font-family: var(--mono); }

.check { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.check input { width: auto; }

.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* --------------------------------------------------------------- filter */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}
.filters .field { margin: 0; }
.filters .field > label { font-size: 11px; }
.filters select, .filters input { min-width: 130px; }
.filters .grow { flex: 1; min-width: 170px; }

/* --------------------------------------------------------------- alerts */

.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid;
    font-size: 13px;
}
.alert--ok    { background: var(--in-soft);   border-color: #b6ddc9; color: #075c38; }
.alert--error { background: var(--out-soft);  border-color: #f0b9b9; color: #8f1f1f; }
.alert--warn  { background: var(--warn-soft); border-color: #eccf9d; color: #7d4a00; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* --------------------------------------------------------------- layout */

.page-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    flex-wrap: wrap;
}
.page-head__text { flex: 1; min-width: 200px; }
.page-head p { margin: 3px 0 0; font-size: 12px; color: var(--ink-3); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.split--wide-left { grid-template-columns: 1.6fr 1fr; }

@media (max-width: 1000px) {
    .split, .split--wide-left { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
    .sidebar {
        position: static;
        width: 100%;
        flex: none;
        height: auto;
    }
    .shell { flex-direction: column; }
    .nav { display: flex; flex-wrap: wrap; padding: 8px; gap: 2px; }
    .nav__group { margin: 0; display: contents; }
    .nav__label { display: none; }
    .nav a { border-left: none; border-radius: 5px; padding: 6px 10px; }
    .nav a.is-active { border-left: none; }
    .content { padding: 14px; }
}

/* ---------------------------------------------------------------- login */

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: var(--ink);
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border-radius: 10px;
    padding: 28px;
    box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 18px; text-align: center; }
.login-card .sub { text-align: center; color: var(--ink-3); font-size: 12px; margin: 4px 0 20px; }
.login-mark {
    width: 46px; height: 46px;
    margin: 0 auto 14px;
    border-radius: 10px;
    background: var(--brand);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700; font-size: 17px;
}

/* --------------------------------------------------------------- charts */

.bars { display: flex; align-items: flex-end; gap: 10px; height: 130px; padding-top: 8px; }
.bars__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.bars__pair { display: flex; align-items: flex-end; gap: 3px; height: 100px; width: 100%; justify-content: center; }
.bars__bar { width: 14px; border-radius: 2px 2px 0 0; min-height: 2px; }
.bars__bar--in  { background: var(--in); }
.bars__bar--out { background: var(--out); }
.bars__label { font-size: 10px; color: var(--ink-3); white-space: nowrap; }

.legend { display: flex; gap: 14px; font-size: 11px; color: var(--ink-3); }
.legend span::before {
    content: "";
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 2px;
    margin-right: 5px;
}
.legend .in::before  { background: var(--in); }
.legend .out::before { background: var(--out); }

.meter { height: 5px; background: #eceef1; border-radius: 3px; overflow: hidden; margin-top: 5px; }
.meter span { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

/* --------------------------------------------------------- print sheets */

.sheet {
    background: #fff;
    color: #000;
    max-width: 900px;
    margin: 0 auto;
    padding: 26px 30px;
}
.sheet--wide { max-width: 1150px; }

.sheet__head { text-align: center; margin-bottom: 16px; }
.sheet__logo { max-height: 56px; margin-bottom: 8px; }
.sheet__company { font-size: 19px; font-weight: 700; letter-spacing: .01em; }
.sheet__meta { font-size: 11px; color: #444; margin-top: 2px; line-height: 1.45; }
.sheet__title {
    margin-top: 12px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
    padding: 5px 0;
}

table.sheet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-top: 12px;
}
table.sheet-table th, table.sheet-table td {
    border: 1px solid #999;
    padding: 5px 7px;
    vertical-align: top;
}
table.sheet-table thead th {
    background: #eee;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    text-align: left;
}
table.sheet-table td.num, table.sheet-table th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
table.sheet-table tr.total td { font-weight: 700; background: #f4f4f4; }
table.sheet-table tr.group td { background: #e8e8e8; font-weight: 700; }

.sheet__sign {
    margin-top: 46px;
    display: flex;
    justify-content: space-between;
    gap: 30px;
    font-size: 12px;
}
.sheet__sign div { text-align: center; min-width: 170px; }
.sheet__sign .line { border-top: 1px solid #000; padding-top: 4px; }

.print-bar {
    max-width: 900px;
    margin: 14px auto;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Invoice specifics */
.inv__top { display: flex; justify-content: space-between; gap: 24px; margin-top: 14px; }
.inv__party { font-size: 12px; line-height: 1.55; }
.inv__party .label {
    font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
    color: #666; margin-bottom: 3px;
}
.inv__party .who { font-weight: 700; font-size: 13px; }
.inv__facts { font-size: 12px; }
.inv__facts table { border-collapse: collapse; }
.inv__facts td { padding: 2px 0 2px 12px; }
.inv__facts td:first-child { padding-left: 0; color: #666; }

.inv__totals { margin-left: auto; width: 290px; font-size: 12px; margin-top: 10px; }
.inv__totals table { width: 100%; border-collapse: collapse; }
.inv__totals td { padding: 4px 8px; border: 1px solid #999; }
.inv__totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.inv__totals tr.grand td { font-weight: 700; background: #eee; font-size: 13px; }

.inv__words {
    margin-top: 12px;
    font-size: 12px;
    border: 1px solid #999;
    padding: 7px 9px;
    background: #fafafa;
}
.inv__words .label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #666; }

.inv__bank {
    margin-top: 14px;
    font-size: 11.5px;
    white-space: pre-line;
    border: 1px solid #999;
    padding: 8px 10px;
}
.inv__bank .label {
    font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
    color: #666; margin-bottom: 3px; white-space: normal;
}
.inv__foot { margin-top: 18px; font-size: 11px; color: #555; text-align: center; }

/* --------------------------------------------------------------- print */

@media print {
    body { background: #fff; }
    .sidebar, .topbar, .print-bar, .no-print { display: none !important; }
    .shell { display: block; }
    .content { padding: 0; }
    .card { border: none; box-shadow: none; }
    .sheet { max-width: none; padding: 0; }
    table.sheet-table thead { display: table-header-group; }
    table.sheet-table tr { page-break-inside: avoid; }
    a { color: #000; text-decoration: none; }
    @page { margin: 12mm; }
}

/* ----------------------------------------------------------- dark mode */

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ink:         #ececec;
        --ink-2:       #c9c6c6;
        --ink-3:       #9a9595;
        --ink-4:       #746f6f;
        --bg:          #171717;
        --surface:     #1f1f1f;
        --surface-2:   #262626;
        --line:        #333;
        --line-strong: #444;
        --brand-soft:  #2a1414;
        --in-soft:     #12271e;
        --out-soft:    #2a1616;
        --warn-soft:   #2a2113;
        --info-soft:   #16203a;
        --in:          #4ec48c;
        --out:         #f27272;
        --warn:        #e0a54a;
        --info:        #7ea2ff;
    }
    :root:not([data-theme="light"]) table.data tbody tr:hover { background: #242424; }
    :root:not([data-theme="light"]) table.data tr.group td { background: #2c2c2c; }
    :root:not([data-theme="light"]) .badge--muted { background: #2e2e2e; }
    :root:not([data-theme="light"]) .meter { background: #2e2e2e; }
    /* Printable sheets stay on white paper regardless of the screen theme. */
    :root:not([data-theme="light"]) .sheet { background: #fff; color: #000; }
}
