:root {
  --accent: #146c63;
  --accent-strong: #0e514a;
  --bg: #f5f7f6;
  --panel: #ffffff;
  --ink: #18201f;
  --muted: #65706e;
  --line: #dbe3e1;
  --warn: #b7791f;
  --danger: #b42318;
  --ok: #157347;
  --shadow: 0 16px 40px rgba(19, 37, 35, 0.10);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.top-bar {
  background: #10211f;
  color: #f7fbfa;
  padding: 16px 28px;
  display: grid;
  grid-template-columns: auto minmax(300px, 1fr) auto;
  align-items: center;
  gap: 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.brand h1,
.brand p,
.page-header h2,
.page-header p,
.import-panel h3,
.mapping-panel h3,
.empty-state h3 {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
}

.brand p {
  color: #b8c8c5;
  font-size: 13px;
  margin-top: 2px;
}

.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.nav-button {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #eff7f6;
  min-height: 42px;
  border-radius: 8px;
  text-align: center;
  padding: 0 16px;
}

.nav-button.active,
.nav-button:hover {
  background: #ffffff;
  color: #10211f;
}

.summary-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.summary-panel div {
  display: grid;
  gap: 2px;
  min-width: 92px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.06);
}

.summary-panel span {
  color: #b8c8c5;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-panel strong {
  font-size: 18px;
}

.main-content {
  padding: 24px 28px 32px;
  min-width: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.page-header h2 {
  font-size: 34px;
  line-height: 1.1;
  margin-top: 4px;
}

.header-actions,
.button-row,
.dialog-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.danger-button,
.save-button,
.icon-button {
  border: 1px solid transparent;
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

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

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

.secondary-button {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}

.save-button {
  background: #ebf7f4;
  color: var(--accent-strong);
  border-color: #b9ddd5;
}

.danger-button {
  background: #fff5f3;
  color: var(--danger);
  border-color: #ffd6d0;
}

.icon-button {
  width: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
  font-size: 20px;
}

.toolbar,
.settings-grid,
.import-grid,
.dashboard-grid,
.breakdown-grid {
  display: grid;
  gap: 14px;
}

.toolbar {
  grid-template-columns: minmax(320px, 2fr) repeat(4, minmax(150px, 1fr));
  margin-bottom: 16px;
  padding: 16px;
  background: #eef5f3;
  border: 1px solid #cfe0dc;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toolbar input,
.toolbar select {
  min-height: 46px;
  border-color: #bfd5d0;
}

.dashboard-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin-bottom: 14px;
}

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

.metric-panel {
  padding: 16px;
}

.metric-panel span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-panel strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.breakdown-grid {
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  margin-bottom: 14px;
}

.breakdown-panel {
  padding: 16px;
}

.breakdown-panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.chart-board {
  display: grid;
  grid-template-columns: minmax(320px, 1.4fr) minmax(260px, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.chart-board[hidden] {
  display: none;
}

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

.chart-panel h3 {
  margin: 0 0 16px;
  font-size: 16px;
}

.tally-table {
  min-width: 0;
  table-layout: fixed;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.tally-table th,
.tally-table td {
  padding: 10px 12px;
}

.tally-table th:nth-child(1),
.tally-table td:nth-child(1) {
  width: 46%;
}

.tally-table th:nth-child(2),
.tally-table td:nth-child(2),
.tally-table th:nth-child(3),
.tally-table td:nth-child(3),
.tally-table th:nth-child(4),
.tally-table td:nth-child(4) {
  width: 18%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tally-table tbody tr:nth-child(even) {
  background: #f8fbfa;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 140px) 1fr 42px;
  gap: 10px;
  align-items: center;
  min-height: 28px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.bar-fill {
  height: 100%;
  background: var(--accent);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  min-height: 40px;
  border-radius: 8px;
  padding: 8px 10px;
}

textarea {
  resize: vertical;
}

.alert-strip {
  background: #fff8e8;
  border: 1px solid #f3d59b;
  color: #6c460a;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-weight: 700;
}

.table-wrap,
.import-panel,
.mapping-panel,
.import-log,
.settings-grid {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1220px;
}

.inventory-table {
  min-width: 1040px;
}

.ebay-table {
  min-width: 1040px;
}

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

body.compact th,
body.compact td {
  padding: 9px 10px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f8faf9;
}

td strong {
  display: block;
}

td small {
  color: var(--muted);
}

.number-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

body.tidy-columns .inventory-table,
body.tidy-columns .ebay-table {
  table-layout: fixed;
}

body.tidy-columns .inventory-table {
  min-width: 980px;
}

body.tidy-columns .inventory-table th:nth-child(1),
body.tidy-columns .inventory-table td:nth-child(1) {
  width: 220px;
}

body.tidy-columns .inventory-table th:nth-child(2),
body.tidy-columns .inventory-table td:nth-child(2) {
  width: 100px;
}

body.tidy-columns .inventory-table th:nth-child(3),
body.tidy-columns .inventory-table td:nth-child(3) {
  width: 140px;
}

body.tidy-columns .inventory-table th:nth-child(4),
body.tidy-columns .inventory-table td:nth-child(4) {
  width: 80px;
}

body.tidy-columns .inventory-table th:nth-child(5),
body.tidy-columns .inventory-table td:nth-child(5),
body.tidy-columns .inventory-table th:nth-child(6),
body.tidy-columns .inventory-table td:nth-child(6),
body.tidy-columns .inventory-table th:nth-child(7),
body.tidy-columns .inventory-table td:nth-child(7) {
  width: 72px;
}

body.tidy-columns .inventory-table th:nth-child(8),
body.tidy-columns .inventory-table td:nth-child(8) {
  width: 150px;
}

body.tidy-columns .inventory-table th:nth-child(9),
body.tidy-columns .inventory-table td:nth-child(9) {
  width: 180px;
}

body.tidy-columns .inventory-table th:nth-child(10),
body.tidy-columns .inventory-table td:nth-child(10) {
  width: 150px;
}

body.tidy-columns td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions-col {
  width: 190px;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: capitalize;
}

.size-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  min-width: 44px;
  border-radius: 8px;
  padding: 0 9px;
  background: #eef3f2;
  color: var(--ink);
  font-weight: 800;
}

.status-available {
  color: #0d5f3a;
  background: #e8f6ee;
}

.status-sold {
  color: #7a3315;
  background: #fff0e8;
}

.status-send {
  color: #185b78;
  background: #e8f4fb;
}

.status-dispatched {
  color: #49348a;
  background: #f0ecff;
}

.status-active {
  color: #0d5f3a;
  background: #e8f6ee;
}

.status-low-stock {
  color: #7a4e0b;
  background: #fff7df;
}

.stock-warning {
  color: var(--warn);
  font-weight: 800;
}

.stock-danger {
  color: var(--danger);
  font-weight: 800;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
}

.empty-state p,
.import-panel p,
.mapping-panel p {
  color: var(--muted);
  line-height: 1.5;
}

.import-grid {
  grid-template-columns: minmax(280px, 1.3fr) minmax(260px, 1fr);
}

.import-panel,
.mapping-panel,
.import-log {
  padding: 20px;
}

.drop-zone {
  margin-top: 14px;
  min-height: 150px;
  border: 2px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
  background: #fbfdfc;
}

.drop-zone input {
  display: none;
}

.drop-zone span {
  color: var(--accent);
  font-size: 18px;
  font-weight: 800;
}

.drop-zone small {
  color: var(--muted);
}

.column-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.column-list span {
  background: #eef3f2;
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 800;
}

.settings-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  padding: 20px;
  margin-bottom: 16px;
}

dialog {
  width: min(720px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(16, 33, 31, 0.52);
}

#itemForm {
  padding: 20px;
}

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

.dialog-header h3 {
  margin: 0;
  font-size: 22px;
}

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

.wide-field {
  grid-column: 1 / -1;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

@media (max-width: 900px) {
  .top-bar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .summary-panel {
    justify-content: stretch;
  }

  .toolbar,
  .settings-grid,
  .import-grid,
  .dashboard-grid,
  .breakdown-grid,
  .chart-board {
    grid-template-columns: 1fr;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .main-content,
  .top-bar {
    padding: 18px;
  }

  .page-header h2 {
    font-size: 28px;
  }

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