:root {
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --border: #e3e5e9;
  --text: #1f2430;
  --text-muted: #6b7280;
  --accent: #2f7d5f;
  --accent-soft: #e6f4ee;
  --header-bg: #f8f9fb;
  --row-hover: #f4f8f6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.customer-view .admin-only { display: none; }

.customer-view .total-summary {
  margin-top: 20px;
}

.customer-view .total-row.accounting-selling {
  margin-top: 0;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-panel {
  width: min(92vw, 360px);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
}

.login-panel h1 { margin: 8px 0 22px; font-size: 22px; }

.login-panel form { display: grid; gap: 10px; }

.login-panel input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

.login-error { color: #a12622; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.3px;
}

.fx-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #cdeadd;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0;
}

.fx-badge.fx-error {
  color: #a12622;
  background: #fdeceb;
  border-color: #f6c6c3;
}

.status {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.dot.live {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2ecc71;
  margin-right: 4px;
}

.live-label {
  font-weight: 600;
  color: var(--text);
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.demo {
  background: #fff3cd;
  color: #8a6d00;
  border: 1px solid #ffe69c;
}

.banner {
  margin: 16px 24px 0;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
}

.order-notice {
  padding: 10px 24px;
  border-bottom: 1px solid #e6d7a7;
  background: #fff9e8;
  color: #635015;
  font-size: 13px;
  line-height: 1.45;
}

.banner.error {
  background: #fdeceb;
  color: #a12622;
  border: 1px solid #f6c6c3;
}

main {
  padding: 24px;
}

.game-filters {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.cart-actions {
  display: flex;
  gap: 10px;
}

.quote-action {
  margin-left: auto;
}

.cart-action {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 11px 16px;
  text-decoration: none;
}

.cart-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.reset-cart { border-color: #d8b54a; }

.generate-quote {
  border-color: #1767aa;
  background: #1767aa;
  color: #fff;
}

.generate-quote:not(:disabled):hover { background: #12578f; }

.game-filter {
  border: 1px solid #b9d9f4;
  border-radius: 8px;
  padding: 12px;
  background: #f4faff;
}

.game-filter.one-piece {
  border-color: #f1c0c5;
  background: #fff7f7;
}

.game-filter.dragonball {
  border-color: #b8ddc3;
  background: #f3fbf5;
}

.game-filter h2 {
  margin: 0 0 8px;
  color: #1767aa;
  font-size: 17px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.game-filter.one-piece h2 { color: #bf2028; }
.game-filter.dragonball h2 { color: #26713a; }

.type-filters { display: flex; gap: 8px; }

.type-filter {
  border: 1px solid #d7e2eb;
  border-radius: 6px;
  background: #fff;
  color: #24415f;
  cursor: pointer;
  font-weight: 700;
  padding: 8px 12px;
}

.type-filter span {
  display: inline-block;
  margin-left: 6px;
  color: #1767aa;
}

.type-filter.is-active { background: #1767aa; border-color: #1767aa; color: #fff; }
.one-piece .type-filter.is-active { background: #d8222a; border-color: #d8222a; }
.dragonball .type-filter.is-active { background: #26713a; border-color: #26713a; }
.type-filter.is-active span { color: #fff; }

.cm-link {
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.cm-column { width: 52px; text-align: center; }

.cm-logo {
  display: block;
  width: 30px;
  height: 30px;
  margin: -5px auto;
  object-fit: contain;
}

.cm-link:hover { color: #18533e; }

.cm-links { white-space: nowrap; }

.cm-links .cm-link + .cm-link { margin-left: 8px; }

.pic-column { width: 72px; text-align: center; }

.pic-cell { padding: 6px 16px; text-align: center; }

.product-image-button {
  display: inline-flex;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  cursor: zoom-in;
}

.product-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-image-button.image-unavailable {
  cursor: default;
}

.product-image-button.image-unavailable::after {
  content: "No image";
  display: grid;
  width: 100%;
  place-items: center;
  color: var(--text-muted);
  font-size: 10px;
}

.product-image-button.image-unavailable .product-thumbnail {
  display: none;
}

.image-dialog {
  max-width: min(92vw, 720px);
  max-height: 92vh;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.image-dialog::backdrop { background: rgba(16, 24, 40, 0.72); }

.image-dialog img {
  display: block;
  max-width: min(88vw, 680px);
  max-height: 82vh;
  object-fit: contain;
}

.image-dialog-close {
  display: block;
  width: 32px;
  height: 32px;
  margin: 0 0 8px auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.quote-dialog {
  width: min(92vw, 560px);
  padding: 22px 26px 26px;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(31, 36, 48, 0.28);
}

.quote-dialog::backdrop { background: rgba(16, 24, 40, 0.48); }

.quote-dialog h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.quote-dialog p {
  margin: 0 0 18px;
  color: var(--text-muted);
  line-height: 1.45;
}

#quote-link {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
}

.quote-dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.quote-open-link { text-align: center; }

.quote-page { background: #f4f5f7; }

.quote-document {
  max-width: 900px;
  margin: 48px auto;
  padding: 32px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.quote-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
  border-bottom: 3px double var(--text);
  padding-bottom: 16px;
}

.quote-brand { color: var(--accent); font-weight: 700; }
.quote-header h1 { margin: 5px 0 0; font-size: 24px; }
.quote-date { color: var(--text-muted); font-size: 13px; }
.quote-table { margin-bottom: 24px; }
.quote-totals { max-width: 380px; margin-left: auto; }

@media (max-width: 760px) {
  .game-filters { flex-direction: column; }
  .type-filters { overflow-x: auto; }
  .cart-actions, .quote-action { width: 100%; margin-left: 0; }
  .cart-action { flex: 1; text-align: center; }
  .quote-header { flex-direction: column; gap: 8px; }
  .quote-document { margin: 16px; padding: 20px; }
}

.toolbar {
  margin-bottom: 12px;
}

.limit-notice {
  display: inline-block;
  margin: 8px 0 0;
  padding: 8px 10px;
  border: 1px solid #e4bd5f;
  border-radius: 6px;
  background: #fff7db;
  color: #785700;
  font-size: 13px;
}

#search {
  width: 100%;
  max-width: 360px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--card-bg);
}

#search:focus {
  outline: none;
  border-color: var(--accent);
}

.table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
}

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

thead th {
  position: sticky;
  top: 0;
  background: var(--header-bg);
  text-align: left;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr:hover {
  background: var(--row-hover);
}

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

.qty-input {
  width: 64px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  text-align: right;
}

.qty-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ==================================================
   TOTAL PRICE INCLUDING SHIPPING
   ================================================== */

.total-section {
  margin-top: 24px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
}

.total-section h2 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 700;
}

.total-empty {
  color: var(--text-muted);
  font-size: 14px;
  padding: 12px 0;
}

#total-table {
  margin-bottom: 16px;
}

#total-table thead th {
  position: static;
}

.total-summary {
  max-width: 340px;
  margin-left: auto;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}

.total-row.accounting-total {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 3px double var(--text);
  font-weight: 700;
}

.total-row.accounting-landed {
  color: #1f5f48;
}

.total-row.accounting-selling {
  color: #194d7a;
}

.total-row.total-grand {
  font-weight: 700;
  font-size: 16px;
  border-top: 3px double var(--text);
  margin-top: 8px;
  padding-top: 10px;
}

.total-row.total-eur {
  color: var(--text-muted);
  font-size: 13px;
}
