:root {
  --ink: #161817;
  --muted: #6d736f;
  --line: #e1e3df;
  --paper: #f3f2ef;
  --surface: #ffffff;
  --surface-soft: #faf9f6;
  --graphite: #5f6260;
  --graphite-dark: #353735;
  --orange: #ff5a00;
  --orange-dark: #dc4d00;
  --orange-soft: #fff0e7;
  --danger: #9e2f24;
}

* {
  box-sizing: border-box;
}

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

.app-shell {
  width: min(1280px, calc(100vw - 40px));
  min-height: calc(100vh - 40px);
  margin: 20px auto;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(35, 36, 34, 0.14);
}

.sidebar {
  position: sticky;
  top: 20px;
  min-width: 0;
  min-height: calc(100vh - 40px);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: #f6f5f2;
  border-right: 1px solid var(--line);
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: inset 0 -3px 0 rgba(255, 90, 0, 0.12);
  font-weight: 900;
  line-height: 1;
}

.brand-mark span {
  color: var(--graphite);
}

.brand-mark strong {
  color: var(--orange);
}

.brand p,
.topbar p,
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.brand h1,
.topbar h2,
.card h3 {
  margin: 0;
  color: var(--ink);
  line-height: 1.12;
}

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

.topbar h2 {
  font-size: 28px;
}

.card h3 {
  font-size: 17px;
}

.side-nav {
  display: grid;
  gap: 7px;
}

.side-nav a,
.logout {
  min-height: 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  color: var(--graphite-dark);
  font-size: 14px;
  font-weight: 750;
  text-decoration: none;
}

.side-nav .active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(29, 30, 28, 0.08);
}

.side-nav .active::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--orange);
}

.logout {
  margin-top: auto;
  border: 1px solid var(--line);
  background: var(--surface);
}

.content {
  min-width: 0;
  padding: 26px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.topbar,
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.status {
  max-width: 360px;
  min-height: 40px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--graphite-dark);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 750;
}

.action-grid,
.metrics {
  display: grid;
  gap: 14px;
}

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

.metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card,
.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.card {
  padding: 18px;
}

.upload-card {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.1fr) auto;
  gap: 14px;
  align-items: end;
}

.file-picker {
  min-height: 46px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  border: 1px dashed #cfd2cd;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--graphite-dark);
  font-weight: 750;
  cursor: pointer;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

button,
.download,
.ghost {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  text-decoration: none;
}

button,
.download {
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  background: var(--orange);
}

button:hover,
.download:hover {
  background: var(--orange-dark);
}

.ghost {
  min-height: 34px;
  padding: 0 12px;
  color: var(--graphite-dark);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.metric {
  padding: 16px;
  background: var(--surface-soft);
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  font-size: 31px;
  line-height: 1;
}

.metric small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  line-height: 1.35;
}

.muted-metric {
  border-color: #d3d8d0;
}

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

.accounts {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.account-option {
  min-height: 42px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 800;
}

.account-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--orange);
}

.account-option strong {
  color: var(--orange-dark);
}

.filter-summary {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.filter-summary[hidden] {
  display: none;
}

.filter-summary div {
  min-height: 76px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--orange-soft);
}

.filter-summary span {
  display: block;
  margin-bottom: 8px;
  color: var(--graphite-dark);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.filter-summary strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.empty-state,
.helper {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.export-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

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

.download.disabled {
  pointer-events: none;
  opacity: 0.42;
}

.table-card {
  padding-bottom: 0;
}

#previewInfo {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.table-wrap {
  width: calc(100% + 36px);
  margin: 16px -18px 0;
  overflow: auto;
  border-top: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  position: sticky;
  top: 0;
  background: #f0efeb;
  color: var(--graphite-dark);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

td:last-child,
th:last-child {
  text-align: right;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--paper);
}

.login-panel {
  width: min(430px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(35, 36, 34, 0.14);
}

.brand-login {
  margin-bottom: 26px;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  font-weight: 850;
  color: var(--graphite-dark);
}

.login-form input {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px;
}

.login-error {
  min-height: 20px;
  margin: 2px 0;
  color: var(--danger);
  font-weight: 800;
}

@media (max-width: 980px) {
  .app-shell {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    grid-template-columns: 1fr;
    border: 0;
    border-radius: 0;
  }

  .sidebar {
    position: static;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .logout {
    margin-top: 0;
  }

  .action-grid,
  .metrics,
  .filter-summary,
  .upload-card {
    grid-template-columns: 1fr;
  }

  .export-card {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    flex-direction: column;
  }

  .status {
    width: 100%;
    max-width: none;
    border-radius: 8px;
  }
}

@media (max-width: 620px) {
  .content,
  .sidebar {
    padding: 18px;
  }

  .side-nav {
    grid-template-columns: 1fr;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .inline-actions {
    width: 100%;
  }

  .inline-actions button {
    flex: 1;
  }
}
