:root {
    color-scheme: light;

    --ink: #15171c;
    --ink-soft: #262932;
    --ink-softer: #383c47;
    --paper: #f5f3ee;
    --surface: #ffffff;
    --border: #e4e0d7;
    --border-soft: #edeae2;
    --text: #1c1e24;
    --text-muted: #6d7078;

    --accent: #c1622b;
    --accent-hover: #a8511f;
    --accent-soft: #f6e5d6;
    --accent-ink: #7a3c15;

    --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

    --status-synced-bg: #e3f4e9;
    --status-synced-text: #1f7a43;
    --status-pending-bg: #eceef2;
    --status-pending-text: #4b5563;
    --status-retry-bg: #e2edfc;
    --status-retry-text: #2758a6;
    --status-mapping_error-bg: #fcefd7;
    --status-mapping_error-text: #9a5b06;
    --status-moco_locked-bg: #f1e5fb;
    --status-moco_locked-text: #7238ab;
    --status-auth_error-bg: #fbe2e1;
    --status-auth_error-text: #b3261e;
    --status-failed-bg: #fbe2e1;
    --status-failed-text: #b3261e;
    --status-deleted-bg: #eceef2;
    --status-deleted-text: #6b7280;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 13.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

/* ---------- Login ---------- */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 20%, rgba(193, 98, 43, 0.16), transparent 45%),
        var(--ink);
}

.login-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 40px 36px;
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.45);
}

.login-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: var(--ink);
    color: #fff;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.02em;
}

.login-form h1 {
    font-size: 17px;
    font-weight: 600;
    margin: 4px 0 0;
}

.login-form p.sub {
    margin: -10px 0 4px;
    color: var(--text-muted);
    font-size: 12.5px;
}

.login-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-muted);
}

.error {
    color: var(--status-failed-text);
    background: var(--status-failed-bg);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12.5px;
    margin: 0;
}

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

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

.sidebar {
    width: 216px;
    flex-shrink: 0;
    background: var(--ink);
    color: #dcdde2;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 14px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.brand-text strong {
    font-size: 13.5px;
    color: #fff;
    font-weight: 600;
}

.brand-text span {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: #8b8e98;
    letter-spacing: 0.02em;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.nav-link {
    display: block;
    padding: 9px 12px;
    border-radius: 7px;
    color: #b7b9c2;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
}

.nav-link:hover {
    background: var(--ink-soft);
    color: #fff;
}

.nav-link.is-active {
    background: var(--ink-softer);
    color: #fff;
    box-shadow: inset 2px 0 0 var(--accent);
}

.nav-logout {
    display: block;
    padding: 9px 12px;
    border-radius: 7px;
    color: #8b8e98;
    text-decoration: none;
    font-size: 12.5px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 10px;
    padding-top: 14px;
}

.nav-logout:hover {
    color: #fff;
}

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

.topbar {
    padding: 26px 32px 18px;
}

.topbar h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.topbar-subtitle {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 12.5px;
    font-family: var(--font-mono);
}

main {
    padding: 0 32px 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1040px;
}

/* ---------- Cards & sections ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 22px;
}

.card-title {
    margin: 0 0 14px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card + .card {
    margin-top: 0;
}

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

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

.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
}

.kpi .kpi-value {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 600;
    line-height: 1.1;
}

.kpi .kpi-label {
    margin-top: 6px;
    font-size: 11.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ---------- Tables ---------- */

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

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

th, td {
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
}

th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tr:last-child td {
    border-bottom: none;
}

td.mono, th.mono {
    font-family: var(--font-mono);
}

.empty-row td {
    color: var(--text-muted);
    font-style: italic;
    white-space: normal;
}

.cell-primary {
    font-weight: 500;
    white-space: normal;
}

.cell-secondary {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}

td.wrap {
    white-space: normal;
    max-width: 320px;
}

/* ---------- Badges ---------- */

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    background: var(--status-pending-bg);
    color: var(--status-pending-text);
}

.badge-synced { background: var(--status-synced-bg); color: var(--status-synced-text); }
.badge-pending { background: var(--status-pending-bg); color: var(--status-pending-text); }
.badge-retry { background: var(--status-retry-bg); color: var(--status-retry-text); }
.badge-mapping_error { background: var(--status-mapping_error-bg); color: var(--status-mapping_error-text); }
.badge-moco_locked { background: var(--status-moco_locked-bg); color: var(--status-moco_locked-text); }
.badge-auth_error { background: var(--status-auth_error-bg); color: var(--status-auth_error-text); }
.badge-failed { background: var(--status-failed-bg); color: var(--status-failed-text); }
.badge-deleted { background: var(--status-deleted-bg); color: var(--status-deleted-text); }

/* ---------- Forms ---------- */

form.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
}

label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

input, select {
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
    font-family: var(--font-sans);
    background: var(--surface);
    color: var(--text);
    min-width: 160px;
}

input:focus, select:focus {
    outline: 2px solid var(--accent-soft);
    outline-offset: 1px;
    border-color: var(--accent);
}

select option[hidden] {
    display: none;
}

button {
    padding: 8px 16px;
    border: none;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-sans);
    transition: background 0.12s ease;
}

button:hover {
    background: var(--accent-hover);
}

button.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

button.btn-ghost:hover {
    background: var(--paper);
    color: var(--text);
}

.btn-ghost-link {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
}

.btn-ghost-link:hover {
    background: var(--paper);
    color: var(--text);
}

.btn-ghost-link.is-active {
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.row-form {
    display: inline-flex;
    margin: 0;
    padding: 0;
    border: none;
}

/* ---------- Flash & hints ---------- */

.flash {
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    color: var(--accent-ink);
    padding: 10px 14px;
    border-radius: 9px;
    font-size: 13px;
}

.hint {
    color: var(--text-muted);
    font-size: 12px;
    margin: 6px 0 0;
}

/* Tooltip-Icon statt Fließtext unter Formularfeldern — verändert nie die
   Zeilenhöhe des Labels, damit unterschiedlich lange Hinweise die Formularzeile
   nicht ungleichmäßig verschieben. */
.hint-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    cursor: help;
    margin-left: 5px;
    flex-shrink: 0;
}

.fetch-warning {
    background: var(--status-mapping_error-bg);
    color: var(--status-mapping_error-text);
    border-radius: 9px;
    padding: 10px 14px;
    font-size: 12.5px;
    margin-bottom: 14px;
}
