.portal {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  background: #f5f6f4;
}
.portal-header, .portal-footer {
  background: var(--paper);
  color: var(--ink);
  border-block-end: 1px solid var(--line);
}
.portal-bar, .portal-footer .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-block: 16px;
}
.portal-nav { display: flex; align-items: center; gap: clamp(12px, 3vw, 32px); }
.portal-nav a, .portal-nav button, .portal-footer a, .portal-back {
  color: var(--ink);
  font: inherit;
  font-size: .94rem;
  font-weight: 700;
  text-decoration: none;
}
.portal-nav button { padding: 5px 0; border: 0; background: transparent; cursor: pointer; }
.portal-nav a:hover, .portal-nav button:hover, .portal-footer a:hover, .portal-back:hover { text-decoration: underline; }
.portal-footer { margin-top: auto; border: 0; border-top: 1px solid var(--line); }
.portal-footer .wrap { padding-block: 22px; color: var(--muted); font-size: .9rem; }
.portal-main { flex: 1; padding-block: clamp(32px, 5vw, 68px) clamp(50px, 8vw, 100px); }
.portal h1 { font-size: clamp(2rem, 4vw, 3.1rem); letter-spacing: -.025em; line-height: 1.08; }
.portal h2 { font-size: clamp(1.3rem, 1.8vw, 1.55rem); line-height: 1.16; }
.portal h3 { font-size: 1.25rem; }
.portal-messages { margin: 0 auto 22px; }
.portal-messages p { margin: 0 0 6px; padding: 12px 16px; background: #fff; border: 1px solid var(--line); border-inline-start: 4px solid var(--lift); border-radius: 3px; }
.portal-messages .error { border-inline-start-color: #a43125; }
.portal-titlebar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 30px; }
.shop-name { margin-top: 10px; color: var(--text); overflow-wrap: anywhere; }
.shop-name span { margin-inline: .25em; }
.shop-name a { font-size: .95rem; font-weight: 650; }
.catalog-layout { display: grid; align-items: start; grid-template-columns: minmax(0, 1fr) minmax(250px, 29%); gap: clamp(16px, 2.1vw, 28px); }
.catalog-panel, .catalog-feed, .portal-card { min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.catalog-panel-head { display: flex; align-items: baseline; justify-content: space-between; padding: 22px 24px; gap: 14px; border-bottom: 1px solid var(--line); }
.catalog-panel-head > span { color: var(--muted); font-size: .92rem; }
.product-table { width: 100%; border-collapse: collapse; text-align: left; font-size: .97rem; }
.product-table th, .product-table td { padding: 15px 10px; overflow-wrap: anywhere; }
.product-table th:first-child { padding-inline-start: 24px; }
.product-table td:last-child { padding-inline-end: 24px; }
.product-table thead th { color: var(--muted); background: #f8f9f7; font-size: .83rem; font-weight: 700; }
.product-table tbody tr + tr { border-top: 1px solid var(--line); }
.product-table tbody th { max-width: 250px; font-weight: 750; }
.product-table tbody td { color: var(--text); }
.product-table .price { white-space: nowrap; }
.product-table .row-actions { text-align: right; }
.row-actions .product-trash { padding: 8px; vertical-align: middle; line-height: 0; }
.product-trash svg { width: 18px; height: 18px; }
.row-actions a { display: inline-block; padding-block: 5px; margin-inline-start: 8px; font-size: .88rem; font-weight: 650; }
.product-brand { display: block; margin-top: 2px; color: var(--muted); font-size: .88rem; font-weight: 500; }
.catalog-empty { padding: clamp(30px, 4vw, 60px) 22px; text-align: center; }
.catalog-empty svg { margin: 0 auto 14px; color: var(--ink); }
.catalog-empty > p { max-width: 33ch; margin: 8px auto 14px; color: var(--muted); font-size: 1rem; }
.catalog-feed { padding: clamp(18px, 2vw, 28px); border-top: 3px solid var(--lift); }
.feed-status { display: inline-flex; gap: 7px; align-items: center; margin: 16px 0 8px; color: var(--ink); font-size: .94rem; font-weight: 750; }
.feed-status span { width: 9px; height: 9px; background: var(--lift); border: 1px solid #a37a00; border-radius: 50%; }
.feed-help, .feed-time, .copy-result { color: var(--muted); font-size: .91rem; line-height: 1.5; }
.feed-time time { display: block; }
.feed-address { margin-block: 18px; }
.feed-address label, .portal-field label { display: block; margin-bottom: 6px; color: var(--ink); font-size: .97rem; font-weight: 700; }
.feed-address input, .portal-field :is(input:not([type=checkbox]):not([type=file]), textarea, select) {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 10px 12px;
  border: 1px solid #a1abad;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}
.feed-address input { height: 38px; padding: 7px 9px; background: #f8f9f7; font-family: ui-monospace, monospace; font-size: .83rem; }
.feed-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 8px; }
.feed-tools button, .feed-tools a { color: var(--ink); font: inherit; font-weight: 700; font-size: .9rem; text-underline-offset: .18em; }
.feed-tools button { padding: 4px 0; background: transparent; border: 0; cursor: pointer; text-decoration: underline; }
.feed-publish { margin-top: 20px; }
.portal .portal-outline { background: #fff; border: 1px solid var(--ink); }
.portal .portal-outline:hover { background: #f0f2ee; }
.portal .portal-dark { background: var(--ink); color: #fff; }
.portal .portal-dark:hover { background: #36424a; }
.portal-card { padding: clamp(22px, 3.6vw, 42px); }
.setup-card { max-width: 640px; }
.setup-card p, .account-box .portal-card > p { margin-top: 12px; color: var(--text); }
.setup-card .button, .account-next { display: inline-flex; margin-top: 20px; }
.portal-editor { width: 100%; max-width: 740px; margin-inline: auto; }
.portal-back { display: inline-flex; margin-bottom: 18px; }
.portal-editor .page-intro { margin: 12px 0 24px; color: var(--muted); }
.account-box { width: 100%; max-width: 500px; margin-inline: auto; }
.account-box h1 { font-size: clamp(1.85rem, 3vw, 2.55rem); }
.account-box .portal-form { margin-top: 24px; }
.portal-field { min-width: 0; margin-bottom: 20px; }
.portal-form fieldset { margin: 0 0 24px; min-width: 0; padding: 0; border: 0; }
.portal-form fieldset legend { padding: 0; margin-bottom: 18px; color: var(--ink); font-size: 1.23rem; font-weight: 800; }
.portal-form .fieldset-help { color: var(--muted); font-size: .95rem; margin: 0 0 16px; }
.product-form-pair { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; }
.variant-fields { padding: 15px 0; border-block: 1px solid var(--line); }
.variant-fields summary { color: var(--ink); cursor: pointer; font-weight: 750; }
.variant-fields summary span { font-size: .87rem; color: var(--muted); font-weight: 400; }
.variant-fields[open] summary { margin-bottom: 15px; }
.portal-field textarea { min-height: 110px; resize: vertical; }
.portal-field input[type=file] { display: block; max-width: 100%; margin-block: 8px; font: inherit; font-size: .94rem; }
.portal-field input[type=checkbox] + label { display: inline; font-size: .88rem; }
.portal-field a { overflow-wrap: anywhere; }
.field-hint { margin-top: 6px; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.field-hint ul, .portal-form .errorlist { padding-left: 1.2em; }
.portal-form-errors, .portal-form .errorlist { margin-block: 7px 14px; color: #963421; font-size: .93rem; }
.portal-field [aria-invalid=true] { border-color: #963421 !important; }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 20px; margin-top: 22px; }
.form-actions a, .account-switch a { font-weight: 700; }
.account-box .portal-card .account-switch { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); font-size: .95rem; }
.mobile-label { display: none; }
.portal-sr { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 890px) {
  .catalog-layout { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .product-form-pair { grid-template-columns: 1fr; }
  .portal-bar { gap: 8px; flex-wrap: wrap; }
  .portal-nav { gap: 12px; }
  .portal-nav a, .portal-nav button { font-size: .85rem; }
  .portal-titlebar { align-items: start; flex-direction: column; gap: 14px; margin-bottom: 24px; }
  .product-table, .product-table tbody, .product-table :is(tr, td, th) { display: block; }
  .product-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .product-table tbody tr { padding: 16px 20px; }
  .product-table tbody :is(td, th):nth-child(n) { max-width: none; padding: 2px 0; text-align: left; }
  .product-table tbody .row-actions { margin-top: 6px; }
  .product-table .mobile-label { display: inline-block; color: var(--muted); font-size: .9rem; min-width: 95px; }
  .row-actions a { margin-inline: 0 18px; }
}
@media (max-width: 370px) {
  .portal-header .brand { font-size: 1.07rem; }
  .portal-header .brand-ai { width: 24px; }
}

.product-identity { display: flex; align-items: center; gap: 12px; }
.product-identity img { width: 52px; height: 52px; flex: none; object-fit: cover; border-radius: 5px; background: var(--concrete); }
.product-identity > div { min-width: 0; }
.product-page-link { display: block; width: fit-content; margin-top: 3px; color: var(--muted); font-size: .85rem; font-weight: 500; }
.catalog-export-help { margin-top: 14px; }
.catalog-store { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.catalog-store .feed-help { margin-top: 8px; }
.store-address { margin-top: 8px; font-size: .9rem; font-weight: 700; overflow-wrap: anywhere; }
.catalog-image-preview { display: block; width: 190px; height: 138px; object-fit: contain; background: var(--concrete); border-radius: 5px; margin-bottom: 18px; }
.product-dialog { width: min(44rem, calc(100% - 24px)); max-height: 90vh; max-height: 90dvh; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.product-dialog::backdrop { background: rgb(28 37 43 / 58%); }
.product-dialog .portal-card { padding: 22px clamp(16px, 4vw, 30px); border: 0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px clamp(16px, 4vw, 30px); border-bottom: 1px solid var(--line); }
.dialog-head button { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--ink); font-family: inherit; font-size: 1.15rem; cursor: pointer; }
.dialog-head button:hover { background: var(--concrete); border-radius: 4px; }
@media (max-width: 620px) {
  .product-identity { margin-bottom: 8px; }
}

/* Billing: activation code, plan choice and saved card */
.code-panel { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.code-panel h2 { font-size: 1.25rem; }
.code-panel p { margin-top: 10px; color: var(--text); }
.code-panel .button { display: inline-flex; margin-top: 16px; }
.code-value {
  display: inline-block;
  margin-top: 14px !important;
  padding: 10px 16px;
  border: 2px dashed var(--ink);
  border-radius: 6px;
  background: #fffbea;
  color: var(--ink) !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: .04em;
}
.plan-choice { margin-top: 6px !important; }
.plan-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.plan-option:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: #fffdf3; }
.plan-option input { margin-top: 4px; accent-color: var(--ink); }
.plan-option span { display: grid; gap: 2px; color: var(--muted); font-size: .92rem; }
.plan-option strong { color: var(--ink); font-size: 1.05rem; }
.card-on-file { margin: 14px 0 12px; color: var(--text); font-size: .95rem; }
.agree-field { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
.agree-field input { flex: 0 0 auto; margin-top: 4px; width: 18px; height: 18px; accent-color: var(--ink); }
.agree-field label { font-size: .93rem !important; font-weight: 400; line-height: 1.45; }
.plan-warning { padding: 10px 14px; border-inline-start: 4px solid #a43125; background: #fff4f2; }
.portal-card .form-actions + .form-actions { margin-top: 12px; }
.test-mode-note { max-width: 500px; margin: 0 auto 16px; padding: 8px 12px; border: 1px dashed #b07d00; border-radius: 4px; background: #fff8dc; color: #5c4400; font-size: .88rem; }
