:root {
  --ink: #172026;
  --muted: #66737d;
  --line: #dce4e8;
  --surface: #f5f8f7;
  --panel: #ffffff;
  --accent: #0b7a75;
  --accent-strong: #075f5b;
  --warn: #b66a00;
  --danger: #bd3d32;
  --good: #207245;
  --shadow: 0 18px 55px rgba(23, 32, 38, .12);
  font-family: "Segoe UI", "Yu Gothic UI", "Meiryo", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(11, 122, 117, .12), transparent 34%),
    linear-gradient(300deg, rgba(182, 106, 0, .10), transparent 32%),
    var(--surface);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  min-width: 0;
}

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

.view-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.view-switch-button {
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.view-switch-button.active {
  background: var(--accent);
  color: #fff;
}

.master-screen {
  display: none;
}

body.master-view .user-screen,
body.master-view .company-logo-display {
  display: none;
}

body.master-view .master-screen {
  display: block;
}

.master-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  padding: 18px 0 12px;
  border-bottom: 1px solid var(--line);
}

.master-heading h2 {
  font-size: 26px;
}

.master-heading > span,
.master-section-heading p {
  color: var(--muted);
  font-size: 13px;
}

.master-section {
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.master-section-heading {
  margin-bottom: 14px;
}

.master-section-heading h3,
.master-section-heading p {
  margin: 0;
}

.master-section-heading h3 {
  margin-bottom: 4px;
  font-size: 17px;
}

.master-section textarea {
  width: 100%;
  min-height: 330px;
  margin: 0 0 12px;
}

.public-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.chrome-url-note {
  margin: 10px 0 0;
  padding: 9px 11px;
  border-left: 3px solid var(--warn);
  background: #fff8e8;
  color: #795000;
  font-size: 12px;
  line-height: 1.5;
}

.chrome-url-note[hidden] {
  display: none;
}

.contract-control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.plan-settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}

.plan-settings-grid label {
  min-width: 0;
}

.contract-summary-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

#accountUsageText {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbfb;
  color: var(--ink);
  font-weight: 800;
}

#accountUsageText.over-limit {
  border-color: rgba(190, 61, 47, .45);
  background: #fff1ee;
  color: #9f2f24;
}

.contract-switch {
  position: relative;
  min-height: 42px;
}

.contract-switch input {
  position: absolute;
  opacity: 0;
}

.contract-switch .toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #cbd5da;
}

.contract-switch .toggle::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
  transition: transform .18s ease;
}

.contract-switch input:checked + .toggle {
  background: var(--accent);
}

.contract-switch input:checked + .toggle::after {
  transform: translateX(20px);
}

.contract-suspended-notice {
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px solid #f0b8b8;
  border-radius: 8px;
  background: #fff2f2;
  color: #b42318;
  font-size: 13px;
  font-weight: 800;
}

.contract-suspended-notice[hidden] {
  display: none;
}

.legal-footer {
  position: fixed;
  right: 18px;
  bottom: 12px;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  max-width: min(92vw, 620px);
  padding: 8px 10px;
  border: 1px solid rgba(203, 213, 218, .85);
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .08);
}

.legal-footer button,
.legal-tabs button {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.legal-footer button:hover,
.legal-tabs button:hover {
  text-decoration: underline;
}

.legal-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .42);
}

.legal-modal[hidden] {
  display: none;
}

.legal-panel {
  width: min(760px, 100%);
  max-height: min(760px, 88vh);
  overflow: auto;
  padding: 20px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(15, 23, 42, .25);
}

.legal-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.legal-panel h2,
.legal-panel h3,
.legal-panel h4,
.legal-panel p {
  margin: 0;
}

.legal-panel h2 {
  font-size: 20px;
}

.legal-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.legal-tabs button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.legal-tabs button.active {
  border-color: var(--accent);
  background: rgba(11, 122, 117, .12);
}

.legal-content {
  display: none;
}

.legal-content.active {
  display: grid;
  gap: 12px;
}

.legal-content h3 {
  font-size: 18px;
}

.legal-content h4 {
  margin-top: 6px;
  color: var(--accent-strong);
  font-size: 14px;
}

.legal-content p {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.75;
}

.master-user-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.user-table-wrap {
  max-height: 420px;
  margin-top: 0;
}

.user-table-wrap td:last-child {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.user-status {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 999px;
  background: #e8f5ed;
  color: var(--good);
  font-size: 11px;
  font-weight: 800;
}

.user-status.disabled {
  background: #faeceb;
  color: var(--danger);
}

.user-action-button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

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

.empty-users {
  padding: 28px !important;
  color: var(--muted);
  text-align: center !important;
}

.admin-security-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.logout-button {
  position: fixed;
  z-index: 20;
  top: 14px;
  right: 14px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.admin-logout-button {
  right: 112px;
}

.master-auth-note {
  display: block;
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.6;
}

body.public-mode .view-switch {
  display: none;
}

.auth-gate[hidden] {
  display: none !important;
}

.auth-gate {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: auto;
  background: #eef3f2;
}

.auth-panel {
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-brand {
  min-height: 38px;
}

.auth-brand img {
  display: block;
  max-width: 180px;
  max-height: 48px;
  object-fit: contain;
}

.auth-brand img[hidden],
.auth-brand p[hidden] {
  display: none !important;
}

.auth-brand p {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.auth-panel > h1 {
  margin-top: 8px;
  font-size: 24px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 22px 0 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-tab {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.auth-tab.active {
  background: #e6f3f2;
  color: var(--accent-strong);
}

.auth-form {
  display: none;
  gap: 13px;
}

.auth-form.active {
  display: grid;
}

.auth-form label span,
.reset-url-box > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.auth-form small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.auth-message {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 12px;
}

.auth-link,
.auth-back {
  justify-self: start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.reset-url-box {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7faf9;
}

.reset-url-box[hidden] {
  display: none;
}

.business-bar,
.customer-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
  min-width: 0;
}

.business-actions {
  display: grid;
  grid-template-columns: minmax(120px, 1fr);
  gap: 6px;
  min-width: 0;
}

.customer-strip {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
}

.business-bar label,
.customer-strip label {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: clamp(26px, 3vw, 42px);
  overflow-wrap: anywhere;
  word-break: keep-all;
}

h2 {
  font-size: 18px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(116px, 1fr));
  gap: 8px;
  min-width: min(620px, 100%);
}

.status-strip div,
.metric,
.input-panel,
.results-panel {
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(220, 228, 232, .92);
  box-shadow: var(--shadow);
}

.status-strip div {
  min-height: 70px;
  padding: 13px 15px;
  border-radius: 8px;
}

.status-strip span,
.metric span,
.bank-detail span,
label > span,
legend {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-strip strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
}

.company-logo-display {
  display: grid;
  min-width: 240px;
  min-height: 82px;
  place-items: center end;
}

.company-logo-display img {
  display: block;
  max-width: 280px;
  max-height: 82px;
  object-fit: contain;
}

.company-logo-preview {
  display: grid;
  width: 240px;
  height: 82px;
  place-items: center;
  padding: 8px 12px;
  border: 1px dashed #aebbc2;
  border-radius: 8px;
  background: rgba(255, 255, 255, .92);
}

.company-logo-preview img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.company-logo-preview img[hidden],
.company-logo-display img[hidden],
.company-logo-preview span[hidden],
.print-brand img[hidden],
.print-brand p[hidden] {
  display: none !important;
}

.company-logo-preview span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.company-logo-actions {
  display: grid;
  gap: 4px;
}

.admin-logo-setting {
  padding: 4px 14px 16px;
  border-bottom: 1px solid var(--line);
}

.admin-logo-setting h3,
.admin-section-title {
  margin: 0 0 10px;
  font-size: 14px;
}

.admin-logo-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-section-title {
  padding: 14px 14px 0;
}

.company-logo-actions input[type="file"] {
  display: none;
}

.logo-upload-button {
  display: grid;
  min-height: 36px;
  place-items: center;
  padding: 0 12px;
  cursor: pointer;
}

.company-logo-actions .text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.company-logo-actions .text-button:disabled {
  cursor: not-allowed;
  opacity: .35;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.input-panel,
.results-panel {
  border-radius: 8px;
  min-width: 0;
}

.input-panel {
  position: sticky;
  top: 18px;
  padding: 18px;
}

.results-panel {
  padding: 18px;
}

.panel-heading,
.bank-toolbar,
.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

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

.fieldset-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.fieldset-heading legend {
  margin: 0;
}

.small-add-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: #fff;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

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

.prepay-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
}

.prepay-row .unit-input,
.prepay-row select {
  margin-top: 5px;
}

.prepay-row label {
  min-width: 0;
}

.prepay-row label:nth-child(3) {
  grid-column: 1 / 3;
}

.prepay-row .remove-prepayment {
  grid-column: 3;
  grid-row: 1 / 3;
  align-self: end;
}

.prepay-row input[type="number"] {
  min-width: 0;
  padding-left: 8px;
  padding-right: 4px;
}

.prepay-row .unit-input em {
  padding-right: 8px;
}

.remove-prepayment:disabled {
  cursor: not-allowed;
  opacity: .35;
}

legend {
  margin-bottom: 9px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 15px;
}

.field-grid.compact {
  margin-top: 12px;
}

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

.step-rate-fields {
  margin-top: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
}

label {
  min-width: 0;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.unit-input input {
  min-width: 0;
  border: 0;
  border-radius: 0;
  padding-right: 6px;
}

input,
select {
  min-height: 42px;
  padding: 0 11px;
}

.unit-input em {
  padding-right: 11px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.field-note {
  display: block;
  margin-top: 5px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
}

.field-note.warning {
  color: var(--danger);
}

.segmented {
  display: grid;
  gap: 8px;
}

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

.segmented label {
  display: block;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  min-height: 42px;
  place-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.segmented input:checked + span {
  border-color: var(--accent);
  background: rgba(11, 122, 117, .12);
  color: var(--accent-strong);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.switch {
  position: relative;
  width: 44px;
  height: 24px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  display: block;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #cbd5da;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
  transition: transform .18s ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

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

.compare-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  min-height: 118px;
  padding: 17px;
  border-radius: 8px;
}

.metric.primary {
  border-color: rgba(11, 122, 117, .45);
}

.metric strong {
  display: block;
  margin-top: 9px;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1;
  white-space: nowrap;
}

.metric small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.decision-row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.assistant-box {
  margin: 16px 0;
  padding: 15px;
  border: 1px solid rgba(46, 90, 116, .28);
  border-radius: 8px;
  background: #f7fafb;
}

.assistant-heading,
.assistant-heading div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.assistant-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.assistant-heading strong {
  color: var(--ink);
  font-size: 15px;
}

.assistant-box textarea {
  width: 100%;
  min-height: 92px;
  margin-top: 10px;
  resize: vertical;
}

.assistant-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.assistant-actions .secondary-button,
.assistant-actions .action-button {
  min-height: 40px;
  padding: 0 14px;
}

.assistant-log {
  display: grid;
  gap: 8px;
  max-height: 220px;
  margin-top: 12px;
  overflow: auto;
}

.assistant-bubble {
  width: fit-content;
  max-width: 96%;
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.55;
}

.assistant-bubble.user {
  justify-self: end;
  background: #0b7f78;
  color: #fff;
}

.assistant-bubble.bot {
  justify-self: start;
  border: 1px solid rgba(46, 90, 116, .22);
  background: #fff;
  color: var(--ink);
}

.assistant-box p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.step-rate-comparison {
  display: none;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid rgba(182, 106, 0, .35);
  border-radius: 8px;
  background: #fffaf1;
}

.step-rate-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.step-rate-heading span,
.step-rate-results span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.step-rate-heading strong {
  display: block;
  margin-top: 3px;
}

.step-rate-heading small {
  color: var(--warn);
  font-weight: 800;
}

.step-rate-results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 11px;
}

.step-rate-results > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.step-rate-results > div.after {
  border-color: rgba(182, 106, 0, .45);
}

.step-rate-results strong {
  display: block;
  margin-top: 5px;
  font-size: 25px;
}

.step-rate-results small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.tax-summary {
  margin: 16px 0;
  padding: 14px;
  border: 1px solid rgba(11, 122, 117, .35);
  border-radius: 8px;
  background: #f4fbfa;
}

.tax-summary-heading,
.tax-summary-heading div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tax-summary-heading span,
.tax-metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tax-summary-heading strong {
  color: var(--accent-strong);
}

.tax-summary-heading small {
  color: var(--muted);
}

.tax-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 11px;
}

.tax-metrics div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.tax-metrics strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
}

.tax-summary p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.tax-special {
  justify-content: space-between;
  min-height: 42px;
}

.tax-estimate-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.gauge {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--good), var(--warn) 64%, var(--danger));
  overflow: hidden;
}

.gauge::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
}

.gauge span {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  border-right: 4px solid var(--ink);
}

.decision-text strong,
.decision-text span {
  display: block;
}

.decision-text strong {
  margin-bottom: 3px;
}

.decision-text span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.tab.active {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.chart-wrap {
  width: 100%;
  min-height: 280px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

canvas {
  display: block;
  width: 100%;
  height: 260px;
}

.table-wrap {
  max-height: 360px;
  margin-top: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: #f7faf9;
  color: var(--muted);
  font-size: 12px;
}

.note-box {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--muted);
  line-height: 1.65;
}

.bank-toolbar {
  align-items: end;
}

.bank-toolbar label {
  flex: 1;
}

.bank-toolbar select {
  margin-top: 6px;
}

.action-button,
.editor-actions button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.bank-detail {
  display: grid;
  grid-template-columns: 1.1fr .8fr 1.4fr;
  gap: 12px;
  margin-top: 12px;
}

.bank-detail div {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.bank-detail strong {
  display: block;
  margin-top: 8px;
  line-height: 1.45;
}

.bank-detail strong a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.bank-detail strong a:hover {
  color: var(--accent);
}

.editor {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.editor summary {
  padding: 13px 14px;
  cursor: pointer;
  font-weight: 800;
}

textarea {
  display: block;
  min-height: 210px;
  margin: 0 14px 12px;
  width: calc(100% - 28px);
  padding: 12px;
  font-family: Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
}

.editor-actions {
  justify-content: flex-end;
  padding: 0 14px 14px;
}

.print-report {
  display: none;
}

body.pdf-export {
  overflow: hidden;
}

body.pdf-export .print-report {
  position: fixed;
  z-index: -1;
  top: 0;
  left: -10000px;
  display: block;
  width: 794px;
  height: 1123px;
  padding: 53px;
  overflow: hidden;
  color: #172026;
  background: #fff;
  font-family: "Yu Gothic UI", "Meiryo", sans-serif;
}

body.pdf-export .print-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 3px solid #0b7a75;
}

body.pdf-export .print-header p {
  margin: 0 0 4px;
  color: #0b7a75;
  font-size: 13px;
  font-weight: 800;
}

body.pdf-export .print-brand {
  min-height: 30px;
}

body.pdf-export .print-brand img {
  display: block;
  max-width: 190px;
  max-height: 42px;
  object-fit: contain;
}

body.pdf-export .print-header h1 {
  font-size: 29px;
}

body.pdf-export .print-meta {
  text-align: right;
}

body.pdf-export .print-meta span,
body.pdf-export .print-customer span,
body.pdf-export .print-grid span,
body.pdf-export .print-results span,
body.pdf-export .print-bank span {
  display: block;
  color: #66737d;
  font-size: 11px;
  font-weight: 700;
}

body.pdf-export .print-meta strong {
  font-size: 13px;
}

body.pdf-export .print-customer {
  display: grid;
  grid-template-columns: 1fr 1.4fr .7fr;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid #dce4e8;
  background: #f7faf9;
}

body.pdf-export .print-customer strong,
body.pdf-export .print-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

body.pdf-export #printRate {
  font-size: 11px;
  line-height: 1.35;
}

body.pdf-export .print-section-title {
  margin: 18px 0 8px;
  padding-left: 8px;
  border-left: 4px solid #0b7a75;
  font-size: 16px;
}

body.pdf-export .print-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid #dce4e8;
  border-left: 1px solid #dce4e8;
}

body.pdf-export .print-grid div {
  min-height: 58px;
  padding: 9px;
  border-right: 1px solid #dce4e8;
  border-bottom: 1px solid #dce4e8;
}

body.pdf-export .print-results {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

body.pdf-export .print-results div {
  min-height: 72px;
  padding: 11px;
  border: 1px solid #9cc9c6;
  background: #eef8f7;
}

body.pdf-export .print-results strong {
  display: block;
  margin-top: 10px;
  font-size: 19px;
  white-space: nowrap;
}

body.pdf-export .print-tax {
  display: grid;
  grid-template-columns: .8fr .9fr 1.4fr;
  gap: 8px;
  margin-top: 10px;
  padding: 9px;
  border: 1px solid #9cc9c6;
  background: #f4fbfa;
}

body.pdf-export .print-step-rate {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #ddb977;
  background: #fffaf1;
}

body.pdf-export .print-step-rate span {
  color: #66737d;
  font-size: 10px;
  font-weight: 700;
}

body.pdf-export .print-step-rate strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
}

body.pdf-export .print-step-rate p {
  grid-column: 1 / -1;
  margin: 0;
  color: #795000;
  font-size: 9px;
}

body.pdf-export .print-tax span {
  color: #66737d;
  font-size: 10px;
  font-weight: 700;
}

body.pdf-export .print-tax strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
}

body.pdf-export .print-tax p {
  grid-column: 1 / -1;
  margin: 0;
  color: #66737d;
  font-size: 9px;
  line-height: 1.35;
}

body.pdf-export .print-detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 4px;
}

body.pdf-export .print-detail-row .print-section-title {
  margin-top: 14px;
}

body.pdf-export .print-chart-frame {
  height: 182px;
  padding: 5px;
  border: 1px solid #dce4e8;
  background: #fff;
}

body.pdf-export .print-chart-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

body.pdf-export .print-prepay-grid {
  display: grid;
  grid-template-columns: 1fr;
  border-top: 1px solid #dce4e8;
  border-left: 1px solid #dce4e8;
}

body.pdf-export .print-prepay-grid div {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  align-items: center;
  min-height: 36px;
  padding: 7px 9px;
  border-right: 1px solid #dce4e8;
  border-bottom: 1px solid #dce4e8;
}

body.pdf-export .print-prepay-grid span {
  color: #66737d;
  font-size: 11px;
  font-weight: 700;
}

body.pdf-export .print-prepay-grid strong {
  font-size: 14px;
  text-align: right;
  white-space: nowrap;
}

body.pdf-export .print-prepay-section > p {
  margin: 7px 0 0;
  color: #66737d;
  font-size: 10px;
  line-height: 1.4;
}

body.pdf-export .print-bank {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #dce4e8;
}

body.pdf-export .print-bank strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
}

body.pdf-export .print-bank p {
  margin: 5px 0 0;
  color: #66737d;
  font-size: 11px;
  line-height: 1.4;
}

body.pdf-export .print-footer {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #dce4e8;
}

body.pdf-export .print-footer p {
  margin: 0;
  color: #66737d;
  font-size: 10px;
  line-height: 1.55;
}

@page {
  size: A4 portrait;
  margin: 14mm;
}

@media print {
  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  body {
    background: #fff;
  }

  .app-shell,
  dialog {
    display: none !important;
  }

  .print-report {
    display: block;
    color: #172026;
    font-family: "Yu Gothic UI", "Meiryo", sans-serif;
  }

  .print-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 3px solid #0b7a75;
  }

  .print-header p {
    margin: 0 0 4px;
    color: #0b7a75;
    font-size: 10pt;
    font-weight: 800;
  }

  .print-brand img {
    display: block;
    max-width: 50mm;
    max-height: 12mm;
    object-fit: contain;
  }

  .print-header h1 {
    font-size: 22pt;
  }

  .print-meta {
    text-align: right;
  }

  .print-meta span,
  .print-customer span,
  .print-grid span,
  .print-results span,
  .print-bank span {
    display: block;
    color: #66737d;
    font-size: 8.5pt;
    font-weight: 700;
  }

  .print-meta strong {
    font-size: 10pt;
  }

  .print-customer {
    display: grid;
    grid-template-columns: 1fr 1.4fr .7fr;
    gap: 10px;
    margin-top: 14px;
    padding: 10px 12px;
    border: 1px solid #dce4e8;
    background: #f7faf9;
  }

  .print-customer strong,
  .print-grid strong {
    display: block;
    margin-top: 4px;
    font-size: 10.5pt;
  }

  #printRate {
    font-size: 8pt;
    line-height: 1.35;
  }

  .print-section-title {
    margin: 18px 0 8px;
    padding-left: 8px;
    border-left: 4px solid #0b7a75;
    font-size: 12pt;
  }

  .print-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid #dce4e8;
    border-left: 1px solid #dce4e8;
  }

  .print-grid div {
    min-height: 58px;
    padding: 9px;
    border-right: 1px solid #dce4e8;
    border-bottom: 1px solid #dce4e8;
  }

  .print-results {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .print-results div {
    min-height: 72px;
    padding: 11px;
    border: 1px solid #9cc9c6;
    background: #eef8f7;
  }

  .print-results strong {
    display: block;
    margin-top: 10px;
    font-size: 15pt;
    white-space: nowrap;
  }

  .print-tax {
    display: grid;
    grid-template-columns: .8fr .9fr 1.4fr;
    gap: 2mm;
    margin-top: 2mm;
    padding: 2mm;
    border: 1px solid #9cc9c6;
    background: #f4fbfa;
  }

  .print-step-rate {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 2mm;
    margin-top: 2mm;
    padding: 2mm;
    border: 1px solid #ddb977;
    background: #fffaf1;
  }

  .print-step-rate span {
    color: #66737d;
    font-size: 7pt;
    font-weight: 700;
  }

  .print-step-rate strong {
    display: block;
    margin-top: 1mm;
    font-size: 10pt;
  }

  .print-step-rate p {
    grid-column: 1 / -1;
    margin: 0;
    color: #795000;
    font-size: 6.5pt;
  }

  .print-tax span {
    color: #66737d;
    font-size: 7pt;
    font-weight: 700;
  }

  .print-tax strong {
    display: block;
    margin-top: 1mm;
    font-size: 9pt;
  }

  .print-tax p {
    grid-column: 1 / -1;
    margin: 0;
    color: #66737d;
    font-size: 6.5pt;
    line-height: 1.3;
  }

  .print-detail-row {
    display: grid;
    grid-template-columns: 1.45fr 1fr;
    gap: 4mm;
  }

  .print-detail-row .print-section-title {
    margin-top: 12px;
  }

  .print-chart-frame {
    height: 47mm;
    padding: 1mm;
    border: 1px solid #dce4e8;
  }

  .print-chart-frame img {
    display: block;
    width: 100%;
    height: 100%;
  }

  .print-prepay-grid {
    border-top: 1px solid #dce4e8;
    border-left: 1px solid #dce4e8;
  }

  .print-prepay-grid div {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    align-items: center;
    min-height: 12mm;
    padding: 2mm;
    border-right: 1px solid #dce4e8;
    border-bottom: 1px solid #dce4e8;
  }

  .print-prepay-grid span {
    color: #66737d;
    font-size: 8pt;
    font-weight: 700;
  }

  .print-prepay-grid strong {
    font-size: 10pt;
    text-align: right;
    white-space: nowrap;
  }

  .print-prepay-section > p {
    margin: 2mm 0 0;
    color: #66737d;
    font-size: 7.5pt;
    line-height: 1.4;
  }

  .print-bank {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid #dce4e8;
  }

  .print-bank strong {
    display: block;
    margin-top: 5px;
    font-size: 12pt;
  }

  .print-bank p {
    margin: 5px 0 0;
    color: #66737d;
    font-size: 9pt;
    line-height: 1.5;
  }

  .print-footer {
    margin-top: 20px;
    padding-top: 8px;
    border-top: 1px solid #dce4e8;
  }

  .print-footer p {
    margin: 0;
    color: #66737d;
    font-size: 8pt;
    line-height: 1.55;
  }
}

@media (max-width: 1120px) {
  .topbar,
  .layout-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .input-panel {
    position: static;
  }
}

@media (max-width: 980px) {
  .plan-settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .plan-settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .app-shell {
    width: 100%;
    overflow-x: hidden;
  }

  .workspace,
  .topbar,
  .layout-grid,
  .input-panel,
  .results-panel {
    width: 100%;
    min-width: 0;
  }

  .topbar {
    gap: 10px;
  }

  .topbar > div:first-child {
    min-width: 0;
  }

  h1 {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .logout-button {
    position: static;
    justify-self: end;
    margin: 0 0 8px auto;
  }

  .business-bar,
  .customer-strip,
  .layout-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 780px) {
  .app-shell {
    width: 100%;
    padding: 14px 10px 96px;
    overflow-x: hidden;
  }

  .workspace {
    width: 100%;
    min-width: 0;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 12px;
  }

  .topbar > div:first-child {
    min-width: 0;
  }

  h1 {
    max-width: 100%;
    font-size: 24px;
    line-height: 1.22;
    white-space: normal;
  }

  .eyebrow {
    font-size: 11px;
  }

  .logout-button {
    position: static;
    justify-self: end;
    width: fit-content;
    margin: 0 0 8px auto;
  }

  .company-logo-display {
    min-width: 0;
    min-height: 64px;
    place-items: center start;
  }

  .view-switch {
    display: grid;
    width: 100%;
  }

  .business-bar,
  .customer-strip {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .business-actions {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .secondary-button,
  .danger-button,
  .customer-strip button {
    width: 100%;
    min-height: 40px;
  }

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

  .public-url-row {
    grid-template-columns: 1fr;
  }

  .master-user-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .company-logo-display img {
    max-width: min(260px, 80vw);
    max-height: 64px;
  }

  .admin-logo-row {
    align-items: stretch;
    flex-direction: column;
  }

  .company-logo-preview {
    width: 100%;
  }

  .status-strip,
  .summary-grid,
  .compare-grid,
  .tax-metrics,
  .bank-detail,
  .decision-row {
    grid-template-columns: 1fr;
  }

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

  .layout-grid {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    gap: 12px;
  }

  .input-panel,
  .results-panel {
    width: 100%;
    padding: 14px;
  }

  .panel-heading {
    align-items: flex-start;
    gap: 8px;
  }

  .prepay-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .prepay-row label:nth-child(3),
  .prepay-row .remove-prepayment {
    grid-column: auto;
    grid-row: auto;
  }

  .prepay-row .remove-prepayment {
    width: 100%;
  }

  .step-rate-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .step-rate-results {
    grid-template-columns: 1fr;
  }

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

  .segmented span {
    justify-content: center;
    padding: 0 12px;
  }

  .assistant-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .bank-toolbar {
    display: grid;
  }

  .action-button {
    width: 100%;
  }

  .metric strong {
    font-size: 28px;
  }
}
