:root {
  color-scheme: light;
  --bg: #eef4f3;
  --panel: #ffffff;
  --ink: #10201d;
  --muted: #64736f;
  --line: #d9e3e0;
  --primary: #007a3f;
  --primary-dark: #005f31;
  --nis-green: #007a3f;
  --app-accent: #007a3f;
  --app-accent-soft: rgba(0,122,63,.10);
  --danger: #b91c1c;
  --warn: #b45309;
  --ok: #007a3f;
}
* { box-sizing: border-box; }
body { min-width: 320px; margin: 0; font-family: Inter, "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: #2f403c; }
.check-row { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; }
.check-row input { width: auto; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; color: var(--ink); }
textarea { resize: vertical; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 46px); line-height: 1; letter-spacing: 0; }
h2 { margin-bottom: 16px; font-size: 20px; }
h3 { margin: 22px 0 12px; font-size: 15px; }
code { display: inline-block; word-break: break-all; padding: 8px; border-radius: 8px; background: var(--app-accent-soft); color: var(--primary-dark); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.strong { font-weight: 800; }
.brand-lockup { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.brand-lockup img { width: 76px; height: 76px; object-fit: contain; border-radius: 18px; box-shadow: 0 12px 26px var(--app-accent-soft); background: #fff; padding: 6px; }
.eyebrow { margin-bottom: 0%; text-transform: uppercase; font-size: 9px; letter-spacing: .08em; font-weight: 800; color: var(--nis-green); }
.primary { min-height: 40px; padding: 10px 14px; border-radius: 8px; background: var(--primary); color: #fff; font-weight: 800; }
.primary:hover { background: var(--primary-dark); }
.primary.danger { background: var(--danger); color: #fff; box-shadow: 0 12px 28px rgba(185,28,28,.18); }
.primary.danger:hover { background: #7f1d1d; }
.ghost { min-height: 40px; padding: 10px 14px; border-radius: 8px; background: var(--app-accent-soft); color: var(--primary-dark); font-weight: 800; text-decoration: none; }
a.ghost, a.primary { display: inline-flex; align-items: center; justify-content: center; }
.danger { color: var(--danger); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.stack { display: grid; gap: 14px; }
.auth-layout, .loading-layout { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, var(--app-accent-soft), #f8fafc); }
.auth-panel { width: min(100%, 520px); display: grid; gap: 20px; padding: 28px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: 0 18px 50px var(--app-accent-soft); }
.loading-card { width: min(100%, 460px); display: grid; justify-items: center; gap: 10px; padding: 30px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); text-align: center; box-shadow: 0 18px 50px var(--app-accent-soft); }
.loading-card img { width: 88px; height: 88px; object-fit: contain; border-radius: 20px; background: #fff; padding: 6px; box-shadow: 0 12px 26px var(--app-accent-soft); }
.loading-card h1 { margin: 2px 0 0; font-size: 28px; }
.loader-bar { width: 100%; height: 8px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: #e5efec; }
.loader-bar span { display: block; width: 42%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); animation: loaderSlide 1.1s ease-in-out infinite; }
@keyframes loaderSlide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(250%); }
}
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 9px; background: #edf5f3; }
.auth-tabs button { padding: 10px; border-radius: 7px; background: transparent; color: var(--muted); font-weight: 800; }
.auth-tabs button.active { background: #fff; color: var(--primary); box-shadow: 0 1px 6px rgba(0,0,0,.06); }
.qr-panel { display: grid; grid-template-columns: 180px 1fr; gap: 14px; align-items: center; }
.qr-panel canvas { width: 180px; height: 180px; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 10px; }
.message { min-height: 20px; margin: 0; color: var(--danger); font-weight: 700; }
.gr-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  color: #6f7f7b;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .01em;
}
.gr-footer span + span::before {
  content: "·";
  margin-right: 8px;
  color: #9aaca7;
}
.app-footer {
  margin-top: 22px;
  padding: 18px 0 4px;
}
.topbar { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(220px, auto) minmax(260px, 1fr); gap: 16px; align-items: center; padding: 22px clamp(16px, 4vw, 40px); background: #fff; border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 28px; margin: 0; }
.app-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.app-brand img { width: 76px; height: 76px; object-fit: contain; border-radius: 16px; background: #fff; padding: 4px; }
.app-brand strong { display: block; font-size: 22px; color: var(--primary); letter-spacing: -.04em; }
.company-center { text-align: center; }
.company-center h1 { color: var(--app-accent); }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; color: var(--muted); font-size: 14px; text-align: right; }
.top-actions span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell { width: min(1420px, 100%); margin: 0 auto; padding: 18px clamp(12px, 3vw, 28px) 36px; }
.nav-tabs { display: flex; gap: 6px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; padding-bottom: 10px; margin-bottom: 18px; }
.nav-tabs button { white-space: nowrap; padding: 10px 12px; border-radius: 8px; background: transparent; color: #45615b; font-weight: 800; }
.nav-tabs button.active { background: #fff; color: var(--primary); box-shadow: 0 1px 6px rgba(0,0,0,.06); }
.panel { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.narrow { max-width: 620px; }
.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 360px);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
  padding: 22px;
  border: 1px solid rgba(0,122,63,.16);
  border-radius: 22px;
  background:
    radial-gradient(circle at top left, var(--app-accent-soft), transparent 44%),
    linear-gradient(135deg, #ffffff, #f7fbfa);
  box-shadow: 0 18px 46px rgba(16,32,29,.07);
}
.dashboard-hero-copy { min-width: 0; align-self: center; }
.dashboard-hero h2 {
  margin: 4px 0 8px;
  font-size: clamp(26px, 3vw, 40px);
  line-height: .96;
  letter-spacing: -.045em;
}
.dashboard-status-card {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 18px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.14), transparent),
    linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 18px 36px var(--app-accent-soft);
}
.dashboard-status-card span,
.dashboard-status-card small {
  color: rgba(255,255,255,.78);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.dashboard-status-card strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 22px;
  line-height: 1.05;
}
.module-shortcuts {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.module-shortcuts button {
  min-width: 0;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  grid-template-areas: "badge title" "badge desc";
  gap: 3px 10px;
  align-items: center;
  text-align: left;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 10px 26px rgba(16,32,29,.06);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.module-shortcuts button:hover {
  border-color: rgba(0,122,63,.24);
  transform: translateY(-1px);
  box-shadow: 0 16px 34px var(--app-accent-soft);
}
.module-shortcuts span {
  grid-area: badge;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--app-accent-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 950;
}
.module-shortcuts strong {
  grid-area: title;
  min-width: 0;
  overflow-wrap: anywhere;
}
.module-shortcuts small {
  grid-area: desc;
  color: var(--muted);
  line-height: 1.25;
}
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stats-grid article {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 12px 26px rgba(16,32,29,.05);
}
.stats-grid article::after {
  content: "";
  position: absolute;
  inset: auto -28px -38px auto;
  width: 86px;
  height: 86px;
  border-radius: 999px;
  background: var(--app-accent-soft);
}
.stats-grid span { color: var(--muted); font-size: 13px; font-weight: 800; }
.stats-grid strong { position: relative; z-index: 1; font-size: 28px; }
.two-col, .builder { display: grid; grid-template-columns: minmax(250px, 360px) 1fr; gap: 16px; }
.two-col { grid-template-columns: 1fr 1fr; }
.toolbar, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.section-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.inline-action-group {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(16,32,29,.05);
}
.toolbar input { flex: 1; min-width: 180px; }
.product-grid, .client-grid { display: grid; gap: 10px; }
.product-card, .client-card, .list-card { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 14px; }
.product-card { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: start; }
.product-card img, .product-placeholder { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; background: #e8f0ee; display: grid; place-items: center; color: var(--muted); font-weight: 900; }
.product-row, .client-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 58px minmax(220px, 1fr) 130px 110px 95px 110px auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.client-row {
  grid-template-columns: minmax(190px, 1fr) 140px 130px minmax(170px, 1fr) minmax(220px, 1.2fr) auto;
}
.row-main { min-width: 0; }
.row-main strong, .row-main p, .product-row > span, .client-row > span { overflow-wrap: anywhere; }
.row-main p {
  max-width: 78ch;
  margin: 5px 0 0;
  line-height: 1.38;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.product-card .muted {
  line-height: 1.42;
  overflow-wrap: anywhere;
}
.card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; min-width: 0; }
.product-row .card-actions, .client-row .card-actions { margin-top: 0; justify-content: flex-end; }
.product-row img, .product-row .product-placeholder { width: 58px; height: 58px; border-radius: 10px; }
.zoomable-img { cursor: zoom-in; transition: transform .18s ease, box-shadow .18s ease; }
.zoomable-img:hover { transform: scale(1.04); box-shadow: 0 12px 24px var(--app-accent-border); }
.pill { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; background: #edf5f3; color: #284a44; font-size: 12px; font-weight: 800; }
.mini-products { display: grid; gap: 8px; max-height: 620px; overflow: auto; }
.mini-product { display: grid; grid-template-columns: 46px 1fr auto; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fbfdfc; }
.mini-product img, .mini-product .product-placeholder { width: 46px; height: 46px; }
.drop-zone { display: grid; place-items: center; min-height: 78px; margin: 12px 0; padding: 14px; border: 2px dashed #9bc7c1; border-radius: 8px; color: var(--muted); background: #f6fbfa; font-weight: 800; text-align: center; }
.drop-zone.drag-over { border-color: var(--primary); color: var(--primary); background: var(--app-accent-soft); }
.quote-zone .panel { border-color: var(--app-accent-border); box-shadow: 0 16px 40px var(--app-accent-soft); }
.quote-zone h2, .quote-zone h3 { color: var(--primary); }
.quote-zone .primary { background: var(--primary); }
.quote-zone .drop-zone { border-color: var(--app-accent-border); background: var(--app-accent-soft); color: var(--primary); }
.line-list { display: grid; gap: 8px; }
.line-item { display: grid; grid-template-columns: 1fr 90px 110px 90px auto; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.total-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 18px; }
.flow-actions {
  display: flex;
  justify-content: flex-end;
  margin: 12px 0 18px;
}
.history-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.history-panel h3 {
  margin-top: 0;
}
.list { display: grid; gap: 10px; }
.list-card { display: grid; gap: 8px; }
.list-card header { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.list-card dl { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0; }
.list-card dt { color: var(--muted); font-size: 12px; font-weight: 800; }
.list-card dd { margin: 2px 0 0; font-weight: 800; }
.user-detail-grid {
  grid-template-columns: 1fr !important;
}
.user-detail-grid div {
  min-width: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.user-detail-grid div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}
.user-detail-grid dd {
  overflow-wrap: anywhere;
  word-break: break-word;
}
dialog { width: min(100% - 24px, 620px); max-height: calc(100dvh - 24px); border: 0; border-radius: 10px; padding: 0; box-shadow: 0 24px 60px rgba(0,0,0,.24); overflow: auto; }
dialog::backdrop { background: rgba(7, 26, 22, .5); }
#image-dialog { width: min(96vw, 1120px); max-width: 1120px; background: transparent; box-shadow: none; overflow: visible; }
#image-dialog::backdrop { background: rgba(7, 26, 22, .78); backdrop-filter: blur(3px); }
.dialog-form { display: grid; gap: 14px; padding: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.preview { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
menu { display: flex; justify-content: flex-end; gap: 10px; padding: 0; margin: 4px 0 0; }
.toast { position: fixed; right: 18px; bottom: 18px; max-width: 360px; padding: 12px 14px; border-radius: 8px; background: #10201d; color: #fff; font-weight: 800; box-shadow: 0 12px 30px rgba(0,0,0,.22); }
.payment-due { border-color: #fecaca; background: #fff1f2; box-shadow: inset 4px 0 0 var(--danger); }
.planner-card { box-shadow: inset 4px 0 0 var(--primary); }
.calendar-panel { margin-bottom: 16px; }
.calendar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.calendar-head h3 { margin: 0; font-size: 20px; text-transform: capitalize; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.calendar-weekday { padding: 8px; text-align: center; color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.calendar-cell {
  min-height: 112px;
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}
.calendar-cell:hover { border-color: var(--primary); box-shadow: 0 12px 24px var(--app-accent-soft); }
.empty-cell { background: transparent; border-style: dashed; box-shadow: none; }
.today-cell { outline: 3px solid var(--app-accent-border); }
.calendar-event { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 4px 6px; border-radius: 999px; background: var(--app-accent-soft); color: var(--primary); font-size: 11px; font-weight: 800; }
.calendar-event.payment { background: #fee2e2; color: var(--danger); }
.planner-mobile-agenda { display: none; }
.mobile-day-card {
  width: 100%;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 10px 28px rgba(16,32,29,.07);
}
.mobile-day-card.today { border-color: var(--primary); box-shadow: inset 4px 0 0 var(--primary), 0 12px 28px var(--app-accent-soft); }
.mobile-day-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-transform: capitalize; }
.mobile-chip { padding: 4px 8px; border-radius: 999px; background: var(--app-accent-soft); color: var(--primary); font-size: 11px; font-weight: 900; }
.mobile-event { display: block; padding: 8px 10px; border-radius: 12px; background: #f2f8f6; color: var(--ink); font-size: 13px; font-weight: 800; }
.mobile-payment { background: #fff1f2; color: var(--danger); }
.mobile-empty { color: var(--muted); font-size: 13px; font-weight: 700; }
.settings-layout { display: grid; grid-template-columns: minmax(320px, 520px) 1fr; gap: 16px; align-items: start; }
.settings-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.action-group {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #fff, #f8fbfa);
  box-shadow: 0 10px 26px rgba(16,32,29,.06);
}
.action-group span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.action-group button { width: 100%; justify-content: center; }
.danger-group { border-color: #fecaca; background: linear-gradient(180deg, #fff, #fff5f5); }
.danger-group .danger { background: #fee2e2; color: var(--danger); }
.danger-group .danger:hover { background: #fecaca; }
.logo-preview { width: 160px; max-height: 90px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 10px; }
.catalog-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.catalog-controls input { min-width: 220px; }
.catalog-mobile-list { display: none; }
.catalog-mobile-card {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(16,32,29,.08);
}
.catalog-mobile-card img,
.catalog-mobile-card .product-placeholder {
  width: 104px;
  height: 104px;
  border-radius: 14px;
  object-fit: cover;
}
.catalog-mobile-card h3 { margin: 8px 0 4px; font-size: 17px; }
.catalog-mobile-card p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.catalog-mobile-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.catalog-mobile-meta strong { color: var(--primary); font-size: 18px; }
.flipbook {
  position: relative;
  width: min(100%, 1120px);
  min-height: 640px;
  margin: 10px auto 0;
  perspective: 2200px;
  overflow: hidden;
}
.book-spread {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr);
  min-height: 640px;
  padding: 22px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 50%, rgba(0,0,0,.18), transparent 42%),
    linear-gradient(135deg, #dbe8e4, #f8fafc);
  box-shadow: 0 30px 80px var(--app-accent-soft);
}
.book-page {
  position: relative;
  min-height: 590px;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  cursor: pointer;
  background:
    linear-gradient(90deg, rgba(255,255,255,.92), rgba(255,255,255,.98)),
    #fff;
  border: 1px solid #d7e2df;
  box-shadow: 0 16px 34px rgba(0,0,0,.10);
  animation: pageTurn .42s ease both;
  transform-style: preserve-3d;
  backface-visibility: hidden;
}
.book-spread::after {
  content: "";
  position: absolute;
  right: 28px;
  bottom: 28px;
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, transparent 50%, var(--app-accent-border) 51%, var(--app-accent-soft));
  border-radius: 0 0 18px 0;
  pointer-events: none;
}
.book-page::before {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 76px;
  height: 76px;
  background: linear-gradient(135deg, transparent 49%, var(--app-accent-border) 50%, rgba(255,255,255,.88) 70%);
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
  z-index: 4;
}
.book-page.right:hover::before { opacity: 1; }
.book-page.left::before {
  right: auto;
  left: 0;
  transform: scaleX(-1);
}
.book-page.left:hover::before { opacity: 1; }
.book-spread.turning-next .book-page.right {
  z-index: 5;
  animation: flipNext .43s cubic-bezier(.2,.8,.2,1) both;
  box-shadow: -30px 20px 50px rgba(0,0,0,.22);
}
.book-spread.turning-prev .book-page.left {
  z-index: 5;
  animation: flipPrev .43s cubic-bezier(.2,.8,.2,1) both;
  box-shadow: 30px 20px 50px rgba(0,0,0,.22);
}
.book-spread.turning-next .book-page.right::after,
.book-spread.turning-prev .book-page.left::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0,0,0,.22), transparent 45%, rgba(255,255,255,.18));
  z-index: 6;
}
.book-page.left {
  border-radius: 22px 8px 8px 22px;
  transform-origin: right center;
  background:
    linear-gradient(90deg, #ffffff 0%, #ffffff 88%, #edf2f0 100%);
}
.book-page.right {
  border-radius: 8px 22px 22px 8px;
  transform-origin: left center;
  background:
    linear-gradient(90deg, #edf2f0 0%, #ffffff 12%, #ffffff 100%);
}
.book-page.left::after,
.book-page.right::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 44px;
  pointer-events: none;
}
.book-page.left::after {
  right: 0;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.12));
}
.book-page.right::before {
  left: 0;
  background: linear-gradient(90deg, rgba(0,0,0,.12), transparent);
}
.book-page.blank {
  background: #f8fafc;
}
.book-spine {
  min-height: 590px;
  background:
    linear-gradient(90deg, rgba(0,0,0,.18), rgba(255,255,255,.36), rgba(0,0,0,.18));
  box-shadow: inset 0 0 20px rgba(0,0,0,.25);
}
@keyframes pageTurn {
  from { opacity: .55; transform: rotateY(-7deg) translateY(4px); }
  to { opacity: 1; transform: rotateY(0deg) translateY(0); }
}
@keyframes flipNext {
  0% { transform: rotateY(0deg); filter: brightness(1); }
  48% { transform: rotateY(-82deg) translateX(-4px); filter: brightness(.86); }
  100% { transform: rotateY(-165deg) translateX(-18px); filter: brightness(.72); opacity: .28; }
}
@keyframes flipPrev {
  0% { transform: rotateY(0deg); filter: brightness(1); }
  48% { transform: rotateY(82deg) translateX(4px); filter: brightness(.86); }
  100% { transform: rotateY(165deg) translateX(18px); filter: brightness(.72); opacity: .28; }
}
.catalog-page-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #10201d);
}
.catalog-page-head span { text-transform: uppercase; font-size: 12px; letter-spacing: .12em; font-weight: 900; opacity: .8; }
.catalog-items { display: grid; gap: 18px; padding: 22px; }
.catalog-item { display: grid; grid-template-columns: 190px 1fr; gap: 16px; align-items: center; padding: 16px; border-radius: 18px; background: rgba(255,255,255,.90); border: 1px solid var(--line); }
.catalog-item img, .catalog-item .product-placeholder {
  width: 190px;
  height: 190px;
  border-radius: 16px;
  object-fit: contain;
  background: linear-gradient(135deg, #f8fafc, #edf5f3);
  border: 1px solid #e2ece8;
  padding: 10px;
  font-size: 48px;
}
.catalog-item h3 { margin: 10px 0 6px; font-size: 24px; letter-spacing: -.03em; }
.catalog-item p { min-height: 42px; margin-bottom: 12px; color: var(--muted); }
.catalog-price { font-size: 26px; font-weight: 950; color: var(--primary); }
.catalog-cover-page {
  place-items: center;
  align-content: center;
  text-align: center;
  color: #fff;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.18), transparent 28%),
    linear-gradient(135deg, var(--primary), #10201d);
}
.catalog-back-page {
  place-items: center;
  align-content: center;
  text-align: center;
  background:
    radial-gradient(circle at 80% 20%, var(--app-accent-border), transparent 32%),
    linear-gradient(135deg, #ffffff, #e7f2ef);
}
.catalog-back-page h3 { font-size: 34px; color: var(--primary); }
.catalog-back-page p { font-size: 18px; color: var(--muted); }
.catalog-cover-page .cover-logo {
  width: 150px;
  height: 150px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 34px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
  font-size: 38px;
  font-weight: 950;
}
.catalog-cover-page img { max-width: 120px; max-height: 90px; object-fit: contain; }
.catalog-cover-page span { text-transform: uppercase; letter-spacing: .18em; font-size: 12px; font-weight: 950; opacity: .8; }
.catalog-cover-page h3 { margin: 12px 0 8px; font-size: 42px; }
.catalog-cover-page p { color: rgba(255,255,255,.75); font-weight: 800; }
.image-zoom {
  width: min(96vw, 1120px);
  max-height: 92vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 18px;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
}
.image-zoom img {
  width: 100%;
  max-width: 100%;
  height: min(76vh, 760px);
  object-fit: contain;
  border-radius: 12px;
  background: linear-gradient(135deg, #f8fafc, #edf5f3);
}
.image-zoom button { justify-self: end; }
.image-zoom strong { text-align: center; overflow-wrap: anywhere; }
.invoice-preview { overflow: auto; max-height: 760px; padding: 12px; background: #edf5f3; border-radius: 14px; }
.invoice-zone .panel { border-color: var(--invoice-ui-border, #fecaca); box-shadow: 0 16px 40px rgba(185,28,28,.08); }
.invoice-zone h2, .invoice-zone h3 { color: var(--invoice-ui-color, #7f1d1d); }
.invoice-zone .primary { background: var(--invoice-ui-color, #b91c1c); box-shadow: 0 12px 28px rgba(185,28,28,.18); }
.invoice-zone .drop-zone { border-color: var(--invoice-ui-border, #fecaca); background: var(--invoice-ui-soft, #fff1f2); color: var(--invoice-ui-color, #991b1b); }
.invoice-card { border-color: var(--invoice-ui-border, #fecaca); background: var(--invoice-ui-soft, #fffafa); box-shadow: inset 4px 0 0 var(--invoice-ui-color, #b91c1c); }
.invoice-card .pill { background: var(--invoice-ui-soft, #fee2e2); color: var(--invoice-ui-color, #991b1b); }
.invoice-sheet { position:relative;background:#fff;border:1px solid #d9e3e0;border-radius:18px;padding:34px;box-shadow:0 20px 60px var(--app-accent-soft);overflow:hidden; }
.invoice-sheet.compact { min-width: min(620px, 100%); padding: 18px; box-shadow: none; border-radius: 14px; }
.document-ribbon { position:absolute;top:0;right:0;padding:10px 18px;background:#10201d;color:#fff;text-transform:uppercase;letter-spacing:.14em;font-size:11px;font-weight:900;border-bottom-left-radius:14px; }
.quote-sheet .document-ribbon { background:var(--doc-color, var(--quote-color, #007a3f)); }
.invoice-document .document-ribbon { background:var(--invoice-color, #b91c1c); }
.invoice-top { display:flex;justify-content:space-between;gap:24px;border-bottom:4px solid var(--doc-color, var(--quote-color, #007a3f));padding-bottom:22px; }
.invoice-document .invoice-top { border-bottom-color:var(--invoice-color, #b91c1c); }
.invoice-brand { display:flex;gap:16px;align-items:flex-start; }
.invoice-logo { width:112px;height:82px;object-fit:contain;border:1px solid #d9e3e0;border-radius:12px;padding:8px;background:#fff; }
.invoice-logo-fallback { width:88px;height:72px;border-radius:16px;background:var(--doc-color, var(--primary));color:#fff;display:grid;place-items:center;font-size:26px;font-weight:900; }
.invoice-document .invoice-logo-fallback { background:var(--invoice-color, #b91c1c); }
.invoice-brand strong { font-size:24px; }
.invoice-brand p { margin:4px 0;color:#64736f; }
.invoice-meta { text-align:right;padding-top:22px; }
.invoice-meta span { display:block;text-transform:uppercase;letter-spacing:.14em;color:var(--doc-color, var(--quote-color, #007a3f));font-weight:900; }
.invoice-document .invoice-meta span { color:var(--invoice-color, #b91c1c); }
.invoice-meta strong { display:block;font-size:34px;margin:8px 0; }
.document-summary { display:grid;grid-template-columns:1.5fr 1fr;gap:14px;margin:24px 0; }
.client-panel,.status-panel { border:1px solid #d9e3e0;border-radius:14px;padding:16px;background:#fbfdfc; }
.invoice-document .client-panel,.invoice-document .status-panel { border-color:var(--invoice-border, #fecaca);background:var(--invoice-soft, #fffafa); }
.client-panel span,.status-panel span,.invoice-totals span,.terms-box span { display:block;color:#64736f;font-size:12px;text-transform:uppercase;font-weight:900;letter-spacing:.05em; }
.client-panel strong { display:block;font-size:20px;margin:6px 0; }
.client-panel p { margin:5px 0;color:#64736f; }
.status-panel { display:grid;gap:10px; }
.status-panel div { display:flex;justify-content:space-between;gap:12px;border-bottom:1px solid #e6eeeb;padding-bottom:8px; }
.status-panel div:last-child { border-bottom:0;padding-bottom:0; }
.invoice-table { width:100%;border-collapse:separate;border-spacing:0;margin-top:14px;border:1px solid #d9e3e0;border-radius:14px;overflow:hidden; }
.invoice-document .invoice-table { border-color:var(--invoice-border, #fecaca); }
.invoice-table th { background:#10201d;color:#fff;text-align:left; }
.invoice-document .invoice-table th { background:var(--invoice-color, #7f1d1d); }
.invoice-table th,.invoice-table td { padding:13px;border-bottom:1px solid #d9e3e0; }
.invoice-table tr:last-child td { border-bottom:0; }
.invoice-table td:last-child,.invoice-table th:last-child { text-align:right; }
.document-bottom { display:grid;grid-template-columns:1fr minmax(280px,360px);gap:24px;margin-top:24px;align-items:start; }
.terms-box { border:1px dashed #b7c9c4;border-radius:14px;padding:16px;background:#fbfdfc; }
.invoice-document .terms-box { border-color:var(--invoice-border, #fecaca);background:var(--invoice-soft, #fffafa); }
.terms-box p { margin:8px 0;color:#64736f; }
.invoice-totals { display:grid;gap:8px; }
.invoice-totals div { display:flex;justify-content:space-between;border-bottom:1px solid #d9e3e0;padding:8px 0; }
.invoice-totals .grand { font-size:24px;color:var(--doc-color, var(--quote-color, #007a3f));border-bottom:3px solid var(--doc-color, var(--quote-color, #007a3f)); }
.invoice-document .invoice-totals .grand { color:var(--invoice-color, #b91c1c);border-bottom-color:var(--invoice-color, #b91c1c); }
.invoice-footer { display:flex;justify-content:space-between;gap:20px;margin-top:34px;padding-top:18px;border-top:1px solid #d9e3e0;color:#64736f; }
.invoice-footer span { min-width:160px;text-align:center;border-top:1px solid #10201d;padding-top:8px;color:#10201d; }
.template-modern {
  border: 0;
  border-radius: 30px;
  padding: 0;
  background: linear-gradient(135deg, var(--doc-color, #007a3f), #10201d);
  box-shadow: 0 28px 80px rgba(16,32,29,.22);
}
.template-modern .document-ribbon { top: 22px; right: 22px; background: rgba(255,255,255,.18); backdrop-filter: blur(8px); }
.template-modern .invoice-top {
  margin: 0;
  padding: 42px 38px 34px;
  border: 0;
  color: #fff;
}
.template-modern .invoice-brand p,
.template-modern .invoice-meta span,
.template-modern .invoice-meta small { color: rgba(255,255,255,.76); }
.template-modern .invoice-meta strong { color: #fff; }
.template-modern .invoice-logo { border-color: rgba(255,255,255,.36); }
.template-modern .document-summary,
.template-modern .invoice-table,
.template-modern .document-bottom,
.template-modern .invoice-footer {
  margin-left: 34px;
  margin-right: 34px;
}
.template-modern .invoice-table {
  width: calc(100% - 68px);
}
.template-modern .document-summary { margin-top: 30px; }
.template-modern .document-bottom { margin-bottom: 28px; }
.template-modern .invoice-table,
.template-modern .client-panel,
.template-modern .status-panel,
.template-modern .terms-box {
  background: #fff;
}
.template-modern .invoice-totals {
  color: #fff;
}
.template-modern .invoice-totals div {
  border-bottom-color: rgba(255,255,255,.26);
}
.template-modern .invoice-totals span,
.template-modern .invoice-totals strong,
.template-modern .invoice-totals .grand {
  color: #fff;
}
.template-modern .invoice-totals .grand {
  border-bottom-color: rgba(255,255,255,.70);
}
.template-modern .invoice-footer { color: rgba(255,255,255,.78); border-top-color: rgba(255,255,255,.22); }
.template-modern .invoice-footer span { color: #fff; border-top-color: rgba(255,255,255,.55); }
.template-clean {
  box-shadow: none;
  border: 1px solid #e4ebe8;
  border-radius: 0;
  padding: 42px;
}
.template-clean .document-ribbon { display: none; }
.template-clean .invoice-top { border-bottom: 1px solid #10201d; padding-bottom: 18px; }
.template-clean .invoice-logo,
.template-clean .invoice-logo-fallback,
.template-clean .client-panel,
.template-clean .status-panel,
.template-clean .terms-box,
.template-clean .invoice-table {
  border-radius: 0;
  box-shadow: none;
  background: #fff;
}
.template-clean .invoice-table th { background: #fff; color: #10201d; border-bottom: 2px solid #10201d; }
.template-clean .invoice-table { border-left: 0; border-right: 0; }
.template-clean .invoice-totals .grand { border-bottom-width: 1px; }
.template-corporate {
  border: 0;
  border-left: 18px solid var(--doc-color, var(--invoice-color, #007a3f));
  border-radius: 6px 24px 24px 6px;
  box-shadow: 0 24px 70px rgba(16,32,29,.18);
}
.template-corporate::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 92px;
  background: linear-gradient(90deg, var(--doc-soft, rgba(0,122,63,.08)), transparent);
  pointer-events: none;
}
.template-corporate .document-ribbon {
  left: auto;
  right: 26px;
  top: 24px;
  border-radius: 999px;
  background: var(--doc-color, var(--invoice-color, #007a3f));
}
.template-corporate .invoice-top {
  position: relative;
  z-index: 1;
  border-bottom: 0;
  padding-top: 34px;
  padding-bottom: 30px;
}
.template-corporate .invoice-meta {
  padding: 22px;
  border-radius: 18px;
  background: var(--doc-soft, rgba(0,122,63,.08));
}
.template-corporate .invoice-table th { background: var(--doc-color, var(--invoice-color, #007a3f)); }
.compact .document-ribbon { display:none; }
.compact .invoice-top { display:block; }
.compact .invoice-meta { text-align:left;margin-top:12px;padding-top:0; }
.compact .document-summary,.compact .document-bottom { grid-template-columns:1fr; }
.compact .invoice-table th,.compact .invoice-table td { padding:8px; }
.compact .invoice-footer { display:none; }
.log-card { box-shadow: inset 4px 0 0 var(--primary); }
.log-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.device-pill { background: #edf5f3; color: var(--ink); }
@media (max-width: 920px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px;
    text-align: left;
  }
  .topbar h1 { font-size: 23px; }
  .company-center { text-align: left; }
  .top-actions { justify-content: space-between; text-align: left; }
  .dashboard-hero { grid-template-columns: 1fr; padding: 18px; }
  .module-shortcuts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col, .builder, .settings-layout { grid-template-columns: 1fr; }
  .toolbar, .section-head { align-items: stretch; }
  .toolbar > *, .section-head > * { max-width: 100%; }
  .line-item { grid-template-columns: 1fr 76px; }
  .line-item .line-total, .line-item button { justify-self: start; }
  .list-card dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-row { grid-template-columns: 64px minmax(0, 1fr); align-items: start; }
  .client-row { grid-template-columns: 1fr; }
  .product-row .card-actions, .client-row .card-actions { justify-content: flex-start; }
  .product-row > .pill,
  .product-row > strong,
  .product-row > span { grid-column: 2; justify-self: start; min-width: 0; max-width: 100%; }
  .product-row .card-actions { grid-column: 1 / -1; width: 100%; }
  .product-row .pill { justify-self: start; }
  .flipbook { min-height: auto; }
  .book-spread { grid-template-columns: 1fr; gap: 14px; min-height: auto; }
  .book-spine { display: none; }
  .book-page, .book-page.left, .book-page.right { min-height: auto; border-radius: 18px; }
  .book-page.left::after, .book-page.right::before { display: none; }
  .catalog-item { grid-template-columns: 130px 1fr; }
  .catalog-item img, .catalog-item .product-placeholder { width: 130px; height: 130px; }
  .calendar-grid { grid-template-columns: 1fr; }
  .calendar-weekday, .empty-cell { display: none; }
  .calendar-cell { min-height: auto; }
  .document-summary, .document-bottom { grid-template-columns: 1fr; }
  .invoice-top, .invoice-footer { flex-direction: column; }
  .invoice-meta { text-align: left; }
  .invoice-table { display: block; overflow-x: auto; white-space: nowrap; }
}
@media (min-width: 921px) and (max-width: 1180px) {
  .topbar { grid-template-columns: minmax(220px, 1fr) minmax(180px, auto) minmax(220px, 1fr); }
  .app-brand img { width: 64px; height: 64px; }
  .topbar h1 { font-size: 24px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-row {
    grid-template-columns: 58px minmax(180px, 1fr) 110px 90px 80px minmax(150px, auto);
  }
  .product-row > span:nth-of-type(4) { display: none; }
  .client-row {
    grid-template-columns: minmax(160px, 1fr) 120px 120px minmax(180px, 1fr) auto;
  }
  .client-row > span:nth-of-type(4) { display: none; }
}

@media (max-width: 760px) {
  .product-row {
    grid-template-columns: 58px minmax(0, 1fr);
    overflow: hidden;
  }
  .product-row .row-main {
    grid-column: 2;
  }
  .product-row .card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .product-row .card-actions button {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
  }
  .row-main p {
    -webkit-line-clamp: 3;
  }
}
@media (max-width: 560px) {
  .auth-layout, .loading-layout { padding: 12px; align-items: start; }
  .auth-panel { padding: 18px; border-radius: 14px; }
  .brand-lockup img, .app-brand img { width: 60px; height: 60px; border-radius: 14px; }
  h1 { font-size: 26px; }
  .shell { padding: 12px 10px 28px; }
  .panel { padding: 14px; border-radius: 12px; }
  .dashboard-hero { border-radius: 16px; padding: 16px; }
  .dashboard-status-card { border-radius: 14px; }
  .module-shortcuts { grid-template-columns: 1fr; }
  .module-shortcuts button { grid-template-columns: 42px minmax(0, 1fr); }
  .nav-tabs { margin-inline: -10px; padding-inline: 10px; }
  .nav-tabs button { padding: 10px 11px; font-size: 13px; }
  .top-actions { display: grid; grid-template-columns: 1fr auto; width: 100%; }
  .stats-grid { grid-template-columns: 1fr; }
  .stats-grid article { padding: 14px; }
  .toolbar input, .toolbar select, .toolbar button,
  .section-head button, .section-actions button, .catalog-controls input, .catalog-controls button {
    width: 100%;
  }
  .section-head, .section-actions { align-items: stretch; flex-direction: column; }
  .inline-action-group { display: grid; grid-template-columns: 1fr; width: 100%; }
  .settings-actions { grid-template-columns: 1fr; }
  .qr-panel, .form-grid { grid-template-columns: 1fr; }
  .product-card { grid-template-columns: 58px 1fr; }
  .product-card img, .product-placeholder { width: 58px; height: 58px; }
  .product-row { grid-template-columns: 58px minmax(0, 1fr); gap: 10px; padding: 10px; }
  .product-row img, .product-row .product-placeholder { width: 58px; height: 58px; }
  .product-row .card-actions, .client-row .card-actions { grid-column: 1 / -1; }
  .card-actions button, .card-actions a, menu button { flex: 1 1 auto; min-width: min(100%, 128px); }
  .mini-product { grid-template-columns: 42px 1fr; }
  .mini-product button { grid-column: 1 / -1; }
  .line-item { grid-template-columns: 1fr; }
  .line-item input, .line-item button { width: 100%; }
  .quote-zone .section-head [data-save-quote],
  .invoice-zone .section-head [data-save-invoice] {
    display: none;
  }
  .flow-actions {
    position: sticky;
    bottom: 8px;
    z-index: 3;
    display: grid;
    margin: 12px 0 22px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255,255,255,.94);
    box-shadow: 0 16px 36px rgba(16,32,29,.16);
    backdrop-filter: blur(8px);
  }
  .flow-actions button {
    width: 100%;
  }
  .history-panel {
    margin-top: 20px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fbfa;
  }
  .list-card dl { grid-template-columns: 1fr; }
  .calendar-head { display: grid; grid-template-columns: 1fr; }
  .calendar-head button { width: 100%; }
  .catalog-item { grid-template-columns: 1fr; text-align: center; }
  .catalog-item img, .catalog-item .product-placeholder {
    width: 100%;
    max-width: 220px;
    height: 180px;
    justify-self: center;
  }
  .catalog-page-head { display: grid; }
  .catalog-cover-page h3 { font-size: 30px; }
  .book-spread { padding: 12px; border-radius: 18px; }
  .catalog-items { padding: 14px; }
  dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .dialog-form { padding: 16px; }
  menu { display: grid; grid-template-columns: 1fr; }
  .toast { left: 10px; right: 10px; bottom: 10px; max-width: none; }
  .invoice-preview { padding: 8px; max-height: 70dvh; }
  .invoice-sheet { padding: 18px; border-radius: 14px; }
  .invoice-brand { flex-direction: column; }
  .invoice-logo { width: 96px; height: 72px; }
  .invoice-meta strong { font-size: 26px; }
  .invoice-footer span { min-width: 0; }
  .calendar-grid { display: none; }
  .planner-mobile-agenda { display: grid; gap: 10px; }
  .flipbook { display: none; }
  .catalog-mobile-list { display: grid; gap: 12px; }
  .catalog-controls { display: grid; grid-template-columns: 1fr; }
  .catalog-mobile-card { grid-template-columns: 92px 1fr; }
  .catalog-mobile-card img,
  .catalog-mobile-card .product-placeholder {
    width: 92px;
    height: 92px;
  }
  .catalog-mobile-card h3 { font-size: 16px; }
  .catalog-mobile-meta { align-items: flex-start; }
  .invoice-zone .builder { gap: 12px; }
  .invoice-card { border-radius: 14px; }
  .log-meta { align-items: flex-start; }
  .device-pill { width: 100%; text-align: center; }
}
