:root {
  --bg: #f4f4f4;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --text: #151515;
  --muted: #606060;
  --line: #d7d7d7;
  --line-strong: #1f1f1f;
  --accent: #ff8c00;
  --accent-dark: #c96b00;
  --danger: #a1260d;
  --ok: #107c10;
  --mono: "Cascadia Code", "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-width: 1265px;
  min-height: 918px;
  color: var(--text);
  background: var(--bg);
  font-family: var(--ui);
  overflow: auto;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: 100%;
  min-width: 1265px;
  height: 918px;
  min-height: 918px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: relative;
  height: 88px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 16px;
}

.topbar > div {
  min-width: 0;
  max-width: 100%;
}

.topbar > div:first-child {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.site-nav {
  flex: 0 0 auto;
  position: absolute;
  left: 464px;
  top: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  font-family: var(--mono);
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 156px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
}

.site-nav a.active {
  border: 2px solid var(--accent);
  background: var(--surface);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
  font-weight: 800;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.topbar-meter {
  text-align: right;
  font-family: var(--mono);
  border: 2px solid var(--line-strong);
  padding: 0 14px;
  min-width: 290px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.rate-card {
  flex: 0 0 auto;
  min-width: 270px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 0 12px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
  display: flex;
  align-items: center;
}

.rate-card strong {
  float: right;
  margin-left: 16px;
}

.topbar-meter span:first-child {
  font-size: 26px;
  font-weight: 800;
}

.topbar-meter small {
  color: var(--muted);
}

.topbar-meter.is-over-limit {
  border-color: var(--danger);
  color: var(--danger);
  background: #fff4ce;
}

.workspace {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(370px, 1.12fr) minmax(420px, 1.18fr);
  gap: 12px;
  padding: 10px 14px 12px;
}

.panel {
  min-height: 0;
  min-width: 0;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.08);
}

.rule-panel,
.bucket-panel,
.payment-panel {
  display: flex;
  flex-direction: column;
}

.rule-panel {
  height: 100%;
  overflow: hidden;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.tab {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

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

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 -3px 0 var(--accent);
  font-weight: 700;
}

.tab-pane {
  display: none;
  padding: 18px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
}

label {
  display: block;
  margin: 10px 0 5px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  font-family: var(--mono);
}

input,
select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--line-strong);
  box-shadow: 2px 2px 0 var(--accent);
}

input[type="checkbox"]:focus,
input[type="radio"]:focus,
input[type="range"]:focus,
select:focus {
  box-shadow: none;
}

.mono-input {
  font-family: var(--mono);
}

.pattern-field {
  display: flex;
  gap: 14px;
  align-items: center;
}

.pattern-input {
  flex: 1 1 24rem;
  max-width: 42rem;
  height: 44px;
  padding-top: 2px;
  font-size: 15px;
  line-height: 44px;
}

.input-composer {
  position: relative;
  width: 100%;
}

.pattern-field .input-composer {
  flex: 1 1 24rem;
  max-width: 42rem;
}

.composer-input {
  text-align: center;
  font-size: 15px;
}

.input-composer:not(.is-editing):not(.is-dirty) .composer-input {
  color: transparent;
  caret-color: var(--text);
}

.composer-overlay {
  position: absolute;
  inset: 1px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
}

.input-composer.is-editing .composer-overlay,
.input-composer.is-dirty .composer-overlay {
  display: none;
}

#dictComposer:not(.is-editing) .composer-input {
  color: transparent;
  caret-color: var(--text);
}

#dictComposer:not(.is-editing) .composer-overlay {
  display: flex;
}

.composer-ghost {
  color: #a8a8a8;
}

.composer-value {
  color: var(--text);
}

.tld-preview {
  min-width: 90px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
}

.tool-row,
.draft-actions,
.coupon-row,
.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-row {
  margin-top: 10px;
}

.small-btn,
.ghost-btn,
.danger-btn,
.primary-btn,
.secondary-btn,
.apply-btn,
.pay-btn {
  border-radius: 0;
  font-family: var(--mono);
  font-weight: 800;
}

.small-btn,
.ghost-btn,
.danger-btn,
.secondary-btn,
.apply-btn {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.danger-btn {
  color: var(--danger);
  margin-left: auto;
}

.primary-btn,
.pay-btn {
  width: 100%;
  min-height: 44px;
  border: 2px solid var(--line-strong);
  color: #fff;
  background: #111;
  box-shadow: 12px 12px 18px rgba(0, 0, 0, 0.34);
}

.secondary-btn {
  width: 100%;
  min-height: 44px;
}

.primary-btn:hover,
.pay-btn:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  box-shadow: 14px 14px 22px rgba(0, 0, 0, 0.38);
}

.pay-btn:disabled,
.primary-btn:disabled {
  color: #777;
  background: #e6e6e6;
  box-shadow: none;
  cursor: not-allowed;
}

.hint {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}

code {
  font-family: var(--mono);
  background: #ededed;
  padding: 1px 4px;
}

.estimate {
  margin: 24px 0 16px;
  padding: 12px;
  border-left: 4px solid var(--accent);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 13px;
}

.tld-panel {
  padding: 12px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.tld-title {
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.tld-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 31px;
  gap: 8px;
  min-height: 70px;
}

.tld-grid label,
.tld-placeholder {
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 0 9px;
  text-transform: none;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  background: #fff;
}

.tld-placeholder {
  color: var(--muted);
  background: var(--surface-2);
}

.tld-grid input {
  width: auto;
  height: auto;
}

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

.letter-grid {
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  gap: 5px;
}

.letter-grid label {
  min-height: 28px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin: 0;
  padding: 0 2px;
  text-transform: none;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.letter-grid input {
  width: auto;
  height: auto;
}

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

.check-grid label,
.segmented label,
.inline-check {
  min-height: 34px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0 9px;
  text-transform: none;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}

.check-grid input,
.segmented input,
.inline-check input {
  width: auto;
  height: auto;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.draft-actions {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
}

.rule-actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: auto 18px 0;
  padding-top: 12px;
}

.rule-actions.is-editing {
  grid-template-columns: 1fr 1fr;
}

.sample-panel {
  flex: 0 0 auto;
  margin: 18px;
  margin-top: 18px;
  border: 2px solid var(--accent);
  height: 138px;
  padding: 10px 14px;
  overflow: hidden;
  background: #fff;
}

.sample-title {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.sample-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(5, 17px);
  grid-auto-flow: column;
  grid-auto-rows: 17px;
  gap: 2px 18px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.25;
  color: var(--muted);
}

.sample-list span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.panel-title h2,
.payment-panel h2 {
  margin: 0;
  font-size: 16px;
}

.limit-track {
  height: 10px;
  background: #e2e2e2;
  border-bottom: 1px solid var(--line);
}

.limit-track span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 180ms ease;
}

.message {
  margin: 12px 16px 0;
  padding: 10px;
  border: 1px solid var(--line-strong);
  font-family: var(--mono);
  font-size: 12px;
  background: #fff4ce;
  color: var(--danger);
}

.rule-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  padding: 30px;
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
}

.rule-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  padding: 12px;
  margin-bottom: 10px;
  background: var(--surface-2);
}

.rule-item.is-selected {
  border-color: var(--line-strong);
  background: #fff;
  box-shadow: inset 4px 0 0 var(--line-strong);
}

.rule-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.rule-name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 800;
  word-break: break-word;
}

.rule-metrics {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  border: 1px solid var(--line);
  background: #fff;
  padding: 6px;
  font-family: var(--mono);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.metric strong {
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.payment-panel {
  padding: 16px 18px;
}

.email-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.email-grid input {
  font-size: 15px;
}

.quote-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: center;
}

.quote-btn {
  min-height: 40px;
  border: 2px solid var(--line-strong);
  color: #fff;
  background: #111;
  border-radius: 0;
  font-family: var(--mono);
  font-weight: 800;
  box-shadow: 10px 10px 16px rgba(0, 0, 0, 0.28);
}

.coupon-apply {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.coupon-apply input {
  height: 40px;
}

.apply-btn {
  min-height: 40px;
  min-width: 78px;
}

.service-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.service-card {
  min-height: 96px;
  border: 1px solid var(--line);
  margin: 0;
  padding: 12px 14px;
  text-transform: none;
  cursor: pointer;
  background: var(--surface-2);
}

.service-card.active {
  border: 2px solid var(--accent);
  background: #fff;
}

.service-card input {
  position: absolute;
  width: auto;
  height: auto;
  opacity: 0;
  pointer-events: none;
}

.service-card span {
  display: block;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 800;
}

.service-card em {
  font-style: normal;
  color: inherit;
}

.service-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.42;
}

.price-box {
  margin: 0 0 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
}

.price-box div {
  min-height: 34px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 12px;
}

.price-box div:last-child {
  border-bottom: 0;
}

.price-box .total {
  border-top: 2px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.payment-result {
  min-height: 268px;
  margin-top: 0;
  padding: 12px;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  background: var(--surface-2);
  word-break: break-word;
}

.quote-result {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: stretch;
}

.quote-left {
  display: flex;
  min-height: 100%;
  flex-direction: column;
}

.quote-left .pay-btn {
  margin-top: auto;
}

.quote-result[hidden] {
  display: none;
}

.qr-wrap {
  margin-top: 8px;
  display: flex;
  justify-content: center;
}

.qr-code {
  width: 172px;
  height: 172px;
  padding: 6px;
  border: 1px solid var(--line);
  background: #fff;
}

.address-copy-area {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.address-copy-area span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-icon {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  padding: 0 2px;
}

.copy-icon:hover {
  opacity: 0.7;
}
