:root {
  --bg: #eef1f6;
  --card: #ffffff;
  --border: #dfe4ec;
  --text: #1c2433;
  --muted: #6b7585;
  --accent: #3b56d6;
  --accent-hover: #2f47bd;
  --accent-soft: #eef1fd;
  --error-bg: #fef2f2;
  --error-border: #f7c4c4;
  --error-text: #b42424;
  --success-bg: #eefaf1;
  --success-border: #b9e6c6;
  --success-text: #1d7a3d;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Layout ---------- */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 16px 72px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.user-box { font-size: 14px; color: var(--muted); }
.user-box a { margin-left: 6px; text-decoration: none; font-weight: 600; }
.user-box a:hover { text-decoration: underline; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
}
.brand-name { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }

/* ---------- Card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 1px 2px rgba(20, 30, 50, 0.04);
}
.card + .card { margin-top: 20px; }

.intro { margin: 0 0 18px; color: var(--text); }
.muted { color: var(--muted); }

/* ---------- Form ---------- */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  font: inherit;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.row input { flex: 1; }

.hint { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn-primary {
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  padding: 11px 18px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-primary.full { width: 100%; margin-top: 8px; }

.btn-ghost {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-ghost:hover { background: #f6f8fb; }
.btn-ghost:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-ghost.copied { border-color: var(--success-border); color: var(--success-text); background: var(--success-bg); }

/* ---------- Status (loading / error / success) ---------- */
.status {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14.5px;
  border: 1px solid transparent;
}
.status.loading { background: var(--accent-soft); border-color: #d4dbfb; color: var(--accent-hover); display: flex; align-items: center; gap: 6px; }
.status.error   { background: var(--error-bg);   border-color: var(--error-border);   color: var(--error-text); }
.status.success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin .7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Result ---------- */
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.result-head h2 { margin: 0; font-size: 18px; }
.copy-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
th {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: none;
  background: #f8fafc;
}
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.sku { font-family: var(--mono); font-size: 13.5px; }
tbody tr:last-child td { border-bottom: none; }

.totals {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 2px solid var(--border);
  font-size: 14.5px;
  color: var(--muted);
}
.totals b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { justify-content: center; margin-bottom: 4px; }
.login-sub { text-align: center; margin: 0 0 18px; }
.login-card label { margin-top: 14px; }

/* ---------- Motion preference ---------- */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.6s; }
  * { transition: none !important; }
}

/* ---------- Small screens ---------- */
@media (max-width: 520px) {
  .row { flex-direction: column; }
  .btn-primary { width: 100%; }
}
