/* Visual layer shared by web and Capacitor. All existing controls stay available. */
:root {
  --ink: #172523;
  --muted: #60706d;
  --paper: #f5f7f8;
  --surface-2: #edf5f1;
  --line: #dce3e2;
  --green: #087762;
  --green-dark: #075847;
  --blue: #2d65a6;
  --radius: 8px;
  --ui-nav-height: 68px;
  --ui-safe-top: env(safe-area-inset-top, 0px);
  --ui-safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { background: #fff; scroll-padding-top: calc(88px + var(--ui-safe-top)); }
body {
  padding-top: 0;
  min-height: 100svh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
button, a { overflow-wrap: anywhere; }
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid #2d65a6;
  outline-offset: 3px;
}
button {
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease,
    box-shadow 140ms ease, transform 100ms ease;
}
button:not(:disabled):active { transform: translateY(1px); }
button:disabled { opacity: 0.5; }

.app-shell {
  padding-top: var(--ui-safe-top);
  background: #fff;
  backdrop-filter: none;
  box-shadow: 0 2px 8px #17252304;
}
.topbar { min-height: 72px; gap: 16px; }
.brand { gap: 10px; min-width: 180px; }
.brand-mark { width: 40px; height: 40px; }
.brand strong { font-size: 17px; font-weight: 750; line-height: 1.3; }
.brand small { margin-top: 2px; font-size: 11px; font-weight: 500; }
.topbar-actions { gap: 12px; }
.nav-actions { border: 0; padding: 0; gap: 4px; }
.ui-decorated { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.ui-icon { display: inline-block; width: 20px; height: 20px; flex: 0 0 20px; pointer-events: none; }
.nav-tab { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-size: 13px; font-weight: 650; padding: 0 12px; min-height: 44px; }
.nav-tab.active { background: #e7f3ee; color: var(--green-dark); }
.nav-tab b, .nav-tab.active b { background: var(--red); color: #fff; }
.nav-tab b { margin-inline-start: 0; }
.language-switch { padding: 3px; background: #f5f7f8; border-color: #e6ebea; }
.language-button { font-size: 13px; min-height: 38px; padding-inline: 10px; font-weight: 700; }
.language-button.active { background: white; box-shadow: 0 1px 4px #17252312; }
.session-box { border: 0; background: transparent; min-height: 44px; padding: 0; font-weight: 600; }

.workspace { margin-top: 24px; }
.screen-header { gap: 16px; margin-bottom: 18px; }
.screen-header h1, .account-page > h1, .legal-page > h1 { margin-top: 4px; margin-bottom: 0; font-size: 28px; line-height: 1.25; font-weight: 750; overflow-wrap: anywhere; }
.section-kicker { font-size: 11px; font-weight: 650; color: var(--muted); }
.form-panel h2, .admin-panel h2 { font-size: 19px; font-weight: 700; line-height: 1.35; }
.form-panel, .cart-panel, .store-rail, .catalog-area { box-shadow: none; }
.form-panel, .store-rail, .admin-panel { background: transparent; border: 0; border-radius: 0; padding: 0; }
.auth-hub { max-width: 620px; margin-top: 24px; gap: 24px; }
.account-page .auth-hub { margin-inline: 0; }
.account-page .form-panel { margin-block: 0; }
.account-page { max-width: 880px; }
.account-page > h1 { margin-bottom: 20px; }
.auth-mode-switch { background: #e9efed; border: 0; padding: 4px; gap: 4px; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.auth-mode-switch button { min-height: 46px; font-size: 14px; line-height: 1.25; font-weight: 650; }
.auth-mode-switch button.active { color: var(--green-dark); background: #fff; box-shadow: 0 1px 5px #17252314; }
.auth-mode-switch.catalog-tabs { max-width: 460px; margin-bottom: 18px; }
.catalog-tabs button { flex-direction: row; }
.catalog-filters { gap: 14px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.catalog-filters > label { font-size: 12px; font-weight: 600; gap: 6px; }
.catalog-filters input::placeholder { color: #7a8783; font-weight: 400; }
#catalog-count { font-size: 13px; font-weight: 600; color: var(--muted); margin-block: 16px; }
.catalog-results { min-width: 0; }
.catalog-results .product-grid { padding: 0; }
#catalog-grid[aria-busy="true"] { min-height: 160px; }
#catalog-grid[aria-busy="true"] > p { color: var(--muted); padding-block: 20px; }
.catalog-layout { gap: 24px; }

label { gap: 7px; font-size: 13px; font-weight: 600; }
input, select, textarea { border-color: #d6dfdc; border-radius: 8px; background: #fff; min-height: 46px; padding: 10px 12px; font-size: 16px; line-height: 1.45; font-weight: 400; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px #08776212; }
input::placeholder, textarea::placeholder { color: #788580; opacity: 1; }
input[type="file"] { min-height: 48px; font-size: 13px; padding: 7px; }
input[type="file"]::file-selector-button { border: 0; border-radius: 5px; padding: 8px 10px; background: #edf2f0; color: var(--ink); font: inherit; margin-inline-end: 10px; }
input[type="checkbox"], input[type="radio"] { min-height: 20px; accent-color: var(--green); }
.primary-action, .secondary-action, .ghost-button, .danger-button, .success-button, .icon-button { min-height: 46px; font-size: 14px; font-weight: 650; line-height: 1.3; padding: 10px 15px; }
.primary-action { box-shadow: 0 2px 4px #07584716; }
.secondary-action { border-color: var(--line); }
.ghost-button { background: #edf5f1; }
.compact { min-height: 38px; padding: 7px 10px; font-size: 13px; }
.icon-button { width: 44px; height: 44px; padding: 0; }
#close-invoice.ui-decorated, #close-registry.ui-decorated { font-size: 0; }
.form-panel > .primary-action, .auth-panel > .primary-action { width: 100%; }
.notice { font-size: 13px; font-weight: 500; line-height: 1.6; background: #fff7e1; border-color: #eddcb0; }
.status-message { font-size: 13px; font-weight: 600; }
.consent-field { font-size: 13px; }
.field-requirement { font-weight: 400; }
.account-section { padding-block: 22px; }
.account-section h2 { margin-block: 0 14px; font-size: 19px; }
.danger-zone { padding-inline-start: 16px; }

.product-card, .store-card-static, .order-card, .admin-card, .merchant-product-card, .stat-card, .account-card { box-shadow: 0 2px 6px #17252304; border-color: #e0e6e4; }
.product-card { padding: 14px; gap: 14px; min-height: 0; }
.product-image { height: 200px; object-fit: contain; background: #f6f8f7; }
.product-card h3 { font-size: 17px; line-height: 1.35; }
.product-card p { min-height: 0; line-height: 1.6; }
.product-foot { border-top: 1px solid #edf0ef; padding-top: 12px; }
.price { color: #174e42; font-size: 19px; font-weight: 750; }
.product-foot > div > span { color: var(--muted); font-size: 12px; }
.store-cover-image { height: 150px; }
.store-logo { width: 46px; height: 46px; inset-inline-start: 14px; bottom: 12px; }
.store-card-static > div:last-child { padding: 16px; gap: 10px; }
.store-card-static > div:last-child > strong { font-size: 18px; }
.store-card-static > div:last-child > .pill { justify-self: start; }
.pill { font-weight: 600; }
.map-link { border: 0; border-radius: 5px; min-height: 36px; padding-inline: 9px; font-weight: 600; }
.map-link .ui-icon, .shop-phone-link .ui-icon { width: 16px; height: 16px; flex-basis: 16px; }
.shop-phone-link { font-size: 14px; gap: 6px; justify-content: flex-start; }
.store-meta-row { flex-wrap: wrap; justify-content: flex-start; gap: 6px; font-size: 12px; color: var(--muted); }
.cart-panel { border: 1px solid var(--line); background: #fff; padding: 18px; }
.cart-line { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 12px 0; }
.cart-line > div:first-child { display: grid; gap: 3px; }
.qty-controls { grid-template-columns: 44px 44px 44px; justify-content: start; }
.qty-controls button { width: 44px; height: 44px; font-size: 20px; background: #fff; }
.qty-controls strong { font-size: 14px; }
.cart-header h3 { font-size: 18px; }
.cart-total { margin-bottom: 14px; }
.order-card { padding: 18px; gap: 16px; }
.order-head strong { font-size: 15px; }
.order-contact, .order-items { border: 0; border-radius: 0; background: #f6f8f7; padding: 12px; }
.order-foot { border-top: 1px solid #edf0ef; padding-top: 14px; }
.order-foot .secondary-action { background: #f1f6f3; border-color: transparent; }
.shop-hero { isolation: isolate; }
.stat-card { padding: 16px; border-top: 3px solid #087762; }
.stat-card:nth-child(2) { border-top-color: #3b77b6; }
.stat-card:nth-child(3) { border-top-color: #cb9529; }
.stat-card:nth-child(4) { border-top-color: #6d7c79; }
.stat-card span { font-weight: 500; }
.stat-card strong { font-weight: 750; font-size: 26px; }
.stats-grid { margin-bottom: 24px; }
.empty-state { background: transparent; border: 0; padding: 32px 16px; }
.empty-state strong { font-size: 17px; }
.empty-state span { font-size: 13px; }
.toast { font-size: 14px; font-weight: 600; line-height: 1.5; box-shadow: 0 4px 18px #17252326; }
.legal-footer { background: transparent; border-color: #e3e8e7; gap: 12px 20px; padding-bottom: 24px; font-size: 12px; }
[dir="rtl"] .ui-icon-arrow-right, [dir="rtl"] .ui-icon-log-in, [dir="rtl"] .ui-icon-log-out { transform: scaleX(-1); }

@media (hover: hover) {
  .primary-action:hover:not(:disabled) { background: #05624f; box-shadow: 0 3px 8px #07584720; }
  .secondary-action:hover:not(:disabled), .nav-tab:not(.active):hover { background: #f1f5f3; }
  .ghost-button:hover:not(:disabled) { background: #e0eee7; }
}

@media (max-width: 1080px) and (min-width: 821px) {
  .topbar { flex-wrap: wrap; padding-block: 12px; }
  .topbar-actions { flex-wrap: wrap; }
}

@media (max-width: 820px) {
  .topbar { min-height: 64px; padding-block: 8px; }
  .brand { min-width: 0; }
  .topbar-actions { gap: 8px; }
  .brand small { display: none; }
  .nav-actions {
    height: calc(var(--ui-nav-height) + var(--ui-safe-bottom));
    min-height: 0;
    padding: 5px max(8px, env(safe-area-inset-right)) calc(5px + var(--ui-safe-bottom)) max(8px, env(safe-area-inset-left));
    align-items: stretch;
    overflow: visible;
    background: #fffffff5;
    box-shadow: 0 -2px 12px #17252307;
    border-top: 1px solid #e5eae8;
    backdrop-filter: blur(12px);
  }
  .nav-tab {
    position: relative;
    flex: 1 1 0;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    min-height: 56px;
    padding: 5px 2px;
    font-size: 11px;
    line-height: 1.2;
    font-weight: 600;
    background: transparent;
    border-radius: 6px;
  }
  .nav-tab.active { background: transparent; color: var(--green); }
  .nav-tab .ui-icon { width: 24px; height: 24px; flex: 0 0 24px; position: relative; z-index: 1; }
  .nav-tab::before { content: ""; position: absolute; top: 3px; width: 48px; height: 32px; border-radius: 7px; background: transparent; transition: background-color 140ms ease; }
  .nav-tab.active::before { background: #e6f3ed; }
  .nav-tab b { position: absolute; top: 0; inset-inline-end: max(4px, calc(50% - 30px)); min-width: 17px; height: 17px; font-size: 10px; padding-inline: 4px; border: 2px solid white; z-index: 2; line-height: 1; }
  .nav-tab span { white-space: normal; }
  body { padding-bottom: calc(var(--ui-nav-height) + var(--ui-safe-bottom)); }
  .toast { bottom: calc(var(--ui-nav-height) + var(--ui-safe-bottom) + 12px); }
  .screen-header { gap: 12px; }
  .screen-header h1, .account-page > h1, .legal-page > h1 { font-size: 26px; }
  .screen-header .toolbar-row { flex-direction: row; flex-wrap: wrap; gap: 10px; }
  .screen-header .toolbar-row > select { flex: 1 1 150px; width: auto; }
  .screen-header .toolbar-row > button { flex: 1 1 180px; }
  .catalog-layout { gap: 24px; }
  .catalog-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .catalog-filters > label:first-child { grid-column: 1 / -1; }
  .catalog-filters > .catalog-filter-wide { grid-column: auto; }
  .catalog-filters > label:has(#market-filter) { grid-column: 1 / -1; }
  .catalog-filters label { font-size: 12px; }
  .auth-mode-switch:not(.catalog-tabs) button { flex-direction: column; min-height: 64px; padding: 7px 5px; font-size: 12px; gap: 5px; }
  .auth-mode-switch:not(.catalog-tabs) .ui-icon { width: 20px; height: 20px; flex-basis: 20px; }
  .auth-mode-switch { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
  .account-page .auth-hub { margin-top: 0; }
  .product-foot { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px; }
  .product-foot .primary-action { flex: 0 1 auto; }
  .product-image { height: 190px; }
  .order-actions { justify-content: flex-start; }
  .order-actions > button { flex: 1 1 150px; }
  .order-foot { gap: 14px; }
  .order-foot > button { width: 100%; }
  .account-grid { grid-template-columns: 1fr; }
  .legal-footer { gap: 10px 18px; }
}

@media (max-width: 560px) {
  .workspace, .topbar, .hero-content { width: calc(100% - 32px); }
  .workspace { margin-top: 20px; margin-bottom: 32px; }
  .brand { gap: 9px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 7px; }
  .brand strong { font-size: 16px; }
  .topbar-actions { flex: 0 0 auto; }
  .language-switch { padding: 2px; }
  .language-button { min-height: 40px; padding-inline: 8px; min-width: 40px; }
  .catalog-tabs { width: 100%; }
  .auth-mode-switch.catalog-tabs button { font-size: 14px; min-height: 44px; }
  .auth-mode-switch.catalog-tabs { margin-bottom: 16px; }
  .form-panel form, .form-panel, .merchant-product-fields { gap: 16px; }
  .merchant-product-card { padding: 14px; }
  .store-cover-image { height: 132px; }
  .stats-grid { gap: 12px; }
  .stat-card { padding: 12px; }
  .stat-card strong { font-size: 23px; overflow-wrap: anywhere; }
  .stat-card span { font-size: 12px; }
  .hero h1 { font-size: 34px; }
  .hero-content { padding-block: 48px; }
  .hero { min-height: min(560px, calc(100svh - 144px)); }
}

@media (max-width: 380px) {
  .workspace, .topbar, .hero-content { width: calc(100% - 24px); }
  .topbar { gap: 8px; }
  .brand { gap: 7px; }
  .brand strong { font-size: 15px; }
  .nav-tab { font-size: 10px; }
  .product-foot > .primary-action { width: 100%; }
  .auth-mode-switch:not(.catalog-tabs) button { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  button, .nav-tab::before, .toast { transition: none; }
  button:not(:disabled):active { transform: none; }
}

@media print {
  body { padding: 0; }
  .ui-icon { display: none; }
}
