:root {
  --blue: #214fb5;
  --blue-2: #173f96;
  --blue-3: #2d63c8;
  --orange: #f47a24;
  --orange-2: #dc5f16;
  --ink: #19233c;
  --muted: #72809b;
  --line: #d8e2f5;
  --soft: #f3f6fc;
  --panel: #ffffff;
  --stage: #17172a;
  --good: #4da85e;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(33, 79, 181, 0.06), transparent 28%),
    #f7f9fe;
}

button,
select,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-header {
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
  color: white;
  background: linear-gradient(90deg, var(--blue-2), var(--blue));
  box-shadow: 0 4px 18px rgba(19, 47, 113, 0.28);
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 20px;
  background: var(--orange);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.brand h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  margin: 5px 0 0;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.72);
}

.header-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.header-pills span,
.header-pills strong,
.header-button {
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 13px;
  color: white;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.header-pills strong {
  background: var(--orange);
  border-color: transparent;
}

.header-pills .validity-badge {
  background: #ffffff;
  color: var(--blue);
  border-color: rgba(255, 255, 255, 0.72);
}

.header-button {
  color: white;
  background: rgba(255, 255, 255, 0.12);
}

.studio-shell {
  display: grid;
  grid-template-columns: 356px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.side-panel,
.workspace {
  min-width: 0;
}

.side-panel {
  display: grid;
  gap: 16px;
  align-content: start;
}

.panel-block,
.editor-card,
.preview-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(28, 71, 150, 0.08);
  overflow: hidden;
}

.panel-block h2 {
  margin: 0;
  padding: 13px 16px;
  color: white;
  background: var(--blue);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: 152px;
  margin: 16px;
  padding: 18px;
  text-align: center;
  border: 2px dashed #cbd8ee;
  border-radius: 8px;
  background: #f7f9ff;
  color: var(--ink);
}

.upload-box.dragging {
  border-color: var(--orange);
  background: #fff7f0;
}

.upload-box input {
  display: none;
}

.upload-icon {
  font-size: 28px;
}

.upload-box strong {
  margin-top: 8px;
  font-size: 16px;
}

.upload-box small {
  max-width: 245px;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
}

.photo-list {
  display: grid;
  gap: 10px;
  padding: 0 16px 14px;
}

.photo-item {
  display: grid;
  grid-template-columns: 54px 1fr 34px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #d6e0f2;
  border-radius: 8px;
  background: #f7f9ff;
}

.photo-item.active {
  border: 2px solid var(--blue);
  background: #f2f6ff;
}

.photo-item img {
  width: 54px;
  height: 62px;
  object-fit: cover;
  border-radius: 6px;
}

.photo-item strong {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-item small {
  color: var(--muted);
  font-weight: 700;
}

.remove-photo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: #db3a42;
  background: white;
  border: 1px solid #dce5f6;
  font-size: 18px;
}

.add-more {
  width: calc(100% - 32px);
  min-height: 42px;
  margin: 0 16px 14px;
  border-radius: 8px;
  border: 1px dashed var(--blue);
  color: var(--blue);
  background: #f4f8ff;
  font-weight: 900;
}

.copies-control {
  display: grid;
  grid-template-columns: 132px 1fr;
  align-items: center;
  gap: 10px;
  margin: 0 16px 16px;
}

.copies-control strong {
  color: #6d7893;
  line-height: 1.35;
}

.copies-control input {
  width: 100%;
  height: 36px;
  border-radius: 8px;
  border: 1px solid #cbd8ee;
  color: var(--ink);
  background: white;
  font-weight: 900;
  padding: 0 10px;
}

.spec-card {
  margin: 0 16px 16px;
  padding: 14px;
  border: 1px solid #cbd9f3;
  border-radius: 8px;
  background: #eef4ff;
}

.spec-card strong {
  display: block;
  color: var(--blue);
  margin-bottom: 10px;
}

.spec-card dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 14px;
  margin: 0;
}

.spec-card div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.spec-card dt {
  color: var(--muted);
  font-weight: 700;
}

.spec-card dd {
  margin: 0;
  color: var(--blue);
  font-weight: 900;
}

.quantity-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px 16px;
}

.quick-quantity-panel {
  display: grid;
  gap: 8px;
  margin: 14px 16px 0;
}

.section-label {
  color: var(--muted);
  font-weight: 900;
}

.quantity-grid.compact {
  grid-template-columns: 1fr 1fr;
  padding: 0;
}

.quantity-card {
  position: relative;
  min-height: 118px;
  padding: 14px 8px;
  border-radius: 8px;
  border: 2px solid #d6e0f2;
  color: var(--ink);
  background: white;
  text-align: center;
}

.quantity-card.active {
  color: white;
  border-color: var(--blue);
  background: linear-gradient(180deg, var(--blue-3), var(--blue));
  box-shadow: 0 10px 18px rgba(33, 79, 181, 0.23);
}

.quantity-card b {
  display: block;
  font-size: 26px;
}

.quantity-card span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 800;
  color: currentColor;
  opacity: 0.72;
}

.quantity-card strong {
  display: block;
  margin-top: 9px;
  color: var(--orange);
  font-size: 18px;
}

.quantity-card.active strong {
  color: #ffd2a8;
}

.quantity-grid.compact .quantity-card {
  min-height: 92px;
  padding: 12px 6px;
}

.quantity-grid.compact .quantity-card b {
  font-size: 24px;
}

.quantity-grid.compact .quantity-card strong {
  margin-top: 6px;
  font-size: 14px;
}

.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  padding: 3px 8px;
  border-radius: 0 7px 0 8px;
  color: white;
  background: var(--orange);
  font-size: 10px;
  font-weight: 900;
}

.hint {
  margin: 0 16px 16px;
  padding: 10px 12px;
  border: 1px solid #f4d6bd;
  border-radius: 8px;
  color: #c86d1f;
  background: #fff6ed;
  font-size: 13px;
  font-weight: 800;
}

.pricing-table {
  display: grid;
  gap: 8px;
  padding: 14px 16px 0;
}

.pricing-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #d6e0f2;
  border-radius: 8px;
  background: #f7f9ff;
}

.pricing-row strong {
  color: var(--blue);
}

.pricing-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.controls-block {
  padding-bottom: 16px;
}

.controls-block label {
  display: grid;
  gap: 6px;
  margin: 14px 16px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.controls-block select {
  width: 100%;
  height: 42px;
  border: 1px solid #d6e0f2;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: white;
}

.toggle-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--ink) !important;
}

.toggle-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--blue);
}

.primary-action {
  width: calc(100% - 32px);
  margin: 16px 16px 0;
  min-height: 56px;
  border-radius: 8px;
  color: white;
  background: linear-gradient(180deg, var(--orange), var(--orange-2));
  box-shadow: 0 12px 22px rgba(244, 122, 36, 0.25);
  font-weight: 900;
  font-size: 16px;
}

.workspace {
  display: grid;
  gap: 16px;
  align-content: start;
}

.tool-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #f3f6fc;
  border: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
}

.tab-button,
.toolbar button,
.download-actions button {
  min-height: 38px;
  padding: 0 15px;
  border-radius: 8px;
  color: #60708f;
  background: #f7f9ff;
  border: 1px solid #dce5f6;
  font-weight: 900;
}

.tab-button.active {
  color: white;
  background: var(--blue);
  border-color: var(--blue);
}

.toolbar button.active {
  color: white;
  background: var(--blue);
  border-color: var(--blue);
}

.editor-card {
  margin-top: -16px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.stage-wrap {
  position: relative;
  margin: 18px;
  min-height: 470px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--stage);
}

#editorCanvas {
  width: 100%;
  height: 470px;
  display: block;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
  color: rgba(255, 255, 255, 0.42);
  font-weight: 900;
}

.empty-state span {
  font-size: 30px;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 18px;
}

.toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  color: #5c6c89;
  background: #f7f9ff;
  border: 1px solid #dce5f6;
  font-weight: 900;
}

.toolbar input[type="range"] {
  width: 132px;
  accent-color: var(--blue);
}

.toolbar input[type="color"] {
  width: 38px;
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
}

.eraser-status {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px;
  color: #5f6f8e;
  background: #eef4ff;
  border: 1px solid #dce5f6;
  font-size: 12px;
  font-weight: 900;
}

.eraser-status[data-tone="success"] {
  color: #287342;
  background: #ecf8ef;
  border-color: #bce5c6;
}

.eraser-status[data-tone="warn"] {
  color: #b05d16;
  background: #fff6ed;
  border-color: #f4d6bd;
}

.swatches {
  display: flex;
  gap: 6px;
}

.swatches button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--swatch);
  border: 2px solid #d4def0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.hidden {
  display: none !important;
}

.preview-card {
  padding: 14px 16px 18px;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.preview-header h2 {
  margin: 0;
  font-size: 15px;
  color: #5f6f8e;
}

.preview-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.download-actions {
  display: flex;
  gap: 8px;
}

.download-actions button:last-child {
  color: white;
  background: #9cb2e0;
}

.download-actions button:not(:disabled):last-child {
  background: var(--blue);
}

.sheet-scroller {
  max-height: 74vh;
  overflow: auto;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid #dfe7f5;
  background: #ecf2fb;
}

.layout-pages {
  display: grid;
  gap: 18px;
}

.layout-page {
  display: grid;
  gap: 8px;
}

.layout-page-label {
  color: #5f6f8e;
  font-size: 12px;
  font-weight: 900;
}

.layout-page canvas,
#layoutCanvas {
  display: block;
  width: min(100%, 980px);
  height: auto;
  margin: 0 auto;
  background: white;
  box-shadow: 0 8px 20px rgba(27, 44, 82, 0.14);
}

.black-white-output #layoutPages canvas,
.black-white-output #editorCanvas {
  filter: grayscale(1);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 25, 50, 0.52);
}

.modal-card {
  position: relative;
  width: min(460px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 22px;
  border-radius: 10px;
  background: white;
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(9, 24, 62, 0.32);
}

.admin-card {
  width: min(620px, 100%);
}

.pricing-modal-card {
  width: min(720px, 100%);
}

.modal-card h2 {
  margin: 0 0 8px;
}

.modal-card p {
  color: var(--muted);
  font-weight: 700;
}

.modal-card label,
.admin-price-fields label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.modal-card input,
.modal-card select {
  height: 42px;
  border: 1px solid #d6e0f2;
  border-radius: 8px;
  padding: 0 12px;
  background: white;
}

.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.password-field input {
  width: 100%;
}

.password-field button,
.upload-report {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid #d6e0f2;
  color: var(--blue);
  background: #f7f9ff;
  font-weight: 900;
}

.password-field button {
  padding: 0 12px;
}

.help-contact {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #d6e0f2;
  border-radius: 8px;
  background: #f7f9ff;
}

.help-contact span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.help-contact strong {
  color: var(--blue);
  font-size: 22px;
}

.help-contact .primary-action {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  text-decoration: none;
}

.payment-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
}

.payment-card {
  padding: 12px;
  border: 1px solid #d6e0f2;
  border-radius: 8px;
  background: #f7f9ff;
}

.payment-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.payment-card strong {
  display: block;
  margin-top: 4px;
  color: var(--blue);
  font-size: 20px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: #db3a42;
  background: #f7f9ff;
  border: 1px solid #dce5f6;
  font-size: 20px;
}

.modal-note {
  margin-bottom: 0;
  font-size: 12px;
}

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

.admin-user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.admin-user-form button,
.user-action {
  min-height: 42px;
  border-radius: 8px;
  color: white;
  background: var(--blue);
  font-weight: 900;
}

.admin-user-form:has(#adminNewPassword) {
  grid-template-columns: minmax(0, 1fr) auto;
}

.admin-user-form:has(#adminSupportPhone) {
  grid-template-columns: minmax(0, 1fr) auto;
}

.admin-user-form.payment-settings-form {
  grid-template-columns: 1fr 1fr auto;
}

.admin-user-form:has(#newUserPlan) {
  grid-template-columns: 1fr 1fr;
}

.admin-user-form:has(#newUserPlan) button#addUserBtn {
  grid-column: 1 / -1;
}

.admin-user-form.report-actions {
  grid-template-columns: 1fr 1fr;
}

.upload-report {
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer;
}

.admin-user-form .upload-report {
  margin-top: 0;
  color: var(--blue);
  font-size: 13px;
}

.upload-report input {
  display: none;
}

.admin-user-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.admin-user-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid #d6e0f2;
  border-radius: 8px;
  background: #f7f9ff;
}

.admin-user-row small {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.price-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px 14px;
}

.price-editor label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.price-editor input,
.price-editor select {
  height: 34px;
  border: 1px solid #d6e0f2;
  border-radius: 8px;
  padding: 0 8px;
}

.admin-pricing-summary {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.access-locked .studio-shell {
  filter: grayscale(0.2);
  pointer-events: none;
  opacity: 0.58;
}

@media (max-width: 1020px) {
  .app-header {
    height: auto;
    padding: 16px;
    align-items: flex-start;
    gap: 14px;
  }

  .studio-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: 1fr 1fr;
  }

  .controls-block {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .app-header {
    display: grid;
  }

  .brand h1 {
    font-size: 23px;
  }

  .studio-shell {
    padding: 10px;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .quantity-grid {
    grid-template-columns: 1fr 1fr;
  }

  .preview-header {
    align-items: stretch;
    flex-direction: column;
  }

  .download-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .stage-wrap {
    min-height: 360px;
    margin: 12px;
  }

  #editorCanvas {
    height: 360px;
  }
}
