:root {
  --bg: #f3f6f9;
  --surface: #ffffff;
  --ink: #252a33;
  --muted: #656b76;
  --line: #e3e8ee;
  --dark: #111318;
  --accent: #b51f2a;
  --accent-dark: #86151e;
  --secondary: #1597d3;
  --secondary-dark: #086a9f;
  --danger: #86151e;
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow: 0 18px 60px rgba(16, 20, 23, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(21,151,211,.15), transparent 25rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app-shell { width: min(1220px, calc(100% - 32px)); margin: 0 auto; }
.topbar {
  position: sticky;
  top: 12px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 12px 0 28px;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 18px;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(18px);
  box-shadow: 0 8px 32px rgba(16,20,23,.08);
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 8px 18px rgba(181,31,42,.24);
  font-size: 14px;
  font-weight: 950;
  letter-spacing: -.04em;
  transform: rotate(-3deg);
}
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; }
.brand-copy { display: grid; line-height: 1.05; }
.brand-copy strong { font-size: 15px; letter-spacing: .08em; }
.brand-copy small { margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.top-actions { display: flex; gap: 8px; }
.icon-btn, .text-btn {
  border: 0;
  border-radius: 11px;
  padding: 10px 13px;
  background: var(--dark);
  color: white;
  font-weight: 800;
}
.icon-btn[hidden] { display: none; }
.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 5px;
  padding: 0 5px;
  border-radius: 99px;
  color: white;
  background: var(--secondary);
  font-size: 11px;
}

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.4fr .6fr;
  gap: 32px;
  min-height: 430px;
  padding: clamp(32px, 6vw, 72px);
  border-radius: var(--radius-xl);
  color: white;
  background:
    radial-gradient(circle at 12% 12%, rgba(181,31,42,.26), transparent 28rem),
    linear-gradient(118deg, rgba(17,19,24,.99), rgba(17,19,24,.82)),
    repeating-linear-gradient(135deg, transparent 0 21px, rgba(255,255,255,.04) 21px 22px);
  box-shadow: var(--shadow);
}
.hero::after {
  content: "";
  position: absolute;
  right: -90px;
  bottom: -100px;
  width: 430px;
  height: 430px;
  border-radius: 50%;
  border: 92px solid rgba(21,151,211,.86);
  opacity: .9;
}
.hero-copy, .hero-stats { position: relative; z-index: 1; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.hero .eyebrow { color: #76d1f7; }
.hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(42px, 7vw, 82px);
  line-height: .96;
  letter-spacing: -.06em;
}
.hero h1 span { color: #76d1f7; }
.hero-copy > p:last-child { max-width: 680px; margin: 25px 0 0; color: #d7dcde; font-size: clamp(16px, 2vw, 19px); }
.hero-stats { align-self: end; display: grid; gap: 10px; }
.hero-stats div { padding: 18px; border: 1px solid rgba(255,255,255,.14); border-radius: 16px; background: rgba(255,255,255,.07); backdrop-filter: blur(8px); }
.hero-stats strong, .hero-stats span { display: block; }
.hero-stats strong { font-size: 20px; }
.hero-stats span { margin-top: 3px; color: #bdc4c7; font-size: 12px; }

.quick-tools {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin: 18px 0 66px;
}
.quick-tools button {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 16px;
  padding: 17px;
  background: var(--surface);
  box-shadow: 0 7px 28px rgba(16,20,23,.06);
  font-weight: 850;
  text-align: left;
}
.quick-tools button:hover { transform: translateY(-2px); }
.quick-tools span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: white; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); font-size: 18px; }

.trade-section, .tool-section, .history-section { margin-bottom: 66px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 22px; }
.section-heading.compact { align-items: center; }
.section-heading h2, .trade-group-head h3, .trust-panel h2 { margin: 0; font-size: clamp(27px, 4vw, 43px); line-height: 1.04; letter-spacing: -.04em; }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(390px, 100%);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; }
.filters { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 20px; padding-bottom: 4px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 9px 14px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
}
.filters button.active { border-color: var(--dark); color: white; background: var(--dark); }
.search-box:focus-within, .input-wrap:focus-within {
  border-color: var(--secondary);
  box-shadow: 0 0 0 4px rgba(21,151,211,.12);
}
.filters button.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}
.trade-card:hover, .trade-card.active { border-color: var(--secondary); }

.trade-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.trade-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  min-height: 142px;
  padding: 18px;
  border: 1px solid rgba(19,23,25,.08);
  border-radius: 18px;
  background: white;
  box-shadow: 0 8px 28px rgba(16,20,23,.05);
  text-align: left;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.trade-card:hover, .trade-card.active { transform: translateY(-3px); border-color: var(--secondary); box-shadow: 0 16px 38px rgba(16,20,23,.11); }
.trade-card.active { background: var(--dark); color: white; }
.trade-icon, .trade-group-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: white; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); font-size: 19px; font-weight: 950; }
.trade-copy { display: grid; align-content: start; }
.trade-copy strong { font-size: 15px; line-height: 1.15; }
.trade-copy small { margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.trade-card.active .trade-copy small { color: #bfc7ca; }
.trade-count { grid-column: 1 / -1; align-self: end; color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
.trade-card.active .trade-count { color: #76d1f7; }
.tool-grid { display: grid; gap: 32px; }
.trade-group { display: grid; gap: 15px; }
.trade-group + .trade-group { padding-top: 28px; border-top: 1px solid var(--line); }
.trade-group-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.trade-group-head > div { display: flex; align-items: center; gap: 13px; }
.trade-group-head h3 { margin: 0; font-size: 29px; }
.trade-group-head .eyebrow { margin-bottom: 3px; }
.cards-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.back-all { border: 1px solid var(--line); border-radius: 99px; padding: 9px 13px; color: var(--ink); background: white; font-size: 12px; font-weight: 850; }
.tool-card {
  position: relative;
  min-height: 210px;
  overflow: hidden;
  border: 1px solid rgba(19,23,25,.07);
  border-radius: var(--radius-lg);
  padding: 23px;
  background: white;
  box-shadow: 0 9px 34px rgba(16,20,23,.05);
  text-align: left;
  transition: transform .18s ease, box-shadow .18s ease;
}
.tool-card:hover { transform: translateY(-4px); box-shadow: 0 18px 42px rgba(16,20,23,.10); }
.tool-card::after {
  content: "";
  position: absolute;
  right: -38px;
  bottom: -60px;
  width: 135px;
  height: 135px;
  border: 28px solid var(--secondary);
  border-radius: 50%;
  opacity: .75;
}
.tool-card .tool-icon { display: grid; place-items: center; width: 43px; height: 43px; margin-bottom: 34px; border-radius: 12px; background: var(--dark); color: #76d1f7; font-size: 20px; font-weight: 900; }
.tool-card h3 { max-width: 80%; margin: 0; font-size: 20px; letter-spacing: -.025em; }
.tool-card p { max-width: 82%; margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.tool-card .tool-arrow { position: absolute; top: 22px; right: 22px; font-size: 21px; }
.empty-state { padding: 30px; border: 1px dashed var(--line); border-radius: 16px; text-align: center; color: var(--muted); }

.history-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.history-item { padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.7); }
.history-item strong, .history-item span { display: block; }
.history-item span { margin-top: 5px; color: var(--muted); font-size: 13px; }
.text-btn { color: var(--ink); background: transparent; }

.trust-panel {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 40px;
  margin: 0 0 68px;
  padding: clamp(28px, 5vw, 56px);
  border: 1px solid rgba(19,23,25,.09);
  border-radius: var(--radius-xl);
  color: white;
  background: linear-gradient(115deg, var(--accent), var(--accent-dark));
}
.trust-panel h2 { color: white; }
.trust-panel .eyebrow { color: #bfeaff; }
.trust-panel > p { margin: 0; align-self: end; font-weight: 650; }

footer { margin: 0 0 24px; padding: 30px; border-radius: 22px; color: white; background: var(--dark); }
.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-brand div { display: grid; }
.footer-brand span { color: #aeb6ba; font-size: 12px; }
.footer-links { display: flex; gap: 16px; margin: 24px 0; }
.footer-links a, .footer-links button { border: 0; padding: 0; color: #76d1f7; background: transparent; font-weight: 800; text-decoration: none; }
footer > p { margin: 0; color: #899397; font-size: 12px; }

.app-dialog {
  width: min(760px, calc(100% - 22px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: transparent;
  box-shadow: var(--shadow);
}
.app-dialog::backdrop { background: rgba(7,10,12,.72); backdrop-filter: blur(5px); }
.dialog-panel { margin: 0; border: 0; background: var(--bg); }
.dialog-head { display: flex; justify-content: space-between; gap: 18px; padding: 25px 25px 20px; color: white; background: var(--dark); }
.dialog-head h2 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.dialog-head p:last-child { margin: 8px 0 0; color: #b7c0c4; font-size: 14px; }
.close-btn { position: relative; z-index: 5; flex: 0 0 auto; display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid rgba(255,255,255,.28); border-radius: 12px; color: white; background: rgba(255,255,255,.06); font-size: 27px; line-height: 1; cursor: pointer; touch-action: manipulation; }
.close-btn:hover, .close-btn:focus-visible { border-color: var(--secondary); color: white; background: var(--secondary); outline: none; }
.dialog-body { max-height: calc(100vh - 180px); overflow-y: auto; padding: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 850; }
.input-wrap { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: white; overflow: hidden; }
.input-wrap input, .input-wrap select { width: 100%; min-height: 47px; border: 0; outline: 0; padding: 11px 12px; background: white; }
.input-unit { flex: 0 0 auto; padding: 0 12px; color: var(--muted); font-size: 12px; font-weight: 800; }
.field small { color: var(--muted); font-size: 11px; }
.form-actions, .result-actions, .shopping-actions { display: flex; gap: 10px; margin-top: 20px; }
.primary-btn, .secondary-btn, .danger-btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 900; }
.primary-btn { color: white; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); box-shadow: 0 10px 22px rgba(181,31,42,.20); }
.secondary-btn { color: white; background: var(--dark); }
.danger-btn { color: var(--danger); background: #f4dede; }
.result-panel { margin-top: 24px; padding: 21px; border-radius: 18px; background: white; box-shadow: 0 10px 30px rgba(16,20,23,.08); }
.result-topline { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.result-topline h3 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.result-status { border-radius: 99px; padding: 6px 9px; color: #075b89; background: #dff4fe; font-size: 10px; font-weight: 900; text-transform: uppercase; }
.result-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; }
.result-kpi { padding: 14px; border-radius: 13px; color: white; background: var(--dark); }
.result-kpi strong, .result-kpi span { display: block; }
.result-kpi strong { color: #76d1f7; font-size: 20px; }
.result-kpi span { margin-top: 2px; color: #bec6c9; font-size: 10px; text-transform: uppercase; }
.result-details { display: grid; gap: 8px; }
.result-row { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid #eceeea; font-size: 13px; }
.result-row span:last-child { font-weight: 850; text-align: right; }
.result-note { margin: 15px 0 0; color: var(--muted); font-size: 11px; }

.shopping-list { display: grid; gap: 9px; }
.shopping-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.shopping-item input { width: 19px; height: 19px; accent-color: var(--accent); }
.shopping-item.checked .shopping-copy { opacity: .45; text-decoration: line-through; }
.shopping-copy { display: grid; }
.shopping-copy small { color: var(--muted); }
.remove-item { border: 0; color: var(--danger); background: transparent; font-size: 19px; }
.empty-shopping { display: grid; place-items: center; min-height: 180px; text-align: center; color: var(--muted); }
.empty-shopping strong { color: var(--ink); }
.empty-shopping span { max-width: 360px; }

.toast { position: fixed; left: 50%; bottom: 22px; z-index: 99; transform: translate(-50%, 30px); padding: 11px 16px; border-radius: 11px; color: white; background: var(--dark); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s ease; font-weight: 800; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .quick-tools { grid-template-columns: repeat(3, 1fr); }
  .hero-stats { grid-template-columns: repeat(3, 1fr); }
  .trade-grid { grid-template-columns: repeat(3, 1fr); }
  .cards-grid, .history-list { grid-template-columns: repeat(2, 1fr); }
  .trust-panel { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .app-shell { width: min(100% - 18px, 1220px); }
  .topbar { top: 7px; margin-top: 7px; }
  .brand-copy strong { font-size: 13px; }
  .brand-copy small { font-size: 10px; }
  .icon-btn { padding: 9px 10px; font-size: 12px; }
  .hero { min-height: auto; padding: 32px 23px 38px; }
  .hero::after { right: -180px; bottom: -220px; }
  .hero h1 { font-size: 45px; }
  .hero-stats { grid-template-columns: 1fr; }
  .quick-tools { grid-template-columns: repeat(2, 1fr); margin-bottom: 50px; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }
  .trade-grid { grid-template-columns: repeat(2, 1fr); }
  .cards-grid, .history-list { grid-template-columns: 1fr; }
  .trade-card { min-height: 132px; padding: 15px; }
  .trade-group-head { align-items: flex-start; }
  .trade-group-head h3 { font-size: 24px; }
  .back-all { display: none; }
  .tool-card { min-height: 185px; }
  .form-grid, .result-summary { grid-template-columns: 1fr; }
  .form-actions, .result-actions, .shopping-actions { flex-direction: column; }
  .form-actions button, .result-actions button, .shopping-actions button { width: 100%; }
  .dialog-body { padding: 17px; }
  .dialog-head { padding: 22px 18px 18px; }
  .dialog-head h2 { font-size: 25px; }
  .result-status { display: none; }
  .footer-links { flex-direction: column; }
}

@media print {
  body * { visibility: hidden; }
  #shoppingDialog, #shoppingDialog * { visibility: visible; }
  #shoppingDialog { position: absolute; inset: 0; display: block; width: 100%; max-height: none; }
  .dialog-head { color: black; background: white; }
  .close-btn, .shopping-actions { display: none; }
}

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  object-fit: contain;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(17, 19, 24, .12);
  flex: 0 0 auto;
}

.footer-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
}

@media (max-width: 720px) {
  .brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  .footer-logo {
    width: 42px;
    height: 42px;
    border-radius: 11px;
  }
}
