
    :root {
      --primary: #0057ff; --primary-hover: #0046cc; --accent: #00c48c;
      --brand-orange: #E8541A; --brand-navy: #1B2B5E;
      --orange: #E8541A; --orange-dark: #c44718;
      --preview-scale: 1; --preview-user-zoom: 1;
      --ink: #0f1419; --ink-soft: #25303a; --muted: #4d5a66; --muted-strong: #3d4a56;
      --border: #d5dee7; --border-strong: #b8c4d2;
      --bg: #f3f6fa; --card: #ffffff; --surface-subtle: #eef3f8; --surface-strong: #e3ebf4;
      --field-bg: #ffffff; --field-readonly: #edf2f7; --field-border: #c8d3df; --field-border-hover: #9fb0c4;
      --focus-ring: rgba(0,87,255,0.2); --focus-ring-orange: rgba(232,84,26,0.24);
      --radius: 10px; --radius-sm: 8px;
      --shadow: 0 4px 24px rgba(15,20,25,0.06);
      --shadow-md: 0 8px 32px rgba(15,20,25,0.10);
      --nav-h: 64px;
      --font: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
      color-scheme: light;
    }
    * { box-sizing: border-box; }
    html { scroll-behavior: smooth; }
    body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--bg); min-height: 100vh; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; font-feature-settings: "kern" 1, "liga" 1; }
    body.rtl { direction: rtl; }
    body.rtl .nav-inner, body.rtl .nav-brand, body.rtl .nav-actions { flex-direction: row-reverse; }
    body.rtl .section-title { border-left: none; border-right: 4px solid var(--primary); padding-left: 0; padding-right: 12px; }

    [lang="zh-HK"] body,
    [lang="zh-CN"] body,
    .cjk-text {
      font-family: "Inter", "PingFang HK", "Noto Sans HK", "Microsoft JhengHei",
                   -apple-system, BlinkMacSystemFont, sans-serif;
      word-break: break-all;
      overflow-wrap: break-word;
    }

    /* Nav */
    .topnav { position: sticky; top: 0; z-index: 100; height: var(--nav-h); background: var(--card); border-bottom: 1px solid var(--border); box-shadow: 0 1px 6px rgba(15,20,25,0.05); }
    nav {
      contain: layout style;
    }
    .split-right .preview-wrap {
      content-visibility: auto;
      contain-intrinsic-size: 595px 842px;
    }
    .nav-inner { max-width: 1380px; margin: 0 auto; padding: 0 20px; height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
    .nav-brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; flex-shrink: 0; }
    .nav-brand > img { flex-shrink: 0; display: block; filter: none !important; mix-blend-mode: normal; opacity: 1; }
    .brand-text { display: flex; flex-direction: column; line-height: 1.2; gap: 2px; }
    .brand-title-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; }
    .brand-name { font-weight: 700; font-size: 2rem; letter-spacing: -0.02em; color: var(--brand-orange); }
    .brand-sep { color: var(--brand-navy); opacity: 0.4; font-weight: 400; font-size: 14px; display: none; }
    .brand-zh { font-weight: 500; font-size: 1.1rem; color: var(--orange-dark); display: none; }
    :root[lang^="zh"] .brand-sep, :root[lang^="zh"] .brand-zh { display: inline; }
    .brand-tagline { font-size: 0.88rem; color: var(--muted-strong); font-weight: 600; margin-top: 2px; letter-spacing: 0.01em; }
    .nav-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

    /* Plan badge */
    .plan-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.03em; }
    .plan-badge.clickable { cursor: pointer; }
    .plan-badge.free { background: var(--surface-strong); color: var(--muted-strong); border: 1px solid var(--border); }
    .plan-badge.pro { background: linear-gradient(135deg,#f4a234,#e85720); color: #fff; border: none; }
    .plan-badge.max { background: linear-gradient(135deg,#7c3aed,#5b21b6); color:#fff; border:none; }
    .plan-badge.trial { background: linear-gradient(135deg, #38a169, #2f855a); color: #fff; border: none; }

    /* Lang dropdown */
    .lang-wrap { position: relative; }
    .lang-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 14px; border: 1px solid var(--field-border); border-radius: var(--radius-sm); background: var(--card); font: inherit; font-size: 0.92rem; font-weight: 600; color: var(--ink); cursor: pointer; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; }
    .lang-btn:hover { border-color: var(--field-border-hover); background: var(--surface-subtle); }
    .lang-btn:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring); }
    .lang-btn .chev { width: 16px; height: 16px; opacity: 0.5; transition: transform 0.2s; }
    .lang-wrap.open .lang-btn .chev { transform: rotate(180deg); }
    .lang-panel { position: absolute; top: calc(100% + 6px); right: 0; min-width: 220px; max-height: min(70vh,360px); overflow-y: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); display: none; z-index: 200; }
    body.rtl .lang-panel { right: auto; left: 0; }
    .lang-wrap.open .lang-panel { display: block; }
    .lang-option { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 10px 14px; border: none; background: transparent; font: inherit; font-size: 0.9rem; text-align: start; cursor: pointer; color: var(--ink); }
    .lang-option:hover, .lang-option:focus { background: var(--surface-subtle); outline: none; }
    .lang-option[aria-selected="true"] { background: rgba(0,87,255,0.08); color: var(--primary); font-weight: 600; }
    .lang-flag { font-size: 1.15rem; line-height: 1; }

    /* Currency dropdown */
    .curr-wrap { position: relative; }
    .curr-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 14px; border: 1px solid var(--field-border); border-radius: var(--radius-sm); background: var(--card); font: inherit; font-size: 0.92rem; font-weight: 600; color: var(--ink); cursor: pointer; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; }
    .curr-btn:hover { border-color: var(--field-border-hover); background: var(--surface-subtle); }
    .curr-btn:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--focus-ring-orange); }
    .curr-btn .chev { width: 16px; height: 16px; opacity: 0.5; transition: transform 0.2s; }
    .curr-wrap.open .curr-btn .chev { transform: rotate(180deg); }
    .curr-panel { position: absolute; top: calc(100% + 6px); right: 0; min-width: 200px; max-height: min(70vh,320px); overflow-y: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); display: none; z-index: 200; }
    body.rtl .curr-panel { right: auto; left: 0; }
    .curr-wrap.open .curr-panel { display: block; }
    .curr-option { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 10px 14px; border: none; background: transparent; font: inherit; font-size: 0.9rem; text-align: start; cursor: pointer; color: var(--ink); }
    .curr-option:hover, .curr-option:focus { background: var(--surface-subtle); outline: none; }
    .curr-option[aria-selected="true"] { background: rgba(232,84,26,0.1); color: var(--orange); font-weight: 600; }

    /* Buttons */
    .btn { font: inherit; font-weight: 700; font-size: 0.9rem; min-height: 44px; padding: 10px 16px; border-radius: var(--radius-sm); cursor: pointer; border: none; transition: background 0.15s, border-color 0.15s, box-shadow 0.15s; }
    .btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--field-border); }
    .btn-ghost:hover { background: var(--surface-subtle); border-color: var(--field-border-hover); }
    /* Upgrade button - orange tint to draw attention in both modes */
    #btnUpgradePro { color: var(--orange-dark); border-color: var(--orange-dark); }
    #btnUpgradePro:hover { background: rgba(232,84,26,0.08); border-color: var(--orange-dark); }
    .btn-fill { background: var(--primary); color: #fff; }
    .btn-fill:hover { background: var(--primary-hover); }
    .btn-orange { background: var(--orange); color: #fff; border: none; }
    .btn-orange:hover { background: var(--orange-dark); }
    .btn-accent { background: var(--accent); color: #fff; border: none; }
    .btn-accent:hover { background: #00aa7a; }

    /* Skeleton Loading */
    @keyframes skeleton-pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.4; }
    }
    .skeleton {
      background: var(--surface-strong);
      border-radius: var(--radius-sm);
      animation: skeleton-pulse 1.5s ease-in-out infinite;
      pointer-events: none;
    }
    .skeleton-text {
      height: 1em;
      width: 100%;
      margin-bottom: 0.5em;
    }
    .skeleton-text.short { width: 60%; }
    .skeleton-text.medium { width: 80%; }
    .skeleton-input {
      height: 46px;
      width: 100%;
      border-radius: var(--radius-sm);
    }
    .skeleton-btn {
      height: 40px;
      width: 120px;
      border-radius: var(--radius-sm);
    }

    /* Split container */
    .split-container { display: flex; gap: 0; min-height: calc(100vh - var(--nav-h)); max-width: 1380px; margin: 0 auto; }
    .split-left { flex: 0 0 50%; max-width: 50%; padding: 26px 26px 56px; overflow-y: auto; }
    .split-right { flex: 0 0 50%; max-width: 50%; background: var(--surface-subtle); border-left: 1px solid var(--border); position: sticky; top: var(--nav-h); height: calc(100vh - var(--nav-h)); overflow-y: auto; display: flex; flex-direction: column; }

    /* Preview */
    .preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--border); flex-shrink: 0; }
    .preview-toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; max-width: min(100%,72%); }
    .preview-toolbar-label { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted-strong); }
    .preview-logo-controls { display: flex; align-items: center; gap: 8px; }
    .preview-logo-controls .btn { min-height: 38px; padding: 7px 12px; font-size: 0.8rem; }
    .logo-lock-msg { font-size: 0.76rem; color: var(--muted); font-style: italic; }
    .upgrade-hint { font-size: 0.76rem; color: var(--orange-dark); font-weight: 600; cursor: pointer; text-decoration: underline dotted; }
    .upgrade-hint:hover { color: var(--orange-dark); }
    .preview-scroll { flex: 1; overflow-y: auto; overflow-x: auto; padding: 16px 12px 24px; display: flex; flex-direction: column; align-items: stretch; min-height: 0; }
    .preview-scale-outer { width: 100%; display: flex; justify-content: center; flex: 1; min-height: 0; }
    .preview-scale-inner { width: 595px; max-width: none; flex-shrink: 0; transform-origin: top center; transform: scale(var(--preview-scale)); will-change: transform; }
    .preview-zoom { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
    .preview-zoom button { width: 34px; height: 34px; border: 1px solid var(--field-border); border-radius: 6px; background: var(--card); font-size: 1.1rem; line-height: 1; cursor: pointer; color: var(--ink); padding: 0; }
    .preview-zoom button:hover { background: var(--surface-subtle); }
    .preview-zoom input[type="range"] { width: 88px; accent-color: var(--orange); }
    .preview-zoom .zoom-pct { font-size: 0.76rem; font-weight: 700; color: var(--muted-strong); min-width: 42px; text-align: end; }
    .preview-actions { flex-shrink: 0; display: flex; gap: 12px; padding: 14px 20px 18px; background: var(--card); border-top: 1px solid var(--border); flex-wrap: wrap; }
    .preview-actions .btn { flex: 1; justify-content: center; text-align: center; min-width: 80px; }
    .btn-print-outline { background: transparent; color: var(--ink); border: 2px solid var(--primary); }
    .btn-print-outline:hover { background: rgba(0,87,255,0.06); }

    /* Footer */
    .site-footer { padding: 16px 16px 24px; text-align: center; }
    .footer-partners {
      margin-bottom: 12px;
      padding-bottom: 12px;
      border-bottom: 1px solid var(--border);
    }
    .footer-partners-label {
      display: block;
      font-size: 0.68rem;
      font-weight: 700;
      color: var(--muted-strong);
      letter-spacing: 0.08em;
      margin-bottom: 8px;
    }
    .footer-partner-links {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 6px 14px;
    }
    .footer-partner-link {
      font-size: 0.75rem;
      color: var(--muted);
      text-decoration: none;
      padding: 4px 10px;
      border: 1px solid var(--border);
      border-radius: 20px;
      background: #f8fafc;
      transition: border-color 0.15s, color 0.15s;
      white-space: nowrap;
    }
    .footer-partner-link:hover {
      color: var(--primary);
      border-color: var(--primary);
      background: rgba(0,87,255,0.04);
    }
    .footer-copy {
      font-size: 0.72rem;
      color: var(--muted);
    }
    .footer-copy a { color: var(--muted); text-decoration: underline dotted; }
    .footer-copy a:hover { color: var(--ink); }
    .footer-sep { margin: 0 4px; opacity: 0.4; }
    #carbonads {
      display: flex;
      max-width: 330px;
      background: #f8fafc;
      border: 1px solid var(--border);
      border-radius: 8px;
      overflow: hidden;
      font-size: 0.75rem;
      line-height: 1.4;
    }
    #carbonads a {
      color: var(--ink);
      text-decoration: none;
    }
    #carbonads a:hover { color: var(--primary); }
    .carbon-wrap { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
    .carbon-img { width: 130px; height: auto; flex-shrink: 0; border-radius: 4px; }
    .carbon-text { font-size: 0.72rem; color: var(--muted); }
    .carbon-poweredby {
      display: block;
      padding: 4px 12px;
      background: #f0f4f8;
      font-size: 0.62rem;
      color: #9aabb8;
      text-align: right;
    }

    /* Preview document */
    .preview-doc { width: 595px; box-sizing: border-box; max-width: none; background: var(--card); border-radius: 10px; box-shadow: var(--shadow-md); padding: 28px 28px 32px; font-family: var(--font); font-size: 0.92rem; color: var(--ink); overflow-wrap: anywhere; word-break: break-word; }
    .preview-doc .doc-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--brand-navy); padding-bottom: 14px; margin-bottom: 18px; gap: 12px; }
    .doc-logo-area { display: flex; align-items: center; gap: 10px; }
    .doc-logo-area .doc-brand-name { font-weight: 700; font-size: 1rem; color: var(--brand-navy); line-height: 1.2; }
    .doc-logo-area .doc-brand-sub { font-size: 0.76rem; color: var(--muted-strong); margin-top: 2px; }
    .doc-logo-img { max-height: 48px; max-width: 160px; object-fit: contain; }
    .doc-meta { text-align: end; font-size: 0.82rem; color: var(--muted-strong); }
    .doc-meta .doc-title { font-size: 1rem; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
    .doc-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
    .doc-block h4 { margin: 0 0 6px; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--orange-dark); }
    .doc-kv dt { font-size: 0.75rem; color: var(--muted-strong); margin: 0; }
    .doc-kv dd { margin: 1px 0 8px; font-weight: 500; font-size: 0.9rem; color: var(--ink); word-break: break-word; }
    .doc-kv dd.empty { color: #c5cdd6; font-style: italic; }
    .doc-kv-single { margin: 1px 0 8px; font-weight: 500; font-size: 0.9rem; color: var(--ink); word-break: break-word; }
    .doc-kv-single.empty { color: #8a95a5; font-style: italic; }
    .doc-kv dd.doc-kv-pre { white-space: pre-wrap; font-weight: 400; }
    .doc-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; margin-bottom: 8px; }
    .doc-table th { padding: 7px 8px; background: var(--surface-subtle); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-strong); border: 1px solid var(--border); text-align: start; }
    .doc-table td { padding: 7px 8px; border: 1px solid var(--border); vertical-align: top; }
    .doc-table .r { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
    .doc-total-row { display: flex; justify-content: flex-end; margin-top: 8px; font-size: 1rem; font-weight: 700; color: var(--primary); }
    .doc-total-row span { margin-left: 10px; }
    .doc-placeholder { text-align: center; padding: 20px 0; color: var(--muted); font-size: 0.9rem; }
    .doc-disclaimer { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 0.72rem; color: var(--muted); font-style: italic; }
    .doc-no-logo-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; background: #f0f4f8; border-radius: 20px; font-size: 0.7rem; color: var(--muted); border: 1px dashed var(--border); }

    /* Form side */
    .hero { margin-bottom: 20px; }
    .hero h1 { margin: 0 0 6px; font-size: clamp(1.35rem,2.5vw,1.68rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1.25; }
    .hero p { margin: 0; color: var(--muted-strong); font-size: 0.96rem; }
    .hero-trial-tag {
      display: inline-flex;
      align-items: center;
      margin: 6px 0 0;
      padding: 4px 12px;
      background: rgba(0,196,140,0.10);
      border: 1px solid rgba(0,196,140,0.30);
      border-radius: 20px;
      font-size: 0.8rem;
      font-weight: 600;
      color: #059669;
      letter-spacing: 0.01em;
    }
    .form-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 28px 24px 32px; }
    section { margin-bottom: 28px; }
    section:last-of-type { margin-bottom: 0; }
    .section-title { margin: 0 0 16px; padding-left: 12px; border-left: 4px solid var(--primary); font-size: 0.84rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--primary); display: flex; align-items: center; justify-content: space-between; }
    body.rtl .section-title { border-left: none; border-right: 4px solid var(--primary); padding-left: 0; padding-right: 12px; }

    [lang="zh-HK"] body,
    [lang="zh-CN"] body,
    .cjk-text {
      font-family: "Inter", "PingFang HK", "Noto Sans HK", "Microsoft JhengHei",
                   -apple-system, BlinkMacSystemFont, sans-serif;
      word-break: break-all;
      overflow-wrap: break-word;
    }
    .grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px 18px; }
    .field label { display: block; font-size: 0.84rem; font-weight: 600; color: var(--muted-strong); margin-bottom: 7px; line-height: 1.3; }
    input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
      width: 100%;
      min-height: 46px;
      padding: 11px 12px;
      border: 1px solid var(--field-border);
      border-radius: var(--radius-sm);
      font: inherit;
      font-size: 0.95rem;
      font-weight: 500;
      color: var(--ink-soft);
      background: var(--field-bg);
      transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    }
    input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.92; }
    input:hover, textarea:hover, select:hover { border-color: var(--field-border-hover); }
    input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring); color: var(--ink); background: var(--card); }

    /* Better keyboard focus — only show ring for keyboard, not mouse */
    :focus:not(:focus-visible) {
      outline: none;
      box-shadow: none;
    }
    :focus-visible {
      outline: 2px solid var(--primary);
      outline-offset: 2px;
    }
    textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
    .field-full { grid-column: 1 / -1; }
    .readonly { background: var(--field-readonly) !important; font-weight: 700; color: var(--ink); }
    .hint { font-size: 0.82rem; color: var(--muted-strong); margin-top: 8px; }
    .cw-mode-row { display: grid; gap: 10px; }
    .cw-toggle { display: inline-flex; border: 1px solid var(--field-border); border-radius: var(--radius-sm); overflow: hidden; width: fit-content; background: var(--card); }
    .cw-toggle button { min-height: 40px; padding: 8px 14px; border: none; background: transparent; font: inherit; font-size: 0.86rem; font-weight: 700; color: var(--muted-strong); cursor: pointer; }
    .cw-toggle button + button { border-left: 1px solid var(--field-border); }
    .cw-toggle button.active { background: var(--brand-navy); color: #fff; }
    .doc-type-toggle { display: flex; width: 100%; max-width: 100%; border: 1px solid var(--field-border); border-radius: var(--radius-sm); overflow: hidden; background: var(--card); margin-bottom: 22px; box-shadow: var(--shadow); }
    .doc-type-toggle button { flex: 1; min-height: 48px; padding: 12px 16px; border: none; background: transparent; font: inherit; font-size: 0.95rem; font-weight: 700; color: var(--muted-strong); cursor: pointer; line-height: 1.25; }
    .doc-type-toggle button + button { border-left: 1px solid var(--field-border); }
    .doc-type-toggle button.active { background: var(--brand-navy); color: #fff; }
    .invoice-fields-wrap { display: none; margin-top: 8px; padding-top: 16px; border-top: 1px dashed var(--border); }
    .invoice-fields-wrap .grid { margin-top: 4px; }
    .transport-mode-row { display: flex; flex-direction: column; gap: 10px; }
    .transport-mode-label { font-size: 0.84rem; font-weight: 600; color: var(--muted-strong); }
    .transport-checks { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; }
    .transport-check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.92rem; font-weight: 600; color: var(--ink-soft); cursor: pointer; user-select: none; }
    .transport-check input { width: 18px; height: 18px; min-height: 18px; accent-color: var(--primary); cursor: pointer; }
    .cw-formula-wrap { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; }
    .cw-formula-wrap .field { margin: 0; }

    /* Breakdown */
    .breakdown { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
    .breakdown table { width: 100%; border-collapse: collapse; }
    .breakdown th, .breakdown td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--border); }
    .breakdown th { background: var(--surface-subtle); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-strong); }
    .breakdown tr:last-child td { border-bottom: none; }
    .breakdown .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
    .breakdown .total-row td { font-weight: 700; font-size: 1rem; background: rgba(0,196,140,0.08); color: var(--ink); border-top: 2px solid var(--accent); }

    /* Actions */
    .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
    .btn-lg { min-height: 46px; padding: 11px 20px; font-size: 0.94rem; border-radius: var(--radius-sm); }
    .btn-primary-lg { background: var(--primary); color: #fff; border: none; font-weight: 600; }
    .btn-primary-lg:hover { background: var(--primary-hover); }
    .btn-secondary-lg { background: #fff; color: var(--ink); border: 1px solid var(--border); font-weight: 600; }
    .btn-secondary-lg:hover { background: #f8fafc; }
    .btn-save-lg { background: #007a57; color: #fff; border: none; font-weight: 600; }
    .btn-save-lg:hover { background: #006849; }
    .btn-save-lg.saved { background: #059669; }
    .btn-save-lg:disabled { opacity: 0.5; cursor: not-allowed; }

    /* Quota badge */
    .quota-info { margin-top: 10px; font-size: 0.78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
    .quota-bar { height: 4px; border-radius: 2px; background: var(--border); width: 80px; overflow: hidden; }
    .quota-bar-fill { height: 100%; border-radius: 2px; background: var(--accent); transition: width 0.3s; }
    .quota-bar-fill.warn { background: var(--orange); }
    .quota-bar-fill.full { background: #ef4444; }
    .quota-text { font-size: 0.75rem; }
    .quota-text.full { color: #ef4444; font-weight: 600; }
    .margin-panel { background: var(--card); }
    @media print { .margin-panel { display: none !important; } }
    .templates-btn {
      display: inline-flex; align-items: center; gap: 5px;
      padding: 3px 10px; border: 1px solid var(--border);
      border-radius: 20px; background: var(--card);
      font: inherit; font-size: 0.7rem; font-weight: 600;
      color: var(--primary); cursor: pointer;
      transition: background 0.15s, border-color 0.15s;
      white-space: nowrap;
    }
    .templates-btn:hover { background: rgba(0,87,255,0.06); border-color: var(--primary); }
    .templates-overlay {
      display: none; position: fixed; inset: 0; z-index: 290;
      background: rgba(15,20,25,0.32);
    }
    .templates-overlay.open { display: block; }
    .templates-panel {
      position: fixed; top: 0; left: 0; bottom: 0;
      width: min(380px, 92vw);
      background: var(--card);
      box-shadow: 4px 0 40px rgba(15,20,25,0.14);
      z-index: 291;
      display: flex; flex-direction: column;
      transform: translateX(-100%);
      transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    }
    .templates-overlay.open .templates-panel { transform: translateX(0); }
    .templates-panel-header {
      padding: 18px 18px 14px;
      border-bottom: 1px solid var(--border);
      display: flex; align-items: center; justify-content: space-between;
      flex-shrink: 0;
    }
    .templates-panel-header h3 { margin: 0; font-size: 1rem; font-weight: 700; }
    .templates-panel-close {
      width: 36px; height: 36px; border: none;
      background: #f0f4f8; border-radius: 8px;
      font-size: 1.2rem; cursor: pointer; color: var(--muted);
      display: flex; align-items: center; justify-content: center;
    }
    .templates-panel-close:hover { background: #e4eaef; }
    .templates-panel-body { flex: 1; overflow-y: auto; padding: 14px; }
    .templates-panel-footer {
      padding: 14px 16px; border-top: 1px solid var(--border);
      background: #f8fafc; flex-shrink: 0;
    }
    .templates-panel-footer label {
      display: block; font-size: 0.72rem; font-weight: 700;
      text-transform: uppercase; letter-spacing: 0.05em;
      color: var(--muted); margin-bottom: 8px;
    }
    .save-tpl-form { display: flex; gap: 8px; }
    .save-tpl-form input { flex: 1; min-height: 40px; }
    .save-tpl-form .btn { padding: 8px 14px; font-size: 0.82rem; white-space: nowrap; }
    .tpl-item {
      border: 1px solid var(--border); border-radius: var(--radius-sm);
      padding: 12px 13px 10px; margin-bottom: 10px;
      transition: border-color 0.15s;
    }
    .tpl-item:hover { border-color: var(--primary); }
    .tpl-item-name { font-weight: 600; font-size: 0.875rem; margin-bottom: 4px; }
    .tpl-item-meta {
      font-size: 0.72rem; color: var(--muted);
      display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px;
    }
    .tpl-item-actions { display: flex; gap: 6px; }
    .tpl-item-actions button {
      flex: 1; padding: 6px 8px; font: inherit; font-size: 0.75rem;
      font-weight: 600; border-radius: 6px; cursor: pointer;
      border: 1px solid var(--border); background: #fff; color: var(--ink);
    }
    .tpl-load { color: var(--primary) !important; border-color: rgba(0,87,255,0.3) !important; }
    .tpl-load:hover { background: rgba(0,87,255,0.06) !important; }
    .tpl-del { color: #e53e3e !important; border-color: rgba(229,62,62,0.3) !important; }
    .tpl-del:hover { background: rgba(229,62,62,0.06) !important; }
    .tpl-empty { text-align: center; padding: 36px 16px; color: var(--muted); font-size: 0.85rem; }
    .tpl-empty .icon { font-size: 2.2rem; display: block; margin-bottom: 10px; }
    .tpl-locked-msg { text-align: center; padding: 28px 16px; color: var(--muted); }
    .tpl-locked-msg .icon { font-size: 1.8rem; display: block; margin-bottom: 8px; }
    .margin-section {
      margin-top: 12px;
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      overflow: hidden;
    }
    .margin-header {
      display: flex; align-items: center; justify-content: space-between;
      padding: 10px 14px; background: #f8fafc;
      cursor: pointer; user-select: none;
    }
    .margin-header:hover { background: #f0f4f8; }
    .margin-header h3 {
      margin: 0; font-size: 0.75rem; font-weight: 700;
      text-transform: uppercase; letter-spacing: 0.06em;
      color: var(--muted); display: flex; align-items: center; gap: 6px;
      flex: 1; justify-content: center;
    }
    .margin-section.open .margin-header .chev { transform: rotate(180deg); }
    .margin-body { display: none; padding: 14px; }
    .margin-section.open .margin-body { display: block; }
    .margin-inputs {
      display: grid; grid-template-columns: 1fr 1fr;
      gap: 10px; margin-bottom: 12px;
    }
    @media (max-width: 768px) { .margin-inputs { grid-template-columns: 1fr; } }
    .margin-result {
      background: #f8fafc; border-radius: 6px;
      padding: 12px 14px; margin-bottom: 8px;
    }
    .margin-row {
      display: flex; justify-content: space-between;
      align-items: center; padding: 4px 0; font-size: 0.85rem;
    }
    .margin-row .lbl { color: var(--muted); }
    .margin-row .val { font-weight: 600; font-variant-numeric: tabular-nums; }
    .margin-row.total {
      font-size: 0.95rem; font-weight: 700;
      padding-top: 9px; margin-top: 5px;
      border-top: 1px solid var(--border);
    }
    .margin-row.total .lbl { color: var(--ink); }
    .profit-pos { color: #38a169; }
    .profit-neg { color: #e53e3e; }
    .margin-locked {
      padding: 20px; text-align: center;
      color: var(--muted); font-size: 0.85rem;
    }
    .margin-locked .icon { font-size: 1.5rem; display: block; margin-bottom: 8px; }
    .margin-locked strong { color: var(--ink); display: block; margin-bottom: 6px; }
    .post-quote-nudge {
      position: fixed;
      bottom: 90px;
      left: 50%;
      transform: translateX(-50%) translateY(20px);
      z-index: 500;
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 12px;
      box-shadow: 0 8px 32px rgba(15,20,25,0.14);
      padding: 14px 44px 14px 16px;
      display: flex;
      align-items: center;
      gap: 12px;
      max-width: min(420px, calc(100vw - 32px));
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.3s, transform 0.3s;
    }
    .post-quote-nudge.show {
      opacity: 1;
      pointer-events: auto;
      transform: translateX(-50%) translateY(0);
    }
    .pqn-close {
      position: absolute;
      top: 8px; right: 10px;
      width: 24px; height: 24px;
      border: none; background: transparent;
      font-size: 1.1rem; cursor: pointer;
      color: var(--muted); line-height: 1;
    }
    .pqn-close:hover { color: var(--ink); }
    .pqn-icon { font-size: 1.4rem; flex-shrink: 0; }
    .pqn-body { flex: 1; min-width: 0; }
    .pqn-title {
      font-size: 0.85rem; font-weight: 600;
      color: var(--ink); margin-bottom: 2px;
    }
    .pqn-sub {
      font-size: 0.75rem; color: var(--muted); line-height: 1.4;
    }
    .pqn-cta {
      flex-shrink: 0;
      padding: 6px 12px;
      border-radius: 6px;
      border: none;
      background: var(--orange);
      color: #fff;
      font: inherit;
      font-size: 0.75rem;
      font-weight: 600;
      cursor: pointer;
      white-space: nowrap;
    }
    .pqn-cta:hover { opacity: 0.9; }
    .rate-intel-alert {
      display: flex;
      align-items: flex-start;
      gap: 8px;
      background: #fff8f0;
      border: 1px solid #fde8d4;
      border-left: 3px solid var(--orange);
      border-radius: 6px;
      padding: 8px 12px;
      margin-top: 10px;
      font-size: 0.78rem;
      animation: fadeIn 0.2s ease;
    }
    @keyframes fadeIn { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:none; } }
    .ria-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
    .ria-body { flex: 1; color: var(--ink); line-height: 1.5; }
    .ria-body strong { display: block; margin-bottom: 2px; color: var(--orange); }
    .result-badge {
      display: inline-flex; align-items: center;
      padding: 2px 8px; border-radius: 10px;
      font-size: 0.68rem; font-weight: 700;
    }
    .result-badge.won { background: #f0fff4; color: #38a169; border: 1px solid #c6f6d5; }
    .result-badge.lost { background: #fff5f5; color: #e53e3e; border: 1px solid #fed7d7; }
    .result-btn {
      padding: 2px 8px; border-radius: 10px;
      font: inherit; font-size: 0.68rem; font-weight: 600;
      cursor: pointer; border: 1px solid var(--border);
      background: #f8fafc; color: var(--muted);
      margin-right: 4px; transition: all 0.15s;
    }
    .won-btn:hover { background: #f0fff4; color: #38a169; border-color: #c6f6d5; }
    .lost-btn:hover { background: #fff5f5; color: #e53e3e; border-color: #fed7d7; }
    .win-rate-card {
      background: linear-gradient(135deg, #1a2340, #2d3a5e);
      border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; color: #fff;
    }
    .wr-title { font-size: 0.75rem; font-weight: 700; opacity: 0.7;
      text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }
    .wr-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
    .wr-stat { text-align: center; }
    .wr-num { display: block; font-size: 1.3rem; font-weight: 700; line-height: 1; }
    .wr-num.green { color: #68d391; }
    .wr-num.red { color: #fc8181; }
    .wr-num.orange { color: #f6ad55; }
    .wr-num.muted { color: rgba(255,255,255,0.5); }
    .wr-lbl { display: block; font-size: 0.62rem; opacity: 0.6; margin-top: 3px; }
    .bank-details-section {
      margin-top: 12px;
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      overflow: hidden;
    }
    .bank-details-header {
      display: flex; align-items: center;
      justify-content: space-between;
      padding: 10px 14px; background: #f8fafc;
      cursor: pointer; user-select: none;
    }
    .bank-details-header:hover { background: #f0f4f8; }
    .bank-details-header h3 {
      margin: 0; font-size: 0.75rem; font-weight: 700;
      text-transform: uppercase; letter-spacing: 0.06em;
      color: var(--muted); display: flex;
      align-items: center; gap: 6px;
    }
    .bank-details-section.open .bank-details-header .chev { transform: rotate(180deg); }
    .bank-details-body { display: none; padding: 14px; }
    .bank-details-section.open .bank-details-body { display: block; }
    .bottom-tab-bar {
      display: none;
      position: fixed;
      bottom: 0; left: 0; right: 0;
      z-index: 160;
      height: calc(56px + env(safe-area-inset-bottom));
      padding-bottom: env(safe-area-inset-bottom);
      background: var(--card);
      border-top: 1px solid var(--border);
      box-shadow: 0 -2px 16px rgba(15,20,25,0.07);
      grid-template-columns: repeat(7, 1fr);
      align-items: stretch;
    }
    .tab-btn {
      display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      gap: 2px; padding: 6px 4px;
      border: none; background: transparent;
      cursor: pointer; color: var(--ink-soft);
      font: inherit; transition: color 0.15s;
      -webkit-tap-highlight-color: transparent;
    }
    .tab-btn.active { color: var(--orange); }
    .tab-btn:active { background: rgba(232,84,26,0.06); }
    .tab-icon { font-size: 1.2rem; line-height: 1; }
    .tab-label { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.03em; color: inherit; }

    /* ── More features + Module Launcher (mobile only) ─── */
    .bottom-tab-more-btn { display: none; }
    .module-launcher-btn { display: none; }
    .module-launcher-btn {
      min-height: 48px;
      transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
      -webkit-tap-highlight-color: transparent;
    }
    .module-launcher-btn:active {
      transform: scale(0.98);
    }
    .module-launcher-btn.open {
      color: var(--primary);
      background: color-mix(in srgb, var(--primary) 12%, transparent);
      box-shadow: none;
    }

    /* Phone + tablet: floating bottom bar + module launcher (≤1024px) */
    @media (max-width: 1024px) {
      .module-nav-btn { display: none !important; }
      .module-launcher-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 8px 6px 10px;
        min-height: 56px;
        border: none;
        border-radius: 12px;
        cursor: pointer;
        letter-spacing: 0.01em;
        color: var(--ink-soft);
        background: transparent;
        box-shadow: none;
        font-size: inherit;
        font-weight: inherit;
      }
      .module-launcher-btn .tab-icon {
        font-size: 1.25rem;
        line-height: 1;
      }
      .module-launcher-btn .tab-label {
        font-size: 0.65rem;
        font-weight: 700;
        letter-spacing: 0.03em;
        line-height: 1.2;
        text-align: center;
        max-width: 100%;
        padding: 0 2px;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        word-break: keep-all;
      }
      .bottom-tab-more-btn {
        display: flex;
        min-height: 56px;
        justify-content: center;
      }
      .bottom-tab-more-btn.open {
        color: var(--primary);
        background: color-mix(in srgb, var(--primary) 12%, transparent);
        border-radius: 12px;
      }
      .bottom-tab-bar {
        display: grid !important;
        grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.25fr) repeat(3, minmax(0, 1fr));
        left: 10px;
        right: 10px;
        bottom: calc(10px + env(safe-area-inset-bottom));
        height: auto;
        min-height: 64px;
        padding: 6px;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 24px;
        box-shadow: 0 14px 34px rgba(15,20,25,0.14);
      }
    }

    /* ── Bottom Sheet Backdrop ──────────────────────────── */
    .module-sheet-backdrop {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.45);
      z-index: 1100;
      opacity: 0;
      transition: opacity 0.25s ease;
      -webkit-backdrop-filter: blur(6px);
      backdrop-filter: blur(6px);
    }
    .module-sheet-backdrop.open {
      display: block;
      opacity: 1;
    }

    /* ── Bottom Sheet Panel ─────────────────────────────── */
    .module-sheet {
      display: none;
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      z-index: 1101;
      background: var(--bg, #fff);
      border: 1px solid var(--border);
      border-bottom: none;
      border-radius: 28px 28px 0 0;
      padding: 0 0 env(safe-area-inset-bottom, 16px);
      box-shadow: 0 -16px 44px rgba(15,20,25,0.18);
      transform: translateY(100%);
      transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
      max-height: 85vh;
      overflow-y: auto;
      overscroll-behavior: contain;
    }
    .module-sheet.open {
      transform: translateY(0);
    }
    .module-sheet-handle {
      width: 40px;
      height: 4px;
      background: var(--border, #e0e0e0);
      border-radius: 2px;
      margin: 12px auto 6px;
    }
    .module-sheet-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 10px 20px 14px;
      border-bottom: 1px solid var(--border, #eee);
    }
    .module-sheet-header h3 {
      font-size: 16px;
      font-weight: 700;
      color: var(--brand-navy, #1B2B5E);
      margin: 0;
    }
    .module-sheet-close-btn {
      background: none;
      border: none;
      font-size: 22px;
      color: var(--muted, #888);
      cursor: pointer;
      padding: 4px 8px;
      line-height: 1;
      border-radius: 8px;
    }
    .module-sheet-close-btn:active { background: var(--surface, #f5f5f5); }
    .module-sheet-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 14px;
      padding: 18px 16px 20px;
    }
    .module-sheet-card {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 10px;
      padding: 18px 10px 16px;
      background: var(--surface, #f8f9fb);
      border: 2px solid transparent;
      border-radius: 18px;
      cursor: pointer;
      transition: all 0.18s ease;
      min-height: 124px;
      text-align: center;
      -webkit-tap-highlight-color: transparent;
      box-shadow: 0 8px 18px rgba(15,20,25,0.06);
    }
    .module-sheet-card:active {
      transform: scale(0.96);
      background: var(--surface, #f0f0f0);
    }
    .module-sheet-card.active {
      border-color: var(--primary, #0057ff);
      background: #eef3ff;
      box-shadow: 0 12px 28px rgba(0,87,255,0.16);
    }
    .module-sheet-card.active .module-sheet-card-icon-wrap {
      box-shadow: 0 12px 28px rgba(0,87,255,0.22);
      transform: scale(1.05);
    }
    .module-sheet-card.active .module-sheet-card-label {
      color: var(--primary, #0057ff);
      font-weight: 700;
    }
    .module-sheet-card.active .module-sheet-card-desc {
      color: var(--primary, #0057ff);
      opacity: 0.88;
    }
    .module-sheet-card-icon-wrap {
      width: 52px;
      height: 52px;
      border-radius: 16px;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 8px 18px rgba(15,20,25,0.1);
      flex-shrink: 0;
      transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    .module-sheet-card-icon-wrap--quotation {
      background: linear-gradient(145deg, var(--primary), var(--brand-navy));
    }
.module-sheet-card-icon-wrap--dg {
      background: linear-gradient(145deg, var(--brand-navy), #334155);
    }
    .module-sheet-card-icon-wrap--conv {
      background: linear-gradient(145deg, var(--accent), #0d9488);
    }
    .module-sheet-card-icon {
      font-size: 26px;
      line-height: 1;
      display: block;
    }
    .module-sheet-card-text {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;
      width: 100%;
    }
    .module-sheet-card-label {
      font-size: 13px;
      font-weight: 600;
      color: var(--brand-navy, #1B2B5E);
      line-height: 1.25;
    }
    .module-sheet-card-desc {
      font-size: 11px;
      font-weight: 500;
      color: var(--muted);
      line-height: 1.3;
      max-width: 100%;
      padding: 0 2px;
    }
    /* Keep ULD card visible in More Features across breakpoints. */
    #moduleSheet #sheetCard-uld {
      display: flex;
    }
    @media (min-width: 769px) {
      #moduleSheet #sheetCard-quotation,
      #moduleSheet #sheetCard-dg,
      #moduleSheet #sheetCard-notoc,
      #moduleSheet #sheetCard-roster {
        display: none;
      }
      #moduleSheet #sheetCard-uld {
        display: flex;
      }
    }
    @media (max-width: 1024px) and (prefers-reduced-motion: no-preference) {
      #moduleQuotation.module-view-enter,
      #moduleDgChecker.module-view-enter,
      #moduleConverter.module-view-enter,
      #moduleRostering.module-view-enter,
      #moduleNotoc.module-view-enter,
      #moduleUld.module-view-enter {
        animation: moduleViewEnter 0.34s cubic-bezier(0.32, 0.72, 0, 1) both;
      }
    }
    @keyframes moduleViewEnter {
      from { opacity: 0.45; transform: translateY(10px); }
      to { opacity: 1; transform: none; }
    }

    /* Phone (≤480px): shrink font, allow labels to truncate */
    @media (max-width: 480px) {
      .bottom-tab-bar {
        padding: 0;
      }
      .tab-btn {
        min-width: 0;
        flex: 1;
        padding: 8px 2px 10px;
        gap: 3px;
      }
      .tab-icon {
        font-size: 1.3rem;
      }
      .tab-label {
        font-size: 0.55rem;
        letter-spacing: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 52px;
      }
      .module-launcher-btn .tab-icon {
        font-size: 1.3rem;
      }
      .module-launcher-btn .tab-label {
        font-size: 0.55rem;
        letter-spacing: 0;
        max-width: 110px;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
      }
      .bottom-tab-more-btn .tab-label {
        max-width: 110px;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
      }
    }

    /* Tablet (481px–1024px): slightly larger tap targets, labels readable */
    @media (min-width: 481px) and (max-width: 1024px) {
      .tab-btn {
        padding: 10px 8px 12px;
        gap: 4px;
      }
      .tab-icon {
        font-size: 1.5rem;
      }
      .tab-label {
        font-size: 0.68rem;
        letter-spacing: 0.02em;
      }
    }
    /* Launcher + More: match tab icon size when bottom bar is tablet width */
    @media (min-width: 481px) and (max-width: 1024px) {
      .module-launcher-btn .tab-icon,
      .bottom-tab-more-btn .tab-icon {
        font-size: 1.5rem;
      }
      .module-launcher-btn .tab-label,
      .bottom-tab-more-btn .tab-label {
        font-size: 0.68rem;
        letter-spacing: 0.02em;
      }
    }

    /* Modals */
    .modal-overlay { position: fixed; inset: 0; z-index: 300; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(15,20,25,0.35); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
    .modal-overlay.open { display: flex; }
    .modal-overlay {
      transition: opacity 0.15s ease;
    }
    .modal-overlay:not(.open) {
      opacity: 0;
      pointer-events: none;
    }
    .modal-overlay.open {
      opacity: 1;
      pointer-events: auto;
    }
    .modal-box {
      transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), opacity 0.15s ease;
      transform-origin: center bottom;
    }
    .modal-card { width: 100%; max-width: 520px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 24px 48px rgba(15,20,25,0.12); padding: 28px 24px 24px; position: relative; animation: modalIn 0.2s ease; }
    @keyframes modalIn { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: none; } }
    .modal-close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border: none; background: #f0f4f8; border-radius: 8px; cursor: pointer; font-size: 1.25rem; line-height: 1; color: var(--muted); }
    body.rtl .modal-close { right: auto; left: 14px; }
    .modal-close:hover { background: #e4eaef; color: var(--ink); }
    .modal-card h2 { margin: 0 0 6px; font-size: 1.2rem; font-weight: 700; }
    .modal-card .field { margin-bottom: 14px; }
    .modal-card .btn-fill { width: 100%; margin-top: 8px; padding: 12px; }
    .modal-forgot { display: inline-block; margin-top: 10px; font-size: 0.8125rem; color: var(--primary); text-decoration: none; font-weight: 500; }
    .modal-forgot:hover { text-decoration: underline; }
    .modal-error { margin: 8px 0 0; padding: 9px 12px; background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius-sm); font-size: 0.82rem; color: #dc2626; display: none; }
    .modal-error.show { display: block; }
    .modal-success { margin: 8px 0 0; padding: 9px 12px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: var(--radius-sm); font-size: 0.82rem; color: #16a34a; display: none; }
    .modal-success.show { display: block; }
    .modal-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

    /* Upgrade modal */
    /* ── Upgrade Modal (Redesigned) ── */
    .modal-upgrade-card { max-width: 520px; }

    .upgrade-modal-header { text-align: center; margin-bottom: 20px; }
    .upgrade-modal-header h2 { margin: 0 0 6px; font-size: 1.25rem; font-weight: 800; color: var(--brand-navy); }
    .upgrade-modal-subtitle { margin: 0; font-size: 0.82rem; color: var(--muted); line-height: 1.4; }

    .upgrade-modal-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }

    .upgrade-plan-tile {
      position: relative;
      border: 2px solid var(--border);
      border-radius: 14px;
      padding: 16px 14px;
      display: flex;
      flex-direction: column;
      background: var(--card);
      transition: border-color 0.2s, box-shadow 0.2s;
    }
    .upgrade-plan-tile:hover { border-color: #d0d7e0; }

    .upgrade-plan-tile--hero {
      border-color: var(--orange);
      background: linear-gradient(180deg, #fff8f5 0%, #fff 40%);
      box-shadow: 0 4px 20px rgba(232,84,26,0.10);
    }
    .upgrade-plan-tile--hero:hover { box-shadow: 0 6px 28px rgba(232,84,26,0.15); }

    .plan-tile-popular {
      position: absolute;
      top: -10px;
      left: 50%;
      transform: translateX(-50%);
      background: linear-gradient(135deg, #E8541A, #ff7043);
      color: #fff;
      font-size: 0.6rem;
      font-weight: 800;
      letter-spacing: 0.08em;
      padding: 3px 12px;
      border-radius: 20px;
      white-space: nowrap;
    }

    .plan-tile-badge {
      display: inline-block;
      font-size: 0.6rem;
      font-weight: 700;
      letter-spacing: 0.06em;
      padding: 2px 8px;
      border-radius: 4px;
      margin-bottom: 6px;
      width: fit-content;
    }
    .plan-tile-badge--free { background: #f1f5f9; color: #64748b; }

    .plan-tile-name { font-weight: 700; font-size: 1rem; color: var(--brand-navy); margin-bottom: 2px; }

    .plan-tile-price { font-size: 1.5rem; font-weight: 800; color: var(--ink); }
    .plan-tile-price--hero { color: var(--orange); }
    .plan-tile-price span { font-size: 0.72rem; font-weight: 400; color: var(--muted); }

    .plan-tile-value { font-size: 0.7rem; color: var(--muted); margin: 2px 0 10px; }

    .plan-tile-features { list-style: none; padding: 0; margin: 0 0 14px; flex: 1; }
    .plan-tile-features li {
      padding: 4px 0;
      font-size: 0.76rem;
      color: #475569;
      display: flex;
      align-items: center;
      gap: 6px;
      line-height: 1.35;
    }
    .plan-tile-features li strong { font-weight: 600; color: var(--ink); }

    .plan-tile-features--hero li { font-size: 0.78rem; }

    .plan-tile-feature--lock { color: #94a3b8; }

    .plan-tile-icon {
      color: var(--accent);
      font-weight: 700;
      font-size: 0.8rem;
      flex-shrink: 0;
    }
    .plan-tile-icon--hero { color: var(--orange); }
    .plan-tile-icon--off { color: #cbd5e1; font-size: 0.75rem; }

    .plan-tile-btn {
      width: 100%;
      padding: 11px;
      border-radius: var(--radius-sm);
      font: inherit;
      font-weight: 700;
      font-size: 0.85rem;
      cursor: pointer;
      border: 1.5px solid var(--field-border);
      background: #fff;
      transition: all 0.2s;
      margin-top: auto;
    }
    .plan-tile-btn--free {
      background: #f8fafc;
      color: #94a3b8;
      border-color: #e2e8f0;
      cursor: default;
    }
    .plan-tile-btn--hero {
      background: linear-gradient(135deg, #E8541A, #ff6b35);
      color: #fff;
      border-color: var(--orange);
      box-shadow: 0 2px 8px rgba(232,84,26,0.25);
    }
    .plan-tile-btn--hero:hover {
      background: linear-gradient(135deg, #c94410, #E8541A);
      box-shadow: 0 4px 14px rgba(232,84,26,0.35);
      transform: translateY(-1px);
    }

    .upgrade-modal-guarantee {
      display: flex;
      justify-content: center;
      gap: 16px;
      padding: 12px 0 4px;
      border-top: 1px solid var(--border);
    }
    .guarantee-item {
      display: flex;
      align-items: center;
      gap: 4px;
      font-size: 0.7rem;
      color: var(--muted);
      white-space: nowrap;
    }
    .guarantee-icon { font-size: 0.85rem; }
    .btn-upgrade { background: linear-gradient(135deg,#f4a234,#e85720); color: #fff; width: 100%; margin-top: 4px; padding: 13px; font-size: 0.95rem; font-weight: 700; border-radius: var(--radius-sm); border: none; cursor: pointer; }
    .btn-upgrade:hover { opacity: 0.92; }
    .btn-upgrade:disabled { opacity: 0.5; cursor: not-allowed; }

    /* Signup Pro Feature Grid */
    .modal-signup-card { max-width: 520px; }
    .signup-trial-badge {
      display: inline-block;
      background: linear-gradient(135deg, var(--accent), #00a878);
      color: #fff;
      font-size: 0.6rem;
      font-weight: 800;
      letter-spacing: 0.1em;
      padding: 3px 12px;
      border-radius: 20px;
      margin-bottom: 6px;
    }
    .signup-tagline {
      margin: 0 0 14px;
      font-size: 0.82rem;
      color: var(--muted-strong);
      line-height: 1.4;
    }
    .signup-pro-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
      margin-bottom: 18px;
    }
    .signup-pro-tile {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;
      padding: 10px 6px;
      background: var(--surface-subtle);
      border: 1px solid var(--border);
      border-radius: 10px;
      text-align: center;
      transition: transform 0.15s, box-shadow 0.15s;
    }
    .signup-pro-tile:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(0,87,255,0.08);
    }
    .signup-pro-tile svg { color: var(--orange); flex-shrink: 0; }
    .signup-pro-tile span { font-size: 0.68rem; font-weight: 600; color: var(--ink-soft); line-height: 1.3; }
    .btn-signup-cta {
      background: linear-gradient(135deg, #E8541A, #ff7043) !important;
      color: #fff !important;
      box-shadow: 0 4px 16px rgba(232,84,26,0.25);
    }
    .btn-signup-cta:hover { opacity: 0.92; }
    .signup-trust-line {
      margin: 14px 0 0;
      text-align: center;
      font-size: 0.7rem;
      color: var(--muted);
      letter-spacing: 0.02em;
    }
    .signup-view-plans {
      display: block;
      text-align: center;
      margin-top: 8px;
      font-size: 0.72rem;
      color: var(--primary);
      text-decoration: none;
      font-weight: 500;
    }
    .signup-view-plans:hover { text-decoration: underline; }

    /* Share buttons */
    .btn-whatsapp { background: #0f6f3c; color: #fff; border: none; font-weight: 600; font-size: 0.875rem; }
    .btn-whatsapp:hover { background: #0c6033; }
    .btn-email { background: #4a5568; color: #fff; border: none; font-weight: 600; font-size: 0.875rem; }
    .btn-email:hover { background: #2d3748; }

    /* Logo upload */
    .logo-upload-input { display: none; }

    /* History Drawer */
    .history-overlay { display: none; position: fixed; inset: 0; z-index: 290; background: rgba(15,20,25,0.35); backdrop-filter: blur(4px); }
    .history-overlay.open { display: block; }
    .history-drawer { position: fixed; top: var(--nav-h); right: 0; bottom: 0; width: min(420px,100vw); background: var(--card); border-left: 1px solid var(--border); box-shadow: -8px 0 40px rgba(15,20,25,0.1); display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.25s ease; z-index: 291; }
    .history-overlay.open .history-drawer { transform: translateX(0); }
    #historyGate { display: none; position: fixed; inset: 0; z-index: 295; align-items: center; justify-content: center; padding: 24px; background: rgba(15,20,25,0.45); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
    #historyGate.history-gate-visible { display: flex; }
    .history-gate-card { max-width: 420px; background: var(--card); border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow); text-align: center; border: 1px solid var(--border); max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .history-gate-card h2 { margin: 0 0 8px; font-size: 1.35rem; color: var(--brand-navy); }
    .history-gate-card p { margin: 0 0 16px; color: var(--muted-strong); font-size: 0.92rem; }
    .history-gate-features { text-align: start; margin: 0 0 20px; padding: 0 0 0 4px; font-size: 0.88rem; color: var(--ink-soft); line-height: 1.7; list-style: none; }
    .history-gate-features .ck { color: var(--accent); font-weight: 700; font-size: 0.9rem; }
    .history-plan-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 12px; text-align: left; }
    .h-plan-card { border: 2px solid var(--border); border-radius: 10px; padding: 14px 12px 12px; position: relative; display: flex; flex-direction: column; min-width: 0; }
    .h-plan-card-featured { border-color: var(--orange); }
    .h-plan-badge { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: var(--orange); color: #fff; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; padding: 2px 10px; border-radius: 10px; white-space: nowrap; }
    .h-plan-name { font-weight: 700; font-size: 1rem; margin-bottom: 3px; }
    .h-plan-price { font-size: 1.05rem; font-weight: 700; color: var(--orange); margin-bottom: 10px; }
    .h-plan-price span { font-size: 0.72rem; color: var(--muted); font-weight: 400; }
    .h-plan-features { list-style: none; padding: 0; margin: 0 0 14px; font-size: 0.75rem; color: var(--muted); flex: 1; }
    .h-plan-features li { padding: 3px 0; border-bottom: 1px solid #f0f4f8; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .h-plan-features li:last-child { border-bottom: none; }
    .h-plan-btn { width: 100%; padding: 10px; border-radius: var(--radius-sm); font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; border: none; margin-top: auto; flex-shrink: 0; }
    .h-plan-btn-pro { background: linear-gradient(135deg, var(--orange), var(--orange-dark)); color: #fff; border: 1px solid var(--orange); }
    .h-plan-btn-pro:hover { filter: brightness(1.05); }
    .h-plan-btn-pro:disabled {
      background: var(--surface-strong);
      color: var(--muted);
      border-color: var(--border-strong);
      cursor: not-allowed;
      opacity: 1;
    }
    .h-plan-btn-max { background: linear-gradient(135deg,#f4a234,#e85720); color: #fff; }
    .h-plan-btn-max:hover { opacity: 0.9; }
    .history-gate-actions { display: flex; flex-direction: column; gap: 10px; }
    .history-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
    .history-header h3 { margin: 0; font-size: 1rem; font-weight: 700; }
    .history-close { width: 36px; height: 36px; border: none; background: #f0f4f8; border-radius: 8px; cursor: pointer; font-size: 1.25rem; color: var(--muted); }
    .history-close:hover { background: #e4eaef; color: var(--ink); }
    .history-filter-tabs {
      display: flex;
      gap: 6px;
      padding: 10px 16px 0;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }
    .history-filter-btn {
      padding: 7px 14px;
      border: 1px solid var(--field-border);
      border-radius: 20px;
      background: transparent;
      font: inherit;
      font-size: 0.82rem;
      font-weight: 600;
      color: var(--muted-strong);
      cursor: pointer;
      transition: all 0.15s;
      min-height: 34px;
    }
    .history-filter-btn:hover {
      background: var(--surface-subtle);
      border-color: var(--field-border-hover);
    }
    .history-filter-btn.active {
      background: var(--brand-navy);
      color: #fff;
      border-color: var(--brand-navy);
    }
    .history-list { flex: 1; overflow-y: auto; padding: 12px 16px; }
    .history-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
    .history-item:hover { border-color: var(--primary); background: rgba(0,87,255,0.02); }
    .history-item-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; gap: 8px; }
    .history-item-qn { font-size: 0.72rem; font-weight: 700; color: var(--muted); font-family: monospace; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
    .history-item-icon { font-size: 1.15rem; line-height: 1; flex-shrink: 0; }
    .history-item-qn-text { font-family: inherit; }
    .history-item-date { font-size: 0.7rem; color: var(--muted); }
    .history-item-route { font-weight: 600; font-size: 0.875rem; margin-bottom: 4px; }
    .history-item-total { font-size: 0.875rem; color: var(--primary); font-weight: 700; }
    .history-item-shipper { font-size: 0.78rem; color: var(--muted); }
    .history-type-badge {
      display: inline-flex;
      align-items: center;
      padding: 2px 7px;
      border-radius: 10px;
      font-size: 0.65rem;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      margin-left: 4px;
    }
    .history-type-badge.quotation {
      background: rgba(0, 87, 255, 0.1);
      color: var(--primary);
    }
    .history-type-badge.invoice {
      background: rgba(0, 196, 140, 0.12);
      color: var(--accent);
    }
    .history-item-modes {
      font-size: 0.85rem;
      margin-right: 4px;
    }
    .history-item-date-extra {
      font-size: 0.72rem;
      color: var(--muted);
      margin-top: 3px;
    }
    .history-empty { text-align: center; padding: 40px 20px; color: var(--muted); }
    .history-empty .history-empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
    .history-loading { text-align: center; padding: 24px; color: var(--muted); font-size: 0.875rem; }
    .history-upgrade-banner { position: sticky; bottom: 0; border-top: 1px solid var(--border); background: var(--surface-subtle); padding: 10px 12px; display: none; gap: 8px; align-items: center; justify-content: space-between; }
    .history-upgrade-banner p { margin: 0; font-size: 0.78rem; color: var(--muted-strong); }
    .history-upgrade-banner button { border: 1px solid var(--field-border); background: #fff; border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 0.78rem; font-weight: 700; cursor: pointer; }
    .history-upgrade-banner button:hover { border-color: var(--orange); color: var(--orange); }

    .plan-compare-header { text-align: center; margin-bottom: 4px; }
    .plan-compare-header h2 { margin: 0 0 6px; font-size: 1.35rem; font-weight: 800; color: var(--brand-navy); }
    .plan-compare-header p { margin: 0; color: var(--muted); font-size: 0.84rem; }
    .plan-compare-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin: 18px 0 12px; }
    .plan-col { border: 2px solid var(--border); border-radius: 12px; padding: 18px 14px 14px; text-align: center; display: flex; flex-direction: column; }
    .plan-col.highlight { border-color: var(--orange); box-shadow: 0 4px 18px rgba(232,84,26,0.10); }
    .plan-col-badge { display: inline-block; background: var(--orange); color: #fff; font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 2px 8px; border-radius: 20px; margin-bottom: 6px; }
    .plan-col h3 { margin: 0 0 4px; font-size: 1.05rem; font-weight: 700; }
    .plan-col .price { font-size: 1.3rem; font-weight: 800; color: var(--orange); margin-bottom: 14px; }
    .plan-col .price small { font-size: 0.68rem; color: var(--muted); display: block; font-weight: 400; }
    .plan-col ul { list-style: none; padding: 0; margin: 0 0 14px; text-align: left; font-size: 0.78rem; flex: 1; }
    .plan-col ul li { padding: 5px 0; border-bottom: 1px solid #f0f4f8; display: flex; gap: 6px; }
    .plan-col ul li:last-child { border-bottom: none; }
    .plan-col ul li .ck { color: var(--accent); font-weight:700; flex-shrink:0; }
    .plan-col ul li .no { color: #cbd5e0; flex-shrink:0; }
    .plan-col ul li.soon { color: var(--muted); }
    .plan-col-btn { width:100%; padding: 11px; border-radius: var(--radius-sm); font: inherit; font-weight: 600; font-size: 0.875rem; cursor:pointer; border: 1.5px solid var(--field-border); background: #fff; margin-top: auto; transition: border-color 0.15s, color 0.15s; }
    .plan-col-btn:hover { border-color: var(--orange); color: var(--orange); }
    .plan-col-btn.btn-primary { background: var(--orange); color: #fff; border-color: var(--orange); }
    .plan-col-btn.btn-primary:hover { background: #c94410; border-color: #c94410; color: #fff; }
    .plan-compare-footnote { margin: 0; font-size: 0.72rem; color: var(--muted); line-height: 1.45; text-align: center; }

    /* Mobile */
    .preview-toggle-wrap { display: none; width: 100%; justify-content: center; }
    .preview-toggle-btn { width: 100%; margin: 0; max-width: calc(100% - 32px); padding: 12px 16px; min-height: 50px; border-radius: var(--radius-sm); border: 1px solid var(--field-border); background: var(--card); font: inherit; font-weight: 700; font-size: 0.95rem; color: var(--ink); cursor: pointer; box-shadow: var(--shadow); }
    .mobile-sticky-bar { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 150; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: rgba(255,255,255,0.96); border-top: 1px solid var(--border); box-shadow: 0 -4px 24px rgba(15,20,25,0.08); gap: 10px; align-items: stretch; }
    .mobile-sticky-bar .btn { flex: 1; min-height: 50px; font-size: 0.95rem; }

    /* Settings drawer */
    .settings-drawer-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 280;
      background: rgba(15,20,25,0.4);
    }
    .settings-drawer-overlay.open { display: block; }

    .settings-drawer {
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 281;
      max-height: 80vh;
      background: var(--card);
      border-radius: 20px 20px 0 0;
      box-shadow: 0 -8px 40px rgba(15,20,25,0.15);
      padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
      transform: translateY(100%);
      transition: transform 0.28s cubic-bezier(0.32,0.72,0,1);
      overflow-y: auto;
    }
    .settings-drawer-overlay.open .settings-drawer {
      transform: translateY(0);
    }

    .settings-drawer-close {
      position: absolute;
      top: 14px;
      right: 14px;
      width: 36px;
      height: 36px;
      border: none;
      background: var(--surface-subtle);
      border-radius: 50%;
      font-size: 1.2rem;
      cursor: pointer;
      color: var(--muted-strong);
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .settings-drawer-close:hover { background: var(--surface-strong); }

    .settings-menu-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .settings-menu-item {
      display: flex;
      align-items: center;
      gap: 14px;
      width: 100%;
      padding: 16px 18px;
      min-height: 60px;
      border: 1px solid var(--border);
      border-radius: 14px;
      background: var(--surface-subtle);
      font: inherit;
      font-size: 1rem;
      font-weight: 600;
      color: var(--ink);
      cursor: pointer;
      text-align: start;
      transition: background 0.15s, border-color 0.15s;
      box-sizing: border-box;
    }
    .settings-menu-item:hover,
    .settings-menu-item:active {
      background: var(--surface-strong);
      border-color: var(--field-border-hover);
    }

    #smHistory { border-color: rgba(0,87,255,0.2); }
    #smHistory:hover { background: rgba(0,87,255,0.05); }
    /* Use left sidebar / bottom tabs for History — not in settings drawer */
    #smHistory { display: none !important; }

    .settings-menu-icon {
      font-size: 1.4rem;
      line-height: 1;
      flex-shrink: 0;
      width: 28px;
      text-align: center;
    }
    .settings-menu-label {
      flex: 1;
      font-size: 1rem;
      font-weight: 700;
    }
    .settings-menu-current {
      font-size: 0.82rem;
      color: var(--muted);
      font-weight: 500;
      margin-right: 4px;
    }
    .settings-menu-chev {
      flex-shrink: 0;
      opacity: 0.35;
    }
    .settings-menu-item-link {
      text-decoration: none;
    }

    .settings-panel-header {
      display: flex;
      align-items: center;
      gap: 12px;
      margin-bottom: 16px;
      padding-bottom: 14px;
      border-bottom: 1px solid var(--border);
    }
    .settings-back-btn {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 36px;
      height: 36px;
      border: none;
      background: var(--surface-subtle);
      border-radius: 10px;
      cursor: pointer;
      flex-shrink: 0;
    }
    .settings-back-btn:hover { background: var(--surface-strong); }

    .settings-option-list {
      display: flex;
      flex-direction: column;
      gap: 6px;
      max-height: 52vh;
      overflow-y: auto;
    }
    .settings-option-list button {
      display: flex;
      align-items: center;
      gap: 10px;
      width: 100%;
      padding: 13px 14px;
      min-height: 50px;
      border: 1px solid var(--field-border);
      border-radius: var(--radius-sm);
      background: var(--surface-subtle);
      font: inherit;
      font-size: 0.95rem;
      text-align: start;
      cursor: pointer;
      color: var(--ink);
    }
    .settings-option-list button:hover { background: var(--surface-strong); }
    .settings-option-list button[aria-selected="true"] {
      border-color: var(--orange);
      background: rgba(232,84,26,0.08);
      font-weight: 600;
    }

    .nav-settings-btn { display: none; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card); font-size: 1.25rem; cursor: pointer; }
    .nav-settings-btn:hover { background: #f5f7fa; }

    .sr-only {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0,0,0,0);
      white-space: nowrap;
      border: 0;
    }
    .skip-link {
      position: absolute;
      top: -40px;
      left: 16px;
      z-index: 10000;
      padding: 8px 16px;
      background: var(--primary);
      color: #fff;
      border-radius: var(--radius-sm);
      font-size: 0.875rem;
      font-weight: 600;
      transition: top 0.2s;
    }
    .skip-link:focus {
      top: 8px;
    }

    /* ─── Left Sidebar Toolbar ─── */
    :root { --sidebar-w: 92px; }

    .left-sidebar {
      position: fixed;
      top: var(--nav-h);
      left: 0;
      bottom: 0;
      width: var(--sidebar-w);
      background: var(--card);
      border-right: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 12px 0;
      gap: 4px;
      z-index: 100;
      overflow: hidden;
    }
    .sidebar-tool-btn {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      width: 82px;
      min-height: 62px;
      border: none;
      border-radius: var(--radius-sm);
      background: transparent;
      cursor: pointer;
      color: var(--muted-strong);
      text-decoration: none;
      transition: background 0.15s, color 0.15s;
      padding: 6px 4px;
      font-family: inherit;
    }
    .sidebar-tool-btn:hover {
      background: var(--surface-subtle);
      color: var(--ink);
    }
    .sidebar-tool-btn.active {
      background: rgba(232,84,26,0.08);
      color: #a63a14;
    }
    .sidebar-icon {
      font-size: 1.2rem;
      line-height: 1;
      margin-bottom: 3px;
      display: block;
    }
    .sidebar-label {
      font-size: 0.72rem;
      font-weight: 600;
      letter-spacing: 0.01em;
      text-align: center;
      line-height: 1.2;
      display: block;
    }

    /* ─── DG Checker Module ─── */
    #moduleDgChecker {
      max-width: 1160px;
      margin: 10px auto;
      padding: 0 16px;
    }
    @media (min-width: 769px) {
      #moduleDgChecker { margin-left: calc(var(--sidebar-w) + 18px); margin-right: 18px; }
    }
    #moduleConverter {
      max-width: 1160px;
      margin: 18px auto;
      padding: 0 16px;
    }
    @media (min-width: 769px) {
      #moduleConverter { margin-left: calc(var(--sidebar-w) + 18px); margin-right: 18px; }
    }
    /* ─── Rostering Module ─── */
    #moduleRostering,
    #moduleNotoc,
    #moduleUld {
      max-width: 1160px;
      margin: 18px auto;
      padding: 0 16px;
    }
    @media (min-width: 769px) {
      #moduleRostering,
      #moduleNotoc,
      #moduleUld { margin-left: calc(var(--sidebar-w) + 18px); margin-right: 18px; }
    }
    .module-sheet-card-icon-wrap--roster {
      background: linear-gradient(145deg, #7c3aed, #5b21b6);
    }
    .conv-container {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 14px;
      box-shadow: 0 8px 30px rgba(15,23,42,0.08);
      padding: 18px 20px 24px;
    }
    .conv-stack { display: grid; gap: 14px; }
    .conv-card {
      border-radius: 12px;
      border: 1px solid var(--border);
      padding: 14px;
      background: var(--card);
      box-shadow: var(--shadow);
    }
    .conv-card-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 12px;
    }
    .conv-card-title {
      margin: 0;
      font-size: 1rem;
      font-weight: 700;
      color: var(--brand-navy);
    }
    .conv-grid-2,
    .conv-grid-3,
    .conv-grid-4 {
      display: grid;
      gap: 10px;
    }
    .conv-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .conv-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .conv-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .conv-field-label {
      display: block;
      font-size: 0.875rem;
      font-weight: 600;
      margin-bottom: 8px;
      color: var(--ink);
    }
    .conv-field-sub {
      margin-top: 6px;
      font-size: 0.74rem;
      color: var(--muted);
    }
    .conv-unit-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
      gap: 8px;
      align-items: end;
    }
    .conv-eq {
      min-height: 44px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 1rem;
      font-weight: 700;
      color: var(--muted-strong);
    }
    .conv-swap-btn {
      width: 44px;
      min-width: 44px;
      height: 44px;
      border-radius: 10px;
      border: 1px solid var(--border);
      background: var(--surface-subtle);
      color: var(--brand-navy);
      font: inherit;
      font-size: 1.1rem;
      font-weight: 700;
      cursor: pointer;
    }
    .conv-swap-btn:hover { background: var(--surface-strong); }
    .conv-result-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
      margin-top: 12px;
    }
    .conv-result-item {
      border: 1px solid var(--border);
      border-radius: 10px;
      background: var(--surface-subtle);
      padding: 10px 12px;
    }
    .conv-result-label {
      font-size: 0.76rem;
      font-weight: 700;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .conv-result-value {
      margin-top: 6px;
      font-size: 1rem;
      font-weight: 700;
      color: var(--brand-navy);
    }
    .conv-charge-box {
      margin-top: 12px;
      border-radius: 12px;
      padding: 14px;
      color: #fff;
      background: var(--accent);
      box-shadow: 0 10px 24px rgba(0,0,0,0.12);
    }
    .conv-charge-top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }
    .conv-charge-title {
      font-size: 0.82rem;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      opacity: 0.95;
    }
    .conv-charge-win {
      font-size: 0.82rem;
      font-weight: 700;
      opacity: 0.95;
    }
    .conv-charge-value {
      margin-top: 8px;
      font-size: 1.7rem;
      font-weight: 800;
      line-height: 1.1;
    }
    .conv-actions {
      display: flex;
      justify-content: flex-end;
      gap: 8px;
      margin-top: 14px;
      flex-wrap: wrap;
    }
    .conv-btn-outline {
      min-height: 42px;
      border-radius: 10px;
      border: 1px solid var(--brand-navy);
      background: transparent;
      color: var(--brand-navy);
      font: inherit;
      font-weight: 700;
      cursor: pointer;
      padding: 0 14px;
    }
    .conv-btn-outline:hover { background: var(--surface-subtle); }
    .conv-btn-fill {
      min-height: 42px;
      border-radius: 10px;
      border: none;
      background: var(--brand-navy);
      color: #fff;
      font: inherit;
      font-weight: 700;
      cursor: pointer;
      padding: 0 14px;
    }
    .conv-btn-fill:hover { opacity: 0.92; }
    .conv-note {
      margin-top: 10px;
      font-size: 0.78rem;
      color: var(--muted-strong);
      line-height: 1.5;
    }
    .dg-container {
      background: var(--card);
      border: 1px solid var(--border);
      border-radius: 14px;
      box-shadow: 0 8px 30px rgba(15,23,42,0.08);
      min-height: calc(100vh - var(--nav-h) - 36px);
    }
    .dg-header {
      position: relative; z-index: 1;
      background: var(--card); border-bottom: 1px solid var(--border);
      padding: 12px 16px; border-radius: 14px 14px 0 0;
    }
    .dg-header-row { display: flex; align-items: center; gap: 12px; }
    .dg-header-logo { height: 34px; width: 34px; border-radius: 8px; object-fit: cover; }
    .dg-header-title { font-size: 1.02rem; font-weight: 800; color: var(--brand-navy); margin: 0; }
    .dg-header-sub { font-size: 0.75rem; color: var(--muted); margin: 0; }
    .dg-beta-banner {
      margin-top: 12px; border-radius: 8px;
      background: rgba(255,102,0,0.1); border: 1px solid #FF6600;
      padding: 8px 12px; font-size: 0.875rem; font-weight: 600; color: #FF6600;
    }
    .dg-auth-notice {
      margin-top: 8px; border-radius: 8px;
      border: 1px solid var(--border); padding: 8px 12px;
      font-size: 0.875rem; display: none;
    }
    .dg-auth-notice.dg-error { display: block; border-color: #fecaca; background: #fef2f2; color: #dc2626; }
    .dg-auth-notice.dg-info { display: block; border-color: var(--border); background: var(--surface-subtle); color: var(--muted-strong); }
    .dg-login-btn {
      display: none; margin-top: 8px;
      height: 44px; min-width: 120px; border-radius: 8px;
      background: var(--brand-navy); color: #fff;
      font-weight: 600; font-size: 0.875rem;
      border: none; cursor: pointer; padding: 0 16px;
    }
    .dg-main { padding: 14px 16px 22px; }
    .dg-search-section { margin-top: 10px; }
    .dg-search-tabs {
      display: flex;
      gap: 8px;
      padding: 6px;
      background: var(--surface-subtle);
      border: 1px solid var(--border);
      border-radius: 12px;
    }
    .dg-search-tab {
      flex: 1;
      min-height: 44px;
      border-radius: 10px;
      border: 1px solid transparent;
      background: transparent;
      color: var(--muted-strong);
      font: inherit;
      font-weight: 800;
      cursor: pointer;
      transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }
    .dg-search-tab:hover { background: rgba(27,43,94,0.06); }
    .dg-search-tab.dg-tab-active {
      background: var(--card);
      border-color: var(--brand-navy);
      color: var(--brand-navy);
      box-shadow: 0 6px 18px rgba(15,23,42,0.08);
    }
    .dg-search-panel { margin-top: 12px; }
    .dg-input-group {
      display: flex;
      align-items: stretch;
      gap: 10px;
    }
    .dg-input-field {
      flex: 1;
      min-width: 0;
      height: 48px;
      border-radius: 12px;
      border: 1px solid var(--field-border);
      padding: 0 14px;
      font: inherit;
      font-size: 16px;
      background: var(--field-bg);
      color: var(--ink);
      box-shadow: 0 1px 0 rgba(15,23,42,0.04);
    }
    .dg-input-field:focus {
      outline: none;
      border-color: var(--brand-navy);
      box-shadow: 0 0 0 3px rgba(27,43,94,0.15);
    }
    .dg-search-btn {
      height: 48px;
      border-radius: 12px;
      border: 1px solid var(--brand-navy);
      background: var(--brand-navy);
      color: #fff;
      font: inherit;
      font-weight: 800;
      padding: 0 16px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      white-space: nowrap;
      transition: transform 0.08s ease, opacity 0.15s ease;
    }
    .dg-search-btn:hover { opacity: 0.92; }
    .dg-search-btn:active { transform: translateY(1px); }
    .dg-hint { margin: 10px 2px 0; font-size: 0.82rem; color: var(--muted-strong); line-height: 1.4; }
    .dg-results-container { margin-top: 16px; }
    @media (max-width: 520px) {
      .dg-input-group { flex-direction: column; }
      .dg-search-btn { width: 100%; }
    }
    .dg-tabs {
      display: grid; grid-template-columns: repeat(3, 1fr);
      gap: 8px; margin-top: 12px;
    }
    .dg-tab-btn {
      min-height: 44px; border: 1px solid var(--border); border-radius: 10px;
      background: var(--surface-subtle); font-size: 0.875rem; font-weight: 700;
      color: var(--muted-strong); cursor: pointer; transition: all 0.15s;
    }
    .dg-tab-btn:hover { background: var(--surface-strong); }
    .dg-tab-btn.dg-tab-active { color: var(--brand-navy); border-color: var(--brand-navy); background: var(--card); }
    .dg-tab-btn[disabled] {
      opacity: 0.55;
      cursor: not-allowed;
      background: var(--surface-subtle);
      color: var(--muted);
      border-color: var(--border);
    }
    .dg-tab-btn[disabled]:hover { background: var(--surface-subtle); }
    .dg-card {
      border-radius: 12px; border: 1px solid var(--border);
      padding: 12px; background: var(--card); box-shadow: var(--shadow);
    }
    .dg-card + .dg-card { margin-top: 12px; }
    .dg-input {
      width: 100%; height: 44px; border-radius: 8px;
      border: 1px solid var(--field-border); padding: 0 12px;
      font: inherit; font-size: 1rem; color: var(--ink);
      background: var(--field-bg);
    }
    .dg-input:focus { outline: none; border-color: var(--brand-navy); box-shadow: 0 0 0 3px rgba(27,43,94,0.15); }
    .dg-select {
      height: 44px; border-radius: 8px; border: 1px solid var(--field-border);
      padding: 0 8px; font: inherit; background: var(--field-bg); color: var(--ink);
    }
    .dg-btn-navy {
      height: 44px; min-width: 84px; border-radius: 8px;
      background: var(--brand-navy); color: #fff; font-weight: 600;
      border: none; cursor: pointer; padding: 0 12px; font: inherit;
    }
    .dg-btn-navy:hover { opacity: 0.9; }
    .dg-btn-navy-full { width: 100%; height: 48px; border-radius: 8px; background: var(--brand-navy); color: #fff; font-weight: 700; font-size: 1rem; border: none; cursor: pointer; }
    .dg-btn-navy-full:hover { opacity: 0.9; }
    .dg-row { display: flex; gap: 8px; }
    .dg-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .dg-grid-3-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
    .dg-label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 8px; color: var(--ink); }
    .dg-substance-card {
      border-radius: 8px; background: var(--surface-subtle);
      border: 1px solid var(--border); padding: 12px;
      font-size: 0.875rem; color: var(--muted-strong);
    }
    .dg-aircraft-btn {
      height: 44px; border-radius: 8px; border: 1px solid var(--border);
      font-weight: 600; cursor: pointer; background: var(--card);
      font: inherit; color: var(--ink);
    }
    .dg-aircraft-btn.dg-aircraft-active {
      background: var(--brand-navy); color: #fff; border-color: var(--brand-navy);
    }
    .dg-result { border-radius: 12px; border: 1px solid var(--border); padding: 16px; box-shadow: var(--shadow); display: none; }
    .dg-result.dg-result-pass { display: block; background: #f0fdf4; border-color: #22C55E; color: #166534; }
    .dg-result.dg-result-fail { display: block; background: #fef2f2; border-color: #EF4444; color: #991b1b; }
    .dg-result.dg-result-warn { display: block; background: #fffbeb; border-color: #F59E0B; color: #92400e; }
    .dg-result-title { font-size: 1.125rem; font-weight: 700; }
    .dg-result-meta { margin-top: 8px; font-size: 0.875rem; }
    .dg-result-list { margin: 8px 0 0; padding-left: 20px; font-size: 0.875rem; }
    .dg-lookup-article {
      border-radius: 12px; border: 1px solid var(--border);
      padding: 12px; box-shadow: var(--shadow); background: var(--card);
    }
    .dg-lookup-article + .dg-lookup-article { margin-top: 12px; }
    .dg-lookup-title { font-weight: 700; font-size: 1rem; }
    .dg-lookup-meta { margin-top: 8px; font-size: 0.875rem; }
    .dg-class-diamond {
      display: inline-block; width: 20px; height: 20px;
      transform: rotate(45deg); border: 1px solid var(--border);
    }
    .dg-class-1 { background: #f97316; } .dg-class-2 { background: #22c55e; }
    .dg-class-3 { background: #ef4444; } .dg-class-4 { background: #b91c1c; }
    .dg-class-5 { background: #eab308; } .dg-class-6 { background: #f8fafc; }
    .dg-class-7 { background: #fde047; } .dg-class-8 { background: #1e293b; }
    .dg-class-9 { background: #64748b; }
    .dg-disclaimer {
      margin-top: 16px; border: 1px solid var(--border); border-radius: 10px;
      background: var(--surface-subtle); padding: 10px 12px;
      font-size: 0.74rem; line-height: 1.5; color: var(--muted-strong);
    }
    .dg-space { margin-top: 12px; }
    .dg-hidden { display: none !important; }

    /* ── DG enhanced UI ── */
    .dg-tabs {
      display: flex; overflow-x: auto; gap: 6px; margin-top: 12px;
      scrollbar-width: none; -webkit-overflow-scrolling: touch;
    }
    .dg-tabs::-webkit-scrollbar { display: none; }
    .dg-tab-btn { flex: 0 0 auto; min-width: 96px; }
    .dg-toggle-group { display: flex; gap: 6px; flex-wrap: wrap; }
    .dg-toggle-btn {
      flex: 1; min-width: 80px; min-height: 44px; border-radius: 8px;
      border: 1px solid var(--border); font: inherit; font-weight: 600;
      font-size: 0.875rem; cursor: pointer; background: var(--card);
      color: var(--muted-strong); transition: all 0.15s;
    }
    .dg-toggle-btn.active-green { background: #f0fdf4; border-color: #22c55e; color: #166534; }
    .dg-toggle-btn.active-red   { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
    .dg-toggle-btn.active-amber { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
    .dg-toggle-btn.active-navy  { background: var(--brand-navy); border-color: var(--brand-navy); color: #fff; }
    .dg-result-section { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(0,0,0,0.07); }
    .dg-result-section-title { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 6px; opacity: 0.75; }
    .dg-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; }
    .dg-badge-green { background: #dcfce7; color: #166534; }
    .dg-badge-red   { background: #fee2e2; color: #991b1b; }
    .dg-badge-amber { background: #fef3c7; color: #92400e; }
    .dg-badge-blue  { background: #dbeafe; color: #1e40af; }
    .dg-result-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
    .dg-btn-outline {
      flex: 1; min-height: 40px; border-radius: 8px; border: 1px solid var(--brand-navy);
      background: transparent; color: var(--brand-navy); font: inherit; font-weight: 600;
      font-size: 0.875rem; cursor: pointer;
    }
    .dg-btn-outline:hover { background: var(--surface-subtle); }

    /* Checklist */
    .dg-checklist-item {
      display: flex; align-items: flex-start; gap: 10px;
      padding: 10px 0; border-bottom: 1px solid var(--border);
    }
    .dg-checklist-item:last-child { border-bottom: none; }
    .dg-checklist-checkbox {
      width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px;
      accent-color: var(--brand-navy); cursor: pointer;
    }
    .dg-checklist-label { font-size: 0.875rem; line-height: 1.5; color: var(--ink); }
    .dg-checklist-category { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em;
      text-transform: uppercase; color: var(--muted); margin: 14px 0 4px; }

    /* History table */
    .dg-history-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
    .dg-history-table th { text-align: left; padding: 8px 10px; font-weight: 700; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 2px solid var(--border); }
    .dg-history-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
    .dg-history-table tr:last-child td { border-bottom: none; }
    .dg-history-table tr.expandable { cursor: pointer; }
    .dg-history-table tr.expandable:hover td { background: var(--surface-subtle); }
    .dg-history-detail { background: var(--surface-subtle); }
    .dg-history-detail td { font-size: 0.8rem; color: var(--muted-strong); }
    .dg-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
    .dg-filter-select { height: 36px; border-radius: 8px; border: 1px solid var(--field-border); padding: 0 8px; font: inherit; font-size: 0.875rem; background: var(--field-bg); color: var(--ink); }
    .dg-filter-input { height: 36px; border-radius: 8px; border: 1px solid var(--field-border); padding: 0 10px; font: inherit; font-size: 0.875rem; background: var(--field-bg); color: var(--ink); flex: 1; min-width: 120px; }
    .dg-empty-state { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 0.9rem; }
    .dg-empty-state-icon { font-size: 2rem; margin-bottom: 8px; }
    .dg-loading { text-align: center; padding: 32px; color: var(--muted); font-size: 0.875rem; }

    /* Reference card enhancements */
    .dg-ref-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
    .dg-ref-class-card {
      border-radius: 12px; border: 1px solid var(--border); padding: 14px 10px;
      cursor: pointer; transition: all 0.15s; text-align: center;
      background: var(--card);
    }
    .dg-ref-class-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); transform: translateY(-2px); }
    .dg-ref-class-card.active { border-color: var(--brand-navy); background: #f0f4ff; }
    .dg-ref-diamond {
      width: 36px; height: 36px; transform: rotate(45deg);
      margin: 0 auto 12px; border: 1px solid rgba(0,0,0,0.2);
    }
    .dg-ref-class-num { font-size: 1.25rem; font-weight: 800; color: var(--ink); }
    .dg-ref-class-name { font-size: 0.7rem; color: var(--muted-strong); margin-top: 2px; line-height: 1.3; }
    .dg-ref-detail { background: var(--surface-subtle); border-radius: 12px; border: 1px solid var(--border); padding: 16px; }
    .dg-ref-search { margin-bottom: 16px; }

    /* Print styles for checklist */
    @media print {
      .dg-checklist-print-only { display: block !important; }
      .dg-no-print { display: none !important; }
    }
    .dg-checklist-print-only { display: none; }

    /* Print */
    @media print {
      @page { margin: 14mm; size: A4; }
      body { background: #fff; }
      .no-print, .topnav, .split-left, .site-footer, .preview-toolbar, .preview-actions,
      .mobile-sticky-bar, .preview-toggle-btn, .settings-drawer-overlay, .nav-settings-btn,
      .history-overlay, #moduleDgChecker, #moduleConverter, #moduleRostering, #moduleNotoc, #moduleUld { display: none !important; }
      .split-container { display: block; max-width: 100%; margin: 0; min-height: 0; }
      .split-right { flex: none !important; max-width: 100% !important; width: 100%; position: static !important; height: auto !important; border: none !important; background: #fff !important; overflow: visible !important; display: block !important; }
      .preview-scroll { padding: 0 !important; overflow: visible !important; display: block !important; }
      .preview-scale-outer, .preview-scale-inner { transform: none !important; width: 100% !important; display: block !important; }
      .preview-doc { width: 100% !important; max-width: 100% !important; box-shadow: none !important; border-radius: 0 !important; padding: 8mm 10mm 12mm !important; font-size: 11pt !important; }
    }

    /* Tablet */
    @media (min-width: 769px) and (max-width: 1024px) {
      :root { --sidebar-w: 80px; }
      body {
        background: linear-gradient(180deg, var(--bg) 0%, var(--surface-subtle) 100%);
        padding-bottom: calc(88px + env(safe-area-inset-bottom));
        scroll-padding-bottom: calc(100px + env(safe-area-inset-bottom));
      }
      .left-sidebar { width: 80px; }
      .sidebar-tool-btn { width: 72px; min-height: 54px; padding: 8px 4px; }
      .nav-inner { padding: 0 16px; }
      .brand-name { font-size: 1.6rem; }
      .hero {
        margin-bottom: 16px;
      }
      .split-left {
        flex: 0 0 46% !important;
        max-width: 46% !important;
        padding: 24px 20px 64px !important;
        font-size: 15px;
      }
      .split-right {
        flex: 0 0 54% !important;
        max-width: 54% !important;
      }
      .hero h1 { font-size: 1.3rem; }
      .form-card {
        padding: 24px 20px 28px;
        border-radius: 20px;
        box-shadow: 0 18px 44px rgba(15,20,25,0.10);
      }
      .grid { grid-template-columns: repeat(2, 1fr); }
      .doc-type-toggle button {
        font-size: 0.9rem;
        min-height: 46px;
      }
      .preview-scroll { padding: 16px 14px 28px; }
      .preview-doc {
        font-size: 0.86rem;
        padding: 22px 22px 26px;
        border-radius: 18px;
        box-shadow: 0 18px 48px rgba(15,20,25,0.12);
      }
      .section-title { font-size: 0.8rem; }
      .btn { padding: 8px 14px; font-size: 0.86rem; min-height: 40px; }
      #moduleDgChecker,
      #moduleConverter,
      #moduleRostering,
      #moduleNotoc,
      #moduleUld {
        margin-top: 24px;
      }
      .dg-container,
      .conv-container {
        border-radius: 22px;
        box-shadow: 0 18px 48px rgba(15,20,25,0.10);
        overflow: hidden;
      }
    }

    @media (min-width: 769px) {
      .split-container {
        margin-left: var(--sidebar-w);
      }
      .site-footer {
        margin-left: var(--sidebar-w);
      }
    }

    /* Mobile */
    @media (max-width: 768px) {
      :root { --nav-h: 56px; }
      body {
        background: linear-gradient(180deg, var(--bg) 0%, var(--surface-subtle) 100%);
        padding-bottom: calc(92px + env(safe-area-inset-bottom));
        scroll-padding-bottom: calc(112px + env(safe-area-inset-bottom));
      }

      .left-sidebar { display: none !important; }
      .split-container { margin-left: 0 !important; }
      .site-footer { margin-left: 0 !important; }

      .nav-desktop-only { display: none !important; }
      .nav-settings-btn { display: inline-flex !important; }
      .mobile-sticky-bar { display: flex !important; }

      .nav-inner {
        padding: 0 14px;
        gap: 8px;
        height: 56px;
      }
      .nav-brand > img { height: 32px !important; }
      .brand-name { font-size: 1.5rem !important; }
      .brand-zh { font-size: 0.92rem !important; }
      .brand-sep { display: none; }
      .brand-tagline { display: none; }

      .nav-actions {
        gap: 6px;
        flex-wrap: nowrap;
      }
      .plan-badge {
        padding: 3px 8px;
        font-size: 0.68rem;
      }
      #btnNavLogin {
        padding: 7px 12px;
        font-size: 0.82rem;
        min-height: 38px;
      }
      #btnNavSignup {
        padding: 7px 12px;
        font-size: 0.82rem;
        min-height: 38px;
      }

      .hero {
        margin-bottom: 14px;
        padding: 4px 4px 0;
      }
      .hero h1 {
        font-size: 1.3rem !important;
        letter-spacing: -0.02em;
        margin-bottom: 0;
      }

      .form-card {
        padding: 18px 16px 22px !important;
        border-radius: 18px;
        box-shadow: 0 16px 38px rgba(15,20,25,0.11);
      }
      .doc-type-toggle { margin-bottom: 16px; }
      .doc-type-toggle button {
        min-height: 44px;
        padding: 10px 8px;
        font-size: 0.88rem;
      }
      .section-title {
        font-size: 0.76rem;
        margin-bottom: 12px;
      }
      .transport-checks {
        gap: 10px 16px;
      }
      .transport-check {
        font-size: 0.88rem;
        gap: 6px;
      }
      .field label {
        font-size: 0.8rem;
        margin-bottom: 5px;
      }
      input[type="text"],
      input[type="email"],
      input[type="password"],
      input[type="number"],
      input[type="date"],
      select,
      textarea {
        min-height: 46px !important;
        font-size: 0.95rem;
        padding: 10px 11px;
      }
      textarea { min-height: 80px !important; }
      .lang-btn, .curr-btn { min-height: 48px; }

      .grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
      }
      .cw-toggle button {
        min-height: 38px;
        padding: 7px 12px;
        font-size: 0.82rem;
      }
      .cw-formula-wrap {
        grid-template-columns: 1fr !important;
        gap: 10px;
      }
      .breakdown th,
      .breakdown td {
        padding: 8px 10px;
        font-size: 0.82rem;
      }

      .split-container { flex-direction: column; min-height: auto; }
      .split-left {
        flex: none;
        max-width: 100%;
        width: 100%;
        padding: 14px 14px 10px !important;
        order: 1;
      }
      .split-right {
        flex: none;
        max-width: 100%;
        width: 100%;
        position: static;
        height: auto;
        min-height: 0;
        border-left: none;
        border-top: none;
        order: 3;
        display: none !important;
      }
      .split-right.preview-open { display: flex !important; flex-direction: column; }
      .preview-toggle-wrap { order: 2; display: flex; padding: 0 14px 10px; }
      .preview-toggle-btn {
        min-height: 48px;
        font-size: 0.92rem;
        border-radius: 14px;
        box-shadow: 0 10px 24px rgba(15,20,25,0.08);
      }
      .preview-scroll {
        padding: 12px 10px 18px;
        max-height: 75vh;
      }
      .preview-doc {
        border-radius: 18px;
        box-shadow: 0 16px 40px rgba(15,20,25,0.10);
      }
      .preview-actions {
        padding: 10px 14px 14px;
        gap: 8px;
        flex-wrap: wrap;
      }
      .preview-actions .btn {
        font-size: 0.82rem;
        min-height: 42px;
        padding: 8px 10px;
        min-width: 70px;
      }

      .mobile-sticky-bar {
        padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
        gap: 8px;
      }
      #btnStickyGenerate {
        font-size: 0.92rem;
        min-height: 48px;
        font-weight: 700;
        flex: 1.5;
      }
      #btnStickyPrint {
        font-size: 0.88rem;
        min-height: 48px;
        flex: 1;
      }

      .modal-overlay {
        padding: 16px 14px;
        align-items: flex-end;
      }
      .modal-card {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        padding: 24px 18px 20px;
        max-height: 92vh;
        overflow-y: auto;
      }
      .modal-card h2 { font-size: 1.1rem; }
      .upgrade-modal-plans {
        grid-template-columns: 1fr !important;
        gap: 12px;
      }
      .upgrade-modal-header h2 { font-size: 1.15rem; }
      .upgrade-modal-guarantee { flex-wrap: wrap; gap: 10px; }

      .settings-drawer {
        padding: 18px 16px calc(22px + env(safe-area-inset-bottom));
        max-height: 85vh;
        border-radius: 26px 26px 0 0;
        box-shadow: 0 -18px 48px rgba(15,20,25,0.18);
      }
      #settingsDrawerTitle {
        font-size: 1rem !important;
        margin-bottom: 14px !important;
      }
      .settings-menu-item {
        padding: 14px 16px;
        min-height: 56px;
        font-size: 0.95rem;
      }
      .settings-option-list button {
        min-height: 46px;
        font-size: 0.9rem;
        padding: 10px 12px;
      }
      .conv-grid-2,
      .conv-grid-3,
      .conv-grid-4,
      .conv-unit-row {
        grid-template-columns: 1fr !important;
      }
      .conv-container {
        padding: 14px;
        border-radius: 22px;
        box-shadow: 0 18px 42px rgba(15,20,25,0.12);
      }
      .conv-card {
        padding: 12px;
        border-radius: 16px;
      }
      .conv-card-head,
      .conv-charge-top {
        flex-direction: column;
        align-items: flex-start;
      }
      .conv-result-grid {
        grid-template-columns: 1fr;
      }
      .conv-charge-value {
        font-size: 1.45rem;
      }
      #moduleDgChecker,
      #moduleConverter,
      #moduleRostering,
      #moduleNotoc,
      #moduleUld {
        margin: 10px auto 0;
        padding: 0 12px;
      }
      .dg-container {
        border-radius: 22px;
        box-shadow: 0 18px 42px rgba(15,20,25,0.12);
        overflow: hidden;
      }
.history-drawer { top: 0; width: 100vw; border-radius: 0; }
      .history-header {
        padding: 14px 16px;
        padding-top: calc(14px + env(safe-area-inset-top));
      }
      .history-filter-tabs {
        padding: 8px 12px 0;
        gap: 6px;
      }
      .history-filter-btn {
        padding: 6px 12px;
        font-size: 0.78rem;
        min-height: 32px;
      }
      .history-item { padding: 10px 12px; }
      .history-item-route { font-size: 0.84rem; }
      .history-item-total { font-size: 0.84rem; }
      .plan-compare-grid { grid-template-columns: 1fr; }
      .post-quote-nudge {
        bottom: 98px;
        flex-wrap: wrap;
      }
      .mobile-sticky-bar { display: none !important; }
      body { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }

      .actions { display: none; }

      /* Progress stepper for mobile form */
      .mobile-progress-bar {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 12px 16px 0;
        margin-bottom: -4px;
      }
      .mobile-progress-step {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--border);
        transition: all 0.2s ease;
        flex-shrink: 0;
      }
      .mobile-progress-step.active {
        width: 24px;
        border-radius: 4px;
        background: var(--primary);
      }
      .mobile-progress-step.completed {
        background: var(--accent);
      }

      /* Smooth section transitions on mobile */
      .form-section {
        transition: opacity 0.2s ease, transform 0.2s ease;
      }
      .form-section.section-hidden {
        opacity: 0;
        transform: translateX(20px);
        pointer-events: none;
        position: absolute;
      }
    }
    @media (max-width: 480px) {
      .plan-compare-grid { grid-template-columns: 1fr; }
      .history-plan-cards { grid-template-columns: 1fr; }
    }
    @media (max-width: 520px) {
      .history-plan-cards { grid-template-columns: 1fr; gap: 16px; }
      .history-gate-card { padding: 20px 16px 16px; max-height: 92vh; }
      .h-plan-features li { white-space: normal; font-size: 0.7rem; }
      .modal-card { max-width: 95vw; }
    }

    /* ═══════════════════════════════════════════════════════
       Quote Calculator Modules — Rate Templates, Calculator, History
       ═══════════════════════════════════════════════════════ */
    .qc-module { display: none; }
    .qc-module.qc-active { display: block; }

    /* Module header bar */
    .qc-module-header {
      display: flex; align-items: center; justify-content: space-between;
      margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
    }
    .qc-module-header h1 { font-size: 1.35rem; font-weight: 700; margin: 0; }
    .qc-module-header .qc-header-actions { display: flex; gap: 8px; }

    /* Rate template cards grid */
    .qc-template-grid {
      display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
    }
    @media (max-width: 768px) {
      .qc-template-grid { grid-template-columns: 1fr; }
    }
    .qc-template-card {
      background: var(--card); border: 1px solid var(--border); border-radius: 12px;
      padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); position: relative;
      transition: box-shadow 0.2s, border-color 0.2s;
    }
    .qc-template-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); border-color: var(--border-strong); }
    .qc-template-card-name { font-weight: 700; font-size: 0.95rem; margin-bottom: 8px; }
    .qc-template-card-meta { font-size: 0.78rem; color: var(--muted); line-height: 1.6; }
    .qc-template-card-actions {
      display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap;
    }
    .qc-template-card-actions .qc-sm-btn {
      font-size: 0.72rem; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border);
      background: var(--surface-subtle); cursor: pointer; font-weight: 600; color: var(--ink-soft);
      transition: background 0.15s;
    }
    .qc-template-card-actions .qc-sm-btn:hover { background: var(--surface-strong); }
    .qc-template-card-actions .qc-sm-btn.qc-sm-btn-primary {
      background: var(--primary); color: #fff; border-color: var(--primary);
    }
    .qc-template-card-actions .qc-sm-btn.qc-sm-btn-primary:hover { background: var(--primary-hover); }

    /* Carrier badge */
    .qc-carrier-badge {
      display: inline-block; font-size: 0.68rem; font-weight: 700; padding: 2px 8px;
      border-radius: 99px; text-transform: uppercase; letter-spacing: 0.03em;
    }
    .qc-carrier-badge.dhl { background: #FFCC00; color: #000; }
    .qc-carrier-badge.fedex { background: #4D148C; color: #fff; }
    .qc-carrier-badge.sf { background: #E42121; color: #fff; }
    .qc-carrier-badge.ups { background: #351C15; color: #fff; }
    .qc-carrier-badge.custom, .qc-carrier-badge.ems { background: #6b7280; color: #fff; }

    /* Sheet / Drawer for template editor */
    .qc-sheet-overlay {
      position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 300;
      display: none; align-items: flex-end; justify-content: flex-end;
    }
    .qc-sheet-overlay.qc-open { display: flex; }
    .qc-sheet-drawer {
      width: min(640px, 100vw); height: 92vh; background: var(--card);
      border-radius: 16px 0 0 0; box-shadow: -4px 0 30px rgba(0,0,0,0.15);
      display: flex; flex-direction: column; overflow: hidden;
      animation: qcSlideIn 0.3s ease;
    }
    @keyframes qcSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
    .qc-sheet-header {
      display: flex; align-items: center; justify-content: space-between;
      padding: 18px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0;
    }
    .qc-sheet-header h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }
    .qc-sheet-close {
      background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--muted);
      width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
      border-radius: 8px; transition: background 0.15s;
    }
    .qc-sheet-close:hover { background: var(--surface-subtle); }
    .qc-sheet-body { padding: 20px 24px; overflow-y: auto; flex: 1; }

    /* Slab table */
    .qc-slab-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
    .qc-slab-table th {
      text-align: left; font-weight: 600; color: var(--muted); font-size: 0.72rem;
      padding: 6px 8px; border-bottom: 1px solid var(--border); text-transform: uppercase;
    }
    .qc-slab-table td { padding: 4px 6px; border-bottom: 1px solid var(--surface-subtle); vertical-align: middle; }
    .qc-slab-table input, .qc-slab-table select {
      width: 100%; padding: 6px 8px; border: 1px solid var(--field-border); border-radius: 6px;
      font-size: 0.82rem; background: var(--field-bg); transition: border-color 0.15s;
    }
    .qc-slab-table input:focus, .qc-slab-table select:focus {
      outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0,87,255,0.12);
    }
    .qc-slab-table .qc-slab-del {
      background: none; border: none; cursor: pointer; color: #ef4444; font-size: 1rem;
      padding: 4px; border-radius: 4px; transition: background 0.15s;
    }
    .qc-slab-table .qc-slab-del:hover { background: #fef2f2; }

    /* Quote Calculator layout */
    .qc-calc-layout {
      display: grid; grid-template-columns: 3fr 2fr; gap: 24px; align-items: start;
    }
    @media (max-width: 900px) {
      .qc-calc-layout { grid-template-columns: 1fr; }
    }
    .qc-calc-form { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 24px; box-shadow: var(--shadow); }
    .qc-calc-results { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 24px; box-shadow: var(--shadow); }
    .qc-section-title { font-size: 0.95rem; font-weight: 700; margin: 0 0 14px; color: var(--ink); }

    /* Chargeable weight banner */
    .qc-cw-banner {
      display: flex; gap: 16px; align-items: center; padding: 12px 16px;
      background: var(--surface-subtle); border-radius: 10px; margin-bottom: 16px;
      font-size: 0.85rem; font-weight: 600;
    }
    .qc-cw-banner.qc-volumetric-highlight { background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; }
    .qc-cw-banner span { white-space: nowrap; }
    .qc-cw-banner strong { color: var(--primary); }
    .qc-cw-banner.qc-volumetric-highlight strong { color: #B45309; }

    /* Carrier comparison table */
    .qc-comp-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
    .qc-comp-table th {
      text-align: left; padding: 8px; font-weight: 600; color: var(--muted); font-size: 0.72rem;
      border-bottom: 2px solid var(--border); text-transform: uppercase;
    }
    .qc-comp-table td { padding: 10px 8px; border-bottom: 1px solid var(--surface-subtle); }
    .qc-comp-table tr.qc-selected-row { background: rgba(0,87,255,0.06); }
    .qc-comp-table .qc-select-btn {
      padding: 4px 14px; border-radius: 6px; border: 1px solid var(--primary);
      background: #fff; color: var(--primary); cursor: pointer; font-weight: 600; font-size: 0.75rem;
      transition: all 0.15s;
    }
    .qc-comp-table .qc-select-btn:hover { background: var(--primary); color: #fff; }
    .qc-comp-table .qc-select-btn.qc-active { background: var(--primary); color: #fff; }

    /* Pricing summary card */
    .qc-pricing-card {
      margin-top: 16px; padding: 16px; background: var(--surface-subtle); border-radius: 10px;
      border: 1px solid var(--border);
    }
    .qc-pricing-card h4 { margin: 0 0 10px; font-size: 0.9rem; }
    .qc-pricing-row {
      display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.82rem;
    }
    .qc-pricing-row.qc-total { font-weight: 700; border-top: 1px solid var(--border-strong); padding-top: 8px; margin-top: 4px; font-size: 0.9rem; }

    /* Risk flag warning */
    .qc-risk-flag {
      display: flex; gap: 8px; align-items: flex-start; padding: 10px 14px;
      background: #FFFBEB; border: 1px solid #FDE68A; border-radius: 8px;
      margin-bottom: 8px; font-size: 0.78rem; color: #92400E;
    }
    .qc-risk-flag svg { flex-shrink: 0; margin-top: 1px; }

    /* Template checklist in calculator */
    .qc-tpl-checklist { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
    .qc-tpl-check-item {
      display: flex; align-items: center; gap: 10px; padding: 8px 12px;
      border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
      transition: background 0.15s, border-color 0.15s;
    }
    .qc-tpl-check-item:hover { background: var(--surface-subtle); }
    .qc-tpl-check-item input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; }

    /* Quote history table */
    .qc-history-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
    .qc-history-table th {
      text-align: left; padding: 8px; font-weight: 600; color: var(--muted);
      font-size: 0.72rem; border-bottom: 2px solid var(--border); text-transform: uppercase;
    }
    .qc-history-table td { padding: 10px 8px; border-bottom: 1px solid var(--surface-subtle); }
    .qc-history-table tr:hover { background: var(--surface-subtle); }

    /* Empty state */
    .qc-empty-state {
      text-align: center; padding: 48px 24px; color: var(--muted);
    }
    .qc-empty-state svg { width: 64px; height: 64px; margin: 0 auto 16px; opacity: 0.4; }
    .qc-empty-state h3 { font-size: 1rem; color: var(--ink-soft); margin: 0 0 6px; }
    .qc-empty-state p { font-size: 0.82rem; margin: 0 0 16px; }

    /* Upgrade CTA banner */
    .qc-upgrade-banner {
      display: flex; align-items: center; justify-content: space-between; gap: 12px;
      padding: 12px 16px; background: linear-gradient(135deg, #EEF2FF, #E0E7FF);
      border: 1px solid #C7D2FE; border-radius: 10px; margin: 12px 0;
    }
    .qc-upgrade-banner p { margin: 0; font-size: 0.82rem; color: #3730A3; }
    .qc-upgrade-banner .qc-upgrade-btn {
      padding: 6px 16px; background: #4F46E5; color: #fff; border: none; border-radius: 8px;
      font-weight: 600; font-size: 0.78rem; cursor: pointer; white-space: nowrap;
    }

    /* Collapsible section */
    .qc-collapsible-header {
      display: flex; align-items: center; justify-content: space-between; cursor: pointer;
      padding: 10px 0; user-select: none;
    }
    .qc-collapsible-header h3 { margin: 0; font-size: 0.88rem; font-weight: 600; }
    .qc-collapsible-header .qc-chevron {
      width: 18px; height: 18px; transition: transform 0.2s; color: var(--muted);
    }
    .qc-collapsible-header.qc-expanded .qc-chevron { transform: rotate(180deg); }
    .qc-collapsible-body { display: none; padding: 8px 0 12px; }
    .qc-collapsible-body.qc-expanded { display: block; }

    /* Skeleton loader */
    .qc-skeleton {
      background: linear-gradient(90deg, var(--surface-subtle) 25%, var(--surface-strong) 50%, var(--surface-subtle) 75%);
      background-size: 200% 100%; animation: qcShimmer 1.5s infinite;
      border-radius: 6px; min-height: 20px;
    }
    @keyframes qcShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

    /* Responsive overrides for new modules */
    @media (max-width: 768px) {
      .qc-sheet-drawer { width: 100vw; height: 95vh; border-radius: 16px 16px 0 0; }
      .qc-calc-layout { grid-template-columns: 1fr; }
      .signup-pro-grid { grid-template-columns: repeat(2, 1fr); }
    }

/* ========================================
   iOS & iPadOS Optimizations
   ======================================== */

/* ── iPhone SE (375x667) and smaller ── */
@media (max-width: 375px) {
  :root {
    --nav-h: 56px;
  }
  
  .split-left {
    padding: 16px 12px 48px;
  }
  
  .form-section {
    padding: 14px;
  }
  
  .input-group label {
    font-size: 0.75rem;
  }
  
  .input-field,
  select.input-field {
    min-height: 40px;
    font-size: 0.85rem;
    padding: 8px 10px;
  }
  
  .btn {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 0.85rem;
  }
  
  .preview-toolbar {
    padding: 8px 12px;
    flex-wrap: wrap;
  }
  
  .preview-scroll {
    padding: 12px 8px 20px;
  }
}

/* ── iPhone 12/13/14/15 Pro (390x844) ── */
@media (min-width: 376px) and (max-width: 428px) {
  .split-left {
    padding: 18px 16px 52px;
  }
  
  .form-section {
    padding: 16px;
  }
  
  .input-field,
  select.input-field {
    min-height: 44px;
    font-size: 0.9rem;
  }
  
  .btn {
    min-height: 44px;
    font-size: 0.88rem;
  }
}

/* ── iPhone Plus/Max models (414px+) ── */
@media (min-width: 414px) and (max-width: 430px) {
  .split-left {
    padding: 20px 18px 54px;
  }
  
  .form-section {
    padding: 18px;
  }
}

/* ── iPhone Landscape Mode ── */
@media (max-height: 500px) and (orientation: landscape) {
  .topnav {
    position: relative;
  }
  
  .split-container {
    flex-direction: column;
  }
  
  .split-left,
  .split-right {
    max-width: 100%;
    flex: 0 0 auto;
  }
  
  .split-right {
    position: relative;
    top: 0;
    height: auto;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  
  .bottom-tab-bar {
    display: none !important;
  }
}

/* ── iPad Mini & iPad (768px - 834px) ── */
@media (min-width: 768px) and (max-width: 834px) {
  :root {
    --nav-h: 60px;
  }
  
  .split-left {
    padding: 24px 20px 56px;
  }
  
  .split-right {
    flex: 0 0 45%;
    max-width: 45%;
  }
  
  .split-left {
    flex: 0 0 55%;
    max-width: 55%;
  }
  
  .form-section {
    padding: 18px;
  }
  
  .input-field,
  select.input-field {
    min-height: 46px;
    font-size: 0.92rem;
  }
  
  .btn {
    min-height: 46px;
    font-size: 0.9rem;
  }
  
  .preview-toolbar {
    padding: 14px 18px;
  }
  
  .preview-scroll {
    padding: 16px 14px 24px;
  }
  
  /* Better touch targets for iPad */
  .lang-btn,
  .curr-btn {
    min-height: 46px;
    padding: 12px 16px;
  }
  
  .tab-btn {
    min-height: 52px;
    padding: 10px 6px 12px;
  }
}

/* ── iPad Pro 11" (834px x 1194px) ── */
@media (min-width: 835px) and (max-width: 1024px) {
  .split-left {
    padding: 26px 24px 56px;
  }
  
  .split-right {
    flex: 0 0 48%;
    max-width: 48%;
  }
  
  .split-left {
    flex: 0 0 52%;
    max-width: 52%;
  }
  
  .form-section {
    padding: 20px;
  }
  
  .preview-toolbar {
    padding: 14px 20px;
  }
}

/* ── iPad Pro 12.9" (1024px+) ── */
@media (min-width: 1025px) and (max-width: 1366px) {
  .split-container {
    max-width: 1440px;
  }
  
  .split-left {
    padding: 28px 28px 56px;
  }
  
  .form-section {
    padding: 22px;
  }
}

/* ── iPad Landscape Mode ── */
@media (min-width: 1024px) and (max-height: 768px) and (orientation: landscape) {
  .split-container {
    min-height: calc(100vh - var(--nav-h));
  }
  
  .split-left {
    padding: 20px 24px 40px;
  }
  
  .split-right {
    height: calc(100vh - var(--nav-h));
  }
  
  .preview-scroll {
    padding: 12px 16px 20px;
  }
}

/* ── iOS Safe Area Support ── */
@supports (padding: max(0px)) {
  /* iPhone with notch/Dynamic Island */
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  
  .topnav {
    padding-top: env(safe-area-inset-top);
    height: calc(var(--nav-h) + env(safe-area-inset-top));
  }
  
  .split-container {
    min-height: calc(100vh - var(--nav-h) - env(safe-area-inset-top));
  }
  
  .bottom-tab-bar {
    bottom: calc(10px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .module-sheet {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  
  /* Modal adjustments for safe area */
  .modal-overlay {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ── iOS Touch Optimization ── */
@media (pointer: coarse) {
  /* Larger touch targets for iOS devices */
  .btn,
  .lang-btn,
  .curr-btn,
  .tab-btn,
  input[type="text"],
  input[type="number"],
  select {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Remove tap highlight on iOS */
  * {
    -webkit-tap-highlight-color: transparent;
  }
  
  /* Smooth scrolling for iOS */
  html {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Prevent text selection on buttons */
  .btn,
  .tab-btn,
  .lang-btn,
  .curr-btn {
    -webkit-user-select: none;
    user-select: none;
  }
}

/* ── Dark Mode Optimization for iOS ── */
@media (prefers-color-scheme: dark) {
  .modal-box {
    background: var(--card);
  }
  
  /* Ensure status bar is visible in dark mode */
  meta[name="apple-mobile-web-app-status-bar-style"] {
    content: "black-translucent";
  }
}

/* ── Print Optimization for iOS Safari ── */
@media print and (max-width: 768px) {
  @page {
    size: A4;
    margin: 10mm;
  }
  
  body {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ── Reduce Motion for Accessibility ── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── High DPI Displays (Retina) ── */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Sharper borders and shadows for Retina displays */
  .modal-card,
  .form-section,
  .preview-wrap {
    box-shadow: 0 2px 12px rgba(15,20,25,0.08);
  }
}

/* ── Foldable Devices ── */
@media (spanning: single-fold-vertical) {
  .split-container {
    flex-direction: column;
  }
  
  .split-left,
  .split-right {
    max-width: 100%;
    flex: 0 0 auto;
  }
}
