:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-soft: #eef3ef;
  --line: #d9ded8;
  --line-strong: #b9c2b9;
  --ink: #202522;
  --muted: #657066;
  --muted-2: #7f897f;
  --green: #176b5b;
  --green-dark: #0e4d42;
  --blue: #315c9b;
  --amber: #a86512;
  --red: #a33b35;
  --shadow: 0 12px 30px rgba(27, 40, 34, 0.08);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: var(--radius);
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(49, 92, 155, 0.28);
  outline-offset: 2px;
}

button.primary {
  background: var(--green);
  color: #fff;
}

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

button.secondary {
  background: #edf1ed;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.secondary:hover {
  background: #e3e9e3;
}

button.danger {
  background: #fff1ef;
  color: var(--red);
  border: 1px solid #efc7c2;
}

button.compact {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.86rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

input,
select {
  min-height: 38px;
  padding: 7px 10px;
}

textarea {
  resize: vertical;
  min-height: 136px;
  padding: 10px;
  line-height: 1.45;
}

label span,
.field-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 6px;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-panel {
  width: min(430px, 100%);
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-panel h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 3rem);
  line-height: 1;
}

.login-copy,
.login-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.login-note {
  font-size: 0.84rem;
  font-weight: 750;
}

.login-separator {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.login-separator::before,
.login-separator::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

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

.topbar h1,
.panel-heading h2,
.report-block h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 0.95;
}

.brand-title {
  display: flex;
  align-items: center;
}

.brand-logo {
  display: block;
  width: min(360px, 82vw);
  height: auto;
  border-radius: 4px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.topbar-actions,
.button-row,
.export-actions,
.database-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 4px 4px 4px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.account-chip span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.view-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tab-button {
  background: #edf1ed;
  color: var(--muted);
  border: 1px solid var(--line);
}

.tab-button.is-active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.metric strong {
  display: block;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  line-height: 1;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(320px, 0.8fr);
  gap: 16px;
  margin-bottom: 16px;
  align-items: start;
}

.tool-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.intake-panel,
.side-panel,
.database-panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  font-size: clamp(1.18rem, 2vw, 1.55rem);
}

.status-pill,
.row-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #eef6f3;
  color: var(--green-dark);
  border: 1px solid #c9ddd5;
  font-size: 0.78rem;
  font-weight: 800;
}

.gmail-box {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid #cfdbd2;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.gmail-box strong {
  display: block;
  overflow-wrap: anywhere;
}

.drop-zone {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 126px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fbfcfb;
  cursor: pointer;
  margin-bottom: 12px;
  text-align: center;
}

.drop-zone.is-dragging {
  border-color: var(--blue);
  background: #eef4ff;
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-title {
  display: block;
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
}

.drop-meta {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.paste-box {
  display: grid;
  gap: 10px;
}

.paste-box label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.receipt-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.receipt-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.receipt-thumb {
  display: block;
  width: 96px;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #f3f5f2;
}

.receipt-file {
  display: grid;
  place-items: center;
  width: 96px;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f7f3ed;
  color: var(--amber);
  font-weight: 900;
}

.receipt-card h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.receipt-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

.receipt-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.mini-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f0f2f0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.side-panel {
  display: grid;
  gap: 16px;
}

.export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.export-actions .primary {
  grid-column: 1 / -1;
}

.admin-controls {
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.inline-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.report-block {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.report-block h3 {
  font-size: 1rem;
  margin-bottom: 12px;
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  gap: 5px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ebe6;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--green);
  border-radius: inherit;
}

.database-heading {
  align-items: center;
}

.filters {
  display: grid;
  grid-template-columns: minmax(230px, 1.4fr) repeat(3, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.table-shell {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 1320px;
  border-collapse: collapse;
  background: #fff;
}

.orders-table {
  min-width: 2450px;
}

.tracking-cell {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.track-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 9px;
  border-radius: 6px;
  background: #eef4ff;
  color: var(--blue);
  border: 1px solid #c8d7ef;
  font-size: 0.78rem;
  font-weight: 850;
  text-decoration: none;
}

.track-link:hover {
  background: #e2ecff;
}

.receiving-table {
  min-width: 1320px;
}

thead {
  background: #f0f4f0;
}

th {
  color: var(--muted);
  font-size: 0.73rem;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

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

tbody tr:hover {
  background: #fbfcfb;
}

td input,
td select {
  min-width: 92px;
  border-color: transparent;
  background: transparent;
  padding-inline: 4px;
}

td input:hover,
td input:focus,
td select:hover,
td select:focus {
  border-color: var(--line);
  background: #fff;
}

td .item-input,
td .notes-input {
  min-width: 190px;
}

td .vendor-input {
  min-width: 150px;
}

.money-cell {
  min-width: 96px;
}

.computed-money {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  color: var(--ink);
  font-weight: 850;
}

.total-money {
  color: var(--green-dark);
}

.empty-state {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px);
  background: #19231d;
  color: #fff;
  padding: 12px 14px;
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
  font-weight: 750;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1060px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .account-chip {
    grid-column: 1 / -1;
    justify-content: space-between;
  }

  .summary-strip {
    grid-template-columns: 1fr 1fr;
  }

  .view-tabs {
    display: grid;
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .database-heading {
    display: grid;
  }

  .database-actions,
  .database-actions button {
    width: 100%;
  }

  .table-shell {
    border: 0;
    overflow: visible;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tbody tr {
    display: grid;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px;
    background: #fff;
  }

  th,
  td {
    border: 0;
    padding: 0;
  }

  td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  td input,
  td select,
  td .item-input,
  td .notes-input,
  td .tracking-cell,
  td .vendor-input {
    min-width: 0;
    border-color: var(--line);
    background: #fff;
  }

  td .tracking-cell input {
    min-width: 0;
  }

  td:last-child {
    grid-template-columns: 1fr;
  }

  td:last-child::before {
    display: none;
  }

  td:last-child button {
    width: 100%;
  }

  .receipt-card {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .receipt-thumb,
  .receipt-file {
    width: 72px;
  }
}

@media (max-width: 440px) {
  .topbar-actions,
  .summary-strip,
  .export-actions,
  .inline-add {
    grid-template-columns: 1fr;
  }

  .gmail-box {
    display: grid;
  }
}
