/* Ledger-inspired visual identity: this is a margin/profit ledger for
   cross-border Amazon resale, so the palette and type lean on financial-
   document conventions (ink, stamps, tabular figures) rather than a
   generic SaaS look. */

:root {
  --paper: #eef0ef;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #d8dbd8;
  --ink: #1c2420;
  --muted: #62706a;
  --accent: #1f5c56;
  --accent-strong: #163e3a;
  --accent-ink: #ffffff;
  --stamp: #a66a2e;
  --stamp-ink: #ffffff;
  --good: #3d7a4a;
  --bad: #a8402f;
  --warn: #a66a2e;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow-card: 0 1px 2px rgba(28, 36, 32, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121614;
    --surface: #1a201d;
    --surface-raised: #1f2622;
    --border: #2a322d;
    --ink: #e7ebe7;
    --muted: #93a099;
    --accent: #4fa89b;
    --accent-strong: #6fc2b4;
    --accent-ink: #0c1615;
    --stamp: #d79a54;
    --stamp-ink: #241505;
    --good: #6fbe7c;
    --bad: #e28376;
    --warn: #d79a54;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 0 0 6px;
  color: var(--ink);
}

h1 { font-size: 1.6rem; }

a { color: var(--accent); }

code, .mono, .tnum {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}
.topbar nav a:hover { color: var(--accent); }

.topbar nav .avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
}
.topbar nav .username {
  font-size: 0.9rem;
  color: var(--muted);
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 32px 64px;
}

/* ---------- Flash messages ---------- */

.flashes { list-style: none; padding: 0; margin: 0 0 24px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.9rem;
}
.flash-success { background: color-mix(in srgb, var(--good) 14%, var(--surface)); color: var(--good); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.flash-error { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }

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

.login-box {
  max-width: 360px;
  margin: 12vh auto 0;
  padding: 44px 36px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-align: center;
  box-shadow: var(--shadow-card);
}
.login-box h1 { font-size: 1.5rem; margin-bottom: 4px; }
.login-box .tagline {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 28px;
  line-height: 1.5;
}
.login-box .button { margin-top: 0; width: 100%; }

/* ---------- Ledger metrics strip ---------- */

.ledger {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  margin-bottom: 28px;
  overflow: hidden;
}
.ledger-figure {
  flex: 1;
  padding: 18px 24px;
  border-left: 1px solid var(--border);
}
.ledger-figure:first-child { border-left: none; }
.ledger-eyebrow {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.ledger-value {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--ink);
}
.ledger-value.good { color: var(--good); }
.ledger-value.bad { color: var(--bad); }

/* ---------- Filters ---------- */

.filters {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.status-tabs {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.status-tabs a {
  padding: 6px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}
.status-tabs a.active { background: var(--accent); color: var(--accent-ink); }

.filters select, .filters input[type="search"] {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.88rem;
}
.filters input[type="search"] { flex: 1; min-width: 180px; }
.filters button {
  margin: 0;
  padding: 8px 18px;
  border-radius: 999px;
}

/* ---------- Table ---------- */

.item-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.item-table th, .item-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.item-table thead th {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: color-mix(in srgb, var(--border) 35%, var(--surface));
}
.item-table tbody tr:last-child td { border-bottom: none; }
.item-table tbody tr[onclick] { cursor: pointer; }
.item-table tbody tr[onclick]:hover { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.item-table td.num, .item-table th.num { font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }

/* Country-code "stamp" badge - references the customs/invoice stamps on
   real cross-border shipments rather than flag icons. */
.stamp-badge {
  display: inline-block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--stamp) 16%, var(--surface));
  color: var(--stamp);
  border: 1px solid color-mix(in srgb, var(--stamp) 35%, transparent);
}

.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  width: fit-content;
}
.badge-bestand { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); }
.badge-verkauft { background: color-mix(in srgb, var(--muted) 18%, var(--surface)); color: var(--muted); }
.badge-warn { background: color-mix(in srgb, var(--warn) 16%, var(--surface)); color: var(--warn); margin-left: 6px; }

.profit-pos, .good { color: var(--good); font-weight: 600; }
.profit-neg, .bad { color: var(--bad); font-weight: 600; }

.empty-state { color: var(--muted); text-align: center; margin-top: 48px; font-size: 0.92rem; }
.hint { color: var(--muted); font-size: 0.86rem; }

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

.item-form {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.item-form label { font-size: 0.82rem; font-weight: 600; margin-top: 10px; color: var(--muted); }
.item-form input, .item-form textarea {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.92rem;
}
.item-form input:focus, .item-form textarea:focus,
.filters select:focus, .filters input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--accent);
}

button, .button {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  margin-top: 16px;
}
button:hover, .button:hover { background: var(--accent-strong); }
button:focus-visible, .button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.discord-button { background: #5865f2; color: #ffffff; }
.discord-button:hover { background: #4752c4; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions form, .inline-form { margin: 0; display: inline; }
.actions .link-button, .link-button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--bad);
  text-decoration: underline;
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
}

/* ---------- Item detail (two-column) ---------- */

.detail { display: flex; gap: 32px; flex-wrap: wrap; align-items: flex-start; }
.detail-photo { width: 240px; border-radius: var(--radius); object-fit: cover; border: 1px solid var(--border); }
.detail-body { flex: 1; min-width: 280px; }
.detail-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 20px;
  margin: 20px 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.detail-facts dt { color: var(--muted); font-size: 0.82rem; }
.detail-facts dd { margin: 0; font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }

/* ---------- Live Amazon-connect viewport ---------- */

.device-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  width: 1100px;
  max-width: 100%;
  box-shadow: var(--shadow-card);
}
.device-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: color-mix(in srgb, var(--border) 40%, var(--surface));
  border-bottom: 1px solid var(--border);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  color: var(--muted);
}
.device-titlebar .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.device-titlebar .dot.running { background: var(--accent); }
.device-titlebar .dot.done { background: var(--good); }
.device-titlebar .dot.error { background: var(--bad); }
.device-titlebar span:nth-child(2) { flex: 1; }
.titlebar-button {
  margin: 0;
  padding: 4px 11px;
  font-size: 0.74rem;
  font-weight: 500;
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: "IBM Plex Sans", sans-serif;
}
.titlebar-button:hover { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-color: var(--accent); }
.device-frame img {
  display: block;
  width: 100%;
  height: auto;
  cursor: text;
  outline: none;
  background: #000;
}
.status-line {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.84rem;
  color: var(--muted);
  margin: 0 0 14px;
}
