    :root {
      color-scheme: light;
      --bg: #f5f7fb;
      --panel: #ffffff;
      --line: #d9e1ef;
      --text: #172033;
      --muted: #667085;
      --primary: #0f766e;
      --primary-strong: #115e59;
      --accent: #2563eb;
      --warning: #b45309;
      --danger: #b42318;
      --success: #067647;
      --shadow: 0 16px 40px rgba(19, 34, 56, .08);
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }

    * { box-sizing: border-box; }
    body {
      margin: 0;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
    }

    button, input, select, textarea {
      font: inherit;
    }

    button {
      border: 0;
      cursor: pointer;
      min-height: 38px;
    }

    .app {
      min-height: 100vh;
      display: grid;
      grid-template-columns: 260px minmax(0, 1fr);
    }

    .sidebar {
      background: #101828;
      color: #f9fafb;
      padding: 20px 16px;
      position: sticky;
      top: 0;
      height: 100vh;
      overflow: auto;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 10px;
      font-weight: 800;
      font-size: 22px;
      letter-spacing: 0;
      margin-bottom: 22px;
    }

    .brand-mark {
      width: 38px;
      height: 38px;
      border-radius: 8px;
      background: #2dd4bf;
      color: #052e2b;
      display: grid;
      place-items: center;
      font-weight: 900;
    }

    .nav {
      display: grid;
      gap: 6px;
    }

    .nav button {
      color: #d0d5dd;
      background: transparent;
      border-radius: 8px;
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px 12px;
      text-align: left;
      width: 100%;
    }

    .nav button.active,
    .nav button:hover {
      background: rgba(255,255,255,.10);
      color: #ffffff;
    }

    .main {
      min-width: 0;
      padding: 22px;
    }

    .topbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      margin-bottom: 18px;
    }

    h1 {
      margin: 0;
      font-size: 26px;
      line-height: 1.2;
      letter-spacing: 0;
    }

    .muted {
      color: var(--muted);
      font-size: 14px;
    }

    .grid {
      display: grid;
      gap: 14px;
    }

    .stats {
      grid-template-columns: repeat(5, minmax(150px, 1fr));
    }

    .two {
      grid-template-columns: minmax(0, 1fr) minmax(320px, .5fr);
      align-items: start;
    }

    .panel,
    .stat,
    .product-item {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 8px;
      box-shadow: var(--shadow);
    }

    .panel {
      padding: 16px;
      overflow: hidden;
    }

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

    .panel h2,
    .panel h3 {
      margin: 0;
      font-size: 16px;
      line-height: 1.25;
      letter-spacing: 0;
    }

    .stat {
      padding: 14px;
      min-height: 102px;
      display: grid;
      align-content: space-between;
    }

    .stat strong {
      display: block;
      font-size: 28px;
      line-height: 1;
      margin-top: 10px;
    }

    .actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      align-items: center;
    }

    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      border-radius: 8px;
      padding: 8px 12px;
      color: #ffffff;
      background: var(--primary);
      white-space: nowrap;
    }

    .btn:hover { background: var(--primary-strong); }
    .btn.secondary {
      color: var(--text);
      background: #eef4ff;
      border: 1px solid #c7d7fe;
    }
    .btn.ghost {
      color: var(--text);
      background: #ffffff;
      border: 1px solid var(--line);
    }
    .btn.danger { background: var(--danger); }

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

    .field {
      display: grid;
      gap: 5px;
      min-width: 0;
    }

    .field.full { grid-column: 1 / -1; }

    .d1-mode-bar {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 10px;
      align-items: center;
    }

    label {
      color: #344054;
      font-size: 12px;
      font-weight: 700;
    }

    input,
    select,
    textarea {
      width: 100%;
      min-width: 0;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #ffffff;
      color: var(--text);
      padding: 9px 10px;
      outline: none;
    }

    textarea {
      min-height: 82px;
      resize: vertical;
    }

    input:focus,
    select:focus,
    textarea:focus {
      border-color: var(--primary);
      box-shadow: 0 0 0 3px rgba(15, 118, 110, .15);
    }

    table {
      width: 100%;
      border-collapse: collapse;
      font-size: 13px;
    }

    th, td {
      padding: 10px;
      border-bottom: 1px solid var(--line);
      text-align: left;
      vertical-align: top;
    }

    th {
      color: #475467;
      background: #f8fafc;
      font-size: 12px;
      position: sticky;
      top: 0;
    }

    .table-wrap {
      overflow: auto;
      border: 1px solid var(--line);
      border-radius: 8px;
      max-height: 440px;
    }

    .badge {
      display: inline-flex;
      align-items: center;
      border-radius: 999px;
      padding: 3px 8px;
      font-size: 12px;
      font-weight: 700;
      background: #eef4ff;
      color: #1849a9;
      margin: 2px 4px 2px 0;
    }

    .badge.gas_admin_d1_test,
    .badge.gas_admin_d1_client_test {
      background: #ecfdf3;
      color: #027a48;
    }

    .badge.d1_admin_readonly {
      background: #fffaeb;
      color: #b54708;
    }

    .badge.active,
    .badge.lifetime { background: #dcfae6; color: var(--success); }
    .badge.trial { background: #fef0c7; color: var(--warning); }
    .badge.expired,
    .badge.suspended { background: #fee4e2; color: var(--danger); }
    .badge.gas_primary { background: #e0f2fe; color: #075985; }
    .badge.d1_mirror { background: #dcfae6; color: var(--success); }
    .badge.d1_validate_only { background: #fef0c7; color: var(--warning); }
    .badge.d1_primary { background: #fee4e2; color: var(--danger); }

    .d1-summary {
      display: grid;
      gap: 10px;
      margin-bottom: 10px;
    }

    .d1-summary-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 10px;
    }

    .d1-summary-item {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #ffffff;
      padding: 10px;
      min-width: 0;
    }

    .d1-summary-item span {
      display: block;
      color: var(--muted);
      font-size: 12px;
      margin-bottom: 5px;
    }

    .d1-summary-item strong {
      display: block;
      color: var(--text);
      font-size: 16px;
      overflow-wrap: anywhere;
    }

    .d1-checklist {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
    }

    .d1-check {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #f8fafc;
      padding: 9px 10px;
      font-size: 13px;
      font-weight: 700;
    }

    .d1-check.ok {
      background: #ecfdf3;
      border-color: #abefc6;
      color: var(--success);
    }

    .d1-check.warn {
      background: #fffaeb;
      border-color: #fedf89;
      color: var(--warning);
    }

    .d1-check.danger {
      background: #fef3f2;
      border-color: #fecdca;
      color: var(--danger);
    }

    .product-list {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 14px;
    }

    .product-item {
      padding: 16px;
      display: grid;
      gap: 10px;
      min-height: 180px;
    }

    .product-item h3 {
      margin: 0;
      font-size: 17px;
    }

    .login {
      min-height: 100vh;
      display: grid;
      place-items: center;
      padding: 18px;
      background: linear-gradient(135deg, #0f172a, #1e293b, #0f172a);
      background-size: 400% 400%;
      animation: gradientBg 15s ease infinite;
      position: relative;
      overflow: hidden;
    }

    .login::before, .login::after {
      content: "";
      position: absolute;
      width: 600px;
      height: 600px;
      border-radius: 50%;
      filter: blur(120px);
      z-index: 0;
      animation: float 20s infinite alternate ease-in-out;
    }
    
    .login::before {
      background: rgba(45, 212, 191, 0.3);
      top: -100px;
      left: -100px;
    }
    
    .login::after {
      background: rgba(37, 99, 235, 0.2);
      bottom: -100px;
      right: -100px;
      animation-delay: -5s;
    }

    @keyframes gradientBg {
      0% { background-position: 0% 50%; }
      50% { background-position: 100% 50%; }
      100% { background-position: 0% 50%; }
    }

    @keyframes float {
      0% { transform: translate(0, 0); }
      100% { transform: translate(100px, 50px); }
    }

    .login-view {
      min-height: 100vh;
      display: grid;
      place-items: center;
      padding: 18px;
      background: linear-gradient(135deg, #f8fafc, #e2e8f0);
      position: relative;
    }

    .auth-modal {
      width: min(400px, 100%);
      background: #ffffff;
      border: 1px solid rgba(0, 0, 0, 0.08);
      border-radius: 20px;
      box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
      overflow: hidden;
      z-index: 1;
      padding: 32px;
      text-align: center;
    }

    .auth-modal-header {
      margin-bottom: 28px;
    }

    .auth-modal-header .brand {
      justify-content: center;
      margin-bottom: 16px;
    }

    .auth-modal-header h1 {
      font-size: 24px;
      font-weight: 700;
      margin-bottom: 6px;
      color: #111827;
    }

    .auth-modal-header .muted {
      font-size: 14px;
      color: #6b7280;
    }

    .auth-modal-body {
      display: grid;
      gap: 16px;
      text-align: left;
    }

    .clean-input {
      background: #ffffff;
      border: 1px solid #d1d5db;
      padding: 12px 14px;
      font-size: 15px;
      border-radius: 8px;
      transition: all 0.2s ease;
      width: 100%;
    }

    .clean-input:focus {
      border-color: #000000;
      box-shadow: 0 0 0 1px #000000;
    }

    .dark-btn {
      background: #111827;
      color: #ffffff;
      border-radius: 8px;
      padding: 12px;
      font-size: 15px;
      font-weight: 600;
      width: 100%;
      transition: background 0.2s;
    }

    .dark-btn:hover {
      background: #1f2937;
    }

    .google-btn {
      background: #ffffff;
      color: #374151;
      border: 1px solid #d1d5db;
      border-radius: 8px;
      padding: 12px;
      font-size: 15px;
      font-weight: 600;
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      transition: background 0.2s;
    }

    .google-btn:hover {
      background: #f9fafb;
    }

    .login-divider {
      display: flex;
      align-items: center;
      text-align: center;
      color: #6b7280;
      font-size: 12px;
      font-weight: 600;
      margin: 4px 0;
    }

    .login-divider::before,
    .login-divider::after {
      content: '';
      flex: 1;
      border-bottom: 1px solid #e5e7eb;
    }

    .login-divider span {
      padding: 0 10px;
    }

    .auth-modal-footer {
      margin-top: 24px;
      font-size: 12px;
    }

    .auth-modal-footer .muted {
      color: #9ca3af;
    }

    .advanced-login {
      display: none; /* Hide advanced login for now */
    }

    .panel-head.compact {
      margin-bottom: 8px;
      align-items: flex-start;
    }

    .feature-manager {
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 12px;
      background: #f8fafc;
    }

    .feature-list {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 10px;
    }

    .feature-chip {
      min-height: 34px;
      display: inline-flex;
      gap: 8px;
      align-items: center;
      border: 1px solid #c7d7fe;
      background: #eef4ff;
      color: #1849a9;
      border-radius: 999px;
      padding: 6px 10px;
      font-size: 12px;
      font-weight: 800;
    }

    .feature-chip small {
      color: #475467;
      font-weight: 600;
    }

    .feature-chip.inactive {
      border-color: #e4e7ec;
      background: #f2f4f7;
      color: #667085;
    }

    .feature-form {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
    }

    .feature-form textarea,
    .feature-form button {
      grid-column: 1 / -1;
    }

    .feature-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }

    .feature-toggle {
      min-height: 58px;
      display: grid;
      grid-template-columns: auto minmax(0, 1fr);
      grid-template-rows: auto auto;
      column-gap: 8px;
      align-items: center;
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 9px 10px;
      background: #ffffff;
      cursor: pointer;
    }

    .feature-toggle input {
      width: auto;
      grid-row: 1 / span 2;
    }

    .feature-toggle span {
      font-size: 13px;
      color: var(--text);
      font-weight: 800;
    }

    .feature-toggle small {
      color: var(--muted);
      font-weight: 500;
      line-height: 1.3;
    }

    .feature-toggle.is-active {
      border-color: #99f6e4;
      background: #f0fdfa;
    }

    .config-section {
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 12px;
      background: #ffffff;
    }

    .section-title {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      margin-bottom: 12px;
    }

    .section-title svg {
      width: 19px;
      height: 19px;
      color: var(--primary);
      margin-top: 2px;
    }

    .section-title h3 {
      margin: 0;
      font-size: 15px;
      line-height: 1.25;
    }

    .form-grid.single {
      grid-template-columns: 1fr;
    }

    .statusbar {
      position: fixed;
      right: 18px;
      bottom: 18px;
      width: min(420px, calc(100vw - 36px));
      background: #101828;
      color: #fff;
      padding: 12px 14px;
      border-radius: 8px;
      box-shadow: var(--shadow);
      display: none;
      z-index: 10;
    }

    .statusbar.show { display: block; }
    .section { display: none; }
    .section.active { display: block; }
    .hidden { display: none !important; }

    .loading-overlay {
      position: fixed;
      inset: 0;
      z-index: 30;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 18px;
      background: rgba(15, 23, 42, .26);
      backdrop-filter: blur(3px);
    }

    .loading-overlay.show {
      display: flex;
    }

    .loading-card {
      width: min(360px, 100%);
      background: #ffffff;
      border: 1px solid var(--line);
      border-radius: 8px;
      box-shadow: var(--shadow);
      padding: 16px;
      display: flex;
      gap: 14px;
      align-items: center;
    }

    .loading-spinner {
      width: 38px;
      height: 38px;
      border-radius: 50%;
      border: 4px solid #d0d5dd;
      border-top-color: var(--primary);
      animation: smartkeySpin .8s linear infinite;
      flex: 0 0 auto;
    }

    .mini-spinner {
      width: 16px;
      height: 16px;
      border-radius: 50%;
      border: 2px solid currentColor;
      border-top-color: transparent;
      animation: smartkeySpin .7s linear infinite;
      display: inline-block;
    }

    .loading-card strong {
      display: block;
      font-size: 15px;
      margin-bottom: 3px;
    }

    .loading-card span {
      color: var(--muted);
      font-size: 13px;
    }

    .is-busy {
      pointer-events: none;
      opacity: .68;
    }

    @keyframes smartkeySpin {
      to { transform: rotate(360deg); }
    }

    .login-divider {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
      text-transform: uppercase;
    }

    .login-divider::before,
    .login-divider::after {
      content: "";
      height: 1px;
      background: var(--line);
      flex: 1;
    }

    .login-divider span {
      padding: 0 10px;
    }

    .google-button-mount {
      min-height: 42px;
      display: grid;
      place-items: center;
    }

    @media (max-width: 1020px) {
      .app { grid-template-columns: 1fr; }
      .sidebar {
        height: auto;
        position: relative;
      }
      .nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }
      .stats,
      .two,
      .product-list {
        grid-template-columns: 1fr;
      }
    }

    @media (max-width: 680px) {
      .main { padding: 14px; }
      .topbar,
      .panel-head {
        align-items: stretch;
        flex-direction: column;
      }
      .nav { grid-template-columns: 1fr 1fr; }
      .form-grid,
      .d1-mode-bar,
      .d1-summary-grid,
      .d1-checklist,
      .login-card {
        grid-template-columns: 1fr;
      }
      .login-side { min-height: 240px; }
      th, td { padding: 8px; }
    }

    .product-config-block {
      background: #f8fafc;
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 16px;
      margin-top: 10px;
    }

    .product-config-block h4 {
      margin: 0 0 10px;
      font-size: 14px;
      color: var(--primary);
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .product-config-block .form-grid {
      gap: 8px;
    }

    .config-fields {
      display: grid;
      gap: 6px;
      margin-top: 6px;
    }

    .config-row {
      display: grid;
      grid-template-columns: 1fr 2fr 32px;
      gap: 6px;
      align-items: center;
    }

    .config-row input {
      padding: 8px 10px;
      font-size: 13px;
    }

    .config-row .remove-prop-btn {
      width: 32px;
      height: 32px;
      border-radius: 6px;
      background: #fee2e2;
      color: var(--danger);
      display: grid;
      place-items: center;
      border: none;
      cursor: pointer;
      min-height: unset;
      padding: 0;
      transition: background 0.2s;
    }

    .config-row .remove-prop-btn:hover {
      background: #fecaca;
    }

    /* GUIDE SECTION STYLES */
    .guide-container {
      max-width: 1000px;
      margin: 0 auto;
    }

    .guide-grid {
      display: grid;
      gap: 20px;
      margin-top: 20px;
    }

    .guide-card {
      background: #f8fafc;
      border: 1px solid var(--line);
      border-radius: 12px;
      padding: 24px;
      transition: transform 0.2s;
    }

    .guide-card:hover {
      transform: translateY(-2px);
    }

    .guide-card h3 {
      display: flex;
      align-items: center;
      gap: 10px;
      color: var(--primary);
      font-size: 18px;
      margin-bottom: 16px;
      border-bottom: 2px solid var(--line);
      padding-bottom: 10px;
    }

    .guide-card ol, .guide-card ul {
      padding-left: 20px;
      margin: 0;
    }

    .guide-card li {
      margin-bottom: 12px;
      line-height: 1.6;
      font-size: 14px;
    }

    .guide-card code {
      background: #e2e8f0;
      padding: 2px 6px;
      border-radius: 4px;
      font-family: monospace;
      font-size: 13px;
    }

    .alert {
      display: flex;
      gap: 12px;
      padding: 16px;
      border-radius: 10px;
      font-size: 14px;
      line-height: 1.5;
    }

    .alert.info {
      background: #eff6ff;
      border: 1px solid #bfdbfe;
      color: #1e40af;
    }

    .alert i {
      flex: 0 0 auto;
    }

    .inline-status {
      border: 1px solid var(--line);
      border-radius: 8px;
      font-size: 13px;
      font-weight: 700;
      line-height: 1.45;
      padding: 10px 12px;
    }

    .inline-status.success {
      background: #ecfdf3;
      border-color: #abefc6;
      color: #067647;
    }

    .inline-status.error {
      background: #fef3f2;
      border-color: #fecdca;
      color: #b42318;
    }
    
    .flex { display: flex; }
    .gap-2 { gap: 0.5rem; }

    .span-2 {
      grid-column: 1 / -1;
    }

    .readiness-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
      gap: 12px;
    }

    .readiness-card {
      border: 1px solid var(--line);
      border-radius: 10px;
      background: #f8fafc;
      padding: 14px;
      display: grid;
      gap: 10px;
    }

    .readiness-card.ready {
      border-color: #bbf7d0;
      background: #f0fdf4;
    }

    .readiness-card.warning {
      border-color: #fed7aa;
      background: #fff7ed;
    }

    .outlet-readiness-panel {
      border: 1px solid #bfdbfe;
      border-radius: 8px;
      background: #eff6ff;
      padding: 12px;
    }

    .outlet-readiness-panel .readiness-head {
      margin-bottom: 10px;
    }

    .readiness-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
    }

    .readiness-head strong,
    .readiness-head span {
      display: block;
    }

    .readiness-head span {
      color: var(--muted);
      font-size: 13px;
      margin-top: 2px;
    }

    .readiness-steps {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }

    .step-ok,
    .step-missing {
      border-radius: 999px;
      font-size: 12px;
      font-weight: 800;
      padding: 5px 8px;
    }

    .step-ok {
      background: #dcfce7;
      color: #166534;
    }

    .step-missing {
      background: #ffedd5;
      color: #9a3412;
    }
