:root {
    --color-ink: #1b2430;
    --color-teal: #1f6f78;
    --color-teal-dark: #144e55;
    --color-muted: #6b7480;
    --color-border: #dde2e6;
    --color-bg: #f6f7f9;
    --color-error: #b3261e;
    --color-success: #2e7d32;
    font-family: "IBM Plex Sans", -apple-system, Segoe UI, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-ink);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--color-ink);
    color: white;
}

.topbar__row { display: none; }
.topbar__toggle { display: none; }
.topbar__toggle-input { display: none; }
.topbar__collapsible { display: contents; }

.topbar__brand { font-weight: 600; }
.topbar__brand-short { display: none; }

.topbar__nav a {
    color: white;
    text-decoration: none;
    margin-right: 1.25rem;
    opacity: 0.85;
}
.topbar__nav a:hover { opacity: 1; text-decoration: underline; }

.topbar__user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }

.content { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }

.page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.table-wrapper { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; background: white; }
.table th, .table td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.table th { font-size: 0.8rem; text-transform: uppercase; color: var(--color-muted); }
.table--compact td, .table--compact th { padding: 0.4rem 0.6rem; }

.text-right { text-align: right; }
.text-muted { color: var(--color-muted); }

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: white;
    color: var(--color-ink);
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
}
.btn--primary { background: var(--color-teal); border-color: var(--color-teal); color: white; }
.btn--primary:hover { background: var(--color-teal-dark); }
.btn--link { border: none; background: none; text-decoration: underline; padding: 0; color: inherit; }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.75rem; }
.badge--muted { background: var(--color-border); color: var(--color-muted); }
.badge--active { background: #e3f1ec; color: var(--color-success); }

.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert--error { background: #fdecea; color: var(--color-error); }
.alert--success { background: #e8f5e9; color: var(--color-success); }

.form-grid { display: flex; flex-direction: column; gap: 0.6rem; max-width: 420px; }
.form-grid--inline { flex-direction: row; gap: 1rem; max-width: none; }
.form-grid label { font-size: 0.85rem; color: var(--color-muted); }
.form-grid input, .form-grid textarea, input, textarea, select {
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.95rem;
}

.form-grid--wide {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.6rem 1rem;
    max-width: 900px;
}
.form-grid--wide .field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.form-grid--wide .field--full { grid-column: 1 / -1; }
.form-grid--wide label { font-size: 0.85rem; color: var(--color-muted); }
.form-grid--wide input, .form-grid--wide select, .form-grid--wide textarea {
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.95rem;
    width: 100%;
}
.form-grid--wide button { grid-column: 1 / -1; justify-self: start; }

.login-page { display: flex; justify-content: center; padding-top: 3rem; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 0.6rem; }

.reconciliation-group fieldset { border: none; padding: 0; margin: 0.75rem 0; display: flex; gap: 1rem; flex-wrap: wrap; }
.reconciliation-group legend { font-size: 0.85rem; color: var(--color-muted); margin-bottom: 0.35rem; }

.definition-list { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1rem; margin: 0; }
.definition-list dt { color: var(--color-muted); }

.search-form { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* --- Responsive: tablets and phones --- */
@media (max-width: 768px) {
    .topbar {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem 1rem;
    }
    .topbar__row {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .topbar__brand-full { display: none; }
    .topbar__brand-short { display: inline; font-size: 1rem; }
    .topbar__toggle {
        display: block;
        font-size: 1.4rem;
        line-height: 1;
        cursor: pointer;
        padding: 0.25rem 0.5rem;
    }
    .topbar__collapsible {
        display: block;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.2s ease;
    }
    .topbar__toggle-input:checked ~ .topbar__collapsible {
        max-height: 400px;
    }
    .topbar__nav {
        display: flex;
        flex-direction: column;
        padding-top: 0.5rem;
    }
    .topbar__nav a {
        margin-right: 0;
        padding: 0.6rem 0;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
    }
    .topbar__user {
        flex-direction: row;
        justify-content: space-between;
        padding: 0.6rem 0;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
    }

    .content { padding: 1.25rem 1rem; }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }
    .page-header > div { display: flex; flex-wrap: wrap; gap: 0.5rem; }

    .card { padding: 1rem; }

    .form-grid--wide { grid-template-columns: 1fr 1fr; max-width: 100%; }

    .col-hide-mobile { display: none; }

    .search-form { width: 100%; }
    .search-form input[type="search"] { flex: 1 1 auto; min-width: 0; }
}

@media (max-width: 480px) {
    .form-grid--wide { grid-template-columns: 1fr; }
    .form-grid { max-width: 100%; }
    .login-card { max-width: 100%; margin: 0 1rem; }
    .btn { padding: 0.5rem 0.75rem; font-size: 0.85rem; }
    h1 { font-size: 1.3rem; }
}
