@import url("https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&display=swap");

:root {
  color-scheme: light;
  --ink: #18211f;
  --muted: #68736f;
  --line: #d9ded8;
  --panel: #fffdfa;
  --page: #f5f2ea;
  --deep: #173d36;
  --deep-2: #0f2d29;
  --mint: #e6f0ec;
  --gold: #b88728;
  --gold-soft: #fff2cf;
  --rose: #a64d43;
  --blue: #315b7d;
  --shadow: 0 16px 42px rgba(24, 33, 31, 0.1);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.workspace {
  display: grid;
  gap: 12px;
}

.topbar,
.market-band,
.panel {
  border: 1px solid rgba(217, 222, 216, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 118px;
  padding: 24px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(184, 135, 40, 0.22), transparent 42%),
    var(--deep);
}

.topbar-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.eyebrow,
.label,
label span,
.hero-number span,
.metrics span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

[dir="rtl"] .eyebrow,
[dir="rtl"] .label,
[dir="rtl"] label span,
[dir="rtl"] .hero-number span,
[dir="rtl"] .metrics span {
  text-transform: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: #e7c36d;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 690px;
  font-size: clamp(1.8rem, 4vw, 3.35rem);
  line-height: 1.03;
  letter-spacing: 0;
}

h2 {
  font-size: 1.08rem;
  font-weight: 800;
}

.status-pill,
.deal-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill {
  color: var(--deep);
  background: #f4d987;
}

.market-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  background: var(--panel);
}

.market-band strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(1.75rem, 4vw, 3rem);
  line-height: 1;
  color: var(--deep);
}

.market-band small,
.hero-number small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.market-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.icon-button,
.text-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.text-button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--deep);
  font-weight: 800;
}

.icon-button:hover,
.text-button:hover {
  border-color: var(--gold);
  box-shadow: 0 8px 18px rgba(184, 135, 40, 0.14);
  transform: translateY(-1px);
}

.select-wrap {
  min-width: 174px;
}

.select-wrap.compact {
  min-width: 140px;
}

.topbar .select-wrap span {
  color: rgba(255, 255, 255, 0.72);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(380px, 0.9fr);
  gap: 12px;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 20px;
  background: var(--panel);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 36px;
  margin-bottom: 16px;
}

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

label {
  display: grid;
  gap: 6px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

.topbar select {
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.topbar select option {
  color: var(--ink);
}

input[type="number"] {
  direction: ltr;
  text-align: start;
}

[dir="rtl"] input[type="number"] {
  text-align: right;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49, 91, 125, 0.15);
  outline: none;
}

.hidden {
  display: none;
}

.result-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 14px;
  background: #fbfaf6;
}

.hero-number {
  padding: 22px;
  border-radius: 8px;
  color: #fff;
  background:
    linear-gradient(160deg, rgba(184, 135, 40, 0.28), transparent 52%),
    var(--deep-2);
}

.hero-number span,
.hero-number small {
  color: rgba(255, 255, 255, 0.75);
}

.hero-number strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1;
}

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

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

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.08rem, 2.4vw, 1.55rem);
  line-height: 1.1;
}

.bargain-strip {
  min-height: 58px;
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  color: #5f4210;
  background: var(--gold-soft);
  font-weight: 800;
}

[dir="rtl"] .bargain-strip {
  border-left: 0;
  border-right: 4px solid var(--gold);
}

.deal-chip {
  color: var(--deep);
  background: var(--mint);
}

.deal-chip.good {
  background: #dfeee9;
  color: var(--deep);
}

.deal-chip.warn {
  background: #fff0c2;
  color: #72500d;
}

.deal-chip.high {
  background: #f4d9d5;
  color: #83352c;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 0 4px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.site-footer a {
  color: var(--deep);
  text-decoration-color: rgba(184, 135, 40, 0.55);
  text-underline-offset: 3px;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 700px);
    padding: 10px 0 20px;
  }

  .topbar,
  .market-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    min-height: auto;
    padding: 20px;
  }

  .topbar-actions,
  .market-actions {
    width: 100%;
    align-items: stretch;
    justify-content: space-between;
  }

  .select-wrap {
    flex: 1;
    min-width: 0;
  }

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

  .result-panel {
    position: static;
  }
}
