:root {
  --ink: #17221d;
  --muted: #66716b;
  --line: #dce3de;
  --paper: #ffffff;
  --canvas: #f3f6f3;
  --green: #14784b;
  --green-dark: #0c5d38;
  --green-soft: #e8f5ee;
  --amber: #9a5c0a;
  --amber-soft: #fff4dc;
  --red: #a3322c;
  --red-soft: #fff0ee;
  --shadow: 0 12px 35px rgba(28, 52, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px max(24px, calc((100vw - 1320px) / 2));
  color: white;
  background: #10291e;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.eyebrow {
  margin-bottom: 6px;
  color: #79d4a5;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.connection,
.inline-actions,
.filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

main {
  width: min(1320px, calc(100% - 32px));
  margin: 28px auto 60px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 32px;
  padding: 34px;
}

.hero .eyebrow,
.panel .eyebrow {
  color: var(--green);
}

.muted {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
}

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

.stat {
  padding: 15px;
  border-radius: 12px;
  background: var(--canvas);
}

.stat strong {
  display: block;
  font-size: 23px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 24px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}

.step {
  padding: 14px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: white;
  text-align: left;
  cursor: pointer;
}

.step:last-child {
  border-right: 0;
}

.step span {
  display: inline-grid;
  width: 26px;
  height: 26px;
  margin-right: 5px;
  place-items: center;
  border-radius: 50%;
  background: var(--canvas);
  font-weight: 800;
}

.step.active {
  color: var(--green-dark);
  background: var(--green-soft);
}

.step.active span {
  color: white;
  background: var(--green);
}

.panel {
  margin-top: 20px;
  padding: 28px;
}

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

.section-heading h2 {
  margin: 0;
  font-size: 25px;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

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

.subtle {
  border-color: var(--line);
  color: var(--ink);
  background: white;
}

.danger {
  color: white;
  background: var(--red);
}

.badge,
.summary-pill,
.status {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge {
  color: #133d29;
  background: #80d9aa;
}

.notice {
  margin-bottom: 18px;
  padding: 14px 17px;
  border: 1px solid #e4c88e;
  border-radius: 12px;
  color: #654009;
  background: var(--amber-soft);
}

.notice.error {
  border-color: #e1aba6;
  color: var(--red);
  background: var(--red-soft);
}

.empty-state {
  padding: 28px;
  border: 1px dashed #bdc9c1;
  border-radius: 12px;
  color: var(--muted);
  background: #fafcfa;
}

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

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

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

th {
  color: var(--muted);
  background: #f7f9f7;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

td.number,
th.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.check {
  width: 44px;
}

select,
input[type="search"],
input[type="text"],
input[type="password"],
.write-controls input {
  width: 100%;
  min-height: 41px;
  padding: 8px 10px;
  border: 1px solid #bdc9c1;
  border-radius: 8px;
  color: var(--ink);
  background: white;
}

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 15%, rgba(38, 150, 92, 0.16), transparent 35%),
    #10291e;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  margin: 0 auto;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  padding: 36px;
}

.login-card h1 {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 30px;
}

.login-card form {
  display: grid;
  gap: 18px;
  margin-top: 26px;
}

.login-submit {
  width: 100%;
}

.login-notice {
  margin-top: 20px;
}

.topbar form {
  display: inline-flex;
}

.batch-card {
  margin-bottom: 22px;
  padding: 28px;
}

.batch-card .section-heading {
  align-items: end;
}

.batch-card .section-heading > div:first-child {
  max-width: 720px;
}

.batch-actions {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  align-items: end;
  gap: 10px;
}

.file-picker input {
  max-width: 320px;
}

.batch-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.batch-footer a {
  color: var(--green-dark);
  font-weight: 700;
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

label {
  display: grid;
  gap: 7px;
  color: #39463f;
  font-size: 13px;
  font-weight: 700;
}

.tax-mappings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.tax-mappings:empty {
  display: none;
}

.class-assignment {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(240px, 0.7fr) auto auto;
  align-items: end;
  gap: 16px;
  margin-bottom: 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8faf8;
}

.class-assignment h3 {
  margin: 0 0 4px;
}

.class-line-list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.class-line {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 150px minmax(220px, 0.7fr);
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  background: white;
}

.class-line .line-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.class-suggestion {
  display: block;
  margin-top: 4px;
  color: var(--green-dark);
  font-size: 11px;
}

.filters {
  margin-bottom: 14px;
}

.filters input[type="search"] {
  width: min(360px, 100%);
}

.filters label {
  display: flex;
  align-items: center;
}

#selectionSummary {
  margin-left: auto;
  color: var(--muted);
}

.status.good {
  color: var(--green-dark);
  background: var(--green-soft);
}

.status.review {
  color: var(--amber);
  background: var(--amber-soft);
}

.status.error {
  color: var(--red);
  background: var(--red-soft);
}

.score {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.invoice-row {
  cursor: pointer;
}

.invoice-row:hover {
  background: #fbfcfb;
}

.invoice-detail td {
  padding: 0;
  background: #f8faf8;
}

.detail-content {
  padding: 16px 24px 22px 58px;
}

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

.detail-grid div {
  padding: 10px;
  border-radius: 8px;
  background: white;
}

.detail-grid strong {
  display: block;
  margin-bottom: 3px;
  font-size: 11px;
  text-transform: uppercase;
}

.warning-list {
  margin: 10px 0 0;
  color: var(--amber);
}

.preview-card {
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.preview-card.invalid {
  border-color: #e1aba6;
  background: var(--red-soft);
}

.preview-card h3 {
  margin: 0 0 7px;
}

.preview-card ul {
  margin: 8px 0 0;
}

.write-controls {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: end;
  gap: 18px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid #e1aba6;
  border-radius: 12px;
  background: var(--red-soft);
}

.disconnect-actions {
  display: flex;
  gap: 12px;
  margin: 24px 0 0;
}

.hidden {
  display: none !important;
}

@media (max-width: 850px) {
  .batch-actions {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .batch-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero,
  .mapping-grid,
  .tax-mappings,
  .class-assignment,
  .class-line {
    grid-template-columns: 1fr;
  }

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

  .step:nth-child(2) {
    border-right: 0;
  }

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