:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #1b1d1f;
  --muted: #667085;
  --line: #d9ded7;
  --accent: #176b5c;
  --accent-dark: #0f4f44;
  --danger: #a23b3b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.topbar {
  align-items: center;
  background: #10201d;
  color: white;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 14px 22px;
}

.brand {
  color: white;
  font-size: 18px;
  font-weight: 700;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.topbar nav a {
  color: #eef7f4;
  font-weight: 600;
}

.page {
  margin: 0 auto;
  max-width: 1180px;
  padding: 22px;
}

.page.page-wide {
  max-width: 100%;
  padding: 16px 28px;
}

.page.page-pos {
  max-width: 1440px;
  padding: 16px 24px;
}

.heading {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 18px;
}

h1,
h2 {
  margin: 0;
}

.panel,
.stats article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 18px;
}

.stats {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.stats article {
  padding: 18px;
}

.stats span {
  display: block;
  font-size: 26px;
  font-weight: 800;
}

.stats p {
  color: var(--muted);
  margin: 6px 0 0;
}

table {
  border-collapse: collapse;
  width: 100%;
}

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

tr.low td {
  background: #fff5ef;
}

tr.inactive td {
  color: var(--muted);
}

td.actions {
  display: flex;
  gap: 8px;
}

td.actions form {
  margin: 0;
}

.topbar nav {
  align-items: center;
}

.topbar .user {
  color: #cfe3dd;
  font-weight: 700;
}

.topbar .logout {
  margin: 0;
}

small {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.button,
button {
  background: #eef2f0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  display: inline-block;
  font: inherit;
  font-weight: 700;
  padding: 10px 14px;
}

.button.primary,
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.button.primary:hover,
button.primary:hover {
  background: var(--accent-dark);
}

.button.danger {
  color: var(--danger);
}

.link-button {
  background: none;
  border: 0;
  color: var(--accent);
  font-weight: 700;
  padding: 0;
}

.wide {
  width: 100%;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  min-height: 42px;
  padding: 9px 10px;
  width: 100%;
}

.form {
  display: grid;
  gap: 14px;
  max-width: 620px;
}

.compact {
  max-width: 460px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.search,
.scan-box {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.search {
  grid-template-columns: 1fr auto;
}

.scan-box {
  grid-template-columns: minmax(0, 1fr) 90px auto;
}

.pos-layout {
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(0, 1fr) 420px;
}

.checkout {
  align-self: start;
  position: sticky;
  top: 18px;
}

.checkout strong {
  display: inline;
  font-size: inherit;
  margin: 0;
}

.page-pos {
  font-size: 16px;
}

.page-pos input,
.page-pos select {
  font-size: 18px !important;
  padding: 12px 16px !important;
  min-height: 48px !important;
}

.page-pos .scan-box {
  grid-template-columns: minmax(0, 1fr) 120px auto;
  gap: 16px;
  margin-bottom: 24px;
}

.page-pos .scan-box input,
.page-pos .scan-box button {
  font-size: 20px !important;
  min-height: 56px !important;
  padding: 14px 20px !important;
}

.page-pos table th {
  font-size: 16px !important;
  padding: 12px 8px !important;
}

.page-pos table td {
  font-size: 18px !important;
  padding: 12px 8px !important;
}

.page-pos .link-button {
  font-size: 16px !important;
}

.page-pos .checkout h3 {
  font-size: 22px !important;
}

.page-pos .summary-breakdown {
  font-size: 17px !important;
  margin: 12px 0 !important;
  padding-top: 12px !important;
}

.page-pos .summary-breakdown strong {
  font-size: 18px !important;
}

.page-pos #summary-total {
  font-size: 32px !important;
}

.page-pos #summary-change-due {
  font-size: 28px !important;
}

.page-pos .button.primary.wide {
  font-size: 20px !important;
  padding: 14px !important;
  min-height: 52px !important;
}

.messages {
  position: fixed;
  top: 75px;
  right: 20px;
  z-index: 9999;
  display: grid;
  gap: 10px;
  max-width: 350px;
  width: 100%;
}

.message {
  background: var(--panel);
  border-left: 4px solid var(--accent);
  padding: 14px 16px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideIn 0.3s ease forwards;
  color: var(--ink);
}

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.message.success {
  background: #f0fdf4;
  border-left-color: #22c55e;
  color: #15803d;
}

.message.error,
.message.danger {
  background: #fef2f2;
  border-left-color: #ef4444;
  color: #991b1b;
}

.message.warning {
  background: #fffbeb;
  border-left-color: #f59e0b;
  color: #92400e;
}

.message.info {
  background: #eff6ff;
  border-left-color: #3b82f6;
  color: #1e40af;
}

.found {
  background: #eef7f4;
  border-radius: 6px;
  margin: 0;
  padding: 10px;
}

.errorlist {
  color: var(--danger);
  margin: -6px 0 4px;
  padding-left: 18px;
}

.summary-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0 0 20px;
}

.summary-list div {
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.summary-list dt {
  color: var(--muted);
  font-size: 13px;
}

.summary-list dd {
  font-size: 18px;
  font-weight: 800;
  margin: 3px 0 0;
}

/* Opening stocktake */
.page-stocktake {
  max-width: 1280px;
}

.stocktake-hero {
  align-items: flex-start;
  background: linear-gradient(135deg, #ffffff 0%, #f0f7f4 100%);
  border: 1px solid #d6e6df;
  border-radius: 16px;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 24px;
}

.stocktake-back {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}

.stocktake-title-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.stocktake-title-row h1 {
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -0.03em;
}

.stocktake-subtitle {
  color: var(--muted);
  line-height: 1.55;
  margin: 10px 0 0;
  max-width: 720px;
}

.status-pill,
.zone-state,
.section-count {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
}

.status-draft { background: #f2f4f7; color: #475467; }
.status-counting { background: #e9f7f2; color: #116149; }
.status-review { background: #fff4e5; color: #9a4d00; }
.status-applied { background: #ecfdf3; color: #067647; }
.status-cancelled { background: #fef3f2; color: #b42318; }

.stocktake-primary-actions form {
  margin: 0;
}

.stocktake-primary-actions .button {
  min-height: 46px;
  padding-inline: 18px;
}

.stocktake-metrics {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 28px;
}

.stocktake-metrics article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 0;
  padding: 18px;
}

.stocktake-metrics strong {
  display: block;
  font-size: 30px;
  margin: 8px 0 4px;
}

.metric-label {
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.metric-warning {
  border-color: #f7c97c !important;
  background: #fffbf3 !important;
}

.stocktake-section {
  margin-top: 28px;
}

.section-heading-row {
  align-items: end;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading-row h2 {
  font-size: 24px;
}

.section-heading-row p {
  color: var(--muted);
  margin: 6px 0 0;
}

.section-count {
  background: #edf4f1;
  color: #175c4f;
}

.zone-card-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.zone-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(16, 32, 29, 0.05);
  display: grid;
  gap: 18px;
  padding: 20px;
}

.zone-card.zone-complete {
  border-color: #9ed4bf;
}

.zone-card-header {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.zone-card-header h3 {
  font-size: 22px;
  margin: 3px 0 0;
}

.zone-card-header p {
  color: var(--muted);
  line-height: 1.45;
  margin: 8px 0 0;
}

.zone-eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.zone-state {
  background: #f2f4f7;
  color: #475467;
  flex: 0 0 auto;
}

.zone-complete .zone-state {
  background: #ecfdf3;
  color: #067647;
}

.zone-card-stats {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.zone-card-stats div {
  background: #f8faf9;
  border-radius: 10px;
  padding: 12px;
}

.zone-card-stats strong {
  display: block;
  font-size: 24px;
}

.zone-card-stats span {
  color: var(--muted);
  font-size: 13px;
}

.team-summary-label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.team-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.team-chip {
  background: #e9f4f0;
  border-radius: 999px;
  color: #175c4f;
  font-size: 13px;
  font-weight: 800;
  padding: 7px 10px;
}

.team-empty {
  color: #b54708;
  font-size: 14px;
  font-weight: 700;
}

.team-assignment-form {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding-top: 16px;
}

.team-assignment-form select {
  min-height: 130px;
}

.zone-count-button {
  text-align: center;
}

.zone-complete-note {
  background: #ecfdf3;
  border-radius: 10px;
  color: #067647;
  font-weight: 700;
  padding: 12px;
}

.table-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow-x: auto;
}

.table-card table {
  min-width: 760px;
}

.table-card th {
  background: #f8faf9;
  color: #475467;
  font-size: 12px;
  text-transform: uppercase;
}

.review-inline-form {
  display: flex;
  gap: 8px;
  min-width: 330px;
}

.review-inline-form input {
  max-width: 90px;
}

.empty-state {
  background: var(--panel);
  border: 1px dashed #b8c5bf;
  border-radius: 14px;
  color: var(--muted);
  grid-column: 1 / -1;
  padding: 36px;
  text-align: center;
}

.compact-empty {
  border: 0;
  padding: 18px;
}

@media (max-width: 980px) {
  .stocktake-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .zone-card-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar,
  .heading,
  .stocktake-hero,
  .section-heading-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats,
  .pos-layout,
  .scan-box,
  .summary-list,
  .stocktake-metrics,
  .zone-card-stats {
    grid-template-columns: 1fr;
  }

  .page {
    padding: 14px;
  }

  table {
    font-size: 14px;
  }

  .stocktake-hero {
    padding: 18px;
  }

  .stocktake-primary-actions,
  .stocktake-primary-actions form,
  .stocktake-primary-actions .button {
    width: 100%;
  }

  .zone-card {
    padding: 16px;
  }

  .review-inline-form {
    align-items: stretch;
    flex-direction: column;
    min-width: 180px;
  }

  .review-inline-form input {
    max-width: none;
  }
}
