/* The desktop layout stays familiar; the navigation and records adapt on mobile. */
.sidebar-head { display: flex; align-items: center; justify-content: space-between; }
.desktop-menu { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.desktop-menu > form { margin-top: auto; }
.mobile-menu { display: none; }
.panel, .editor, .review-card { box-shadow: 0 8px 28px rgba(58, 37, 24, .035); }
.panel small, .review-card small { line-height: 1.45; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid #fd9b76; outline-offset: 3px; }

@media (max-width: 1024px) {
  .sidebar { position: relative; z-index: 10; display: block; width: 100%; padding: 14px 18px; }
  .sidebar-head { min-height: 42px; gap: 12px; }
  .sidebar .brand { width: min(170px, 50vw); }
  .desktop-menu { display: none; }
  .mobile-menu { display: block; }
  .mobile-menu summary { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid #6b5148; border-radius: 10px; color: #fff; font-size: .85rem; font-weight: 800; cursor: pointer; list-style: none; }
  .mobile-menu summary::-webkit-details-marker { display: none; }
  .menu-icon { color: #ff926c; font-size: 1.15rem; line-height: 1; }
  .mobile-menu[open] summary { background: #3a2925; }
  .mobile-menu-content { position: absolute; top: 100%; left: 0; right: 0; max-height: calc(100vh - 70px); overflow-y: auto; padding: 8px 18px 20px; background: #241a18; border-top: 1px solid #44332e; box-shadow: 0 18px 28px rgba(20, 10, 6, .18); }
  .sidebar .mobile-menu-content .role { display: block; margin: 8px 10px 10px; }
  .sidebar .mobile-menu-content nav { display: grid; gap: 4px; }
  .mobile-menu-content nav a { min-height: 44px; }
  .sidebar .mobile-menu-content form { margin: 12px 0 0; }
  .sidebar .mobile-menu-content .logout { min-height: 44px; }
  .workspace { width: 100%; margin: 0; padding: 34px 18px 64px; }
  .topbar { align-items: flex-start; flex-direction: column; margin-bottom: 28px; }
  .topbar.compact { margin-bottom: 24px; }
  .topbar h1 { font-size: clamp(2rem, 8vw, 3.1rem); line-height: 1.05; letter-spacing: -.055em; }
  .topbar p:not(.eyebrow) { font-size: .95rem; line-height: 1.6; }
  .primary-link { min-height: 48px; }
  .panel { overflow: visible; }
  .panel-title { gap: 15px; padding: 18px; }
  .panel table, .panel tbody, .panel tr, .panel td { display: block; width: 100%; }
  .panel thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .panel tbody tr { padding: 19px 18px; border-bottom: 1px solid var(--line); }
  .panel tbody tr:last-child { border-bottom: 0; }
  .panel tbody td, .panel tbody tr:last-child td { min-width: 0; padding: 8px 0; border: 0; overflow-wrap: anywhere; font-size: .9rem; }
  .panel tbody td[data-label]::before { display: block; margin-bottom: 5px; color: var(--muted); font-size: .67rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; content: attr(data-label); }
  .panel tbody td:first-child { padding-top: 0; font-size: 1rem; line-height: 1.35; }
  .panel tbody td:last-child { padding-bottom: 0; }
  .panel tbody td small { margin-top: 4px; color: var(--muted); }
  .panel tbody td.empty { text-align: center; }
  .panel .inline-form { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
  .panel .inline-form select, .panel .inline-form button { width: 100%; min-height: 46px; }
  .panel .inline-form button { font-size: .85rem; }
  .editor { padding: 20px 17px; }
  .review-card { grid-template-columns: minmax(0, 1fr); padding: 20px 18px; }
  .metric-grid { grid-template-columns: 1fr; }
  .conversation { padding: 16px; }
  .message { max-width: 94%; overflow-wrap: anywhere; }
  input, textarea, select { min-width: 0; font-size: 1rem; }
}

@media (max-width: 360px) {
  .workspace { padding-right: 14px; padding-left: 14px; }
  .sidebar { padding-right: 14px; padding-left: 14px; }
  .sidebar .brand { width: 140px; }
}

/* Longer names, upload controls and nested forms must fit in every panel view. */
.workspace, .auth, .workspace > *, .editor, .review-card, .login-card, .setup-card { min-width: 0; max-width: 100%; }
.workspace h1, .workspace h2, .workspace p, .workspace a, .workspace code,
.auth h1, .auth p, .auth a, .auth code { overflow-wrap: anywhere; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel + .panel { margin-top: 20px; }
.panel > h2 { padding: 22px 24px 0; }
.panel > .editor { max-width: none; margin: 0; border: 0; box-shadow: none; }
.panel.conversation + .editor { margin-top: 20px; }
.empty-box { padding: 22px; color: var(--muted); }
.desktop-menu { overflow-y: auto; }

@media (max-width: 1024px) {
  .sidebar { position: sticky; top: 0; padding-top: max(12px, env(safe-area-inset-top)); }
  .mobile-menu summary { min-width: 88px; justify-content: center; }
  .menu-icon { display: grid; gap: 3px; width: 18px; }
  .menu-icon i { display: block; width: 18px; height: 2px; border-radius: 2px; background: currentColor; }
  .mobile-menu[open] .menu-icon i:nth-child(2) { opacity: .45; }
  .mobile-menu-content { max-height: calc(100vh - 74px); max-height: calc(100dvh - 74px); overscroll-behavior: contain; }
  .sidebar .mobile-menu-content nav a { display: flex; align-items: center; }
  .topbar .primary-link { width: 100%; }
  .two-columns { grid-template-columns: minmax(0, 1fr); }
  .workspace .panel > h2 { padding: 20px 18px 0; }
  .panel > .editor { padding: 20px 18px; }
  .editor input[type='file'] { max-width: 100%; padding: 10px; }
  .editor label code, .setup-card code { overflow-wrap: anywhere; word-break: break-word; }
  .review-actions button, .form-actions button, .login-card button { min-height: 48px; white-space: normal; }
  .auth { padding: 20px 16px; }
  .login-card, .setup-card { padding: 28px 20px; }
  .login-card h1, .setup-card h1 { font-size: clamp(1.9rem, 8vw, 3rem); line-height: 1.06; }
  .login-card .brand { margin-bottom: 40px; }
}

@media (max-width: 320px) {
  .workspace { padding-right: 12px; padding-left: 12px; }
  .sidebar .brand { width: min(130px, 48vw); }
  .mobile-menu summary { min-width: 78px; padding: 0 10px; }
  .panel tbody tr { padding-right: 14px; padding-left: 14px; }
  .editor, .panel > .editor { padding-right: 14px; padding-left: 14px; }
}

/* Product funnel analytics */
.analytics-header { gap: 28px; }
.analytics-filter { display: grid; grid-template-columns: 1fr auto; gap: 8px; min-width: 220px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fffdfb; }
.analytics-filter label { grid-column: 1 / -1; color: var(--muted); font-size: .69rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.analytics-filter select, .analytics-filter button { min-height: 42px; margin: 0; }
.analytics-filter button { padding: 0 14px; border-color: #c9502a; background: #c9502a; color: #fff; white-space: nowrap; }
.analytics-metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin: 0 0 20px; }
.analytics-metrics article { min-width: 0; padding: 21px 20px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 8px 28px rgba(58, 37, 24, .035); }
.analytics-metrics span, .analytics-metrics small { display: block; color: var(--muted); }
.analytics-metrics span { margin-bottom: 9px; font-size: .69rem; font-weight: 850; letter-spacing: .075em; text-transform: uppercase; }
.analytics-metrics strong { display: block; overflow-wrap: anywhere; font-size: clamp(1.45rem, 2.5vw, 2.05rem); line-height: 1.05; letter-spacing: -.05em; }
.analytics-metrics small { margin-top: 9px; font-size: .8rem; line-height: 1.4; }
.analytics-funnel { margin: 0 0 20px; padding: 28px; border-radius: 18px; color: #fff8f5; background: linear-gradient(118deg, #241a18 0%, #41271f 56%, #c84d1f 180%); box-shadow: 0 14px 34px rgba(55, 30, 18, .12); }
.funnel-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.funnel-head .eyebrow { color: #ff9d76; }
.funnel-head h2 { margin: 0; color: #fff; font-size: 1.55rem; letter-spacing: -.04em; }
.funnel-head > p { max-width: 300px; margin: 0; color: #e5cfc4; font-size: .85rem; line-height: 1.45; text-align: right; }
.funnel-steps { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr); align-items: stretch; gap: 12px; margin-top: 26px; }
.funnel-steps article { min-width: 0; padding: 20px; border: 1px solid rgba(255,255,255,.2); border-radius: 14px; background: rgba(255,255,255,.09); }
.funnel-steps article b, .funnel-steps article span, .funnel-steps article small { display: block; }
.funnel-steps article b { color: #ff9d76; font-size: .7rem; letter-spacing: .1em; }
.funnel-steps article span { margin-top: 13px; color: #ead6ce; font-size: .8rem; font-weight: 750; }
.funnel-steps article strong { display: block; margin-top: 5px; overflow-wrap: anywhere; color: #fff; font-size: 2rem; line-height: 1.05; letter-spacing: -.06em; }
.funnel-steps article small { margin-top: 7px; color: #e5cfc4; line-height: 1.35; }
.funnel-connector { display: grid; align-content: center; min-width: 76px; color: #fff; text-align: center; }
.funnel-connector::before { width: 100%; height: 1px; margin-bottom: 8px; background: rgba(255,255,255,.36); content: ''; }
.funnel-connector strong { color: #ffb497; font-size: .92rem; }
.funnel-connector span { margin-top: 4px; color: #e5cfc4; font-size: .7rem; line-height: 1.2; }
.analytics-note { margin: 20px 0 0; color: #e5cfc4; font-size: .76rem; line-height: 1.5; }
.analytics-setup { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: 0 0 20px; padding: 24px 26px; border: 1px solid #f1c6b5; border-radius: 17px; background: #fff7f2; }
.analytics-setup .eyebrow { margin-bottom: 8px; }
.analytics-setup h2 { margin: 0; font-size: 1.18rem; letter-spacing: -.035em; }
.analytics-setup p:not(.eyebrow) { max-width: 760px; margin: 8px 0 0; color: #765c53; line-height: 1.55; }
.analytics-setup code { padding: 2px 4px; border-radius: 4px; background: #f5e9e4; color: #5a3225; font-size: .82em; overflow-wrap: anywhere; }
.secondary-link { display: inline-flex; flex: 0 0 auto; align-items: center; min-height: 44px; padding: 0 14px; border: 1px solid #cb5d39; border-radius: 9px; color: #a64122; font-size: .85rem; font-weight: 850; text-decoration: none; }
.analytics-table .panel-title > span { color: var(--muted); font-size: .82rem; font-weight: 750; }
.analytics-table td small { display: block; }
.analytics-table-note { margin: 0; padding: 0 24px 22px; color: var(--muted); font-size: .75rem; line-height: 1.5; }
.conversion-heat > span { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 99px; font-size: .68rem; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.conversion-heat.heat-high > span { color: #145f40; background: #d7f4e7; }
.conversion-heat.heat-medium > span { color: #94560b; background: #fff0c4; }
.conversion-heat.heat-low > span { color: #ad4728; background: #ffe0d3; }
.conversion-heat.heat-none > span { color: #766e69; background: #eeeae7; }
.conversion-heat strong { display: block; margin-top: 7px; }

@media (max-width: 1024px) {
  .analytics-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-funnel { padding: 22px 18px; }
  .funnel-head { align-items: flex-start; flex-direction: column; }
  .funnel-head > p { text-align: left; }
  .funnel-steps { grid-template-columns: 1fr; gap: 8px; }
  .funnel-connector { grid-template-columns: auto 1fr; align-items: center; justify-items: start; min-width: 0; padding: 5px 10px; text-align: left; }
  .funnel-connector::before { display: none; }
  .funnel-connector strong { margin-right: 7px; }
  .funnel-connector span { margin: 0; }
  .analytics-setup { align-items: flex-start; flex-direction: column; padding: 21px 18px; }
  .analytics-table-note { padding: 0 18px 19px; }
}

@media (max-width: 480px) {
  .analytics-metrics { grid-template-columns: 1fr; }
  .analytics-filter { width: 100%; min-width: 0; }
  .analytics-filter select { min-width: 0; }
  .analytics-metrics article { padding: 18px; }
  .analytics-funnel { border-radius: 14px; }
}
