/**
 * The admin console's own stylesheet.
 *
 * Self-contained, like the root index.html's styles and for the same reason:
 * this page and the storefront should not be able to break each other. The
 * colours match so the domain still feels like one property.
 */

:root {
  --ink: #0d1b26;
  --ink-soft: #4a5c68;
  --ink-faint: #7b8c98;
  --surface: #ffffff;
  --surface-2: #f6f9fb;
  --line: #dbe5ec;
  --accent: #0f6d92;
  --accent-wash: #e4f1f7;
  --danger: #a3232b;
  --danger-wash: #fdeceb;
  --good: #1d6b46;
  --shadow: 0 1px 2px rgba(13, 27, 38, 0.06), 0 2px 8px rgba(13, 27, 38, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8f0f5;
    --ink-soft: #a6b8c4;
    --ink-faint: #7d919e;
    --surface: #0f2131;
    --surface-2: #0b1926;
    --line: #23404f;
    --accent: #4bb8dd;
    --accent-wash: #12303f;
    --danger: #ff9b9b;
    --danger-wash: #3a1a1c;
    --good: #6ddba4;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  padding: 28px 16px 56px;
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial,
    sans-serif;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
}

h1 {
  margin: 0 0 4px;
  font-size: clamp(1.4rem, 4vw, 1.8rem);
  letter-spacing: -0.025em;
  line-height: 1.2;
}

h2 {
  margin: 36px 0 2px;
  font-size: 1.05rem;
  letter-spacing: -0.015em;
}

.sub {
  margin: 0 0 20px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

h2 + .sub {
  margin-bottom: 14px;
}

/* --- Cards: the signed-out screens ---------------------------------------- */

.card {
  max-width: 420px;
  margin: 6vh auto 0;
  padding: 28px 26px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

/* --- Fields --------------------------------------------------------------- */

.field {
  margin-bottom: 16px;
}

label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.85rem;
  font-weight: 620;
}

.hint {
  margin: 0 0 6px;
  font-size: 0.8rem;
  color: var(--ink-faint);
  line-height: 1.45;
}

input[type='email'],
input[type='password'],
input[type='number'],
input[type='text'] {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  font-size: 1rem; /* 16px, or iOS zooms the page on focus */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
}

input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* --- Buttons -------------------------------------------------------------- */

.btn {
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  .btn-primary {
    color: #06202c;
  }
}

.btn-block {
  display: block;
  width: 100%;
  margin-top: 6px;
}

.btn-quiet {
  padding: 7px 12px;
  font-size: 0.85rem;
  font-weight: 560;
}

.link {
  padding: 0;
  font: inherit;
  font-size: 0.88rem;
  color: var(--accent);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
}

/* --- Messages ------------------------------------------------------------- */

.error {
  margin: 0 0 14px;
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--danger);
  background: var(--danger-wash);
  border: 1px solid currentColor;
  border-radius: 9px;
}

.note {
  margin: 0 0 18px;
  padding: 11px 13px;
  font-size: 0.87rem;
  color: var(--ink-soft);
  background: var(--accent-wash);
  border-radius: 9px;
  line-height: 1.5;
}

.minor {
  margin: 16px 0 0;
  font-size: 0.88rem;
}

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

.centred {
  margin-top: 34px;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 18px;
  font-size: 0.9rem;
  color: #fff;
  background: #16323f;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 10;
}

@media (prefers-color-scheme: dark) {
  .toast {
    color: #06202c;
    background: #cfe6f0;
  }
}

/* --- The console ---------------------------------------------------------- */

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

.topbar .sub {
  margin-bottom: 0;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

/* Tables are the one thing allowed to be wider than the phone. Each scrolls in
   its own box so the page itself never slides sideways. */
.table-scroll {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

thead th {
  font-size: 0.76rem;
  font-weight: 640;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  background: var(--surface-2);
}

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

.num,
td.num {
  text-align: right;
}

.mid,
td.mid {
  text-align: center;
}

.loading {
  padding: 22px 12px;
  color: var(--ink-faint);
  text-align: center;
}

.colour-name {
  font-weight: 600;
}

.item-code {
  display: block;
  font-size: 0.74rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink-faint);
  letter-spacing: 0.01em;
}

/* The count and threshold cells are editable in place. */
td input[type='number'] {
  width: 5.5rem;
  padding: 6px 8px;
  text-align: right;
  font-size: 0.95rem;
}

td.warn-cell input[type='number'] {
  width: 4.5rem;
}

/* A shelf that has gone negative — an order that beat its own hold. It should
   be impossible to scan past. */
.negative {
  color: var(--danger);
  font-weight: 700;
}

.sold-out {
  color: var(--danger);
  font-weight: 640;
}

.low {
  color: #9a6207;
  font-weight: 620;
}

@media (prefers-color-scheme: dark) {
  .low {
    color: #f0b95e;
  }
}

.untracked {
  color: var(--ink-faint);
  font-style: italic;
}

.ledger-sale {
  color: var(--ink-soft);
}

.ledger-oversell {
  color: var(--danger);
  font-weight: 620;
}

.delta-up {
  color: var(--good);
}

.delta-down {
  color: var(--ink-soft);
}

.ledger-note {
  display: block;
  max-width: 22rem;
  font-size: 0.8rem;
  color: var(--ink-faint);
  white-space: normal;
}

.when {
  font-size: 0.83rem;
  color: var(--ink-faint);
}

/* Switch, for the Track column. A real checkbox underneath, so it is reachable
   by keyboard and announced correctly. */
.switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch span {
  display: block;
  width: 38px;
  height: 22px;
  background: var(--line);
  border-radius: 999px;
  transition: background 0.15s ease;
  position: relative;
}

.switch span::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--surface);
  border-radius: 50%;
  transition: transform 0.15s ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(16px);
}

.switch input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .switch span,
  .switch span::after {
    transition: none;
  }
}

@media (max-width: 520px) {
  .topbar {
    flex-direction: column;
  }
  .card {
    margin-top: 2vh;
    padding: 22px 18px 18px;
  }
}
