:root {
    /* Theme "harbour" (default). --navy* are the sidebar shades, --amber the accent. */
    --navy: #17324d;
    --navy-2: #1f4266;
    --navy-3: #2a5279;
    --amber: #ff8a65;
    --accent-ink: #3a1a10;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bg: #f4f6f9;
    --card: #ffffff;
    --line: #e4e8ec;
    --text: #1e2a33;
    --muted: #8793a0;
    --chip: #5ab5d1;
    --blue: #2b7fd0;
    --green: #2fb86a;
    --teal: #1fa5a0;
    --red: #e0524a;
    --orange: #e8973a;
    --grey: #a3adb8;
    --input-bg: #ffffff;
    --hover: #f8fafb;
    --subtle: #fafbfc;
    --ghost-ink: var(--navy);
    --ok-bg: #e9f7ef;
    --ok-line: #bfe5cf;
    --radius: 6px;
    color-scheme: light;
    font-family: var(--font);
    font-size: 15px;
    color: var(--text);
}

:root[data-theme="midnight"] {
    --navy: #1b2240;
    --navy-2: #262f57;
    --navy-3: #33407a;
    --amber: #34d399;
    --accent-ink: #052e1f;
    --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bg: #f3f4f8;
}
:root[data-theme="cobalt"] {
    --navy: #1d3fae;
    --navy-2: #2a52c9;
    --navy-3: #3a62d8;
    --amber: #ffd166;
    --accent-ink: #3d2c00;
    --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bg: #f2f5fb;
}

/* Dark mode: only the neutrals change, so every theme keeps its sidebar and accent. */
:root[data-mode="dark"] {
    --bg: #0e141b;
    --card: #161f29;
    --line: #263241;
    --text: #e2e8ee;
    --muted: #8d9aa8;
    --grey: #6b7785;
    --input-bg: #111922;
    --hover: #1b2633;
    --subtle: #131c25;
    --ghost-ink: #d5e2f0;
    --ok-bg: #12301f;
    --ok-line: #1f5a37;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root[data-mode="auto"] {
        --bg: #0e141b;
        --card: #161f29;
        --line: #263241;
        --text: #e2e8ee;
        --muted: #8d9aa8;
        --grey: #6b7785;
        --input-bg: #111922;
        --hover: #1b2633;
        --subtle: #131c25;
        --ghost-ink: #d5e2f0;
        --ok-bg: #12301f;
        --ok-line: #1f5a37;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
button, input, select, textarea { font-family: inherit; }
body { margin: 0; background: var(--bg); display: flex; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 1.35rem; margin: 0; font-weight: 600; }
h2 { font-size: 1rem; margin: 1.2rem 0 .6rem; font-weight: 600; }
code { background: var(--bg); padding: 1px 4px; border-radius: 3px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* Sidebar */
.sidebar {
    width: 230px; flex-shrink: 0; background: var(--navy); color: #dfe8ee;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; font-weight: 700; font-size: 1.1rem; color: #fff; letter-spacing: .1px; }
.brand .mark {
    width: 30px; height: 30px; border-radius: 8px; background: var(--amber); color: var(--accent-ink);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1rem;
}
.sidebar nav { display: flex; flex-direction: column; padding: 6px 0; flex: 1; overflow-y: auto; }
.sidebar nav a {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 20px; font-size: 1rem; color: #e6eef3; border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: var(--navy-2); }
.sidebar nav a.active { color: var(--amber); border-left-color: var(--amber); background: var(--navy-2); }
.sidebar nav a.add { color: var(--amber); margin-top: 10px; }
.count {
    background: var(--navy-3); color: #fff; font-size: .75rem; padding: 2px 7px;
    border-radius: 4px; min-width: 26px; text-align: center;
}
.sidebar nav a.active .count { background: var(--amber); color: var(--accent-ink); }
.logout { padding: 14px 20px; }
.logout button { background: none; border: 1px solid var(--navy-3); color: #b9c7d1; border-radius: var(--radius); padding: 6px 12px; cursor: pointer; width: 100%; }

main { flex: 1; min-width: 0; padding: 18px 26px 40px; }

/* Toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input, .filters select,
.edit input, .edit select, .edit textarea, .login input, form input[type=number] {
    font: inherit; font-size: .92rem; padding: 7px 10px; border: 1px solid var(--line);
    border-radius: var(--radius); background: var(--input-bg); color: var(--text);
}
.filters input[type=search] { width: 220px; }
.results { margin: 4px 0 10px; font-size: .95rem; }
.badge { background: var(--navy); color: #fff; padding: 2px 8px; border-radius: 4px; font-weight: 600; font-size: .85rem; }

/* List rows */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.list > .row:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.row {
    display: grid; grid-template-columns: 52px minmax(0, 1fr) 120px 110px 80px 64px;
    align-items: center; gap: 12px; padding: 6px 12px; border-bottom: 1px solid var(--line); min-height: 58px;
}
.row:last-child { border-bottom: none; }
a.row:hover { background: var(--hover); }
.row.head {
    min-height: 0; padding: 8px 12px; font-size: .8rem; font-weight: 600; color: var(--muted);
    text-transform: uppercase; letter-spacing: .4px; background: var(--subtle);
}
.row.head > div:nth-child(n+3) { text-align: center; }
.thumb {
    position: relative; width: 44px; height: 44px; border-radius: 4px; background: var(--navy-3);
    display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: .85rem;
}
.thumb img.small { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
.thumb img.big {
    display: none; position: absolute; left: 54px; top: 50%; transform: translateY(-50%); z-index: 30;
    width: 420px; max-width: 60vw; height: auto; border-radius: 6px; background: var(--card);
    box-shadow: 0 8px 28px rgba(11, 37, 51, .35); pointer-events: none;
}
.thumb:hover img.big { display: block; }
@media (hover: none) { .thumb img.big { display: none !important; } }
.title .name { font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title .sub { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.chip {
    background: var(--chip); color: #fff; font-size: .7rem; padding: 1px 6px; border-radius: 3px;
    font-weight: 600; white-space: nowrap; display: inline-block;
}
.chip.plat-kickstarter { background: #05ce78; }
.chip.plat-gamefound { background: #2b2d42; }
.chip.plat-backerkit { background: #2d6cdf; }
.chip.business { background: #7b5cd6; }
.chip.unknown { background: var(--orange); }
.chip.pickup { background: var(--red); }
.chip.contents { background: var(--teal); }
.hint { font-size: .75rem; color: var(--grey); }
.money, .pay, .eta { text-align: center; }
.money .eur { font-weight: 600; }
.money .orig, .pay { color: var(--muted); font-size: .8rem; }
.eta { display: flex; flex-direction: column; line-height: 1.2; }
.eta .when { font-weight: 600; font-size: .85rem; }
.eta .na { color: var(--grey); font-size: .85rem; }
.eta .slip { color: var(--red); font-size: .7rem; font-weight: 600; margin-top: 2px; }
.eta.late .when { color: var(--red); }
.tile {
    min-width: 64px; height: 26px; padding: 0 10px; border-radius: 13px; color: #fff; font-weight: 600; font-size: .75rem;
    display: inline-flex; align-items: center; justify-content: center; justify-self: center; white-space: nowrap;
}
.st-campaign { background: var(--grey); }
.st-pledgemanager { background: var(--orange); }
.st-lockedin { background: var(--blue); }
.st-shipping { background: var(--teal); }
.st-shipped { background: #27a05c; }
.st-received { background: var(--green); }
.st-cancelled { background: #c8ced5; }
.st-late { background: var(--red); }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* Dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: var(--radius); padding: 12px 14px; }
.stat:hover { background: var(--subtle); }
.stat.business { border-left-color: #7b5cd6; }
.stat.warn { border-left-color: var(--red); }
.stat.attention { border-left-color: var(--orange); }
.stat .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin: 2px 0; }
.stat .split { color: var(--muted); font-size: .8rem; }
.columns { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
.list.compact .row { grid-template-columns: 52px minmax(0, 1fr) 110px 80px 64px; }
.list.compact .pay { display: none; }
.actions { list-style: none; padding: 0; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.actions li { padding: 9px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; }
.actions li:last-child { border-bottom: none; }
.actions a { font-weight: 600; }
.actions .muted { font-size: .82rem; }

/* Pickups */
.pickup-group h2 .muted { font-weight: 400; font-size: .85rem; margin-left: 6px; }
.pickups { list-style: none; padding: 0; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.pickups li { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.pickups li:last-child { border-bottom: none; }
.pickups .check {
    width: 34px; height: 34px; flex-shrink: 0; border-radius: 6px; border: 2px solid var(--grey);
    background: var(--card); font-size: 1.1rem; font-weight: 700; color: #fff; cursor: pointer;
}
.pickups li.done .check { background: var(--green); border-color: var(--green); }
.pickups li.done .name { text-decoration: line-through; color: var(--muted); }
.pickups .what { flex: 1; min-width: 0; }
.pickups .name { font-weight: 600; }
.pickups .sub { color: var(--muted); font-size: .8rem; display: flex; gap: 8px; flex-wrap: wrap; }
.pickups .note { font-size: .85rem; margin-top: 2px; }
.pickups .contents { font-size: .85rem; margin-top: 2px; }
.pickups .who { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* Forms */
.button {
    display: inline-block; font: inherit; font-weight: 600; font-size: .92rem; padding: 8px 16px; border-radius: var(--radius);
    border: 1px solid var(--navy); background: var(--navy); color: #fff; cursor: pointer;
}
.button.ghost { background: var(--card); color: var(--ghost-ink); border-color: var(--line); }
.button.danger { background: var(--card); color: var(--red); border-color: var(--red); }
.edit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card h2 { margin-top: 0; }
.edit label, .card label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--muted); margin-bottom: 10px; }
.edit label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.edit input, .edit select, .edit textarea { color: var(--text); width: 100%; }
.edit label.check input { width: auto; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cover { width: 96px; height: 96px; border-radius: 6px; overflow: hidden; background: var(--navy-3); color: #fff; font-weight: 700; font-size: 1.4rem; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-large { display: block; margin-bottom: 12px; }
.cover-large img { display: block; width: 100%; max-height: 320px; object-fit: contain; background: var(--bg); border-radius: 6px; }
.history { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: -4px 0 12px; font-size: .82rem; }
.history .chip { background: var(--bg); color: var(--text); font-weight: 500; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.card.merge { margin-top: 24px; max-width: 760px; }
.import-form { margin-top: 16px; }
.import-form label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--muted); margin-bottom: 10px; max-width: 760px; }
.import-form input, .import-form textarea { font: inherit; font-size: .9rem; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); }
.import-form .form-actions { flex-wrap: wrap; }
.button.bookmarklet { margin: 0 8px 8px 0; background: var(--amber); border-color: var(--amber); color: var(--accent-ink); cursor: grab; }
.steps { padding-left: 18px; line-height: 1.6; }
.preview li > span:first-child { display: flex; gap: 6px; align-items: center; }
.chip.kind-new { background: var(--green); }
.list-card { margin-bottom: 16px; overflow-x: auto; }
table.lists { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.lists th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.lists td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.lists tr.new td { background: var(--subtle); }
table.lists input, table.lists select { font: inherit; font-size: .88rem; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); width: 100%; min-width: 120px; }
table.lists .num { text-align: center; color: var(--muted); }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.row-actions .button { padding: 6px 12px; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.chip.kind-updated { background: var(--blue); }
.chip.kind-skipped { background: var(--red); }
.merge-row { display: flex; gap: 10px; flex-wrap: wrap; }
.merge-row select { flex: 1; min-width: 240px; font: inherit; font-size: .92rem; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.errors { color: var(--red); font-size: .9rem; }
.errors ul { margin: 0 0 10px; }
.message { background: var(--ok-bg); border: 1px solid var(--ok-line); padding: 8px 12px; border-radius: var(--radius); }

/* Login */
.login-page { align-items: center; justify-content: center; background: var(--navy); }
.login { width: 320px; display: flex; flex-direction: column; }
.login .brand { color: var(--text); padding: 0 0 14px; justify-content: center; }
.login .button { margin-top: 6px; }

/* Phone */
@media (max-width: 860px) {
    body { flex-direction: column; }
    .sidebar { width: auto; height: auto; position: sticky; top: 0; z-index: 10; }
    .brand { padding: 10px 14px; font-size: 1rem; }
    .sidebar nav { flex-direction: row; overflow-x: auto; padding: 0 6px 6px; }
    .sidebar nav a { padding: 6px 10px; border-left: none; border-bottom: 2px solid transparent; white-space: nowrap; gap: 6px; font-size: .9rem; }
    .sidebar nav a.active { border-bottom-color: var(--amber); }
    .sidebar nav a.add { margin-top: 0; }
    .logout { display: none; }
    main { padding: 12px 10px 30px; }
    .filters input[type=search] { width: 100%; }
    .filters { width: 100%; }
    .filters select { flex: 1; }
    .row, .list.compact .row {
        grid-template-columns: 44px minmax(0, 1fr) 56px;
        grid-template-areas: "thumb title tile" "thumb meta tile";
        row-gap: 2px;
    }
    .row.head { display: none; }
    .thumb { grid-area: thumb; width: 40px; height: 40px; }
    .title { grid-area: title; }
    .tile { grid-area: tile; min-width: 0; padding: 0 8px; }
    .money, .pay { display: none; }
    .eta { grid-area: meta; flex-direction: row; gap: 4px; align-items: baseline; text-align: left; }
    .eta .when, .eta .na { font-size: .75rem; }
    .eta .slip { margin-top: 0; }
    .columns { grid-template-columns: 1fr; }
    .pair { grid-template-columns: 1fr; gap: 0; }
    .pickups li { flex-wrap: wrap; }
    .pickups .who { width: 100%; justify-content: flex-start; padding-left: 48px; }
}

/* Dashboard search */
.dash-search { display: flex; gap: 8px; flex: 1; max-width: 460px; }
.dash-search input { flex: 1; font: inherit; font-size: .95rem; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); }

/* Every form control follows the theme (also in dark mode). */
input, select, textarea { background-color: var(--input-bg); color: var(--text); border-color: var(--line); }

/* Appearance switcher at the bottom of the sidebar */
.appearance { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 20px 4px; }
.swatches { display: flex; gap: 6px; }
.swatch {
    width: 22px; height: 22px; border-radius: 50%; cursor: pointer; padding: 0;
    border: 2px solid rgba(255, 255, 255, .35); background: linear-gradient(135deg, var(--sw-a) 50%, var(--sw-b) 50%);
}
.swatch.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, .25); }
.mode {
    border: 1px solid var(--navy-3); background: none; color: #dfe8ee; border-radius: 12px;
    font: inherit; font-size: .78rem; padding: 3px 10px; cursor: pointer; white-space: nowrap;
}
.mode:hover, .swatch:hover { opacity: .85; }
@media (max-width: 860px) {
    .appearance { position: absolute; top: 6px; right: 8px; padding: 0; }
}
