/* =====================================================================
 * style.css — سامانه آنلاین محاسبه تلویزیون شهری
 * Mobile-First • RTL • Vazirmatn
 * ===================================================================== */

/* ---------------- Tokens ---------------- */
:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #eef2f8;
  --ink: #0e1626;
  --ink-2: #44506a;
  --ink-3: #7c879c;
  --line: #e2e7ef;
  --line-2: #d3dae6;

  --accent: #1f5eff;
  --accent-2: #1849c9;
  --accent-soft: #eaf0ff;
  --accent-ring: rgba(31, 94, 255, .22);
  --cyan: #38e1ff;

  --dark: #0a1020;
  --dark-2: #111a30;
  --dark-3: #1a2540;

  --red: #c8372d;
  --red-ink: #9e2a22;
  --red-bg: #fff5f4;
  --red-bg-2: #ffeceb;
  --red-line: #f3c1bc;

  --green: #12976a;
  --amber: #c27c0e;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --shadow-1: 0 1px 2px rgba(14, 22, 38, .05), 0 1px 1px rgba(14, 22, 38, .03);
  --shadow-2: 0 2px 4px rgba(14, 22, 38, .04), 0 10px 28px -10px rgba(14, 22, 38, .14);
  --shadow-3: 0 24px 60px -18px rgba(10, 16, 32, .45);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t: .18s;
  --sticky-h: 96px;
  --font: 'Vazirmatn', 'Vazir', Tahoma, 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01";
}
body.page-calc { padding-bottom: calc(var(--sticky-h) + 16px); }
body.modal-open { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.4; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
img { max-width: 100%; }
[hidden] { display: none !important; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .86em; background: var(--surface-3); padding: 1px 6px; border-radius: 6px; direction: ltr; unicode-bidi: embed; }
.ltr { direction: ltr; text-align: left; }
.ltr-num { direction: ltr; unicode-bidi: embed; }
.muted { color: var(--ink-3); font-size: 13px; }
.text-red { color: var(--red); }
.empty { color: var(--ink-3); font-size: 14px; padding: 8px 0; }

.container { width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 14px; }

/* =====================================================================
 * Header — حس نمایشگر صنعتی (Dot Matrix)
 * ===================================================================== */
.app-header {
  position: relative;
  color: #fff;
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .07) 1px, transparent 1.4px) 0 0 / 9px 9px,
    radial-gradient(120% 140% at 0% 0%, #1b2d5c 0%, transparent 55%),
    linear-gradient(160deg, var(--dark-2), var(--dark));
  padding: 14px 0 12px;
  overflow: hidden;
}
.app-header::after {
  content: "";
  position: absolute; inset: auto 0 0 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--accent), transparent);
  opacity: .7;
}
.header-inner { display: flex; flex-direction: column; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; overflow: hidden;
  color: var(--cyan);
  background: linear-gradient(145deg, rgba(56, 225, 255, .16), rgba(31, 94, 255, .14));
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 0 24px -6px rgba(56, 225, 255, .5);
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-text { flex: 1; min-width: 0; }
.brand-text h1 { font-size: 16px; font-weight: 800; letter-spacing: -.2px; }
.brand-text p { font-size: 12px; color: rgba(255, 255, 255, .62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot-sep { opacity: .5; margin: 0 4px; }

.icon-btn {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  display: inline-grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  transition: background var(--t), color var(--t), border-color var(--t), transform var(--t);
  font-size: 16px; text-decoration: none;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.header-admin, .icon-btn-light {
  background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .14); color: rgba(255, 255, 255, .85);
}
.header-admin:hover { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .3); }

.partner-strip {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -14px; padding: 0 14px 2px;
}
.partner-strip::-webkit-scrollbar { display: none; }
.p-chip {
  flex: none; display: flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; font-size: 12.5px;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .1);
}
.p-chip span { color: rgba(255, 255, 255, .55); }
.p-chip b { font-weight: 700; }

/* =====================================================================
 * Layout
 * ===================================================================== */
.main-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding-top: 14px; padding-bottom: 14px; }
.col-form, .col-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.col-side { order: -1; } /* موبایل: پیش‌نمایش بالای فرم */
.side-sticky { display: flex; flex-direction: column; gap: 14px; }

/* ---------------- Card ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--t) var(--ease), border-color var(--t);
}
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 16px; font-weight: 800; }
.card-head h2 small { font-weight: 500; color: var(--ink-3); font-size: 12px; }
.card-sub { font-size: 12.5px; color: var(--ink-3); line-height: 1.6; margin-top: 2px; }
.card-title { font-size: 15px; font-weight: 800; margin-bottom: 14px; }
.step {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
  color: var(--accent); background: var(--accent-soft);
}

/* ---------------- Fields ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.req { color: var(--red); font-style: normal; }
.help { font-size: 12px; color: var(--ink-3); line-height: 1.6; }

.input, .select {
  width: 100%; min-height: 50px; padding: 10px 14px;
  border: 1.5px solid var(--line-2); border-radius: 12px;
  background: var(--surface); font-size: 15px;
  transition: border-color var(--t), box-shadow var(--t);
  -webkit-appearance: none; appearance: none;
}
textarea.input { min-height: 80px; resize: vertical; line-height: 1.8; }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.select {
  cursor: pointer; padding-left: 40px; font-weight: 600;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2344506a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 14px center;
}
.input-sm { min-height: 42px; width: 84px; text-align: center; padding: 6px 8px; font-weight: 700; }
.input-inline { min-height: 36px; width: 140px; padding: 4px 10px; font-weight: 700; }
.two-col { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
.two-col .field { margin-bottom: 12px; }

/* عدد + واحد + Stepper */
.num-input {
  display: flex; align-items: stretch; min-height: 56px;
  border: 1.5px solid var(--line-2); border-radius: 14px; background: var(--surface);
  overflow: hidden; transition: border-color var(--t), box-shadow var(--t);
}
.num-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.num-input.is-error { border-color: var(--red); box-shadow: 0 0 0 4px rgba(200, 55, 45, .15); }
.num-input input, .input-plain {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent;
  font-size: 22px; font-weight: 800; text-align: center; padding: 6px;
}
.num-input .unit { display: grid; place-items: center; padding: 0 10px; color: var(--ink-3); font-size: 13px; font-weight: 600; }
.stepper {
  flex: none; width: 52px; border: 0; cursor: pointer;
  background: var(--surface-2); color: var(--ink-2); font-size: 22px; font-weight: 600;
  transition: background var(--t), color var(--t);
  touch-action: manipulation;
}
.stepper:hover { background: var(--accent-soft); color: var(--accent); }
.stepper:active { background: var(--accent); color: #fff; }
.num-input-lg { max-width: 220px; }
.num-input-lg input { font-size: 30px; }

/* ---------------- Range Slider (لمسی) ---------------- */
.range {
  --p: 50%;
  width: 100%; height: 34px; margin: 10px 0 0; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none; direction: rtl; touch-action: pan-y;
}
.range:focus { outline: none; }
.range::-webkit-slider-runnable-track {
  height: 8px; border-radius: 99px;
  background: linear-gradient(to left, var(--accent) var(--p), var(--surface-3) var(--p));
}
.range::-moz-range-track { height: 8px; border-radius: 99px; background: var(--surface-3); }
.range::-moz-range-progress { height: 8px; border-radius: 99px; background: var(--accent); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -10px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); box-shadow: 0 2px 8px rgba(31, 94, 255, .35);
  transition: transform var(--t);
}
.range::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  border: 3px solid var(--accent); box-shadow: 0 2px 8px rgba(31, 94, 255, .35);
}
.range:active::-webkit-slider-thumb { transform: scale(1.12); }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 6px var(--accent-ring); }
.range-scale { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); margin-top: -2px; }

.dim-field { padding: 12px; border-radius: 14px; background: var(--surface-2); margin-bottom: 10px; }
.dim-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.dim-real { font-size: 12.5px; color: var(--ink-3); }
.dim-real b { color: var(--green); }
.hint { font-size: 12.5px; color: var(--ink-2); background: var(--accent-soft); border-radius: 10px; padding: 8px 12px; margin: 4px 0 10px; line-height: 1.8; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 1.5px solid transparent;
  font-weight: 700; font-size: 14.5px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--t), color var(--t), border-color var(--t), transform var(--t), box-shadow var(--t);
  touch-action: manipulation;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 18px -8px rgba(31, 94, 255, .7); }
.btn-primary:hover { background: var(--accent-2); }
.btn-outline { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.btn-outline:hover { background: var(--accent-soft); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-ink); }
.btn-danger-ghost { background: var(--red-bg); color: var(--red); border-color: var(--red-line); }
.btn-glass { background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .16); min-height: 42px; padding: 8px 14px; }
.btn-glass:hover { background: rgba(255, 255, 255, .16); }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: 13px; }
.btn-xl { min-height: 58px; font-size: 16.5px; border-radius: 14px; }
.btn-block { width: 100%; }
.form-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }

/* ---------------- Model chips ---------------- */
.model-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-bottom: 14px; }
.model-chip {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  padding: 10px 6px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--line-2); background: var(--surface);
  transition: all var(--t) var(--ease);
}
.model-chip b { font-size: 17px; font-weight: 900; direction: ltr; }
.model-chip small { font-size: 11px; color: var(--ink-3); }
.model-chip:hover { border-color: var(--accent); }
.model-chip.is-active { border-color: var(--accent); background: var(--accent); color: #fff; box-shadow: 0 8px 20px -10px rgba(31, 94, 255, .8); }
.model-chip.is-active small { color: rgba(255, 255, 255, .8); }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.info { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; min-width: 0; }
.info span { font-size: 11.5px; color: var(--ink-3); }
.info b { font-size: 13.5px; font-weight: 700; }
.info-wide { grid-column: 1 / -1; }

/* ---------------- محیط نصب ---------------- */
.env-field { margin-bottom: 4px; }
.env-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.env-opt { position: relative; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.env-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.env-box {
  display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 10px 12px;
  border: 1.5px solid var(--line-2); border-radius: 12px; background: var(--surface);
  transition: border-color var(--t), background var(--t), box-shadow var(--t);
}
.env-opt:hover .env-box { border-color: var(--accent); }
.env-check {
  flex: none; width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line-2);
  display: grid; place-items: center; transition: all var(--t);
}
.env-check::after { content: ""; width: 10px; height: 6px; border: solid #fff; border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; transition: opacity var(--t); }
.env-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.5; }
.env-text b { font-size: 14.5px; font-weight: 800; }
.env-text small { font-size: 11.5px; color: var(--ink-3); }
.env-opt input:checked + .env-box { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 6px 16px -10px rgba(31, 94, 255, .7); }
.env-opt input:checked + .env-box .env-check { background: var(--accent); border-color: var(--accent); }
.env-opt input:checked + .env-box .env-check::after { opacity: 1; }
.env-opt input:focus-visible + .env-box { box-shadow: 0 0 0 4px var(--accent-ring); }
.g-env { background: var(--dark); color: #fff; border-color: var(--dark); font-weight: 800; }
.env-disc { border-color: var(--line-2) !important; background: var(--surface-2) !important; }
.env-disc input { color: var(--accent) !important; }
.model-chip { min-height: 52px; justify-content: center; }

/* ---------------- Formula / calc lines ---------------- */
.formula {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 12px; border-radius: 12px; background: var(--dark); color: #fff; margin-top: 4px;
}
.f-part { display: flex; flex-direction: column; align-items: center; padding: 4px 10px; border-radius: 9px; background: rgba(255, 255, 255, .06); }
.f-part small { font-size: 10.5px; color: rgba(255, 255, 255, .55); }
.f-part b { font-size: 16px; font-weight: 800; }
.f-op { color: var(--cyan); font-weight: 800; }
.f-result { background: linear-gradient(135deg, var(--accent), #2f86ff); }
.f-result small { color: rgba(255, 255, 255, .8); }
.calc-line {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; margin-top: 10px; border-radius: 10px; background: var(--surface-2); font-size: 13.5px;
}
.calc-line span { color: var(--ink-2); }
.calc-line b { font-weight: 800; white-space: nowrap; }
.calc-line.muted b { color: var(--ink-3); }
.lp-desc { font-size: 12.5px; color: var(--ink-3); margin-top: -4px; }

/* ---------------- Accessories ---------------- */
.acc-group + .acc-group { margin-top: 14px; }
.acc-group-head { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 700; color: var(--ink-3); padding: 0 4px 6px; }
.acc-group-head b { color: var(--ink-2); }
.acc-item {
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: "sw main" "sw nums";
  align-items: center; gap: 4px 12px;
  padding: 12px; border-radius: 12px; border: 1.5px solid var(--line); cursor: pointer;
  margin-bottom: 8px; transition: border-color var(--t), background var(--t);
  -webkit-tap-highlight-color: transparent;
}
.acc-item:hover { border-color: var(--line-2); }
.acc-item.is-on { border-color: rgba(31, 94, 255, .45); background: linear-gradient(0deg, rgba(234, 240, 255, .55), rgba(234, 240, 255, .55)); }
.acc-item .switch { grid-area: sw; }
.acc-main { grid-area: main; display: flex; flex-direction: column; min-width: 0; }
.acc-name { font-weight: 700; font-size: 14.5px; }
.acc-rule { font-size: 11.5px; color: var(--ink-3); line-height: 1.6; }
.acc-nums { grid-area: nums; display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.acc-qty { color: var(--ink-2); font-weight: 600; }
.acc-total { font-weight: 800; }
.acc-item:not(.is-on) .acc-total { color: var(--ink-3); }

/* Switch */
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.switch {
  position: relative; display: inline-block; flex: none; width: 46px; height: 28px; border-radius: 99px;
  background: var(--line-2); transition: background var(--t) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform var(--t) var(--ease);
}
.switch-input:checked + .switch { background: var(--accent); }
.switch-input:checked + .switch::after { transform: translateX(-18px); }
.switch-input:focus-visible + .switch { box-shadow: 0 0 0 4px var(--accent-ring); }
.switch-wrap { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; position: relative; font-size: 14px; }
.toggle-row { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); margin-bottom: 8px; }

/* =====================================================================
 * Preview (نمایشگر)
 * ===================================================================== */
.preview-card {
  background:
    radial-gradient(100% 80% at 100% 0%, rgba(31, 94, 255, .25), transparent 60%),
    linear-gradient(170deg, var(--dark-2), var(--dark));
  border-color: #1d2946; color: #fff;
}
.preview-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.preview-head h2 { font-size: 15px; font-weight: 800; }
.preview-head p { font-size: 11.5px; color: rgba(255, 255, 255, .55); }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .1); }
.seg-btn { border: 0; background: transparent; color: rgba(255, 255, 255, .65); font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 8px; cursor: pointer; min-height: 32px; transition: all var(--t); }
.seg-btn.is-active { background: #fff; color: var(--dark); }

.preview-stage { display: flex; flex-direction: column; gap: 6px; }
.preview-row { display: flex; gap: 6px; align-items: stretch; }
.canvas-wrap { flex: 1; min-width: 0; display: flex; justify-content: center; align-items: center; min-height: 80px; }
#gridCanvas {
  display: block; max-width: 100%; border-radius: 6px;
  box-shadow: 0 0 0 4px #1b263f, 0 0 0 5px #2a3756, 0 18px 40px -12px rgba(56, 225, 255, .35);
}
.ruler { color: rgba(255, 255, 255, .6); font-size: 11.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; position: relative; }
.ruler-x { padding-right: 24px; height: 18px; }
.ruler-x::before { content: ""; position: absolute; inset: 50% 24px auto 0; border-top: 1px dashed rgba(255, 255, 255, .25); }
.ruler-x span, .ruler-y span { background: var(--dark-2); padding: 0 8px; position: relative; border-radius: 6px; }
.ruler-y { width: 18px; }
.ruler-y::before { content: ""; position: absolute; inset: 0 50% 0 auto; border-right: 1px dashed rgba(255, 255, 255, .25); }
.ruler-y span { writing-mode: vertical-rl; padding: 8px 0; white-space: nowrap; }

.preview-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: rgba(255, 255, 255, .62); margin: 12px 0 10px; }
.preview-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.lg-mod { background: linear-gradient(135deg, #2563eb, #7c3aed); }
.lg-req { border: 1.5px dashed #fff; }
.lg-power { background: conic-gradient(#3b82f6 0 25%, #14b8a6 0 50%, #f59e0b 0 75%, #a855f7 0); }

.preview-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ps { display: flex; flex-direction: column; padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .06); min-width: 0; }
.ps span { font-size: 11px; color: rgba(255, 255, 255, .55); }
.ps b { font-size: 16px; font-weight: 800; white-space: nowrap; }
@media (max-width: 639px) { .ps { padding: 6px 8px; } .ps span { font-size: 10.5px; } .preview-stats.light { grid-template-columns: repeat(2, 1fr); } }
.ps-wide { grid-column: span 2; }
.ps-accent { background: linear-gradient(135deg, rgba(31, 94, 255, .5), rgba(56, 225, 255, .25)); border-color: rgba(56, 225, 255, .3); }
.preview-stats.light .ps { background: var(--surface-2); border-color: var(--line); }
.preview-stats.light .ps span { color: var(--ink-3); }

/* Mini summary */
.mini-summary { display: flex; flex-direction: column; gap: 2px; }
.ms-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.ms-row span { color: var(--ink-2); }
.ms-row b { font-weight: 700; white-space: nowrap; }
.ms-profit b, .ms-profit span { color: var(--red); }
.ms-final { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; }
.ms-final span { font-weight: 800; }
.ms-final b { font-size: 21px; font-weight: 900; color: var(--accent); white-space: nowrap; }

/* =====================================================================
 * Results
 * ===================================================================== */
.results { display: flex; flex-direction: column; gap: 14px; scroll-margin-top: 12px; }
.results.reveal { animation: rise .5s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.results-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; padding: 6px 2px 0; }
.eyebrow { font-size: 11.5px; font-weight: 800; color: var(--accent); letter-spacing: .3px; }
.results-head h2 { font-size: 22px; font-weight: 900; }
.results-head p { font-size: 12.5px; color: var(--ink-3); }

.glance {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1);
}
.g-hero { display: flex; align-items: center; gap: 14px; }
.g-model {
  flex: none; font-size: 26px; font-weight: 900; direction: ltr;
  padding: 8px 16px; border-radius: 14px; color: #fff; background: linear-gradient(135deg, var(--dark-3), var(--dark));
  box-shadow: inset 0 0 0 1px rgba(56, 225, 255, .25);
}
.g-hero b { display: block; font-size: 18px; font-weight: 800; }
.g-hero small { font-size: 13px; color: var(--ink-3); }
.g-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.g-chip { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.g-chip b { color: var(--ink); font-weight: 900; font-size: 14.5px; }

.results-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.r-title { font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.r-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 13px; }

.kv { margin: 0; display: flex; flex-direction: column; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--ink-3); font-size: 13.5px; }
.kv dd { margin: 0; font-weight: 600; text-align: left; }
.tag { display: inline-block; direction: ltr; padding: 0 10px; border-radius: 8px; background: var(--dark); color: #fff; }

.parts { list-style: none; margin: 0; padding: 0; }
.parts li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.parts li:last-child { border-bottom: 0; }
.p-label { display: flex; flex-direction: column; font-weight: 700; font-size: 14px; min-width: 0; }
.p-label small { font-weight: 400; color: var(--ink-3); font-size: 11.5px; line-height: 1.6; }
.p-qty { flex: none; padding: 3px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-2); font-weight: 800; font-size: 13.5px; white-space: nowrap; }
.parts .p-sep { display: block; font-size: 12px; color: var(--ink-3); font-weight: 800; padding: 14px 0 4px; border-bottom: 1px solid var(--line); }

/* جدول قیمت — موبایل: کارت */
.price-table { display: flex; flex-direction: column; }
.pt-head { display: none; }
.pt-section { display: flex; justify-content: space-between; padding: 10px 12px; margin-top: 10px; border-radius: 10px; background: var(--surface-3); font-size: 13px; font-weight: 800; color: var(--ink-2); }
.pt-section:first-of-type { margin-top: 0; }
.pt-row { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 12px 4px; border-bottom: 1px dashed var(--line); }
.pt-desc { grid-column: 1 / -1; display: flex; flex-direction: column; }
.pt-desc b { font-size: 14.5px; }
.pt-desc small { color: var(--ink-3); font-size: 12px; }
.pt-cell { font-size: 13.5px; display: flex; flex-direction: column; }
.pt-cell::before { content: attr(data-label); font-size: 11px; color: var(--ink-3); }
.pt-total { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; font-weight: 900; font-size: 15px; padding-top: 4px; }
.pt-sum { display: flex; justify-content: space-between; gap: 10px; padding: 14px 12px; margin-top: 12px; border-radius: 12px; background: var(--dark); color: #fff; font-weight: 800; }
.pt-sum b { font-size: 17px; white-space: nowrap; }

/* جمع‌ها */
.totals-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.cost-card { display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.t-label { font-size: 13.5px; font-weight: 700; color: var(--ink-2); }
.t-value { font-size: 28px; font-weight: 900; letter-spacing: -.3px; }
.t-foot { font-size: 12px; color: var(--ink-3); }

/* کارت سود همکار — قرمز ملایم */
.profit-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px; border-radius: var(--r);
  background: linear-gradient(160deg, var(--red-bg), var(--red-bg-2));
  border: 1.5px solid var(--red-line);
  color: var(--red-ink);
  box-shadow: 0 10px 30px -18px rgba(200, 55, 45, .55);
}
.profit-card::before {
  content: ""; position: absolute; inset: 0 0 auto auto; width: 140px; height: 140px; border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 55, 45, .12), transparent 70%); transform: translate(30%, -40%);
}
.profit-top { display: flex; justify-content: space-between; align-items: center; }
.profit-title { font-size: 15px; font-weight: 900; }
.profit-badge { font-size: 26px; font-weight: 900; color: var(--red); background: #fff; border: 1.5px solid var(--red-line); border-radius: 14px; padding: 0 14px; }
.profit-value { font-size: 30px; font-weight: 900; color: var(--red); letter-spacing: -.3px; }
.profit-foot { font-size: 12.5px; color: var(--red-ink); opacity: .85; }

/* کارت قیمت نهایی — بزرگ‌ترین عدد صفحه */
.final-card {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 1fr; gap: 16px;
  padding: 22px 18px; border-radius: var(--r-lg); color: #fff;
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .06) 1px, transparent 1.4px) 0 0 / 10px 10px,
    radial-gradient(90% 120% at 0% 100%, rgba(56, 225, 255, .28), transparent 60%),
    linear-gradient(150deg, #13224a, var(--dark));
  box-shadow: var(--shadow-3);
}
.final-rows { display: flex; flex-direction: column; gap: 6px; }
.final-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, .1); font-size: 14px; }
.final-row span { color: rgba(255, 255, 255, .7); }
.final-row em { font-style: normal; color: #ff9d94; }
.final-row b { font-weight: 800; white-space: nowrap; }
.final-row:nth-child(2) b { color: #ff9d94; }
.final-main { display: flex; flex-direction: column; gap: 2px; }
.final-label { font-size: 14px; font-weight: 800; color: var(--cyan); letter-spacing: .3px; }
.final-value { font-size: clamp(34px, 9vw, 58px); font-weight: 900; line-height: 1.25; letter-spacing: -1px; text-shadow: 0 0 30px rgba(56, 225, 255, .35); word-break: break-word; }
.final-value small { font-size: .4em; font-weight: 700; color: rgba(255, 255, 255, .7); letter-spacing: 0; }
.final-words { font-size: 12.5px; color: rgba(255, 255, 255, .6); line-height: 1.8; }

/* =====================================================================
 * Sticky Bottom Bar
 * ===================================================================== */
.sticky-bar {
  position: fixed; inset: auto 0 0 0; z-index: 40;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  background: rgba(10, 16, 32, .94);
  -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px);
  color: #fff; border-top: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 -10px 30px -10px rgba(10, 16, 32, .45);
}
.sticky-inner { display: flex; flex-direction: column; gap: 8px; }
.sb-metrics { display: flex; gap: 6px; }
.sb-item { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; padding: 3px 4px; border-radius: 9px; background: rgba(255, 255, 255, .06); }
.sb-item span { font-size: 10.5px; color: rgba(255, 255, 255, .55); }
.sb-item b { font-size: 13.5px; font-weight: 800; white-space: nowrap; }
.sb-desk { display: none; }
.sb-profit b { color: #ff9d94; }
.sb-final { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sb-final-text { display: flex; flex-direction: column; min-width: 0; }
.sb-final-text span { font-size: 11px; color: var(--cyan); font-weight: 700; }
.sb-final-text b { font-size: 19px; font-weight: 900; white-space: nowrap; line-height: 1.3; }
.sb-btn { min-height: 46px; padding: 8px 16px; flex: none; }

/* =====================================================================
 * Modal
 * ===================================================================== */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8, 12, 24, .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: fade .2s ease both; }
.modal-panel {
  position: relative; width: 100%; max-height: 94vh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-3);
  animation: sheet .28s var(--ease) both;
}
@keyframes fade { from { opacity: 0; } }
@keyframes sheet { from { transform: translateY(30px); opacity: 0; } }
.modal-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-toolbar strong { font-size: 16px; font-weight: 800; }
.modal-toolbar .icon-btn-light { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.toolbar-actions { display: flex; gap: 8px; align-items: center; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 20px 20px; }
.modal-confirm { max-width: 440px; }
.modal-confirm h3 { font-size: 17px; font-weight: 800; margin-bottom: 6px; }
.modal-confirm p { color: var(--ink-2); font-size: 14px; }
.modal-invoice { height: 94vh; max-width: 980px; background: var(--surface-3); }
.invoice-scroll { flex: 1; overflow: auto; padding: 14px; }

/* =====================================================================
 * Invoice
 * ===================================================================== */
.invoice {
  background: #fff; color: #111827; margin: 0 auto; max-width: 860px; min-width: 0;
  padding: 22px; border-radius: 10px; box-shadow: var(--shadow-2); font-size: 13px;
}
.inv-head { display: grid; grid-template-columns: 1fr; gap: 14px; padding-bottom: 14px; border-bottom: 2px solid #111827; }
.inv-brand { display: flex; align-items: center; gap: 12px; }
.inv-brand img { width: 56px; height: 56px; object-fit: contain; }
.inv-logo-ph { width: 56px; height: 56px; border-radius: 12px; display: grid; place-items: center; background: #0a1020; color: var(--cyan); font-weight: 900; font-size: 14px; direction: ltr; }
.inv-brand h2 { font-size: 16px; font-weight: 900; }
.inv-brand p { color: #6b7280; font-size: 12px; direction: ltr; text-align: right; }
.inv-title h1 { font-size: 26px; font-weight: 900; }
.inv-title p { color: #6b7280; }
.inv-meta { display: flex; flex-direction: column; gap: 2px; }
.inv-meta div { display: flex; justify-content: space-between; gap: 12px; }
.inv-meta span { color: #6b7280; }
.inv-parties { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 14px 0; }
.inv-box { border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px; }
.inv-box h4, .inv-notes h4 { font-size: 13px; font-weight: 900; margin-bottom: 6px; }
.inv-box p, .inv-notes p { line-height: 1.9; }
.inv-box span, .inv-notes span { color: #6b7280; }
.inv-specs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.inv-specs div { background: #f3f4f6; border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; }
.inv-specs span { font-size: 11px; color: #6b7280; }
.inv-specs b { font-size: 14px; }
.inv-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: 12px; }
.inv-table th { background: #111827; color: #fff; font-weight: 700; padding: 8px 6px; text-align: center; }
.inv-table td { border-bottom: 1px solid #e5e7eb; padding: 8px 6px; text-align: center; vertical-align: top; }
.inv-table tbody tr:nth-child(even) td { background: #f9fafb; }
.inv-table .t-desc { text-align: right; }
.inv-table .t-desc b { display: block; }
.inv-table .t-desc small { color: #6b7280; }
.inv-bottom { display: grid; grid-template-columns: 1fr; gap: 14px; }
.inv-note-text { color: #374151; font-size: 12px; }
.inv-totals { border: 1.5px solid #111827; border-radius: 10px; overflow: hidden; }
.inv-totals > div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid #e5e7eb; }
.inv-profit { background: var(--red-bg); color: var(--red-ink); }
.inv-final { background: #111827; color: #fff; font-size: 16px; }
.inv-final b { font-size: 18px; }
.inv-words { padding: 8px 12px; font-size: 11.5px; color: #374151; }
.inv-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 24px; }
.inv-sign div { border-top: 1px dashed #9ca3af; padding-top: 8px; text-align: center; color: #6b7280; font-size: 12px; min-height: 70px; }

/* =====================================================================
 * Toast
 * ===================================================================== */
.toast {
  position: fixed; z-index: 200; left: 50%; top: 16px; transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: var(--dark); color: #fff; padding: 10px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-3); transition: all .25s var(--ease); max-width: calc(100% - 28px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ok { background: #0c6b4c; }
.toast-err { background: var(--red); }

/* =====================================================================
 * Admin
 * ===================================================================== */
.app-header--admin { padding-bottom: 14px; }
.admin-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding-top: 14px; padding-bottom: 40px; }
.admin-nav {
  position: sticky; top: 0; z-index: 30;
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -14px; padding: 8px 14px; background: rgba(238, 241, 246, .92);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.admin-nav::-webkit-scrollbar { display: none; }
.nav-item {
  flex: none; display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 6px 12px;
  border-radius: 12px; color: var(--ink-2); text-decoration: none; font-weight: 700; font-size: 13.5px;
  background: var(--surface); border: 1px solid var(--line); transition: all var(--t);
}
.nav-item:hover { color: var(--accent); border-color: var(--accent); }
.nav-item.is-active { background: var(--dark); color: #fff; border-color: var(--dark); }
.nav-ic { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; background: var(--surface-3); color: var(--ink-2); font-size: 13px; }
.nav-item.is-active .nav-ic { background: rgba(255, 255, 255, .12); color: var(--cyan); }
.nav-count { font-size: 11px; padding: 0 7px; border-radius: 99px; background: var(--surface-3); color: var(--ink-3); }
.nav-item.is-active .nav-count { background: rgba(255, 255, 255, .14); color: #fff; }

.admin-main { min-width: 0; }
.section-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.section-head h2 { font-size: 20px; font-weight: 900; }
.section-head p { font-size: 13px; color: var(--ink-3); max-width: 680px; line-height: 1.8; }
.section-head .btn { align-self: flex-start; }
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.list-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.search { flex: 1; min-width: 200px; }
.search .input { min-height: 44px; }

.commission-edit { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 10px; }
.commission-edit .num-input { border-color: var(--red-line); background: var(--red-bg); }
.commission-edit .num-input input { color: var(--red); }
.commission-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn { min-height: 38px; padding: 4px 12px; border-radius: 10px; border: 1.5px solid var(--line-2); background: var(--surface); font-weight: 700; cursor: pointer; transition: all var(--t); }
.chip-btn:hover { border-color: var(--red); color: var(--red); }

.logo-edit { display: flex; gap: 14px; align-items: flex-start; margin-top: 4px; flex-wrap: wrap; }
.logo-preview { width: 88px; height: 88px; border-radius: 14px; border: 1.5px dashed var(--line-2); display: grid; place-items: center; overflow: hidden; background: var(--surface-2); color: var(--ink-3); font-size: 12px; flex: none; }
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-actions { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.logo-actions .input { min-height: 42px; }

.save-bar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); margin: 0 -14px;
  background: rgba(255, 255, 255, .94); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.save-state { font-size: 13px; color: var(--green); font-weight: 600; }
.save-state.is-dirty { color: var(--amber); }

/* لیست داده — موبایل: کارت */
.data-list { display: flex; flex-direction: column; gap: 10px; }
.dl-head { display: none; }
.dl-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center;
  padding: 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1);
  transition: box-shadow var(--t), opacity var(--t);
}
.dl-row.is-off { opacity: .62; }
.dl-name { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.dl-name b { font-size: 15.5px; font-weight: 800; }
.dl-name small { flex-basis: 100%; color: var(--ink-3); font-size: 12px; }
.dl-price { display: flex; flex-direction: column; }
.dl-price small { color: var(--ink-3); font-size: 11.5px; }
.price-edit { font-size: 18px; font-weight: 900; cursor: text; border-bottom: 1.5px dashed transparent; align-self: flex-start; transition: border-color var(--t); }
.price-edit:hover { border-color: var(--accent); color: var(--accent); }
.dl-detail { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); padding: 6px 10px; border-radius: 9px; }
.dl-status { grid-row: 2; grid-column: 2; }
.sw-text { font-size: 12.5px; color: var(--ink-2); }
.dl-actions { grid-column: 1 / -1; display: flex; gap: 6px; justify-content: flex-end; border-top: 1px dashed var(--line); padding-top: 10px; }
.icon-danger:hover { color: var(--red); border-color: var(--red); }
.pill { font-size: 11px; font-weight: 800; padding: 1px 9px; border-radius: 99px; background: var(--dark); color: #fff; }
.pill-soft { background: var(--accent-soft); color: var(--accent-2); }
.empty-state { text-align: center; padding: 40px 16px; border: 2px dashed var(--line-2); border-radius: var(--r); background: var(--surface); display: flex; flex-direction: column; gap: 14px; align-items: center; color: var(--ink-3); }

/* فرم مودال */
.modal-form { max-width: 640px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
.form-grid .field { margin-bottom: 12px; }
.rule-box { border: 1.5px solid var(--line); border-radius: 14px; padding: 12px; margin: 0 0 12px; min-width: 0; }
.rule-box legend { font-size: 13px; font-weight: 800; padding: 0 6px; color: var(--ink-2); }
.rule-sentence { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-weight: 700; margin-bottom: 12px; }
.rule-sentence.is-fixed > span:first-child, .rule-sentence.is-fixed > [name="calc.per"], .rule-sentence.is-fixed > [data-base-unit], .rule-sentence.is-fixed > .rule-eq { display: none; }
.rule-eq { color: var(--accent); font-size: 18px; }
.rule-preview { font-size: 12.5px; color: var(--ink-2); background: var(--accent-soft); border-radius: 10px; padding: 8px 12px; line-height: 1.9; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.code { background: var(--dark); color: #cfe7ff; padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: 12.5px; margin: 10px 0 0; font-family: ui-monospace, Menlo, Consolas, monospace; }
.hide-sm { display: none; }

/* =====================================================================
 * Admin — ورود و پیام وضعیت
 * ===================================================================== */
.login-screen { min-height: calc(100vh - 90px); display: grid; grid-template-columns: minmax(0, 400px); justify-content: center; align-content: center; padding: 24px 14px 60px; }
.login-card {
  width: 100%; min-width: 0; display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 28px 22px; box-shadow: var(--shadow-2); text-align: center;
  animation: rise .4s var(--ease) both;
}
.login-card .field { text-align: right; margin: 14px 0 4px; }
.login-card h2 { font-size: 20px; font-weight: 900; }
.login-icon {
  width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 18px; display: grid; place-items: center;
  color: var(--cyan); background: linear-gradient(150deg, var(--dark-3), var(--dark));
  box-shadow: 0 10px 30px -10px rgba(31, 94, 255, .6);
}
.pass-input input { font-size: 20px; letter-spacing: 2px; }
.pass-input .stepper { font-size: 18px; }
.login-error { min-height: 22px; color: var(--red); font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.login-back { font-size: 13px; color: var(--ink-3); margin-top: 10px; text-decoration: none; }
.login-back:hover { color: var(--accent); }
.btn:disabled { opacity: .7; pointer-events: none; }

.banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 12px 16px; margin-bottom: 14px; border-radius: var(--r);
  background: #fff8e8; border: 1.5px solid #f2d79b; color: #7a5300; font-size: 13.5px; line-height: 1.8;
}
.banner b { font-weight: 800; }
.banner-err { background: var(--red-bg); border-color: var(--red-line); color: var(--red-ink); }

/* =====================================================================
 * ≥ 640px
 * ===================================================================== */
@media (min-width: 640px) {
  .container { padding: 0 20px; }
  .partner-strip { margin: 0; padding: 0; flex-wrap: wrap; }
  .brand-text h1 { font-size: 19px; }
  .brand-text p { font-size: 13px; }
  .card { padding: 20px; }
  .two-col, .form-grid { grid-template-columns: 1fr 1fr; }
  .field-wide { grid-column: 1 / -1; }
  .info-grid { grid-template-columns: repeat(3, 1fr); }
  .form-actions { grid-template-columns: 2fr 1fr; }
  .preview-stats { grid-template-columns: repeat(4, 1fr); }
  .ps-wide { grid-column: span 2; }
  .acc-item { grid-template-columns: auto 1fr auto; grid-template-areas: "sw main nums"; }
  .acc-nums { flex-direction: column; align-items: flex-end; gap: 0; text-align: left; }
  .results-grid { grid-template-columns: 1fr 1fr; }
  .totals-grid { grid-template-columns: 1fr 1fr; }

  /* جدول واقعی */
  .pt-head, .pt-row { display: grid; grid-template-columns: minmax(0, 2.4fr) 1.1fr 1.1fr 1.3fr; gap: 12px; align-items: center; }
  .pt-head { padding: 8px 12px; font-size: 12px; font-weight: 700; color: var(--ink-3); border-bottom: 1px solid var(--line); }
  .pt-head span:not(:first-child) { text-align: left; }
  .pt-row { padding: 11px 12px; }
  .pt-desc { grid-column: auto; }
  .pt-cell { text-align: left; display: block; }
  .pt-cell::before { display: none; }
  .pt-total { grid-column: auto; padding: 0; display: block; }
  .pt-row:hover { background: var(--surface-2); }

  .sticky-inner { flex-direction: row; align-items: center; gap: 14px; }
  .sb-metrics { flex: 1; }
  .sb-final { gap: 16px; }

  .modal { align-items: center; padding: 20px; }
  .modal-panel { border-radius: 20px; }
  .modal-invoice { height: 92vh; }
  .invoice-scroll { padding: 24px; }
  .invoice { padding: 34px; }
  .inv-head { grid-template-columns: 1.3fr 1fr 1fr; align-items: center; }
  .inv-title { text-align: center; }
  .inv-parties { grid-template-columns: 1fr 1fr; }
  .inv-specs { grid-template-columns: repeat(5, 1fr); }
  .inv-bottom { grid-template-columns: 1.2fr 1fr; }

  .admin-nav { margin: 0; padding: 8px 0; }
  .section-head { flex-direction: row; justify-content: space-between; align-items: flex-start; }
  .hide-sm { display: inline; }
  .save-bar { margin: 0; border: 1px solid var(--line); border-radius: var(--r); }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .card-wide, .save-bar { grid-column: 1 / -1; }
}

/* =====================================================================
 * ≥ 1024px — Desktop: فرم راست، پیش‌نمایش چپ، ریز محاسبات پایین
 * ===================================================================== */
@media (min-width: 1024px) {
  body { font-size: 15.5px; }
  .app-header { padding: 18px 0; }
  .header-inner { flex-direction: row; align-items: center; justify-content: space-between; gap: 20px; }
  .brand { flex: 1; min-width: 0; }
  .brand-logo { width: 52px; height: 52px; border-radius: 14px; }
  .brand-text h1 { font-size: 21px; }
  .partner-strip { flex-wrap: nowrap; order: 2; }
  .header-admin { order: 3; }
  .page-calc .brand { order: 1; }
  .page-calc .header-inner .partner-strip { justify-content: flex-end; }

  .main-grid { grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 20px; padding-top: 22px; align-items: start; }
  .col-side { order: 0; }
  .side-sticky { position: sticky; top: 16px; }
  .results { grid-column: 1 / -1; }
  .card:hover { box-shadow: var(--shadow-2); }
  .preview-card:hover { box-shadow: var(--shadow-3); }
  .preview-stats { grid-template-columns: repeat(4, 1fr); }
  .results-grid { grid-template-columns: 1fr 1.15fr; }
  .totals-grid { grid-template-columns: 1fr 1fr; }
  .final-card { grid-template-columns: 1fr 1.5fr; align-items: center; padding: 30px 32px; gap: 32px; }
  .final-rows { border-left: 1px solid rgba(255, 255, 255, .1); padding-left: 28px; }
  .final-value { font-size: 60px; }

  .sb-desk { display: flex; }
  .sb-item { padding: 5px 10px; }
  .sb-item span { font-size: 11.5px; }
  .sb-item b { font-size: 15px; }
  .sb-final-text b { font-size: 23px; }

  .admin-layout { grid-template-columns: 250px minmax(0, 1fr); gap: 24px; padding-top: 24px; align-items: start; }
  .admin-nav { position: sticky; top: 16px; flex-direction: column; overflow: visible; background: transparent; padding: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .nav-item { min-height: 48px; }
  .nav-count { margin-inline-start: auto; }

  .data-list { gap: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-1); }
  .dl-head, .dl-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1.5fr) 130px 210px; gap: 14px; align-items: center; }
  .dl-head { padding: 10px 16px; font-size: 12px; font-weight: 700; color: var(--ink-3); background: var(--surface-2); border-bottom: 1px solid var(--line); }
  .dl-row { border-radius: 0; border: 0; border-bottom: 1px solid var(--line); box-shadow: none; padding: 12px 16px; }
  .dl-row:last-child { border-bottom: 0; }
  .dl-row:hover { background: var(--surface-2); }
  .dl-name, .dl-detail, .dl-actions { grid-column: auto; }
  .dl-status { grid-row: auto; grid-column: auto; }
  .dl-detail { background: transparent; padding: 0; }
  .dl-actions { border: 0; padding: 0; justify-content: flex-start; }
  .dl-actions .icon-btn { width: 36px; height: 36px; }
}

@media (min-width: 1280px) {
  .main-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* =====================================================================
 * Reduced motion
 * ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* =====================================================================
 * Print — فقط پیش‌فاکتور چاپ می‌شود (A4)
 * ===================================================================== */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; padding: 0 !important; }
  body > *:not(#invoiceModal) { display: none !important; }
  #invoiceModal { position: static; display: block; }
  .modal-backdrop, .no-print { display: none !important; }
  .modal-panel, .modal-invoice { position: static; height: auto; max-height: none; box-shadow: none; background: #fff; border-radius: 0; animation: none; }
  .invoice-scroll { padding: 0; overflow: visible; }
  .invoice { box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
  .inv-head { grid-template-columns: 1.3fr 1fr 1fr; align-items: center; }
  .inv-title { text-align: center; }
  .inv-parties { grid-template-columns: 1fr 1fr; }
  .inv-specs { grid-template-columns: repeat(5, 1fr); }
  .inv-bottom { grid-template-columns: 1.2fr 1fr; }
  .inv-table th, .inv-final, .inv-logo-ph, .inv-profit { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .inv-table tr { break-inside: avoid; }
}
