/* Work Log — lightweight ledger styling. Mobile-first, no frameworks. */

:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --ink: #1f2933;
    --ink-soft: #52606d;
    --line: #e1e6eb;
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --green: #047857;
    --red: #b91c1c;
    --amber: #b45309;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    font-size: 16px;
}

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

/* ---- Layout ----------------------------------------------------------- */
.container {
    max-width: 1040px;
    margin: 0 auto;
    padding: 20px 16px 48px;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.topbar-inner {
    max-width: 1040px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--ink);
}
.brand:hover { text-decoration: none; }
.mainnav {
    display: flex;
    gap: 4px;
    flex: 1;
    flex-wrap: wrap;
}
.mainnav a {
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--ink-soft);
    font-size: .95rem;
}
.mainnav a:hover { background: var(--bg); text-decoration: none; }
.mainnav a.active { background: var(--brand); color: #fff; }

.userbox { display: flex; align-items: center; gap: 10px; }
.who { font-size: .9rem; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.role-tag {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.sitefooter {
    border-top: 1px solid var(--line);
    color: var(--ink-soft);
    padding: 16px;
    text-align: center;
}

/* ---- Headings & sections --------------------------------------------- */
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 28px 0 12px; }
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.subtitle { color: var(--ink-soft); margin: 0 0 16px; }

/* ---- Summary cards ---------------------------------------------------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin: 16px 0 8px;
}
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}
.card .label {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-soft);
    margin-bottom: 6px;
}
.card .value { font-size: 1.5rem; font-weight: 700; }
.card.is-due .value { color: var(--red); }
.card.is-paid .value { color: var(--green); }
.card.is-clear .value { color: var(--green); }

/* ---- Tables ----------------------------------------------------------- */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}
table.ledger {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
}
table.ledger th, table.ledger td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.ledger td.wrap { white-space: normal; min-width: 220px; }
table.ledger thead th {
    background: #f8fafc;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--ink-soft);
}
table.ledger tbody tr:hover { background: #fafbfc; }
table.ledger .num { text-align: right; font-variant-numeric: tabular-nums; }
table.ledger tfoot td {
    font-weight: 700;
    background: #f8fafc;
    border-top: 2px solid var(--line);
}
.empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--ink-soft);
}

/* ---- Buttons & forms -------------------------------------------------- */
.btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: .92rem;
    cursor: pointer;
    background: var(--brand);
    color: #fff;
    font-family: inherit;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #991b1b; }
.btn-sm { padding: 4px 10px; font-size: .82rem; }

.row-actions { display: flex; gap: 6px; }
.row-actions form { display: inline; margin: 0; }

form.card-form, .panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 20px;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field.full { grid-column: 1 / -1; }
label { font-size: .85rem; color: var(--ink-soft); font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=month], input[type=search], select, textarea {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 10px;
    font-size: .95rem;
    font-family: inherit;
    background: #fff;
    color: var(--ink);
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--brand);
    outline-offset: 0;
    border-color: var(--brand);
}
textarea { min-height: 64px; resize: vertical; }
.form-actions { margin-top: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---- Toolbar (filters/search) ---------------------------------------- */
.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 16px;
}
.toolbar .field { min-width: 150px; }
.toolbar-spacer { flex: 1; }

/* ---- Flash / alerts --------------------------------------------------- */
.flash {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    font-size: .95rem;
}
.flash-success { background: #ecfdf5; border-color: #a7f3d0; color: var(--green); }
.flash-error   { background: #fef2f2; border-color: #fecaca; color: var(--red); }

/* ---- Login ------------------------------------------------------------ */
.login-wrap {
    max-width: 380px;
    margin: 8vh auto 0;
    padding: 0 16px;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px;
}
.login-card h1 { text-align: center; margin-bottom: 18px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; }
.muted { color: var(--ink-soft); font-size: .88rem; }

.client-switch select { width: auto; }

/* ---- Print statement -------------------------------------------------- */
@media print {
    .topbar, .sitefooter, .no-print, .toolbar, .row-actions { display: none !important; }
    body { background: #fff; }
    .container { max-width: none; padding: 0; }
    .table-wrap, .card, .panel { box-shadow: none; border-color: #ccc; }
    a { color: inherit; text-decoration: none; }
}
