:root {
  color-scheme: light;
  --bg: #eef1f5;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #617084;
  --line: #d8dee8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #e2f3f1;
  --brand-red: #e30613;
  --brand-red-dark: #b80712;
  --warn: #b45309;
  --shadow: 0 18px 45px rgba(31, 41, 55, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 22px;
  display: grid;
  place-items: center;
}

.workspace {
  width: min(980px, 100%);
}

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

.brand-block {
  display: grid;
  gap: 8px;
}

.store-logo {
  width: min(210px, 55vw);
  height: auto;
  display: block;
}

.topbar h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
  font-weight: 750;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.result-label,
.metric-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0;
}

.calculator-grid {
  display: grid;
  grid-template-columns: minmax(300px, 370px) minmax(390px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel {
  padding: 20px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

label {
  color: #253244;
  font-size: 15px;
  font-weight: 700;
}

.money-input {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  height: 54px;
  border: 1px solid #b9c3d2;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.money-input:focus-within,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

input,
select {
  width: 100%;
  border: 1px solid #b9c3d2;
  background: #ffffff;
  color: var(--ink);
}

input {
  min-width: 0;
  height: 52px;
  border: 0;
  padding: 0 16px;
  font-size: 24px;
  font-weight: 700;
}

input:focus,
select:focus {
  outline: none;
}

.money-input span {
  padding: 0 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

select {
  height: 48px;
  padding: 0 12px;
  border-radius: 8px;
  font-weight: 650;
}

.mode-summary {
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  line-height: 1.45;
}

.mode-summary strong {
  color: var(--ink);
}

.quick-adjust {
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px dashed #c7d0dd;
  border-radius: 8px;
  background: #fbfcfe;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #253244;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
}

.toggle-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-red);
}

.quick-adjust-fields {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.quick-adjust-fields label {
  font-size: 12px;
}

.quick-adjust-input {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  width: min(180px, 100%);
  height: 38px;
  border: 1px solid #b9c3d2;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.quick-adjust-input input {
  height: 36px;
  border: 0;
  padding: 0 10px;
  font-size: 16px;
}

.quick-adjust-input span {
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.button-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.settings-button,
.secondary-button {
  height: 42px;
  padding: 0 18px;
  border: 1px solid #b9c3d2;
  border-radius: 8px;
  background: #ffffff;
  color: #263548;
  cursor: pointer;
  font-weight: 750;
}

.settings-button {
  flex: 0 0 auto;
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

.settings-button:hover {
  background: #2a3748;
}

.secondary-button:hover {
  background: #f8fafc;
}

.primary-button {
  height: 42px;
  padding: 0 18px;
  border: 1px solid var(--brand-red);
  border-radius: 8px;
  background: var(--brand-red);
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
}

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

.result-panel {
  position: relative;
  overflow: hidden;
  min-height: 300px;
  padding: 24px;
  display: grid;
  align-content: start;
  justify-items: end;
  text-align: right;
  border-color: #f1c4c8;
}

.result-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--brand-red);
}

.result-price {
  margin-top: 12px;
  font-size: clamp(54px, 7vw, 86px);
  line-height: 1;
  color: var(--brand-red);
  letter-spacing: 0;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  text-wrap: balance;
}

.result-subtitle {
  margin-top: 12px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 650;
}

.metric-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(118px, 1fr));
  gap: 10px;
  margin-top: 28px;
  text-align: left;
}

.metric-grid div {
  min-height: 84px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.metric-grid strong {
  display: block;
  margin-top: 10px;
  font-size: 21px;
  font-variant-numeric: tabular-nums;
}

.negative {
  color: var(--warn);
}

.settings-dialog {
  width: min(1000px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
}

.settings-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.settings-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(760px, calc(100vh - 32px));
  background: var(--panel);
}

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

.settings-header h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.settings-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.settings-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.settings-footer > div {
  display: flex;
  gap: 10px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
}

.settings-content {
  overflow: auto;
  padding: 18px 20px 22px;
}

.settings-section {
  padding: 16px 0 18px;
  border-bottom: 1px solid var(--line);
}

.settings-section:first-child {
  padding-top: 0;
}

.settings-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.settings-section h3,
.settings-product h4 {
  margin: 0 0 12px;
}

.settings-section-title,
.custom-product-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-section h3 {
  font-size: 18px;
}

.settings-note,
.empty-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.settings-product {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  margin-bottom: 10px;
}

.settings-product h4 {
  font-size: 15px;
}

.compact-button {
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.remove-button {
  height: 32px;
  padding: 0 10px;
  border: 1px solid #f1c4c8;
  border-radius: 8px;
  background: #fff5f6;
  color: var(--brand-red-dark);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(118px, 1fr) minmax(82px, 112px) minmax(100px, 0.8fr) minmax(82px, 112px);
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.settings-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-transform: uppercase;
}

.settings-row strong {
  color: var(--ink);
  font-size: 14px;
}

.settings-row input {
  height: 40px;
  border: 1px solid #b9c3d2;
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
  font-size: 15px;
  font-weight: 700;
}

.custom-settings-row {
  grid-template-columns: minmax(72px, 90px) minmax(220px, 1fr) minmax(98px, 120px) minmax(82px, 112px);
}

@media (max-width: 860px) {
  .app-shell {
    padding: 18px;
    place-items: start center;
  }

  .topbar,
  .calculator-grid {
    grid-template-columns: 1fr;
  }

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

  .settings-button {
    width: max-content;
  }

  .result-panel {
    justify-items: start;
    text-align: left;
  }

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

@media (max-width: 520px) {
  .app-shell {
    padding: 12px;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .result-price {
    font-size: clamp(48px, 15vw, 70px);
  }

  .input-panel,
  .result-panel {
    padding: 16px;
  }

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

  .settings-header,
  .settings-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-footer > div {
    display: grid;
  }

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

  .settings-section-title,
  .custom-product-header {
    align-items: stretch;
    flex-direction: column;
  }

  .custom-settings-row {
    grid-template-columns: 1fr;
  }
}

/* Agenda Prink integration */

:root {
  --bg: transparent;
  --ink: #17191d;
  --muted: #656b75;
  --line: #dde1e6;
  --accent: #e3062e;
  --accent-dark: #b90024;
  --accent-soft: #fff0f3;
  --brand-red: #e3062e;
  --brand-red-dark: #b90024;
  --shadow: 0 1px 2px rgba(23, 25, 29, 0.04), 0 10px 28px rgba(23, 25, 29, 0.06);
}

html,
body {
  background: transparent;
  min-height: 0;
  overflow-x: hidden;
}

.app-shell {
  min-height: 0;
  padding: 0 1px 24px;
  place-items: start stretch;
}

.workspace {
  width: 100%;
}

.topbar {
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 12px;
  min-height: 38px;
}

.brand-block {
  display: none;
}

.tool-header-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.sync-status {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 750;
  gap: 6px;
}

.sync-status::before {
  background: #9aa0a9;
  border-radius: 50%;
  content: "";
  height: 7px;
  width: 7px;
}

.sync-status[data-state="synced"]::before {
  background: #18864b;
  box-shadow: 0 0 0 3px rgba(24, 134, 75, 0.12);
}

.sync-status[data-state="loading"]::before {
  background: #d28a13;
}

.settings-button,
.primary-button {
  background: var(--brand-red);
  border-color: var(--brand-red);
}

.settings-button:hover,
.primary-button:hover {
  background: var(--brand-red-dark);
}

.calculator-grid {
  grid-template-columns: minmax(300px, 0.8fr) minmax(390px, 1.2fr);
}

.panel,
.settings-panel {
  border-radius: 7px;
}

.result-panel {
  background: #17191d;
  color: #fff;
}

.result-panel .result-label,
.result-panel .result-subtitle,
.result-panel .metric-grid span {
  color: #aeb3bc;
}

.result-panel .metric-grid > div {
  background: #25282e;
  border-color: #3a3e46;
}

.result-panel .metric-grid strong {
  color: #fff;
  font-size: clamp(17px, 2vw, 21px);
  overflow-wrap: anywhere;
}

.result-panel .metric-grid strong.negative {
  color: #ff8da0;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 0 0 20px;
  }

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

  .topbar {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }

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

@media (max-width: 520px) {
  .sync-status {
    font-size: 10px;
  }

  .settings-button {
    min-height: 40px;
  }
}
