/* miniapp.css — ProfCalc Telegram Mini App */
:root {
  --bg: #f5f2ec;
  --card: #ffffff;
  --text: #1f1d1a;
  --muted: #7a756c;
  --faint: #b3aea3;
  --accent: #b56b3a;
  --accent-dark: #8a4d24;
  --accent-soft: #fdf6ee;
  --accent-tint: #fce8d8;
  --rule: rgba(40,30,20,0.08);
  --good: #5e8a4a;
  --warn: #c89240;
  --bad: #c25a4a;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tab-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: 'Inter', -apple-system, system-ui, sans-serif; min-height: 100vh; overscroll-behavior: contain; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }

#root { min-height: 100vh; }

/* Top bar */
.bar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-top) + 14px) 16px 12px;
  background: var(--bg); border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 5;
}
.bar .back { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; color: var(--accent); border: none; background: transparent; padding: 0; }
.bar .title { flex: 1; font-size: 17px; font-weight: 600; letter-spacing: -.2px; }
.bar .icon-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; color: var(--text); border: none; background: transparent; padding: 0; position: relative; }
.bar .badge { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; background: var(--accent); color: #fff; border-radius: 8px; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; line-height: 1; }

.body { padding: 18px 16px calc(var(--tab-h) + 24px); }
.body.no-tabs { padding-bottom: 32px; }
.section-label { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; margin: 4px 0 8px; }

.card { background: var(--card); border-radius: 14px; border: 1px solid var(--rule); }
.card.pad { padding: 14px; }
.card.list { overflow: hidden; }
.card.list > .row { padding: 12px 14px; border-top: 1px solid var(--rule); display: flex; align-items: center; gap: 12px; }
.card.list > .row:first-child { border-top: none; }
.card.list > .row.tap:active { background: #faf7f1; }

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.right { text-align: right; }
.row-flex { display: flex; align-items: center; gap: 12px; }

/* Bottom tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: rgba(245,242,236,0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--rule);
  padding-bottom: var(--safe-bottom);
  display: flex; height: var(--tab-h);
}
.tabs button {
  flex: 1; background: transparent; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 10px; font-weight: 600; padding: 6px 4px; position: relative;
}
.tabs button .ico { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.tabs button.active { color: var(--accent); }
.tabs button.active .ico::after { content: ''; position: absolute; top: 4px; left: 50%; transform: translateX(-50%); width: 24px; height: 3px; border-radius: 2px; background: var(--accent); }
.tabs button .badge { position: absolute; top: 6px; right: 24%; min-width: 16px; height: 16px; padding: 0 4px; background: var(--accent); color: #fff; border-radius: 8px; font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; line-height: 1; }

/* Buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; border: none; border-radius: 14px; padding: 14px 20px; font-size: 15px; font-weight: 600; letter-spacing: -.1px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--text); color: #fff; box-shadow: 0 6px 18px rgba(40,30,20,.18); }
.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 6px 18px rgba(181,107,58,.25); width: 100%; }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--rule); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-row { display: flex; gap: 8px; }

/* Greeting */
.greet { margin-bottom: 18px; }
.greet .hi { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: .2px; text-transform: uppercase; }
.greet .q { font-size: 22px; font-weight: 700; letter-spacing: -.4px; margin-top: 2px; }

.big-action {
  width: 100%; border: none; cursor: pointer; background: var(--text); color: #fff;
  padding: 18px 20px; border-radius: 16px; display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; box-shadow: 0 6px 18px rgba(40,30,20,.18);
}
.big-action .label { font-size: 16px; font-weight: 600; letter-spacing: -.2px; }
.big-action .sub { font-size: 12px; color: rgba(255,255,255,.6); margin-top: 2px; }
.big-action .plus {
  width: 36px; height: 36px; border-radius: 12px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; color: #fff;
}

/* Quick stats grid */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 22px; }
.stat { background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: 12px; }
.stat .label { font-size: 10.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-size: 18px; font-weight: 700; font-family: var(--mono); margin-top: 4px; letter-spacing: -.3px; }
.stat .delta { font-size: 11px; color: var(--good); margin-top: 2px; font-weight: 600; }

/* Tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 22px; }
.tile { background: var(--card); border-radius: 14px; padding: 12px; border: 1px solid var(--rule); display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.tile .preview { height: 84px; background: #f0ece4; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 6px; }
.tile .label { font-size: 13.5px; font-weight: 600; letter-spacing: -.1px; }
.tile .sub { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* Templates grid (Топ окон) */
.templates-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tpl { background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 12px; cursor: pointer; }
.tpl.sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 4px 12px rgba(181,107,58,.15); }
.tpl .preview { height: 100px; background: #f0ece4; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 6px; margin-bottom: 8px; }
.tpl .name { font-size: 13.5px; font-weight: 600; letter-spacing: -.1px; }
.tpl .sub { font-size: 10.5px; color: var(--muted); font-family: var(--mono); margin-top: 1px; }
.tpl .dim { font-size: 10px; color: var(--faint); font-family: var(--mono); margin-top: 4px; }

/* Stepper */
.stepper { display: flex; gap: 6px; margin-bottom: 16px; }
.stepper .step { flex: 1; }
.stepper .bar-line { height: 3px; border-radius: 2px; background: #e3ddd1; }
.stepper .step.active .bar-line { background: var(--accent); }
.stepper .step .name { font-size: 10px; color: var(--muted); margin-top: 6px; font-weight: 500; text-align: center; }
.stepper .step.active .name { color: var(--text); font-weight: 600; }

/* Constructor sections */
.size-line { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.size-line .dims { font-size: 12px; color: var(--muted); font-family: var(--mono); letter-spacing: .3px; }
.size-line .edit { font-size: 12px; color: var(--accent); font-weight: 600; background: none; border: none; padding: 4px 8px; border-radius: 6px; }
.size-line .edit:active { background: var(--accent-soft); }
.draw { display: flex; justify-content: center; padding: 8px 4px 4px; }
.section-tag {
  font-size: 11px; font-family: var(--mono); padding: 6px 8px;
  border-radius: 6px; background: #f0ece4; color: var(--muted); font-weight: 600;
  border: 1px solid transparent; cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.section-tag.active { background: var(--accent-tint); color: var(--accent-dark); border-color: var(--accent); }

/* Quick actions row */
.quick-row { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.quick {
  flex: 1 1 calc(50% - 4px); padding: 10px 8px; text-align: center; background: var(--card);
  border: 1px solid var(--rule); border-radius: 10px; font-size: 12px; font-weight: 500; cursor: pointer; min-width: 0;
}
.quick:active { background: #faf7f1; }

/* Opening picker */
.opening-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.opening-grid .opt {
  padding: 10px 4px; border-radius: 10px; text-align: center; cursor: pointer; background: transparent; border: none;
}
.opening-grid .opt.sel { background: var(--accent); color: #fff; }
.opening-grid .opt .glyph { height: 26px; display: flex; align-items: center; justify-content: center; }
.opening-grid .opt .code { font-size: 10px; font-family: var(--mono); font-weight: 600; margin-top: 2px; }

/* Glazing list */
.glaz-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--rule); cursor: pointer; }
.glaz-row:first-child { border-top: none; }
.glaz-row.sel { background: var(--accent-soft); }
.glaz-row .radio { width: 22px; height: 22px; border-radius: 11px; border: 1.5px solid var(--faint); flex-shrink: 0; }
.glaz-row.sel .radio { border-width: 6px; border-color: var(--accent); }
.glaz-row .meta { flex: 1; min-width: 0; }
.glaz-row .meta .label { font-size: 13.5px; font-weight: 500; }
.glaz-row .meta .sub { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 1px; }
.glaz-row .price { font-size: 13px; font-weight: 600; font-family: var(--mono); }

/* Comparison cards */
.cmp { display: flex; flex-direction: column; gap: 10px; }
.cmp .card { padding: 14px; position: relative; }
.cmp .card.best { border: 1.5px solid var(--accent); }
.cmp .badge { position: absolute; top: -9px; right: 12px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .5px; padding: 3px 8px; border-radius: 6px; text-transform: uppercase; }
.cmp .head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.cmp .logo { width: 36px; height: 36px; border-radius: 8px; background: #f0ece4; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; font-family: var(--mono); flex-shrink: 0; }
.cmp .title { font-size: 14px; font-weight: 600; letter-spacing: -.1px; }
.cmp .meta { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.cmp .pricing { display: flex; align-items: baseline; gap: 8px; padding-top: 6px; border-top: 1px solid var(--rule); }
.cmp .pricing .label { font-size: 11px; color: var(--muted); font-family: var(--mono); padding-top: 8px; }
.cmp .pricing .strike { font-size: 12px; color: var(--faint); font-family: var(--mono); text-decoration: line-through; padding-top: 8px; }
.cmp .pricing .disc { font-size: 11px; color: var(--accent); font-weight: 600; font-family: var(--mono); padding-top: 8px; }
.cmp .pricing .final { font-size: 18px; font-weight: 700; font-family: var(--mono); letter-spacing: -.4px; margin-left: auto; }
.cmp .card.best .pricing .final { color: var(--accent-dark); }

/* Result */
.banner { background: var(--card); border-radius: 16px; border: 1px solid var(--rule); padding: 18px; margin-bottom: 14px; text-align: center; }
.banner .sub { font-size: 13px; color: var(--muted); margin-top: 8px; font-family: var(--mono); }
.total { background: var(--text); color: #fff; border-radius: 16px; padding: 18px; margin-bottom: 14px; }
.total .label { font-size: 12px; color: rgba(255,255,255,.6); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.total .value { font-size: 32px; font-weight: 700; font-family: var(--mono); letter-spacing: -1px; margin-top: 4px; }
.total .meta { display: flex; gap: 14px; margin-top: 12px; font-size: 12px; color: rgba(255,255,255,.7); font-family: var(--mono); flex-wrap: wrap; }

.spec-row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--rule); }
.spec-row:first-child { border-top: none; }
.spec-row .l { flex: 1; min-width: 0; }
.spec-row .l .label { font-size: 13px; }
.spec-row .l .qty { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 1px; }
.spec-row .price { font-size: 13px; font-weight: 500; font-family: var(--mono); }

/* KP paper */
.kp-paper {
  background: #fff; border-radius: 12px;
  box-shadow: 0 8px 30px rgba(40,30,20,.10), 0 0 0 1px rgba(40,30,20,.06);
  padding: 18px; font-size: 11px; color: var(--text); margin-bottom: 14px;
}
.kp-paper .head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid #e9e3d5; }
.kp-paper .head .from .name { font-size: 14px; font-weight: 700; letter-spacing: -.2px; }
.kp-paper .head .from .info { color: var(--muted); margin-top: 2px; font-family: var(--mono); font-size: 9px; }
.kp-paper .head .num { text-align: right; }
.kp-paper .head .num .label { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.kp-paper .head .num .value { font-family: var(--mono); font-weight: 700; font-size: 13px; }
.kp-paper .head .num .date { color: var(--muted); margin-top: 2px; font-family: var(--mono); font-size: 9px; }
.kp-paper .client { margin-bottom: 12px; }
.kp-paper .client .label { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .4px; font-weight: 600; margin-bottom: 4px; }
.kp-paper .client .value { font-size: 11.5px; font-weight: 500; }
.kp-paper .preview { background: #faf7f1; border-radius: 6px; padding: 10px 6px; margin-bottom: 12px; text-align: center; border: 1px solid #efe9da; }
.kp-paper table { width: 100%; border-collapse: collapse; font-size: 10px; }
.kp-paper th { color: var(--muted); text-transform: uppercase; font-size: 8.5px; letter-spacing: .4px; font-weight: 600; padding: 4px 0; border-bottom: 1px solid #e9e3d5; }
.kp-paper td { padding: 5px 0; border-bottom: 1px solid #f3eee2; }
.kp-paper td.qty { text-align: right; font-family: var(--mono); color: var(--muted); }
.kp-paper td.sum { text-align: right; font-family: var(--mono); }
.kp-paper .totals { margin-top: 10px; padding-top: 10px; border-top: 1px solid #e9e3d5; }
.kp-paper .totals .row { display: flex; justify-content: space-between; padding: 2px 0; font-family: var(--mono); font-size: 10px; }
.kp-paper .totals .grand { display: flex; justify-content: space-between; margin-top: 6px; padding-top: 6px; border-top: 1px solid #e9e3d5; }
.kp-paper .totals .grand .label { font-weight: 700; font-size: 12px; }
.kp-paper .totals .grand .value { font-weight: 700; font-family: var(--mono); font-size: 14px; color: var(--accent-dark); }
.kp-paper .terms { margin-top: 10px; color: var(--muted); font-size: 9px; line-height: 1.4; }

/* Bottom sheet (number input, etc) */
.sheet-bg { position: fixed; inset: 0; background: rgba(20,15,10,.4); display: flex; align-items: flex-end; z-index: 50; animation: fade .15s ease; }
.sheet { width: 100%; background: #fff; border-radius: 18px 18px 0 0; padding: 22px 22px calc(22px + var(--safe-bottom)); animation: rise .2s ease; max-height: 85vh; overflow-y: auto; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes rise { from { transform: translateY(40px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }
.sheet h3 { margin: 0 0 8px; font-size: 17px; }
.sheet .label-line { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.sheet input, .sheet select, .sheet textarea {
  display: block; width: 100%; border: 1px solid var(--rule); border-radius: 10px;
  font-size: 16px; font-family: inherit; padding: 12px; margin-top: 6px; background: #fff;
}
.sheet input.num { font-family: var(--mono); text-align: center; font-size: 20px; }
.sheet .grid { display: grid; gap: 14px; margin-top: 10px; }
.sheet .row { display: flex; gap: 8px; margin-top: 16px; }

/* Profile screen */
.profile-card { background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 18px; margin-bottom: 14px; display: flex; align-items: center; gap: 14px; }
.profile-card .avatar { width: 56px; height: 56px; border-radius: 14px; background: #fbe4d3; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.profile-card .name { font-size: 17px; font-weight: 600; letter-spacing: -.2px; }
.profile-card .role { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.menu { background: var(--card); border-radius: 14px; border: 1px solid var(--rule); overflow: hidden; margin-bottom: 14px; }
.menu .item { padding: 14px 16px; display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--rule); cursor: pointer; }
.menu .item:first-child { border-top: none; }
.menu .item:active { background: #faf7f1; }
.menu .item .ico { width: 28px; height: 28px; border-radius: 8px; background: #f0ece4; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 14px; }
.menu .item .label { flex: 1; font-size: 14.5px; }
.menu .item .meta { font-size: 12px; color: var(--muted); }
.menu .item .chev { color: var(--faint); }

/* Notification list */
.notif { padding: 14px; display: flex; align-items: flex-start; gap: 12px; border-top: 1px solid var(--rule); }
.notif:first-child { border-top: none; }
.notif.unread { background: var(--accent-soft); }
.notif .ico { width: 32px; height: 32px; border-radius: 16px; background: var(--accent-tint); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif .l { flex: 1; min-width: 0; }
.notif .l .title { font-size: 13.5px; font-weight: 600; letter-spacing: -.1px; }
.notif .l .body { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.notif .l .time { font-size: 11px; color: var(--faint); margin-top: 4px; font-family: var(--mono); }

/* Order status pill */
.pill { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .3px; }
.pill-new { background: #e8f0f9; color: #2c5fa0; }
.pill-contacted { background: #fbe4d3; color: var(--accent-dark); }
.pill-measuring { background: #f5e8d3; color: var(--accent-dark); }
.pill-production { background: #f0ece4; color: var(--text); }
.pill-installation { background: #e8f5dd; color: var(--good); }
.pill-done { background: #d6eccd; color: var(--good); }
.pill-cancelled { background: #f5e0e0; color: var(--bad); }

/* Catalog */
.cat-card { display: flex; gap: 12px; padding: 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--rule); margin-bottom: 10px; cursor: pointer; }
.cat-card .logo { width: 42px; height: 42px; border-radius: 10px; background: #f0ece4; display: flex; align-items: center; justify-content: center; font-weight: 700; font-family: var(--mono); font-size: 13px; flex-shrink: 0; }
.cat-card .l { flex: 1; min-width: 0; }
.cat-card .name { font-size: 14.5px; font-weight: 600; }
.cat-card .meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.cat-card .star { font-size: 11px; color: var(--accent); margin-top: 4px; font-weight: 600; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px + var(--safe-bottom)); transform: translateX(-50%); background: var(--text); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13px; box-shadow: 0 12px 30px rgba(20,15,10,.3); z-index: 100; max-width: 90vw; text-align: center; }
.toast.error { background: var(--bad); }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.spin { display: inline-block; width: 22px; height: 22px; border: 2.5px solid rgba(0,0,0,.1); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader { display: flex; align-items: center; justify-content: center; padding: 60px 0; }

.footer { margin-top: 22px; padding: 14px 16px; background: #ece7dd; border-radius: 12px; font-size: 12.5px; color: var(--muted); line-height: 1.4; }

/* Onboarding */
.role-card { width: 100%; text-align: left; background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 16px; margin-bottom: 10px; cursor: pointer; display: flex; gap: 14px; align-items: flex-start; }
.role-card:active { background: #faf7f1; }
.role-card .ico { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 22px; }
.role-card .name { font-size: 15px; font-weight: 600; letter-spacing: -.2px; }
.role-card .sub { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.role-card .level { font-size: 11px; color: var(--accent); margin-top: 6px; font-family: var(--mono); font-weight: 600; }

/* Inputs in onboarding/registration */
.tinp { display: block; width: 100%; padding: 13px 14px; border: 1px solid var(--rule); border-radius: 10px; font-size: 15px; font-family: inherit; background: #fff; margin-bottom: 12px; }
.tinp:focus { outline: 2px solid rgba(181,107,58,.35); border-color: var(--accent); }
.label-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; }
.label-row .ck { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--faint); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.label-row.sel .ck { background: var(--accent); border-color: var(--accent); color: #fff; }
.label-row .l { flex: 1; }

/* Role pill */
.role-pills { display: flex; gap: 6px; background: #f0ece4; padding: 4px; border-radius: 10px; margin-bottom: 16px; }
.role-pills button { flex: 1; padding: 9px; border: none; border-radius: 7px; font-size: 12.5px; font-weight: 600; cursor: pointer; background: transparent; color: var(--text); }
.role-pills button.active { background: var(--text); color: #fff; }
