:root {
  --bg: #070b16;
  --bg-soft: #0d1425;
  --card: rgba(19, 28, 48, 0.72);
  --card-border: rgba(120, 160, 255, 0.14);
  --text: #e8eeff;
  --muted: #8b9bc4;
  --accent: #38e1c4;
  --accent-2: #6f8cff;
  --accent-3: #b06bff;
  --danger: #ff6b8b;
  --radius: 22px;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.75);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 700px at 90% -10%, rgba(111, 140, 255, 0.16), transparent 60%),
    radial-gradient(1000px 600px at -10% 20%, rgba(56, 225, 196, 0.1), transparent 55%),
    linear-gradient(160deg, #070b16 0%, #0a1120 55%, #080d19 100%);
  color: var(--text);
  font-family: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding: 28px clamp(16px, 4vw, 56px) 40px;
}

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
  animation: float 14s ease-in-out infinite alternate;
}
.glow-a { width: 420px; height: 420px; background: rgba(111, 140, 255, 0.3); top: -140px; left: -100px; }
.glow-b { width: 380px; height: 380px; background: rgba(56, 225, 196, 0.22); bottom: -160px; right: -80px; animation-delay: -6s; }

@keyframes float {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(30px, 40px, 0) scale(1.12); }
}

.site-header, .layout, .site-footer { position: relative; z-index: 1; max-width: 1160px; margin-inline: auto; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.brand { display: flex; align-items: center; gap: 16px; }

.brand-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #06121a;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 30px -8px rgba(56, 225, 196, 0.55);
}
.brand-icon svg { width: 30px; height: 30px; }

.version-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #9ff5e6;
  background: rgba(56, 225, 196, 0.1);
  border: 1px solid rgba(56, 225, 196, 0.28);
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: 4px;
}

.brand-text h1 {
  margin: 0;
  font-size: clamp(1.15rem, 2.4vw, 1.6rem);
  font-weight: 900;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, #ffffff, #b9c8ff 60%, #7ef2dd);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-text p { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  color: #9ff5e6;
  background: rgba(56, 225, 196, 0.08);
  border: 1px solid rgba(56, 225, 196, 0.25);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgba(56, 225, 196, 0.6); animation: pulse 2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(56, 225, 196, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(56, 225, 196, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 225, 196, 0); }
}

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

.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  cursor: pointer;
  color: #c3d2ff;
  background: rgba(130, 165, 255, 0.07);
  border: 1px solid rgba(130, 165, 255, 0.18);
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
}
.icon-btn:hover { background: rgba(130, 165, 255, 0.14); border-color: rgba(130, 165, 255, 0.34); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-sun { display: none; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }

.install-btn {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  color: #06121a;
  background: linear-gradient(135deg, var(--accent), #8fd0ff);
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  box-shadow: 0 8px 22px -10px rgba(56, 225, 196, 0.8);
}
.install-btn[hidden] { display: none; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.85fr);
  gap: 22px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 26px;
}

.form-card { animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.result-card { position: sticky; top: 24px; animation: rise 0.6s 0.08s cubic-bezier(0.2, 0.8, 0.2, 1) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.card-head h2 { margin: 0; font-size: 1.05rem; font-weight: 700; }

.group { padding-block: 18px; border-top: 1px solid rgba(140, 170, 255, 0.09); }
.group:first-of-type { border-top: none; }

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 0.86rem;
  font-weight: 700;
  color: #c3d2ff;
}
.group-title span { font-size: 1rem; }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.fields .field:nth-child(3):last-child { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: 0.8rem; color: var(--muted); font-weight: 500; }

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 22px;
}

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(130, 165, 255, 0.08);
  border: 1px solid rgba(130, 165, 255, 0.16);
}
.seg button {
  font-family: inherit;
  font-size: 0.66rem;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 3px 9px;
  cursor: pointer;
  transition: color 0.18s, background 0.18s, box-shadow 0.18s;
}
.seg button:hover { color: #cfe0ff; }
.seg button.active {
  color: #04121a;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #8fd0ff);
  box-shadow: 0 4px 12px -4px rgba(56, 225, 196, 0.6);
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(8, 14, 28, 0.7);
  border: 1px solid rgba(130, 165, 255, 0.16);
  border-radius: 14px;
  padding: 4px 12px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.input-wrap:focus-within {
  border-color: rgba(56, 225, 196, 0.6);
  box-shadow: 0 0 0 4px rgba(56, 225, 196, 0.12);
  background: rgba(10, 20, 36, 0.9);
}

.input-wrap input {
  flex: 1;
  min-width: 0;
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 9px 0;
  font-variant-numeric: tabular-nums;
}
.input-wrap input::-webkit-outer-spin-button,
.input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-wrap input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.unit { flex: none; font-size: 0.72rem; color: #7789b3; padding-inline-start: 8px; border-inline-start: 1px solid rgba(130, 165, 255, 0.16); white-space: nowrap; }

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(111, 140, 255, 0.06);
  border: 1px solid rgba(130, 165, 255, 0.12);
}
.mini { display: flex; flex-direction: column; gap: 4px; text-align: center; }
.mini span { font-size: 0.72rem; color: var(--muted); }
.mini strong { font-size: 0.9rem; font-weight: 700; color: #bcd8ff; font-variant-numeric: tabular-nums; }

.result-top {
  text-align: center;
  padding: 10px 6px 22px;
  border-bottom: 1px dashed rgba(140, 170, 255, 0.16);
}
.eyebrow { font-size: 0.78rem; color: var(--muted); letter-spacing: 0.02em; }
.price {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
  background: linear-gradient(95deg, #7ef2dd, #9fb4ff 55%, #cf9dff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.price #finalPrice {
  font-size: clamp(2.1rem, 5.4vw, 3.1rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  filter: drop-shadow(0 6px 24px rgba(56, 225, 196, 0.25));
}
.price small { font-size: 0.85rem; font-weight: 500; color: #8fa2cc; }
.price-caption { display: block; font-size: 0.72rem; color: #6f7ea6; margin-top: 4px; }

.breakdown { display: flex; flex-direction: column; gap: 13px; padding-block: 20px; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.82rem; margin-bottom: 6px; }
.row-head span { color: var(--muted); }
.row-head strong { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.bar { height: 7px; border-radius: 999px; background: rgba(130, 165, 255, 0.12); overflow: hidden; }
.bar i {
  display: block;
  height: 100%;
  width: var(--w, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.row[data-key="machine"] .bar i { background: linear-gradient(90deg, #6f8cff, #b06bff); }
.row[data-key="labor"] .bar i { background: linear-gradient(90deg, #ffb86b, #ff7a8a); }
.row[data-key="waste"] .bar i { background: linear-gradient(90deg, #ff7a8a, #ff5f9e); }
.row[data-key="profit"] .bar i { background: linear-gradient(90deg, #7ef2dd, #6f8cff); }

.totals { border-top: 1px dashed rgba(140, 170, 255, 0.16); padding-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.total-line { display: flex; align-items: center; justify-content: space-between; }
.total-line span { font-size: 0.82rem; color: var(--muted); }
.total-line strong { font-size: 1.02rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.total-line.muted strong { color: var(--accent); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.actions .wide { grid-column: 1 / -1; }

.name-field { margin-top: 18px; }

.btn {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 13px;
  padding: 12px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn.primary {
  color: #04121a;
  background: linear-gradient(135deg, var(--accent), #8fd0ff);
  box-shadow: 0 12px 26px -12px rgba(56, 225, 196, 0.75);
}
.btn.primary:hover { box-shadow: 0 14px 30px -10px rgba(56, 225, 196, 0.9); }
.btn.ghost {
  color: #b9c8ea;
  background: rgba(130, 165, 255, 0.07);
  border-color: rgba(130, 165, 255, 0.18);
}
.btn.ghost:hover { background: rgba(130, 165, 255, 0.13); border-color: rgba(130, 165, 255, 0.32); }

.hint { text-align: center; font-size: 0.72rem; color: #64739a; margin: 14px 0 0; }

.history-card { margin-top: 22px; animation: rise 0.6s 0.16s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  margin-inline-start: 6px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #04121a;
  background: linear-gradient(135deg, var(--accent), #8fd0ff);
  vertical-align: middle;
}
.history-tip { margin: 10px 0 0; font-size: 0.78rem; color: var(--muted); }
.history-empty {
  margin: 18px 0 4px;
  padding: 26px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 0.84rem;
  border: 1px dashed rgba(140, 170, 255, 0.2);
  border-radius: 16px;
}
.history-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.select-all {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.select-all input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.history-list { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.history-list:empty { display: none; }
.history-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(130, 165, 255, 0.055);
  border: 1px solid rgba(130, 165, 255, 0.12);
  transition: background 0.2s, border-color 0.2s;
}
.history-item.is-selected {
  background: rgba(56, 225, 196, 0.07);
  border-color: rgba(56, 225, 196, 0.4);
}
.pick { display: flex; align-items: center; }
.pick input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.history-main { min-width: 0; flex: 1 1 180px; display: flex; flex-direction: column; gap: 3px; }
.history-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-meta { font-size: 0.7rem; color: var(--muted); }
.history-price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 0.95rem;
  font-weight: 800;
  color: #bcd8ff;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.history-price small { font-size: 0.68rem; font-weight: 500; color: var(--muted); }
.price-total { font-size: 0.66rem; font-weight: 600; color: var(--muted); }
.price-total[hidden] { display: none; }
.qty-box { display: flex; align-items: center; gap: 6px; font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.qty-box input {
  width: 58px;
  padding: 6px 4px;
  text-align: center;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  background: rgba(8, 14, 28, 0.6);
  border: 1px solid rgba(130, 165, 255, 0.18);
  border-radius: 9px;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.qty-box input:focus { border-color: rgba(56, 225, 196, 0.6); box-shadow: 0 0 0 3px rgba(56, 225, 196, 0.1); }
.history-actions { display: flex; gap: 6px; }
.chip-btn {
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 9px;
  cursor: pointer;
  color: #b9c8ea;
  background: rgba(130, 165, 255, 0.06);
  border: 1px solid rgba(130, 165, 255, 0.18);
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.chip-btn:hover { background: rgba(130, 165, 255, 0.14); }
.chip-btn.danger { color: #ff9db0; background: rgba(255, 107, 139, 0.07); border-color: rgba(255, 107, 139, 0.25); }
.chip-btn.danger:hover { background: rgba(255, 107, 139, 0.14); }
.history-total {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed rgba(140, 170, 255, 0.16);
}
.history-total[hidden] { display: none; }
.history-total div { display: flex; flex-direction: column; gap: 2px; }
.history-total span { font-size: 0.72rem; color: var(--muted); }
.history-total strong { font-size: 1rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }

.order-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px dashed rgba(140, 170, 255, 0.16);
}
.order-summary[hidden] { display: none; }
.order-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(130, 165, 255, 0.055);
  border: 1px solid rgba(130, 165, 255, 0.12);
}
.order-stat span { font-size: 0.7rem; color: var(--muted); }
.order-stat strong { font-size: 1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.order-stat.highlight {
  background: linear-gradient(135deg, rgba(56, 225, 196, 0.12), rgba(111, 140, 255, 0.12));
  border-color: rgba(56, 225, 196, 0.3);
}
.order-stat.highlight strong { color: var(--accent); }

.print-sheet { display: none; }

.site-footer { text-align: center; color: #5b6a90; font-size: 0.75rem; margin-top: 30px; }

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: rgba(14, 24, 42, 0.95);
  border: 1px solid rgba(56, 225, 196, 0.4);
  color: #9ff5e6;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 20;
  backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

html[data-theme="light"] {
  --bg: #eef2fb;
  --card: rgba(255, 255, 255, 0.82);
  --card-border: rgba(32, 58, 120, 0.12);
  --text: #16203a;
  --muted: #5d6c8c;
  --accent: #0fae98;
  --accent-2: #4f6cff;
  --shadow: 0 24px 60px -30px rgba(30, 50, 110, 0.32);
}
html[data-theme="light"] body {
  background:
    radial-gradient(1200px 700px at 90% -10%, rgba(111, 140, 255, 0.18), transparent 60%),
    radial-gradient(1000px 600px at -10% 20%, rgba(15, 174, 152, 0.12), transparent 55%),
    linear-gradient(160deg, #f6f8ff 0%, #eef3fc 60%, #f4f7ff 100%);
}
html[data-theme="light"] .glow-a { background: rgba(111, 140, 255, 0.2); }
html[data-theme="light"] .glow-b { background: rgba(15, 174, 152, 0.16); }
html[data-theme="light"] .brand-text h1 {
  background: linear-gradient(90deg, #0b1530, #2b4bb5 60%, #0a9d87);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
html[data-theme="light"] .version-badge,
html[data-theme="light"] .status-pill {
  color: #0a7d6c;
  background: rgba(15, 174, 152, 0.1);
  border-color: rgba(15, 174, 152, 0.3);
}
html[data-theme="light"] .icon-btn {
  color: #3a4a78;
  background: rgba(40, 70, 140, 0.06);
  border-color: rgba(40, 70, 140, 0.16);
}
html[data-theme="light"] .icon-btn:hover { background: rgba(40, 70, 140, 0.12); }
html[data-theme="light"] .group-title { color: #33406b; }
html[data-theme="light"] .input-wrap {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(40, 70, 140, 0.16);
}
html[data-theme="light"] .input-wrap:focus-within {
  background: #fff;
  border-color: rgba(15, 174, 152, 0.6);
  box-shadow: 0 0 0 4px rgba(15, 174, 152, 0.12);
}
html[data-theme="light"] .unit { color: #64749a; border-color: rgba(40, 70, 140, 0.14); }
html[data-theme="light"] .seg { background: rgba(40, 70, 140, 0.06); border-color: rgba(40, 70, 140, 0.14); }
html[data-theme="light"] .seg button:hover { color: #2b4bb5; }
html[data-theme="light"] .mini-stats { background: rgba(79, 108, 255, 0.06); border-color: rgba(40, 70, 140, 0.12); }
html[data-theme="light"] .mini strong { color: #2b4bb5; }
html[data-theme="light"] .price { background: linear-gradient(95deg, #0fae98, #4f6cff 55%, #8b4dff); -webkit-background-clip: text; background-clip: text; color: transparent; }
html[data-theme="light"] .price small { color: #5d6c8c; }
html[data-theme="light"] .price-caption { color: #7b87a5; }
html[data-theme="light"] .row-head strong { color: #1d2846; }
html[data-theme="light"] .bar { background: rgba(40, 70, 140, 0.1); }
html[data-theme="light"] .total-line strong { color: #16203a; }
html[data-theme="light"] .total-line.muted strong { color: #0a9d87; }
html[data-theme="light"] .btn.ghost { color: #3a4a78; background: rgba(40, 70, 140, 0.06); border-color: rgba(40, 70, 140, 0.16); }
html[data-theme="light"] .btn.ghost:hover { background: rgba(40, 70, 140, 0.12); border-color: rgba(40, 70, 140, 0.3); }
html[data-theme="light"] .history-item { background: rgba(79, 108, 255, 0.05); border-color: rgba(40, 70, 140, 0.1); }
html[data-theme="light"] .history-item.is-selected { background: rgba(15, 174, 152, 0.07); border-color: rgba(15, 174, 152, 0.35); }
html[data-theme="light"] .history-price { color: #2b4bb5; }
html[data-theme="light"] .qty-box input { background: #fff; border-color: rgba(40, 70, 140, 0.16); color: var(--text); }
html[data-theme="light"] .order-stat { background: rgba(79, 108, 255, 0.05); border-color: rgba(40, 70, 140, 0.1); }
html[data-theme="light"] .order-stat.highlight { background: linear-gradient(135deg, rgba(15, 174, 152, 0.1), rgba(79, 108, 255, 0.1)); border-color: rgba(15, 174, 152, 0.3); }
html[data-theme="light"] .order-stat.highlight strong { color: #0a9d87; }
html[data-theme="light"] .chip-btn { color: #3a4a78; background: rgba(40, 70, 140, 0.06); border-color: rgba(40, 70, 140, 0.16); }
html[data-theme="light"] .chip-btn:hover { background: rgba(40, 70, 140, 0.12); }
html[data-theme="light"] .chip-btn.danger { color: #c22a4c; background: rgba(255, 107, 139, 0.1); border-color: rgba(255, 107, 139, 0.3); }
html[data-theme="light"] .hint { color: #7b87a5; }
html[data-theme="light"] .site-footer { color: #8b96b3; }
html[data-theme="light"] .toast { background: #fff; color: #0a7d6c; border-color: rgba(15, 174, 152, 0.4); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .result-card { position: static; }
}

@media (max-width: 700px) {
  .order-summary { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .history-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 12px;
  }
  .pick { grid-column: 1; grid-row: 1; }
  .history-main { grid-column: 2 / -1; grid-row: 1; }
  .history-price { grid-column: 1 / 2; grid-row: 2; align-items: flex-start; margin: 0; }
  .qty-box { grid-column: 2 / 3; grid-row: 2; justify-self: start; }
  .history-actions { grid-column: 1 / -1; grid-row: 3; justify-content: flex-end; }
}

@media (max-width: 560px) {
  body { padding: 18px 14px 30px; }
  .card { padding: 20px; border-radius: 18px; }
  .fields { grid-template-columns: 1fr; }
  .mini-stats { grid-template-columns: 1fr 1fr; }
  .mini:last-child { grid-column: 1 / -1; }
  .status-pill { display: none; }
  .brand-text p { display: none; }
  .header-actions .install-btn { padding: 8px 12px; font-size: 0.72rem; }
}

@media print {
  @page { size: A4; margin: 14mm 13mm; }
  html, body { background: #fff !important; color: #111 !important; padding: 0 !important; margin: 0 !important; }
  body > *:not(.print-sheet) { display: none !important; }
  .print-sheet {
    display: block !important;
    color: #16203a;
    font-family: "Vazirmatn", Tahoma, sans-serif;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-bar {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, #38e1c4, #6f8cff, #b06bff);
    margin-bottom: 18px;
  }
  .print-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e3e8f2;
  }
  .print-brand { display: flex; align-items: center; gap: 12px; }
  .print-logo {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(135deg, #38e1c4, #4f6cff);
  }
  .print-logo svg { width: 26px; height: 26px; }
  .print-brand h1 { margin: 0; font-size: 16px; font-weight: 900; color: #101a33; }
  .print-brand p { margin: 1px 0 0; font-size: 10px; color: #74809c; }
  .print-meta { display: flex; flex-direction: column; gap: 3px; text-align: left; font-size: 10px; color: #74809c; }
  .print-meta strong { color: #1d2846; font-size: 11px; }
  .print-piece {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 18px 0;
    padding: 12px 16px;
    border-radius: 12px;
    background: #f4f7fd;
    border: 1px solid #e3e8f2;
  }
  .print-piece span { font-size: 11px; color: #74809c; }
  .print-piece strong { font-size: 14px; color: #101a33; }
  .print-info { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
  .print-info div { padding: 9px 10px; border-radius: 10px; border: 1px solid #e7ebf4; }
  .print-info span { display: block; font-size: 9px; color: #74809c; margin-bottom: 2px; }
  .print-info strong { font-size: 11px; color: #1d2846; }
  .print-table { width: 100%; border-collapse: collapse; font-size: 11px; }
  .print-table th {
    padding: 8px 12px;
    text-align: right;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(90deg, #4f6cff, #38c7b4);
  }
  .print-table th:last-child { text-align: left; }
  .print-table td { padding: 9px 12px; border-bottom: 1px solid #eef1f7; color: #2a3555; }
  .print-table td:last-child { text-align: left; font-weight: 700; font-variant-numeric: tabular-nums; }
  .print-table tr.sub td { background: #f6f8fd; font-weight: 800; border-bottom: 1px solid #e3e8f2; }
  .print-final {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 16px;
    padding: 14px 18px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(56, 225, 196, 0.16), rgba(79, 108, 255, 0.14));
    border: 1px solid rgba(79, 108, 255, 0.25);
  }
  .print-final span { font-size: 11px; font-weight: 600; color: #46527a; }
  .print-final strong { font-size: 20px; font-weight: 900; color: #101a33; font-variant-numeric: tabular-nums; }
  .print-order { margin-top: 18px; }
  .print-order[hidden] { display: none; }
  .print-order h2 { margin: 0 0 8px; font-size: 12px; font-weight: 900; color: #101a33; }
  .print-order .print-table th { background: linear-gradient(90deg, #38c7b4, #4f6cff); }
  .print-order .print-table th:nth-child(2),
  .print-order .print-table th:nth-child(3),
  .print-order .print-table td:nth-child(2),
  .print-order .print-table td:nth-child(3) { text-align: center; }
  .print-order-total {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    background: #f4f7fd;
    border: 1px solid #e3e8f2;
    font-size: 12px;
    color: #46527a;
  }
  .print-order-total strong { font-size: 15px; color: #101a33; }
  .print-order-avg {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
    padding: 0 4px;
    font-size: 10px;
    color: #6b7794;
  }
  .print-order-avg strong { color: #1d2846; }
  .print-foot {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 26px;
    padding-top: 10px;
    border-top: 1px solid #eef1f7;
    font-size: 9px;
    color: #8a94ad;
  }
}
