:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #66737d;
  --line: #d7dee3;
  --panel: #ffffff;
  --page: #eef3f1;
  --soft: #f7faf9;
  --green: #0f7a5f;
  --green-dark: #095944;
  --blue: #2f5f98;
  --amber: #9b6b11;
  --red: #a1443c;
  --shadow: 0 18px 50px rgba(23, 32, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(15, 122, 95, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(47, 95, 152, 0.07) 1px, transparent 1px),
    var(--page);
  background-size: 38px 38px;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.workspace {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-height: calc(100vh - 48px);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: #fbfdfc;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.55rem, 2vw, 2.2rem);
}

h2 {
  font-size: 1.02rem;
}

.input-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(4, minmax(150px, 1fr));
  gap: 14px;
  padding: 18px 24px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}

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

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #c6d1d8;
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 95, 152, 0.16);
}

.controls,
.summary-band,
.table-section,
.custom-acid {
  padding-left: 24px;
  padding-right: 24px;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-top: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.source-note {
  margin: 0;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfd;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(110px, auto));
  border: 1px solid #bcc8cf;
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}

.segment {
  min-height: 40px;
  border: 0;
  border-right: 1px solid #bcc8cf;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

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

.segment.active {
  background: var(--blue);
  color: #fff;
}

.toggle {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.toggle input {
  width: 18px;
  min-height: 18px;
}

.action-row {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

button {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 700;
}

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

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

.ghost-button {
  background: #fff;
  border-color: #bdc9cf;
  color: var(--ink);
}

.ghost-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.summary-band {
  display: grid;
  grid-template-columns: 2fr 1fr 0.7fr;
  gap: 16px;
  padding-top: 16px;
  padding-bottom: 16px;
  background: #fdfcf8;
  border-bottom: 1px solid var(--line);
}

.summary-band > div {
  border-left: 4px solid var(--green);
  padding-left: 12px;
}

.summary-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.table-section {
  padding-top: 20px;
}

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

.search-box {
  position: relative;
  width: min(360px, 100%);
}

.search-box span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-box input {
  padding-left: 34px;
}

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

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

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

th {
  position: sticky;
  top: 0;
  background: #edf4f1;
  color: #40515b;
  font-size: 0.78rem;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #f8fbfd;
}

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

.amount {
  font-weight: 800;
  color: var(--green-dark);
}

.acid-class {
  color: var(--blue);
  font-weight: 800;
}

.cell-note {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.strong {
  background: #dff3ec;
  color: var(--green-dark);
}

.badge.possible {
  background: #fff0c9;
  color: var(--amber);
}

.badge.weak {
  background: #f8dddd;
  color: var(--red);
}

.custom-acid {
  padding-top: 22px;
  padding-bottom: 24px;
}

.custom-acid h2 {
  margin-bottom: 12px;
}

.custom-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(140px, 0.8fr) minmax(120px, 0.7fr) minmax(170px, 1fr) auto;
  gap: 14px;
  align-items: end;
}

@media (max-width: 980px) {
  .input-panel,
  .summary-band,
  .custom-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .action-row {
    margin-left: 0;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: 100%;
    padding: 0;
  }

  .workspace {
    min-height: 100vh;
    border-left: 0;
    border-right: 0;
  }

  .topbar,
  .table-header,
  .action-row,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .input-panel,
  .summary-band,
  .custom-grid {
    grid-template-columns: 1fr;
  }

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

  .segment {
    border-right: 0;
    border-bottom: 1px solid #bcc8cf;
  }

  .segment:last-child {
    border-bottom: 0;
  }

  .controls,
  .source-note,
  .summary-band,
  .table-section,
  .custom-acid,
  .topbar,
  .input-panel {
    padding-left: 16px;
    padding-right: 16px;
  }
}
