:root {
  --brand: #333333;
  --bg: #f5f5f5;
  --card: #ffffff;
  --text: #222222;
  --muted: #666666;
  --line: #e2e2e2;
  --danger: #b02a37;
  --ok: #1e7e34;
  --warn-bg: #fff3cd;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --card: #222428;
    --text: #e8e8e8;
    --muted: #a0a0a0;
    --line: #3a3d42;
    --danger: #ff6b78;
    --ok: #5cd27a;
    --warn-bg: #3d3420;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--brand); }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border-bottom: 3px solid var(--brand);
}
.brand { font-weight: 700; font-size: 18px; text-decoration: none; color: var(--text); }
.user-box { display: flex; gap: 12px; align-items: center; font-size: 14px; color: var(--muted); }
main { width: 100%; max-width: 880px; margin: 24px auto; padding: 0 16px; flex: 1; }
.footer { text-align: center; padding: 20px 16px; font-size: 14px; }
.footer a { color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
}
.card.narrow { max-width: 420px; margin: 6vh auto 20px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h2.spaced { margin-top: 24px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 13px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
input[type=email], input[type=password], input[type=text], input[type=tel] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-block;
  margin-top: 18px;
  padding: 11px 20px;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn.block { width: 100%; }
.btn.secondary { background: transparent; color: var(--brand); border: 1px solid var(--brand); margin-right: 8px; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 18px; }
.qr { margin: 12px 0; }
.qr img { background: #fff; padding: 6px; border-radius: 6px; border: 1px solid var(--line); }
.key { font-size: 15px; letter-spacing: .05em; white-space: normal; word-break: break-all; }
#tfa-code { max-width: 160px; font-size: 20px; letter-spacing: .2em; }
.codes { columns: 2; list-style: none; padding: 0; margin: 12px 0; font-size: 16px; }
.codes li { padding: 4px 0; }
.btn:disabled { opacity: .6; cursor: default; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; }
.row-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 14px; }

.msg { margin-top: 12px; font-size: 14px; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }
.notice { background: var(--warn-bg); border-radius: 6px; padding: 10px 12px; font-size: 14px; margin-top: 12px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab {
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 10px 14px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg); }
.num { text-align: right; white-space: nowrap; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; white-space: nowrap; }

/* Phones: each order becomes a two-column block instead of a wide table row */
@media (max-width: 600px) {
  .orders-table thead { display: none; }
  .orders-table tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
  .orders-table td { border: 0; padding: 0; }
  .orders-table td:nth-child(4) { text-align: right; font-weight: 600; }
  .orders-table td:nth-child(2) { grid-column: 1; grid-row: 2; color: var(--muted); font-size: 13px; }
  .orders-table td:nth-child(3) { grid-column: 2; grid-row: 2; text-align: right; }
  .orders-table td:nth-child(5) { grid-column: 1 / -1; font-size: 13px; }
  .orders-table td:nth-child(5):has(.muted) { display: none; }
}

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: var(--line); color: var(--text); }
.badge.good { background: #d4edda; color: #155724; }
.badge.bad { background: #f8d7da; color: #721c24; }
.badge.info { background: #d1ecf1; color: #0c5460; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 20px; margin-bottom: 16px; }
.summary .lbl { display: block; font-size: 12px; color: var(--muted); }
.totals { margin-left: auto; max-width: 320px; margin-top: 12px; font-size: 14px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .grand { font-weight: 700; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; }

/* Embedded in the tenant's page: its theme provides header, footer and background,
   and decides light/dark, so the portal keeps the light palette there */
.embedded {
  --bg: #f5f5f5; --card: #ffffff; --text: #222222; --muted: #666666;
  --line: #e2e2e2; --danger: #b02a37; --ok: #1e7e34; --warn-bg: #fff3cd;
}
.embedded .toast { top: 12px; bottom: auto; }
.embedded body { background: transparent; min-height: 0; }
.embedded .brand, .embedded .footer { display: none; }
.embedded .topbar { background: transparent; border-bottom: 0; justify-content: flex-end; padding: 0 0 8px; }
.embedded main { margin: 0 auto; padding: 0; }
.embedded .card.narrow { margin-top: 0; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  max-width: calc(100% - 32px);
}
.toast.err { background: var(--danger); }
