:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --panel: #ffffff;
  --panel-strong: #fdfbf6;
  --ink: #202522;
  --muted: #657168;
  --line: #dce2dc;
  --accent: #146c5a;
  --accent-dark: #0f5144;
  --accent-soft: #dcefe9;
  --warning: #a76018;
  --warning-soft: #fff0d8;
  --blue: #2466a6;
  --blue-soft: #e3eef9;
  --shadow: 0 18px 45px rgba(30, 42, 36, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 420px);
  display: grid;
  gap: 16px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin-bottom: 6px;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.login-divider::before,
.login-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.topbar,
.main-page,
.admin-page,
.entry-section,
.list-panel {
  margin-bottom: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.storage-warning {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid #e3bf8e;
  border-radius: var(--radius);
  background: var(--warning-soft);
  color: #6f3e0c;
  line-height: 1.4;
}

.storage-warning strong {
  font-size: 0.9rem;
}

.storage-warning span {
  font-size: 0.86rem;
}

.account-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.account-copy {
  display: grid;
  gap: 3px;
  min-width: 120px;
  text-align: right;
}

.account-copy span {
  font-weight: 850;
}

.account-copy small {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.65rem);
  line-height: 1.05;
}

h2 {
  font-size: 1.15rem;
  line-height: 1.2;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(84px, 1fr));
  gap: 10px;
  min-width: min(100%, 330px);
}

.summary div {
  min-height: 70px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
}

.summary span {
  display: block;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.1;
}

.summary small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.main-page,
.admin-page {
  display: grid;
  gap: 18px;
}

.supplier-view .primary-list {
  margin-top: 0;
}

.entry-panel,
.admin-panel,
.list-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.entry-panel,
.admin-panel {
  padding: 20px;
}

.list-panel {
  padding: 20px;
}

.admin-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.entry-section {
  width: min(100%, 980px);
}

.primary-list {
  order: -1;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.panel-heading,
.table-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading {
  margin-bottom: 18px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin: 0 0 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f4f7f5;
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 750;
}

.segmented input:checked + span {
  background: var(--panel);
  color: var(--accent-dark);
  box-shadow: 0 1px 8px rgba(28, 49, 42, 0.08);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cdd7cf;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 11px;
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 90, 0.14);
}

.field textarea {
  min-height: 76px;
  padding: 10px 11px;
  resize: vertical;
}

.form-message {
  min-height: 18px;
  margin: 10px 0 0;
  color: #9b2f2f;
  font-size: 0.84rem;
  font-weight: 750;
}

.span-two {
  grid-column: span 2;
}

.primary-action,
.secondary-action,
.icon-button,
.row-action {
  border: 0;
  border-radius: 6px;
  font-weight: 800;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.primary-action {
  width: 100%;
  min-height: 46px;
  margin-top: 18px;
  background: var(--accent);
  color: #fff;
}

.primary-action:hover {
  background: var(--accent-dark);
}

.secondary-action {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.secondary-action:hover {
  background: #cce5dd;
}

.clear-action {
  min-height: 40px;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.subtle {
  border: 1px solid var(--line);
  background: #f8faf8;
  color: var(--accent-dark);
}

.subtle:hover {
  background: var(--accent-soft);
}

.destination-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.supplier-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.supplier-grid {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.supplier-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
}

.supplier-card strong,
.supplier-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supplier-card small,
.empty-admin {
  color: var(--muted);
}

.empty-admin {
  padding: 14px 2px;
  font-size: 0.9rem;
}

.destination-form-actions {
  display: flex;
  gap: 8px;
}

.destination-form-actions .secondary-action {
  flex: 1 1 0;
}

.destination-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 16px;
}

.destination-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
  overflow: hidden;
}

.destination-card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
}

.destination-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  padding: 0 8px;
  text-align: left;
}

.destination-toggle:hover {
  background: var(--accent-soft);
}

.destination-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.destination-cue {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 850;
}

.destination-address {
  margin: 0 8px 8px;
  padding: 10px 11px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.destination-address p {
  margin: 0;
}

.destination-address-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.destination-remove {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: #edf1ed;
  color: var(--muted);
  font-weight: 900;
  line-height: 1;
}

.destination-remove:hover {
  background: #f3dddd;
  color: #9b2f2f;
}

.table-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, auto) auto minmax(0, 1fr);
  align-items: end;
  gap: 14px;
  margin-bottom: 16px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.compact {
  width: min(170px, 100%);
}

.compact input,
.compact select {
  min-height: 38px;
}

.export-button {
  align-self: end;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 1240px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f4f7f5;
  color: #445047;
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  font-size: 0.92rem;
}

tbody tr:hover {
  background: #fbfcfb;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 850;
  white-space: nowrap;
}

.pill.pending {
  background: var(--warning-soft);
  color: var(--warning);
}

.pill.in-transit {
  background: var(--blue-soft);
  color: var(--blue);
}

.pill.delivered {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.tracking-link {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.tracking-link:hover {
  text-decoration: underline;
}

.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.actions-heading {
  text-align: right;
}

.row-action {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.row-action:hover {
  background: var(--accent-soft);
  border-color: #c4ddd4;
  color: var(--accent-dark);
}

.row-action.danger:hover {
  background: #f7e5e5;
  border-color: #e4c4c4;
  color: #983333;
}

.empty-state {
  display: none;
  padding: 32px 18px;
  color: var(--muted);
  text-align: center;
}

.empty-state.is-visible {
  display: block;
}

.is-hidden {
  display: none;
}

@media (max-width: 980px) {
  .topbar,
  .admin-stack {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .account-bar {
    justify-content: space-between;
    margin-left: 0;
  }

  .account-copy {
    text-align: left;
  }

  .summary {
    width: 100%;
    min-width: 0;
  }

  .table-toolbar {
    grid-template-columns: 1fr;
  }

  .page-actions {
    justify-content: stretch;
  }

  .page-actions .secondary-action {
    flex: 1 1 160px;
  }

  .table-toolbar {
    align-items: stretch;
  }

  .filters {
    justify-content: stretch;
  }

  .compact {
    flex: 1 1 150px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 10px;
  }

  .topbar,
  .entry-panel,
  .admin-panel,
  .list-panel,
  .page-heading {
    padding: 16px;
  }

  .summary {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .destination-form,
  .supplier-form {
    grid-template-columns: 1fr;
  }

  .span-two {
    grid-column: span 1;
  }

  .filters {
    display: grid;
    grid-template-columns: 1fr;
  }

  .compact {
    width: 100%;
  }

  .export-button {
    width: 100%;
  }
}
