:root {
  --bg: #F1F3EE;
  --panel: #FFFFFF;
  --ink: #171B1E;
  --ink-soft: #626B67;
  --ink-faint: #93998F;
  --line: #DEE3D9;
  --line-strong: #C7CEC1;
  --accent: #146C46;
  --accent-ink: #0E4E33;
  --accent-soft: #E3F1E8;
  --danger: #AE3327;
  --danger-soft: #FBEBE9;
  --radius-card: 18px;
  --radius-input: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-feature-settings: "tnum" 1;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 28px clamp(20px, 5vw, 56px) 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.brand-sub {
  margin-left: 10px;
  font-size: 0.85rem;
  color: var(--ink-faint);
}

.topbar-hint {
  font-size: 0.8rem;
  color: var(--ink-soft);
  display: none;
}

@media (min-width: 720px) {
  .topbar-hint { display: block; }
}

/* ---------- Ticker tabs ---------- */
.ticker {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 14px clamp(20px, 5vw, 56px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  scrollbar-width: thin;
}

.ticker::-webkit-scrollbar { height: 6px; }
.ticker::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }

.tab-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ink-soft);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  background: var(--bg);
}

.tab-btn.active {
  color: var(--ink);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.tab-monogram {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
  flex: 0 0 auto;
}

/* ---------- Desk layout ---------- */
.desk {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  padding: clamp(20px, 4vw, 40px) clamp(20px, 5vw, 56px);
  max-width: 1080px;
  margin: 0 auto;
}

@media (min-width: 860px) {
  .desk {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: start;
  }
}

/* ---------- Ticket (inputs) ---------- */
.ticket {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 26px clamp(20px, 3vw, 32px) 28px;
}

.ticket-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.ticket-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  flex: 0 0 auto;
}

.ticket-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.ticket-kicker {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--ink-faint);
}

.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-bottom: 7px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-input);
  background: var(--bg);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-wrap .prefix {
  padding: 0 0 0 14px;
  font-size: 0.88rem;
  color: var(--ink-faint);
  font-family: "IBM Plex Mono", monospace;
}

.input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: "IBM Plex Mono", monospace;
  color: var(--ink);
  min-width: 0;
}

.input-wrap input:focus { outline: none; }

.input-wrap input::-webkit-outer-spin-button,
.input-wrap input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 10px;
  background: var(--bg);
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 6px 16px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-soft);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.seg-btn.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.error-line {
  min-height: 18px;
  font-size: 0.82rem;
  color: var(--danger);
  margin: 4px 0 14px;
}

.calc-btn {
  width: 100%;
  padding: 13px 18px;
  border: none;
  border-radius: var(--radius-input);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.05s ease;
}

.calc-btn:hover { background: var(--accent-ink); }
.calc-btn:active { transform: translateY(1px); }

/* ---------- Stub (results) ---------- */
.stub {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 22px clamp(20px, 3vw, 30px) 26px;
  position: relative;
}

.stub::before {
  content: "";
  position: absolute;
  top: -1px; left: 0; right: 0;
  height: 4px;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  background: repeating-linear-gradient(90deg, var(--line-strong) 0 8px, transparent 8px 14px);
}

.stub-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
  text-transform: none;
  color: var(--ink-faint);
  margin-bottom: 16px;
  font-family: "IBM Plex Mono", monospace;
}

.stub-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.9rem;
}

.stub-label { color: var(--ink-soft); }
.stub-value { color: var(--ink); font-weight: 500; }

.stub-divider { height: 6px; }

.stub-primary {
  display: flex;
  gap: 10px;
  margin: 4px 0 14px;
}

.size-block {
  flex: 1;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
}

.size-block:first-child {
  background: var(--accent);
}

.size-block:first-child .size-label,
.size-block:first-child .size-value {
  color: #fff;
}

.size-label {
  display: block;
  font-size: 0.68rem;
  color: var(--accent-ink);
  margin-bottom: 6px;
}

.size-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent-ink);
}

.stub-note {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin: 4px 0 0;
  line-height: 1.45;
}

.stub.has-error .stub-primary .size-block {
  opacity: 0.45;
}

/* ---------- Footer ---------- */
.disclaimer {
  text-align: center;
  font-size: 0.76rem;
  color: var(--ink-faint);
  padding: 22px 20px 34px;
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.5;
}

@media (max-width: 480px) {
  .field-row { grid-template-columns: 1fr; }
  .stub-primary { flex-wrap: wrap; }
  .size-block { min-width: 30%; }
}
