.topbar {
  flex-direction: row;
  justify-content: space-between;
  gap: 20px;
  padding: 16px max(24px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
}

.brand-logo { width: 190px; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 20px; margin-left: auto; }
.topbar nav a { font-size: 14px; text-underline-offset: 5px; }

.account-main {
  max-width: 1180px;
  padding-top: 36px;
  padding-bottom: 64px;
}

.account-main > #page-title {
  margin: 0;
  font-size: 38px;
  line-height: 1.12;
  letter-spacing: -.035em;
}


.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.card { min-width: 0; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.section { margin-top: 28px; padding-top: 0; scroll-margin-top: 80px; }
.form, .label { display: grid; gap: 8px; }
.form { gap: 16px; }
.label { color: var(--muted); font-size: 14px; }
.label input, .label select, .label textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #b8b5ae;
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
}
.label textarea { resize: vertical; font: inherit; }
.label input[type=checkbox] { width: auto; min-height: 0; }

.status { margin: 20px 0; padding: 16px; border-radius: 12px; background: var(--blue-bg); overflow-wrap: anywhere; }
.status:empty { display: none; }
.status[data-error=true], #account-dialog-status[data-error=true], #chat-status[data-error=true] { color: #9d1b16; }

.cabinet-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 4px;
  margin: 0 -8px;
  padding: 8px;
  overflow-x: auto;
  border-block: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  scrollbar-width: thin;
}

.cabinet-nav a {
  display: inline-flex;
  flex: none;
  align-items: center;
  min-height: 40px;
  padding: 8px 13px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.cabinet-nav a:hover, .cabinet-nav a:focus-visible { background: var(--panel); color: var(--text); }

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.section-heading h2 { margin: 0; font-size: 24px; line-height: 1.25; letter-spacing: -.025em; }
.section-heading p { max-width: 68ch; margin: 6px 0 0; }

.account-overview {
  margin-top: 28px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}
.account-stats { display: grid; grid-template-columns: 1.35fr 1fr .8fr; border-block: 1px solid var(--line); }
.account-stats article { min-width: 0; padding: 14px 16px; }
.account-stats article + article { border-left: 1px solid var(--line); }
.account-stats span { display: block; color: var(--muted); font-size: 13px; font-weight: 500; }
.account-stats .value { margin: 8px 0 4px; font-size: 27px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; overflow-wrap: anywhere; }
.account-stats .note { margin: 0; }
.sync-state { margin: 16px 0 0; color: var(--muted); font-size: 13px; }

.key-access { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 16px; align-items: start; }
.key-access > .card { padding: 0; border: 0; border-radius: 0; background: transparent; }
.key-access h2, #try-model h2 { margin: 0 0 10px; font-size: 22px; letter-spacing: -.02em; }
.key-access h3 { margin: 20px 0 8px; font-size: 17px; }
#key-list { grid-template-columns: minmax(0, 1fr); }
#key-list > .card { padding: 14px 0 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; }

.account-payments { scroll-margin-top: 96px; }
.payment-methods { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.payment-method { min-width: 0; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.payment-method > h3, .payment-method-heading h3 { margin: 0; font-size: 20px; line-height: 1.3; letter-spacing: -.02em; }
.payment-method-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.payment-method-heading p { margin: 6px 0 0; }
.availability { margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.payment-section .form { max-width: 32rem; }
.payment-section p { max-width: 72ch; overflow-wrap: anywhere; }
.payment-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.payment-actions > * { max-width: 100%; white-space: normal; }
.payment-section [hidden] { display: none !important; }
#top-up { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 20px; padding-block: 16px; }
#top-up .payment-method-heading { display: contents; }
#top-up .payment-method-heading button { align-self: start; min-height: 44px; padding: 10px 16px; }
#top-up .availability { grid-column: 1 / -1; margin: 0; padding-top: 0; border: 0; }
#top-up-content { grid-column: 1 / -1; }

#usage-statistics { padding-top: 8px; }
.table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.table th { color: var(--muted); font-size: 12px; font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.empty { padding: 18px; border: 1px dashed #b8b5ae; border-radius: 12px; color: var(--muted); }

.account-calculator { padding-top: 8px; border-top: 1px solid var(--line); }
.account-calculator h2 { margin: 0 0 10px; font-size: 24px; letter-spacing: -.025em; }
.account-calculator > p { max-width: 72ch; }
.account-calculator .form { max-width: 820px; gap: 20px; margin-top: 24px; }
.calculator-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.calculator-model { grid-column: 1 / -1; }
#calculator-form > .calculator-fields { grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr)); align-items: end; }
#calculator-form > .calculator-fields > .calculator-model { grid-column: auto; }
.calculator-advanced { border-block: 1px solid var(--line); }
.calculator-advanced > summary { display: flex; align-items: center; gap: 12px; min-height: 44px; padding-block: 10px; cursor: pointer; list-style: none; font-size: 14px; font-weight: 500; }
.calculator-advanced > summary::-webkit-details-marker { display: none; }
.calculator-advanced > summary::before { content: ''; flex: 0 0 7px; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); }
.calculator-advanced[open] > summary::before { transform: rotate(45deg); }
.calculator-advanced > .calculator-fields { padding-block: 4px 12px; }
.account-calculator .calculator-advanced > .note { margin: 0 0 12px; }
.account-calculator .actions { justify-content: flex-start; }
.account-calculator .note { margin: 0; line-height: 1.6; }
.account-calculator > p:last-child { margin-top: 20px; }
#calc-result { display: block; font-variant-numeric: tabular-nums; line-height: 1.7; overflow-wrap: anywhere; }
#calc-result:empty { display: none; }
.entity-mode-switch { display:flex; gap:8px; margin-bottom:20px; }
#dashboard[data-account-mode=company] > p,
#dashboard[data-account-mode=company] #key-history { display:none; }
.entity-mode-switch button[aria-pressed=true] { background:var(--ink,#202020); color:var(--bg,#fff); }
#entity-interface > .label { max-width:640px; margin:20px 0 8px; }
.entity-register-form,.entity-invoice-form { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; padding:16px 0; max-width:820px; }
#entity-interface details { padding:14px 0; border-bottom:1px solid var(--line); }
#entity-interface summary { cursor:pointer; }
#entity-interface h3 { margin:24px 0 8px; }
@media(max-width:700px){.entity-register-form,.entity-invoice-form { grid-template-columns:minmax(0,1fr); } }
#calc-result:not(:empty) { padding: 18px; border-radius: 12px; background: var(--blue-bg); }
#calc-result[data-error=true] { color: var(--blue); }

#try-model { max-width: 820px; }
.chat-messages { display: grid; gap: 10px; max-height: 420px; overflow-y: auto; }
.chat-messages:empty { display: none; }
.chat-message { min-width: 0; padding: 14px; border-radius: 12px; background: var(--blue-bg); }
.chat-message[data-role=assistant] { border: 1px solid var(--line); background: var(--panel); }
.chat-message p { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.value { overflow-wrap: anywhere; }
.note { color: var(--muted); font-size: 13px; line-height: 1.5; }
.card .actions { margin-top: 12px; }
.card summary { cursor: pointer; font-weight: 700; }
.danger { padding: 12px 20px; border: 1px solid #b42318; border-radius: 10px; background: #b42318; color: #fff; }
.danger:disabled { opacity: .5; }
pre { max-width: 100%; padding: 16px; overflow-x: auto; border-radius: 12px; background: #f3f2ef; font-size: 13px; }
code { overflow-wrap: anywhere; }
#new-api-key { display: block; margin: 12px 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.api-key-value { display: block; white-space: normal; overflow-wrap: anywhere; }
.api-key-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.api-key-row .api-key-value { flex: 0 1 auto; min-width: 0; margin-right: 4px; }
.key-icon { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 40px; height: 44px; padding: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; appearance: none; }
.key-icon:hover:not(:disabled) { background: var(--blue-bg); color: var(--text); }
.key-icon:disabled { cursor: default; opacity: .4; }
.key-icon svg { width: 22px; height: 22px; pointer-events: none; }
.key-icon:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

#key-history { padding: 20px 0 0; border-top: 1px solid var(--line); }
#key-history summary { cursor: pointer; font-weight: 700; }
.key-history-list { margin: 14px 0 0; padding: 0; list-style: none; }
.key-history-list > li { padding: 14px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.key-history-list > li:last-child { border-bottom: 0; }
.key-history-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; min-width: 0; }
.key-history-heading code { min-width: 0; }

.account-control { position: relative; flex: none; color: var(--text); }
.account-control > summary { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: var(--panel); cursor: pointer; list-style: none; }
.account-control > summary::-webkit-details-marker { display: none; }
.account-control > summary svg { width: 22px; height: 22px; }
.account-control[open] > summary { background: var(--blue-bg); }
.account-dropdown { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; width: 260px; max-width: calc(100vw - 32px); padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 14px 36px #201a161f; }
.account-dropdown #account-email { margin: 0 6px 4px; padding: 10px 4px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.account-dropdown > a, .account-dropdown > button { display: flex; align-items: center; width: 100%; min-height: 44px; padding: 10px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: inherit; font-size: 14px; text-align: left; text-decoration: none; }
.account-dropdown > a:hover, .account-dropdown > button:hover { background: var(--blue-bg); }
.account-dropdown > .account-delete-link { color: #9d1b16; }

.account-dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 20px; overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); }
.account-dialog::backdrop { background: #0007; }
.account-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.account-dialog-heading h2 { margin: 0; font-size: 19px; }
.dialog-close { display: grid; flex: none; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 28px; }
.dialog-close:hover { background: var(--blue-bg); }
.account-deletion { max-width: 440px; margin-top: 14px; }
#delete-form { gap: 10px; }
#delete-form .confirmation { display: flex; align-items: center; min-height: 44px; gap: 10px; cursor: pointer; }
#delete-confirm { flex: 0 0 18px; width: 18px; height: 18px; min-width: 18px; min-height: 18px; margin: 0; padding: 0; accent-color: var(--blue); }
#delete-account { justify-self: start; min-height: 44px; }

::selection { background: #e3bdb6; color: var(--text); }
input, select, textarea { caret-color: var(--blue); }

#dashboard .cabinet-fold-wrap { padding: 0; border: 0; border-radius: 0; background: transparent; max-width: none; }
.cabinet-fold { border-block: 1px solid var(--line); }
.cabinet-fold > summary { display: flex; align-items: center; gap: 14px; min-height: 56px; padding-block: 10px; cursor: pointer; list-style: none; }
.cabinet-fold > summary::-webkit-details-marker { display: none; }
.cabinet-fold > summary::before { content: ''; flex: 0 0 7px; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); }
.cabinet-fold[open] > summary::before { transform: rotate(45deg); }
#dashboard .cabinet-fold > summary h2 { margin: 0; font-size: 18px; line-height: 1.4; letter-spacing: -.02em; }
.payment-method.company-invoices > h3 { margin: 0; font-size: 18px; }
.cabinet-fold-body { min-width: 0; padding: 4px 0 20px; }
.cabinet-fold-body .section-heading { margin-bottom: 12px; }
.cabinet-fold-body > p:first-child { margin-top: 0; }
.cabinet-fold-body .empty { padding: 12px 0; border: 0; border-radius: 0; }
.account-calculator .form { margin-top: 16px; gap: 12px; }
.calculator-fields { gap: 12px 16px; }
.cabinet-fold-body #test-access-form { grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; }
.cabinet-fold-body #test-access-form button { width: auto; }
.cabinet-fold-body.key-access { gap: 24px; }
.cabinet-fold-body #test-chat-form { max-width: 820px; }
.account-main summary:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .payment-methods { grid-template-columns: 1fr; }
  .account-stats { grid-template-columns: 1fr 1fr; }
  .account-stats article:last-child { grid-column: 1 / -1; border-top: 1px solid var(--line); border-left: 0; }
}

@media (max-width: 700px) {
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; gap: 8px; padding: 14px 16px; }
  .brand-logo { width: 164px; }
  .topbar nav { grid-row: 2; grid-column: 1 / -1; gap: 16px; margin-left: 0; overflow-x: auto; white-space: nowrap; }
  .account-control { grid-row: 1; grid-column: 2; }
  .account-main { padding: 26px 16px 40px; }
  .account-main > #page-title { font-size: 32px; }
  .cabinet-nav { margin-inline: -16px; padding-inline: 12px; }
  .section { margin-top: 24px; scroll-margin-top: 80px; }
  .account-overview { margin-top: 24px; padding: 20px; }
  .section-heading { align-items: stretch; flex-direction: column; margin-bottom: 16px; }
  .section-heading > button { width: 100%; }
  .account-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .account-stats article { padding: 12px 8px; }
  .account-stats article:first-child { padding-left: 0; }
  .account-stats article + article, .account-stats article:last-child { grid-column: auto; border-top: 0; border-left: 1px solid var(--line); }
  .account-stats .value { font-size: 20px; }
  .account-stats .note { font-size: 12px; }
  .key-access, .calculator-fields, .grid { grid-template-columns: minmax(0, 1fr); }
  .calculator-model { grid-column: auto; }
  #calculator-form > .calculator-fields { grid-template-columns: minmax(0, 1fr); }
  .payment-method { padding: 20px; }
  .payment-method-heading { align-items: stretch; flex-direction: column; }
  .payment-method-heading button { width: 100%; }
  #top-up .payment-method-heading button { width: auto; }
  .cabinet-fold-body #test-access-form { grid-template-columns: 1fr; }
  .cabinet-fold-body #test-access-form button { justify-self: start; }
  .account-calculator { padding-top: 28px; }
  .account-calculator .actions { align-items: stretch; flex-direction: column; }
  .footer { padding: 28px 16px; }
  .primary, .secondary { min-height: 44px; }
  .label input, .label select, .label textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .cabinet-nav { scroll-behavior: auto; }
}

.access-tools{display:flex;align-items:baseline;flex-wrap:wrap;gap:8px 16px;margin-top:12px}
.access-tools>.secondary{width:auto;justify-self:start}
.access-probe{padding:0;border:0;max-width:36rem}
.access-probe>summary{min-height:44px;align-content:center;font-size:14px}
.access-probe[open]{flex-basis:100%}
.access-probe-form{display:grid;grid-template-columns:minmax(0,20rem);gap:12px;padding:8px 0}
.access-probe-form>label:not(.access-consent){display:grid;gap:6px;font-size:14px}
.access-probe-form select{width:100%;min-width:0;font-size:16px;min-height:44px}
.access-consent{display:flex;align-items:flex-start;gap:8px;font-size:14px;line-height:1.5;min-height:44px}
.access-consent input{flex:none;width:18px;height:18px;margin:2px 0 0;accent-color:var(--blue)}
.access-probe-form .note{margin:0;max-width:60ch}
.access-probe-form button{width:auto;justify-self:start}
.access-status{margin:8px 0;font-size:14px;line-height:1.5;max-width:68ch;overflow-wrap:anywhere}
.access-status:empty{display:none}
#entity-interface .ec-usage{padding:0;margin:16px 0;border-block:1px solid var(--line)}
#entity-interface .ec-usage summary{min-height:44px;align-content:center;font-size:14px;overflow-wrap:anywhere}
#entity-interface .ec-usage-filter{display:flex;align-items:end;flex-wrap:wrap;gap:12px;padding-top:8px}
#entity-interface .ec-usage-filter .label{flex:0 1 150px;margin:0;font-size:14px}
#entity-interface .ec-usage-filter input{min-width:0;width:100%;font-size:16px;min-height:44px}
#entity-interface .ec-usage-filter button{min-height:44px;width:auto;justify-self:start}
#entity-interface .ec-usage-totals{display:flex;flex-wrap:wrap;gap:16px 32px;margin:16px 0;font-variant-numeric:tabular-nums}
#entity-interface .ec-usage-totals dt{font-size:13px;color:var(--ec-muted)}
#entity-interface .ec-usage-totals dd{margin:4px 0 0;font-size:16px;font-weight:600}
#entity-interface .ec-usage-table{max-width:100%;overflow-x:auto;scrollbar-width:thin;scrollbar-color:var(--line) transparent}
#entity-interface .ec-usage-table table{width:100%;min-width:30rem;border-collapse:collapse;font-size:14px;font-variant-numeric:tabular-nums}
#entity-interface .ec-usage-table caption{text-align:left;font-size:14px;font-weight:600;padding:0 0 8px}
#entity-interface .ec-usage-table th,#entity-interface .ec-usage-table td{padding:10px 8px;border-bottom:1px solid var(--line);text-align:right}
#entity-interface .ec-usage-table th:first-child,#entity-interface .ec-usage-table td:first-child{text-align:left;overflow-wrap:anywhere;max-width:16rem}
#entity-interface .ec-usage-table th{font-weight:500;color:var(--ec-muted)}
#entity-interface .ec-usage-history,#entity-interface .ec-usage-entry{padding:0;border:0}
#entity-interface .ec-usage-entry{border-top:1px solid var(--line)}
.access-tools :focus-visible,.ec-usage :focus-visible{outline:2px solid var(--blue);outline-offset:3px}
.access-tools ::selection,.ec-usage ::selection{background:#ead1cb;color:var(--text)}
/* Corporate cabinet only. Preserve personal UI, routing and accounting. */
#entity-interface { --ec-muted: #62625f; max-width: 54rem; }
#entity-interface .ec-caption, #entity-interface .ec-list-note, #entity-interface .ec-entity-address { color: var(--ec-muted); font-size: .875rem; line-height: 1.5; }
#entity-interface .ec-status { margin: .75rem 0; font-size: .875rem; line-height: 1.5; overflow-wrap: anywhere; }
#entity-interface .ec-status:empty { display: none; }
#entity-interface .ec-list-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: .75rem; }
#entity-interface .ec-list-heading h2 { margin: 0; font-size: 1.375rem; line-height: 1.3; letter-spacing: -.02em; }
#entity-interface .ec-list-note { margin: .5rem 0 1.25rem; max-width: 70ch; }
#entity-interface .ec-entity-list { border-top: 1px solid var(--line); }
#entity-interface .ec-entity-row { padding: 0; }
#entity-interface .ec-entity-summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0; list-style: none; }
#entity-interface .ec-entity-summary::-webkit-details-marker { display: none; }
#entity-interface .ec-entity-summary:hover { color: var(--blue); }
#entity-interface .ec-entity-summary:focus-visible { border-radius: .25rem; }
#entity-interface .ec-entity-summary > svg { width: 1.125rem; height: 1.125rem; flex: none; transition: transform 160ms ease-out; }
#entity-interface .ec-entity-row[open] > .ec-entity-summary > svg { transform: rotate(90deg); }
#entity-interface .ec-entity-identity { display: grid; gap: .25rem; min-width: 0; }
#entity-interface .ec-entity-identity strong { font-size: 1rem; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
#entity-interface .ec-entity-panel { padding: 0 0 1.25rem; min-width: 0; }
#entity-interface .ec-entity-address { margin: 0 0 1rem; overflow-wrap: anywhere; }
#entity-interface .ec-overview { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
#entity-interface .ec-balance { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1rem; }
#entity-interface .ec-balance-value { font-size: 1.125rem; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#entity-interface .ec-entity-panel h3 { margin: 1.25rem 0 .375rem; font-size: .9375rem; font-weight: 600; line-height: 1.4; letter-spacing: 0; }
#entity-interface .ec-key-section > p { margin: 0; }
#entity-interface .ec-invoice-create summary, #entity-interface .ec-register summary { font-size: .875rem; line-height: 1.5; min-height: 2.75rem; align-content: center; }
#entity-interface .ec-key-controls { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 1rem; max-width: 28rem; }
#entity-interface .ec-key-input { flex: 1 1 12rem; width: 12rem; min-width: 0; max-width: 22rem; height: 2.5rem; padding: .5rem .75rem; border: 1px solid #b8b5ae; border-radius: .5rem; background: var(--panel); color: var(--text); font-size: 1rem; line-height: 1.5; }
#entity-interface .ec-key-input::placeholder { color: var(--ec-muted); opacity: 1; font-size: .875rem; }
#entity-interface .ec-icon-actions { display: flex; flex: none; gap: .25rem; }
#entity-interface .ec-icon-button { position: relative; display: inline-flex; flex: none; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem; min-height: 2.5rem; padding: .5rem; border: 1px solid var(--line); border-radius: .5rem; color: var(--text); background: transparent; }
#entity-interface .ec-icon-button svg { width: 1.125rem; height: 1.125rem; pointer-events: none; }
#entity-interface .ec-icon-button:hover:not(:disabled) { background: var(--panel); border-color: #b8b5ae; }
#entity-interface .ec-icon-button:active:not(:disabled) { background: var(--blue-bg); }
#entity-interface .ec-icon-button:disabled { opacity: .45; }
#entity-interface .ec-icon-button[aria-busy=true] { cursor: wait; }
#entity-interface .ec-icon-button::after { content: attr(data-tooltip); display: none; position: absolute; z-index: 20; bottom: calc(100% + .5rem); right: 0; width: max-content; max-width: 14rem; padding: .375rem .5rem; border-radius: .25rem; background: var(--text); color: var(--panel); font-size: .75rem; font-weight: 400; line-height: 1.4; pointer-events: none; }
#entity-interface .ec-icon-button:is(:hover, :focus-visible)::after { display: block; }
#entity-interface .ec-invoice-create { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; }
#entity-interface .entity-invoice-form { grid-template-columns: minmax(0, 12rem) 6rem auto; max-width: 36rem; align-items: end; gap: .75rem; padding: .25rem 0 1rem; }
#entity-interface .entity-invoice-form button, #entity-interface .entity-register-form button { padding: .625rem 1rem; min-height: 2.75rem; font-size: .875rem; justify-self: start; }
#entity-interface .ec-invoice-row { padding: 0; }
#entity-interface .ec-invoice-summary { display: grid; grid-template-columns: minmax(0, 1fr) auto auto 1rem; align-items: center; gap: .75rem; padding: .75rem 0; font-size: .875rem; font-variant-numeric: tabular-nums; }
#entity-interface .ec-invoice-summary svg { width: 1rem; height: 1rem; }
#entity-interface .ec-invoice-row[open] > .ec-invoice-summary svg { transform: rotate(90deg); }
#entity-interface .ec-invoice-summary > span { overflow-wrap: anywhere; }
#entity-interface .ec-invoice-row > p { margin: 0 0 .5rem; }
#entity-interface .ec-pdf-link { display: inline-block; padding: .5rem 0; font-size: .875rem; text-underline-offset: .2em; }
#entity-interface .ec-register { padding: .5rem 0; border-bottom: 0; }
#entity-interface .entity-register-form { max-width: 46rem; gap: .75rem 1rem; padding: .5rem 0 1rem; }
#entity-interface .entity-register-form > button { grid-column: 1 / -1; }
@media (max-width: 600px) {
  #entity-interface .ec-icon-button { width: 2.75rem; height: 2.75rem; min-height: 2.75rem; }
  #entity-interface .ec-key-controls { flex-wrap: nowrap; }
  #entity-interface .ec-key-input { flex: 1 1 0; width: 0; height: 2.75rem; max-width: 22rem; }
  #entity-interface .ec-icon-actions .ec-icon-button:first-child::after { right: auto; left: 0; }
  #entity-interface .ec-invoice-summary { grid-template-columns: minmax(0, 1fr) auto 1rem; gap: .25rem .5rem; }
  #entity-interface .ec-invoice-summary > .ec-caption { grid-column: 1 / 3; grid-row: 2; }
  #entity-interface .ec-invoice-summary > svg { grid-column: 3; grid-row: 1 / 3; }
  #entity-interface .entity-invoice-form { grid-template-columns: minmax(0, 1fr) 6rem; }
  #entity-interface .entity-invoice-form > button { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { #entity-interface .ec-entity-summary > svg { transition: none; } }
/* Compact cabinet rhythm; corporate key widgets keep their existing protections. */
.account-main{padding-top:20px;padding-bottom:40px}
.account-main>#page-title{font-size:28px;line-height:1.2;letter-spacing:-.025em}
.account-main h2,.account-main .section-heading h2{font-size:22px}
.account-main h3{font-size:18px}
.account-main .section{margin-top:20px;padding-top:0}
.account-main .section-heading{margin-bottom:12px;gap:12px}
.account-overview{margin-top:20px;padding:16px}
.account-main .account-overview{padding:16px}
.account-stats .value{font-size:22px}
.account-main .card,.account-main .payment-method{padding:16px}
.account-main .primary,.account-main .secondary,.account-main .danger{min-height:40px;padding:9px 14px;font-size:14px}
.account-calculator{padding-top:20px}
.account-main .section-heading>button{width:auto;align-self:flex-start}
.account-main .payment-method-heading button{width:auto;align-self:flex-start}
#entity-interface .ec-list-heading h2{font-size:20px}
#entity-interface .ec-list-note{margin-bottom:12px}
/* A single overview heading row: same sync action, quiet accessible icon. */
#overview .overview-heading{display:block;margin-bottom:12px}
#overview .overview-title-row{display:flex;align-items:center;gap:8px;min-width:0}
#overview .overview-heading>p{margin:4px 0 0}
#overview .overview-refresh{display:inline-flex;flex:0 0 40px;align-items:center;justify-content:center;width:40px;height:40px;min-height:40px;padding:8px;border:0;border-radius:8px;background:transparent;color:var(--muted)}
#overview .overview-refresh svg{display:block;width:20px;height:20px;pointer-events:none}
#overview .overview-refresh:hover{background:var(--bg);color:var(--text)}
#overview .overview-refresh:focus-visible{outline:3px solid var(--blue);outline-offset:2px}
@media(max-width:700px){.cabinet-nav a{min-height:44px}#overview .overview-refresh{flex-basis:44px;width:44px;height:44px;min-height:44px}}
#entity-interface .entity-mode-switch{gap:20px;margin-bottom:12px;border-bottom:1px solid var(--line)}
#entity-interface .entity-mode-switch button{width:auto;min-height:44px;padding:8px 0;border:0;border-bottom:2px solid transparent;border-radius:0;background:transparent;color:var(--muted);font-size:14px}
#entity-interface .entity-mode-switch button[aria-pressed=true]{border-bottom-color:var(--text);background:transparent;color:var(--text)}
@media(max-width:700px){.account-stats .value{font-size:18px}}
@media(max-width:700px){.account-main{padding-top:16px}.account-main>#page-title{font-size:26px}.account-main h2,.account-main .section-heading h2{font-size:20px}.account-main .primary,.account-main .secondary,.account-main .danger{min-height:44px;padding:10px 14px}.account-overview{padding:14px}.account-main .section{margin-top:16px}.account-main .card,.account-main .payment-method{padding:16px}}

/* Current location in the existing cabinet anchor navigation. */
.cabinet-nav a[aria-current="location"]{color:var(--text);text-decoration:underline;text-decoration-thickness:2px;text-underline-offset:8px}

/* Match the cabinet content gutter without changing the authentication shell. */
@media(min-width:701px){.site:has(>.account-main)>.topbar{padding-inline:max(24px,calc((100% - 1180px) / 2 + 24px))}}

.account-email-change { max-width: 44rem; overflow-wrap: anywhere; }
.account-email-change summary { cursor: pointer; padding-block: 12px; font-weight: 600; }
.email-change-content { padding-block: 4px 12px; max-width: 34rem; }
.account-email-change .form { max-width: 30rem; }
.account-email-change input { min-width: 0; width: 100%; }
.account-email-change .actions { flex-wrap: wrap; }
.account-email-change button { white-space: normal; }
.account-email-change :is(input,button,summary) { scroll-margin-block: 24px; }
.account-email-change .field-error:empty,
#email-change-status:empty { display: none; }
#email-change-status[data-error="true"] { color: var(--danger, #a52a24); }

/* Presentation-only section navigation. Authentication and payer mode own hidden. */
#dashboard.cabinet-sidebar-layout{display:grid;grid-template-columns:210px minmax(0,1fr);column-gap:28px;align-items:start}
#dashboard.cabinet-sidebar-layout[hidden]{display:none}
#dashboard.cabinet-sidebar-layout>.cabinet-nav{grid-column:1;grid-row:1/4;position:sticky;top:24px;display:flex;flex-direction:column;gap:4px;margin:0;padding:8px 12px 8px 0;border-block:0;border-right:1px solid var(--line);background:transparent;overflow:visible}
#dashboard.cabinet-sidebar-layout>.cabinet-nav a{gap:10px;min-height:44px;white-space:normal;line-height:1.4;overflow-wrap:anywhere}
.cabinet-nav a svg{width:19px;height:19px;flex:none}
#dashboard.cabinet-sidebar-layout>.cabinet-nav a[aria-current=location]{background:var(--blue-bg);color:var(--text);text-decoration:none}
#dashboard.cabinet-sidebar-layout>.section,#dashboard.cabinet-sidebar-layout>#key-history{grid-column:2;grid-row:2;margin-top:16px;min-width:0}
#dashboard.cabinet-sidebar-layout>#entity-interface{grid-column:2;grid-row:1;max-width:none;margin-top:0}
#dashboard.cabinet-sidebar-layout>#key-history{grid-row:3}
#dashboard .cabinet-view-inactive{display:none!important}
#entity-interface.cabinet-entity-context .ec-entity-panel,#entity-interface.cabinet-entity-context .ec-company-work{display:none}
#dashboard>.cabinet-nav-toggle{display:none}
#dashboard.cabinet-sidebar-layout>.cabinet-nav a[hidden]{display:none}
#dashboard .cabinet-nav :focus-visible,#dashboard>.cabinet-nav-toggle:focus-visible{outline:2px solid var(--blue);outline-offset:3px}
@media(max-width:760px){
 #dashboard.cabinet-sidebar-layout{grid-template-columns:minmax(0,1fr);column-gap:0}
 #dashboard.cabinet-sidebar-layout>.cabinet-nav-toggle{display:block;grid-column:1;grid-row:1;justify-self:start;min-height:44px;margin-bottom:12px}
 #dashboard.cabinet-sidebar-layout>.cabinet-nav{display:none;grid-column:1;grid-row:2;position:static;gap:2px;margin:0 0 16px;padding:0 0 12px;border-right:0;border-bottom:1px solid var(--line)}
 #dashboard.cabinet-sidebar-layout.cabinet-nav-open>.cabinet-nav{display:flex}
 #dashboard.cabinet-sidebar-layout>#entity-interface{grid-column:1;grid-row:3}
 #dashboard.cabinet-sidebar-layout>.section,#dashboard.cabinet-sidebar-layout>#key-history{grid-column:1;grid-row:4}
 #dashboard.cabinet-sidebar-layout>#key-history{grid-row:5}
}

/* Cabinet refinement: retain the existing sections and navigation behavior. */
.account-main>#page-title{font-size:28px;font-weight:600;line-height:1.2;letter-spacing:-.025em;margin-bottom:16px}
#dashboard.cabinet-sidebar-layout{column-gap:32px}
#dashboard.cabinet-sidebar-layout>.cabinet-nav{border-right:0;padding:0 8px 0 0;gap:2px}
#dashboard.cabinet-sidebar-layout>.cabinet-nav a{font-weight:400;border-radius:7px;padding:9px 12px}
#dashboard.cabinet-sidebar-layout>.cabinet-nav a[aria-current=location]{font-weight:500}
#dashboard.cabinet-sidebar-layout>.cabinet-nav a:not([aria-current]):hover{background:var(--panel);color:var(--text)}
#dashboard.cabinet-sidebar-layout>.cabinet-nav svg{width:18px;height:18px}
#dashboard.cabinet-sidebar-layout>#entity-interface .entity-mode-switch{border-bottom:0;margin-bottom:8px;gap:24px}
#dashboard.cabinet-sidebar-layout>#entity-interface .entity-mode-switch button{font-weight:400;min-height:40px;padding:6px 0}
#dashboard.cabinet-sidebar-layout>#entity-interface .entity-mode-switch button[aria-pressed=true]{font-weight:500}
#dashboard.cabinet-sidebar-layout>#entity-interface>p{font-size:13px;color:var(--muted);margin:4px 0 8px}
#dashboard.cabinet-sidebar-layout>.section{margin-top:12px}
#dashboard.cabinet-sidebar-layout .cabinet-fold{border-block:0}
#dashboard.cabinet-sidebar-layout .secondary{border:1px solid transparent;border-radius:7px;background:var(--panel);color:var(--text);box-shadow:none;font-weight:400}
#dashboard.cabinet-sidebar-layout .secondary:hover:not(:disabled){background:var(--blue-bg)}
#dashboard.cabinet-sidebar-layout .secondary:focus-visible{outline:2px solid var(--blue);outline-offset:3px}
#dashboard.cabinet-sidebar-layout .cabinet-fold>summary{min-height:44px;gap:10px;padding-block:8px}
#dashboard.cabinet-sidebar-layout .cabinet-fold>summary h2{font-size:20px;font-weight:600}
@media(max-width:760px){
 .account-main>#page-title{font-size:26px;margin-bottom:12px}
 #dashboard.cabinet-sidebar-layout{column-gap:0}
 #dashboard.cabinet-sidebar-layout>.cabinet-nav-toggle{margin-bottom:8px}
 #dashboard.cabinet-sidebar-layout>.cabinet-nav{padding:4px 0 12px;margin-bottom:12px}
 #dashboard.cabinet-sidebar-layout>.cabinet-nav a,#dashboard.cabinet-sidebar-layout .secondary,#dashboard.cabinet-sidebar-layout>#entity-interface .entity-mode-switch button{min-height:44px}
 #dashboard.cabinet-sidebar-layout>.section{margin-top:8px}
}

/* Company context stays above the common navigation at every width. */
#dashboard.cabinet-sidebar-layout>.company-context{grid-column:1;grid-row:1;min-width:0;margin-bottom:16px;padding-right:8px}
#dashboard.cabinet-sidebar-layout[data-account-mode=company]>.cabinet-nav{grid-row:2/5}
.company-context label{display:grid;gap:6px;font-size:13px;color:var(--muted)}
.company-context select{width:100%;min-width:0;min-height:44px;font:inherit;font-size:14px;padding:9px 10px;background:var(--panel);color:var(--text);border:1px solid var(--line);border-radius:7px}
.company-context .company-selected-name{font-size:13px;overflow-wrap:anywhere;margin:8px 0;color:var(--text)}
.company-context .secondary{font-size:13px;min-height:44px;max-width:100%;white-space:normal}
.company-context .ec-caption{font-size:12px;color:var(--muted)}
.company-context :focus-visible{outline:2px solid var(--blue);outline-offset:3px}
#entity-interface .ec-company-content{min-width:0}
#entity-interface .ec-destination{margin-top:16px;min-width:0}
#entity-interface .ec-destination>h2{margin:0 0 12px;font-size:20px;line-height:1.4}
#entity-interface .ec-destination .ec-key-section>h3{display:none}
#entity-interface.cabinet-entity-context .ec-company-work{display:none}
@media(max-width:760px){
 #dashboard.cabinet-sidebar-layout>.company-context{grid-column:1;grid-row:1;padding:0;margin-bottom:12px}
 #dashboard.cabinet-sidebar-layout>.cabinet-nav-toggle{grid-row:2}
 #dashboard.cabinet-sidebar-layout>.cabinet-nav,#dashboard.cabinet-sidebar-layout[data-account-mode=company]>.cabinet-nav{grid-row:3}
 #dashboard.cabinet-sidebar-layout>#entity-interface{grid-row:4}
 #dashboard.cabinet-sidebar-layout>.section{grid-row:5}
 #dashboard.cabinet-sidebar-layout>#key-history{grid-row:6}
 .company-context select{font-size:16px}
}

/* Keep sidebar context and links together without coupling their row heights to content. */
#dashboard.cabinet-sidebar-layout>.cabinet-sidebar{grid-column:1;grid-row:1/4;position:sticky;top:24px;min-width:0;align-self:start}
.cabinet-sidebar>.company-context{margin-bottom:16px;padding-right:8px}
.cabinet-sidebar>.cabinet-nav{position:static;display:flex;flex-direction:column;gap:2px;margin:0;padding:0 8px 0 0;border:0;background:transparent;overflow:visible}
.cabinet-sidebar>.cabinet-nav a{gap:10px;min-height:44px;white-space:normal;line-height:1.4;overflow-wrap:anywhere;font-weight:400;padding:9px 12px;border-radius:7px}
.cabinet-sidebar>.cabinet-nav a[aria-current=location]{background:var(--blue-bg);color:var(--text);font-weight:500;text-decoration:none}
.cabinet-sidebar>.cabinet-nav a[hidden]{display:none}
.cabinet-sidebar>.cabinet-nav svg{width:18px;height:18px}
.cabinet-sidebar>.cabinet-nav-toggle{display:none}
@media(max-width:760px){
 #dashboard.cabinet-sidebar-layout>.cabinet-sidebar{grid-column:1;grid-row:1;position:static}
 .cabinet-sidebar>.company-context{padding:0;margin-bottom:12px}
 .cabinet-sidebar>.cabinet-nav-toggle{display:block;min-height:44px;margin-bottom:8px}
 .cabinet-sidebar>.cabinet-nav{display:none;padding:4px 0 12px;margin-bottom:12px}
 .cabinet-nav-open>.cabinet-sidebar>.cabinet-nav{display:flex}
 #dashboard.cabinet-sidebar-layout>#entity-interface{grid-row:2}
 #dashboard.cabinet-sidebar-layout>.section{grid-row:3}
 #dashboard.cabinet-sidebar-layout>#key-history{grid-row:4}
}

/* Existing requisites, without introducing editable financial or profile fields. */
#entity-interface .ec-requisites{display:grid;gap:16px;margin:12px 0;max-width:44rem}
#entity-interface .ec-requisites>div{min-width:0}
#entity-interface .ec-requisites dt{font-size:13px;color:var(--muted)}
#entity-interface .ec-requisites dd{margin:4px 0 0;font-size:15px;overflow-wrap:anywhere}
#account-balance>h2,#account-notifications>h2,#account-requisites>h2{margin-top:0;font-size:20px;line-height:1.4}
#overview.cabinet-view-inactive{display:none!important}

#account-logs>h2{margin-top:0;font-size:20px;line-height:1.4}
