:root {
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-2: #eef5f1;
  --text: #23313a;
  --muted: #64737a;
  --line: #d8ded8;
  --primary: #14786f;
  --primary-dark: #0d5c55;
  --accent: #b86626;
  --danger: #b3261e;
  --shadow: 0 18px 50px rgba(35, 49, 58, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
}

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

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

button.secondary {
  background: #e5ebe7;
  color: var(--text);
}

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

button.danger {
  color: var(--danger);
}

button.text-button {
  background: transparent;
  color: var(--primary);
  min-height: auto;
  padding: 0;
  text-align: left;
}

button.text-button:hover {
  background: transparent;
  color: var(--primary-dark);
  text-decoration: underline;
}

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

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 120, 111, 0.14);
  outline: 0;
}

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

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

legend {
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 8px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1rem;
}

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

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td span {
  color: var(--muted);
  font-size: 0.82rem;
}

.auth-wrap {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.auth-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 20px;
  margin: 0 auto;
  max-width: 440px;
  padding: 28px;
  width: 100%;
}

.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 40px);
}

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

.tabs {
  background: #eef1ea;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  padding: 10px clamp(16px, 4vw, 40px);
}

.tab {
  background: transparent;
  color: var(--muted);
  min-height: 36px;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
}

.workspace {
  padding: clamp(16px, 4vw, 40px);
}

.calc-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 26px rgba(35, 49, 58, 0.06);
  padding: 20px;
}

.calculator-panel {
  align-content: start;
  display: grid;
  gap: 18px;
}

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

.input-unit {
  align-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.input-unit input {
  border: 0;
  border-radius: 0;
  min-width: 0;
}

.input-unit span {
  color: var(--muted);
  padding: 0 10px;
}

.choice-grid {
  display: grid;
  gap: 10px;
}

.choice {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: grid;
  font-weight: 600;
  grid-template-columns: 18px minmax(0, 1fr);
  min-height: 48px;
  padding: 10px 12px;
}

.choice input[type="radio"] {
  min-height: auto;
  width: 16px;
}

.choice strong {
  color: var(--primary);
  margin-left: 6px;
}

.inline-number {
  display: inline-block;
  margin-left: 8px;
  max-width: 130px;
  min-height: 34px;
}

.result-panel {
  display: grid;
  gap: 18px;
}

.empty-result {
  align-content: center;
  color: var(--muted);
  display: grid;
  gap: 10px;
  min-height: 320px;
  text-align: center;
}

.result-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.result-header h2 {
  font-size: clamp(1.65rem, 4vw, 2.5rem);
}

.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric {
  background: #f5f7f4;
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  display: grid;
  gap: 6px;
  padding: 14px;
}

.metric.accent {
  border-left-color: var(--accent);
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric strong {
  font-size: 1.4rem;
}

.breakdown {
  display: grid;
  gap: 10px;
}

dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
  text-align: right;
}

.items-table-wrap,
.table-scroll {
  overflow-x: auto;
}

.table-scroll.tall {
  max-height: 560px;
}

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

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

.admin-alert {
  margin-bottom: 16px;
}

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

.compact-label {
  max-width: 420px;
  margin-bottom: 16px;
}

.editor-toolbar {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.editor-toolbar .compact-label {
  margin-bottom: 0;
  min-width: min(420px, 100%);
}

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

.admin-grid table input,
.admin-grid table select {
  min-width: 120px;
}

.table-actions {
  white-space: nowrap;
}

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

.user-form button {
  grid-column: 1 / -1;
}

.eyebrow {
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.alert {
  background: #fff0ed;
  border: 1px solid #efc0ba;
  border-radius: 6px;
  color: var(--danger);
  padding: 10px 12px;
}

.notice {
  background: #edf7f4;
  border: 1px solid #afd8ce;
  border-radius: 6px;
  color: var(--primary-dark);
  padding: 10px 12px;
}

@media (max-width: 920px) {
  .calc-grid,
  .admin-grid,
  .metric-grid,
  .field-row,
  .settings-grid {
    grid-template-columns: 1fr;
  }

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

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }
}
