:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --border: #e4e1da;
  --text: #1c1b19;
  --muted: #6f6b63;
  --accent: #1c1b19;
  --focus: #2f6fde;
  --todo-bg: #fff3d6;  --todo-fg: #7a5600;
  --ordered-bg: #e3edff; --ordered-fg: #1d4fa8;
  --shipped-bg: #dff3e6; --shipped-fg: #1c6b3a;
  --paid-fg: #1c6b3a;
  --danger: #b3261e;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}

button, input, select, textarea { font: inherit; color: inherit; }

.zh { color: var(--muted); font-weight: normal; }

/* ---------- Header ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
}
.topbar h1 { margin: 0; font-size: 17px; letter-spacing: .02em; }
.topbar h1 small { color: #b9b5ad; font-weight: normal; margin-left: 8px; }
.topbar .spacer { flex: 1; }
.topbar .user { color: #d6d2ca; font-size: 13px; }
.topbar button {
  background: transparent;
  border: 1px solid #55524c;
  color: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
.topbar button:hover { border-color: #aaa59b; }

/* ---------- Toolbar ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 10px;
}

.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.tab .count {
  display: inline-block;
  min-width: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.tab[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab[aria-pressed="true"] .zh { color: #cfcac1; }
.tab[aria-pressed="true"] .count { background: #3a3833; color: #fff; }

.search {
  margin-left: auto;
  min-width: 220px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.summary {
  padding: 0 20px 10px;
  color: var(--muted);
  font-size: 13px;
}
.summary strong { color: var(--text); }

/* ---------- Tabel ---------- */

.table-wrap {
  margin: 0 20px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: calc(100vh - 170px);
}

table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1280px; }

th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 9px 10px;
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
th .zh { display: block; font-size: 11px; }

td {
  border-bottom: 1px solid #efece6;
  padding: 8px 10px;
  vertical-align: top;
}
tr:hover td { background: #fcfbf8; }
tr.cancelled td { opacity: .55; }

.num { text-align: right; white-space: nowrap; }

.order-link {
  background: none;
  border: none;
  padding: 0;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.sub { color: var(--muted); font-size: 12px; }
.flag { display: inline-block; margin-top: 3px; font-size: 11px; color: var(--danger); font-weight: 600; }

.products { display: flex; flex-direction: column; gap: 6px; min-width: 240px; }
.product { display: flex; gap: 8px; align-items: center; }
.product img, .product .noimg {
  width: 44px; height: 44px; flex: none;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.product .name { font-weight: 600; font-size: 13px; }
.product .variant { color: var(--muted); font-size: 12px; }
.qty { font-weight: 700; }
.qty.multi { color: var(--danger); }

.cell-input {
  width: 100%;
  min-width: 70px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--surface-2);
}
.cell-input:hover { border-color: var(--border); }
.cell-input:focus { outline: none; border-color: var(--focus); background: #fff; }
.cell-input.money { text-align: right; width: 84px; }
.cell-input.tracking { min-width: 170px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.cell-input.notes { min-width: 160px; }
.cell-input.saving { border-color: #c9c4ba; }
.cell-input.saved { border-color: #5aa97a; }
.cell-input.error { border-color: var(--danger); background: #fdf0ef; }
.cell-input:disabled { background: transparent; color: var(--muted); }

.status-select {
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
}
.status-select[data-status="to_order"] { background: var(--todo-bg); color: var(--todo-fg); }
.status-select[data-status="ordered"] { background: var(--ordered-bg); color: var(--ordered-fg); }
.status-select[data-status="shipped"] { background: var(--shipped-bg); color: var(--shipped-fg); }
.status-select.error { border-color: var(--danger); }

.paid { color: var(--paid-fg); font-weight: 600; }
.unpaid { color: var(--muted); }

.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Detailpaneel ---------- */

.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 19, 17, .35);
  z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  background: var(--surface);
  z-index: 50;
  overflow-y: auto;
  box-shadow: -10px 0 30px rgba(0,0,0,.15);
  padding: 20px 22px 40px;
}
.drawer h2 { margin: 0 0 4px; font-size: 20px; }
.drawer h3 { margin: 22px 0 8px; font-size: 14px; }
.drawer .close {
  float: right;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
.address {
  white-space: pre-line;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 15px;
}
.copy {
  margin-top: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
.big-product { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid #efece6; }
.big-product img, .big-product .noimg {
  width: 120px; height: 120px; flex: none;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.big-product .name { font-weight: 700; }
.big-product .qty { font-size: 18px; margin-top: 6px; }
.history { font-size: 12px; color: var(--muted); }
.history div { padding: 4px 0; border-bottom: 1px dashed #ece9e2; }

.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: #1c1b19; color: #fff;
  padding: 10px 16px; border-radius: 8px;
  z-index: 60;
  max-width: calc(100vw - 32px);
}
.toast.error { background: var(--danger); }

/* ---------- Inloggen ---------- */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.login-card label { display: block; margin: 12px 0 6px; font-weight: 600; font-size: 13px; }
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.login-card input:focus { outline: none; border-color: var(--focus); }
.login-card button {
  width: 100%;
  margin-top: 20px;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.login-error { margin-top: 12px; color: var(--danger); min-height: 1.4em; }

@media (max-width: 700px) {
  .topbar { padding: 10px 16px; }
  .topbar h1 small { display: none; }
  .toolbar, .summary { padding-left: 16px; padding-right: 16px; }
  .search { margin-left: 0; width: 100%; }
  .table-wrap { margin: 0 16px 30px; max-height: none; }
}

/* ---------- Samenvatting en meldingen ---------- */

.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 20px 12px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  min-width: 150px;
}
.stat small { display: block; color: var(--muted); font-size: 12px; }
.stat strong { display: block; font-size: 20px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.main { border-color: var(--accent); }
.stat.main strong { font-size: 24px; }
.stat.warn { border-color: var(--danger); }
.stat.warn strong { color: var(--danger); }

.notice {
  margin: 0 20px 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #fff3d6;
  color: #6b4b00;
  border: 1px solid #f0d99a;
  font-size: 13px;
}

.sync-badge { font-size: 12px; font-weight: 600; white-space: nowrap; }
.sync-badge.ok { color: var(--paid-fg); }
.sync-badge.pending { color: var(--muted); }
.sync-badge.error { color: var(--danger); }
.sync-error { font-size: 11px; color: var(--danger); max-width: 200px; margin-top: 2px; }

.paid-select, .method-select {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.paid-select[data-paid="true"] { background: var(--shipped-bg); color: var(--shipped-fg); font-weight: 600; }

.product .opts { color: var(--muted); font-size: 12px; }
.product .opts b { color: var(--text); font-weight: 600; }

@media (max-width: 700px) {
  .cards { padding: 0 16px 12px; }
  .notice { margin: 0 16px 12px; }
}

/* ---------- Navigatie, retouren, correctie ---------- */

.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a {
  color: #d6d2ca;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
}
.nav a:hover { background: #2b2925; color: #fff; }
.nav a[aria-current="page"] { background: #3a3833; color: #fff; }
.nav a[hidden] { display: none; }

.flag.return { color: #7a3fb0; display: block; }

.return-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.danger-button {
  border: 1px solid var(--danger);
  background: #fff;
  color: var(--danger);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}
.danger-button:hover { background: #fdf0ef; }
.danger-button:disabled { opacity: .6; cursor: wait; }

.cell-input.tracking:disabled::placeholder { color: #b0aba2; font-family: inherit; }

/* ---------- Kostenpagina ---------- */

.costs-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  padding: 14px 20px;
}
.control-group { display: flex; flex-direction: column; gap: 6px; }
.control-group > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.control-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.control-row input[type="date"], .control-row select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.costs-table { min-width: 760px; }
.costs-table td, .costs-table th { white-space: nowrap; }
.costs-table tfoot td {
  position: sticky;
  bottom: 0;
  background: var(--surface-2);
  border-top: 2px solid var(--border);
  font-weight: 700;
}
.period-label small { display: block; color: var(--muted); font-size: 12px; font-weight: normal; }

@media (max-width: 700px) {
  .nav { margin-left: 0; }
  .costs-controls { padding: 12px 16px; }
}

.period-row { cursor: pointer; }
.period-row:hover td { background: #f7f5f0; }
.period-row:focus { outline: 2px solid var(--focus); outline-offset: -2px; }
.period-row .caret { display: inline-block; width: 1em; color: var(--muted); transition: transform .15s; }
.period-row[aria-expanded="true"] .caret { transform: rotate(90deg); }
.period-detail > td { background: var(--surface-2); padding: 6px 10px 12px 28px; }
.detail-table { min-width: 0; width: 100%; font-size: 13px; }
.detail-table th { position: static; background: transparent; }
.detail-table td { border-bottom: 1px solid #ece9e2; padding: 6px 8px; }

/* Nog niet betaald: zacht rood, in dezelfde stijl als geel (te bestellen) en groen (verzonden). */
:root { --unpaid-bg: #fbe7e4; --unpaid-fg: #a2392d; }
.paid-select[data-paid="false"] {
  background: var(--unpaid-bg);
  color: var(--unpaid-fg);
  border-color: #f2cdc7;
  font-weight: 600;
}
span.unpaid {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--unpaid-bg);
  color: var(--unpaid-fg);
  font-weight: 600;
}
span.paid {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--shipped-bg);
  color: var(--shipped-fg);
}

/* Kostenpagina: euro onder het RMB-bedrag */
.eur { display: block; font-size: 12px; color: var(--muted); font-weight: normal; margin-top: 1px; }
.stat .eur { font-size: 13px; margin-top: 2px; }
.rate-note { margin: -28px 20px 40px; color: var(--muted); font-size: 12px; }
@media (max-width: 700px) { .rate-note { margin: -18px 16px 30px; } }

/* Datumfilter op de bestellingenpagina */
.date-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 0 20px 12px;
}
.date-filter input[type="date"], .date-filter select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
@media (max-width: 700px) { .date-filter { padding: 0 16px 12px; } }

/* ---------- Productfoto groot bekijken ---------- */

img.zoomable { cursor: zoom-in; }
body.no-scroll { overflow: hidden; }

.photo-box {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(16, 15, 14, .92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 16px 110px;
}
.photo-box[hidden] { display: none; }

.photo-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  cursor: zoom-in;
}
.photo-box img.zoomed {
  max-width: none;
  max-height: none;
  width: auto;
  cursor: zoom-out;
}
.photo-box:has(img.zoomed) { overflow: auto; align-items: flex-start; }

.photo-close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 2;
  border: 1px solid #55524c;
  background: rgba(0, 0, 0, .5);
  color: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
.photo-close:hover { border-color: #aaa59b; }

.photo-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 48px;
  height: 64px;
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
}
.photo-nav:hover { background: rgba(0, 0, 0, .7); }
.photo-nav.prev { left: 12px; }
.photo-nav.next { right: 12px; }
.photo-nav[hidden] { display: none; }

.photo-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 20px 20px;
  background: linear-gradient(to top, rgba(0, 0, 0, .85), transparent);
  color: #fff;
  text-align: center;
  pointer-events: none;
}
.photo-title { font-size: 17px; font-weight: 700; }
.photo-caption { margin-top: 4px; font-size: 15px; color: #e6e2da; }
.photo-counter { margin-top: 4px; font-size: 13px; color: #b9b5ad; }

@media (max-width: 700px) {
  .photo-box { padding: 56px 8px 100px; }
  .photo-nav { width: 40px; height: 56px; font-size: 26px; }
}

/* Gegevens onder de grote foto: losse blokjes in plaats van punten achter elkaar */
.photo-caption {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}
.photo-caption .chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.photo-caption .chip em {
  font-style: normal;
  font-weight: 500;
  font-size: 13px;
  color: #c9c4bb;
}
.photo-caption .chip .zh { color: #a8a39a; }

/* ---------- Logo ---------- */

/* Het logo is wit op zwart; "screen" laat het zwart wegvallen in de donkere balk. */
.logo {
  height: 38px;
  width: auto;
  display: block;
  mix-blend-mode: screen;
}
.topbar h1 { display: flex; align-items: center; gap: 12px; }
.topbar h1 small { margin-left: 0; }

/* Inlogscherm: lichte achtergrond, dus daar het logo omkeren naar zwart op wit. */
.logo-login {
  display: block;
  width: 190px;
  height: auto;
  margin: 0 auto 6px;
  filter: invert(1);
  mix-blend-mode: multiply;
}
.login-card { text-align: center; }
.login-card label { text-align: left; }

@media (max-width: 700px) { .logo { height: 30px; } }

/* Kostenpagina: openstaand bedrag in zacht rood, zodat het opvalt */
.costs-table td.open-amount { color: var(--unpaid-fg); font-weight: 700; }
.costs-table td.open-amount .eur { color: #c4877e; }
