/* Signed-in cabinet: sidebar navigation and panels. Tokens live in auth.css. */
#cabinet > * + *, #cabinet + #profile { margin-top: 16px; }
#cabinet[hidden] + #profile { margin-top: 0; }

.sidebar { position: sticky; top: 0; flex: 0 0 272px; width: 272px; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 24px; padding: 20px 16px; border-right: 1px solid var(--line); background: var(--sidebar); }
.sidebar > .brand { padding: 0 8px; }
.account-card { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); }
.account-card:has(.account-name:empty) { display: none; }
.avatar { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.account-name { min-width: 0; font-size: .875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; flex-direction: column; gap: 4px; }
.nav-label { padding: 16px 12px 6px; color: var(--accent); font-size: .75rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.nav-label:first-child { padding-top: 0; }
.tab { position: relative; justify-content: flex-start; gap: 12px; width: 100%; min-height: 48px; padding: 10px 12px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-weight: 600; text-align: left; }
.tab > span { flex: 1 1 auto; }
.tab .chevron { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: .45; }
.tab:hover { background: var(--hover); color: var(--text); }
.tab[aria-selected="true"] { background: var(--accent-soft); color: var(--text); }
.tab[aria-selected="true"]::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--accent); }
.tab[aria-selected="true"] .icon { color: var(--accent); }
.tab:focus-visible { outline-offset: -2px; }
/* Focused from script only (tabindex="-1"), so no ring. */
[role="tabpanel"]:focus, #quotePanel:focus, #profile:focus { outline: 0; }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-head h2 { min-width: 0; }
.panel-head button { flex: 0 0 auto; margin-right: -8px; }
.panel-head h2 { font-size: 1.375rem; }
.payment { border-color: var(--accent); }

.rows { list-style: none; padding: 0; }
.rows > li, .device-row { padding: 16px 0; border-top: 1px solid var(--line); }
.rows > li:first-child, .device-row:first-child { border-top: 0; padding-top: 0; }
.rows > li:last-child, .device-row:last-child { padding-bottom: 0; }
.rows p + p, .device-row p { margin-top: 4px; }

.steps { list-style: none; padding: 0; }
.howto { padding-left: 20px; }
.howto li + li { margin-top: 4px; }
.steps li { padding-left: 24px; position: relative; }
.steps li + li { margin-top: 4px; }
.steps li::before { content: "–"; position: absolute; left: 0; width: 16px; text-align: center; color: var(--muted); }
.steps li.done::before { content: "✓"; color: var(--ok); font-weight: 700; }
.steps li.wait { color: var(--muted); }

.app-picker { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; }
.app-picker legend { padding: 0; margin-bottom: 8px; font-size: .875rem; font-weight: 600; }
.app-picker label { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius); font-weight: 550; cursor: pointer; }
.app-picker input { width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0; accent-color: var(--accent); }
.app-picker label:has(:checked) { border-color: var(--accent); background: var(--accent-soft); }
.app-picker label:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-picker input:focus-visible { outline: 0; }

.connection-grid { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 32px; }
.connection-grid > div > * + * { margin-top: 12px; }
.connection-grid h3 + .actions { margin-top: 8px; }
.connection-grid > div > h3:not(:first-child), .connection-grid label { margin-top: 24px; }
textarea { resize: vertical; font: .8125rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; display: block; }
#vpnQr { display: block; width: min(100%, 240px); height: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }

.periods { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.period { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; min-height: 0; padding: 16px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); text-align: left; }
.period:hover { border-color: var(--accent); }
.period[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.period-title { font-size: 1.0625rem; font-weight: 700; }
.period-price { font-weight: 600; }
.period-note { color: var(--muted); font-size: .8125rem; font-weight: 500; }
.period-detail { margin-top: 16px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.period-detail > * + * { margin-top: 16px; }
.device-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.device-option { flex-direction: column; gap: 0; min-height: 60px; background: var(--surface); }
.device-option[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.period-buy { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.period-buy .price { margin: 0; font-size: 1.5rem; font-weight: 700; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; max-width: 420px; }
.inline-form input { flex: 1 1 160px; width: 0; }
.total { font-size: 1.125rem; font-weight: 650; }
#quoteInfo > * + *, #subscriptionInfo > * + *, #renewalInfo > * + *, #queueInfo > * + *, #mergePreview > * + * { margin-top: 12px; }
#mergePreview:empty, #upgradeOffers:empty, #installLinks:empty, #deviceList:empty, #offers:empty { display: none; }
#connect .panel-head, #devices .panel-head { margin-bottom: 0; }

.device-row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.device-row > div { flex: 1 1 180px; min-width: 0; }

.signed-in #emailForm, .signed-in #codeSection { max-width: 420px; }

#emailDialog { width: min(100% - 32px, 440px); max-height: calc(100% - 32px); padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--text); }
#emailDialog::backdrop { background: rgba(6, 12, 29, .55); }
#emailDialog > * + *, #emailDialogBody > * + * { margin-top: 16px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dialog-head button { flex: 0 0 auto; width: 44px; padding: 0; margin-right: -8px; font-size: 1.125rem; }
/* In the dialog only the form and the code matter. */
#emailDialog #emailTitle, #emailDialog #emailFacts, #emailDialog #emailSuggestion, #emailDialog #emailChange { display: none !important; }
#emailDialog #emailForm, #emailDialog #codeSection { max-width: none; }
#emailDialog .stack > button, #emailDialog #emailForm .actions > button { width: 100%; }

@media (max-width: 640px) {
  .connection-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .facts dd { margin-bottom: 8px; }
  .facts dd:last-child { margin-bottom: 0; }
}
/* Narrow screens: the sidebar turns into a bottom tab bar. */
@media (max-width: 900px) {
  .sidebar { position: fixed; inset: auto 0 0 0; z-index: 25; flex-direction: row; width: auto; height: auto; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--sidebar) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
  .sidebar > .brand, .account-card, .nav-label, .tab .chevron { display: none; }
  .sidebar nav { width: 100%; }
  .tabs { flex-direction: row; gap: 2px; }
  .tab { flex: 1 1 0; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; min-height: 54px; padding: 6px 1px; font-size: .6875rem; text-align: center; }
  .tab > span { flex: 0 0 auto; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab[aria-selected="true"]::before { left: 30%; right: 30%; top: 0; bottom: auto; width: auto; height: 3px; }
  .signed-in .brand-compact { display: inline-flex; }
  .signed-in .shell { width: min(100% - 32px, 960px); padding: 20px 0 104px; }
  .signed-in .topbar { padding: 10px 16px; min-height: 60px; }
  #logoutTop span { display: none; }
  #logoutTop { width: 44px; padding: 0; }
}
}
#mergeBot > * + * { margin-top: 12px; }
