/* Responsive UI release 2026-10-08. No backend or licence-policy changes. */
:root {
  --sidebar-width: 248px;
  --accent: #65e0b3;
  --chart-balance: #4cc9f0;
  --chart-equity: #89f7a1;
}
[data-theme="light"] { --accent: #067858; --chart-balance: #086b9f; --chart-equity: #187649; }
[data-theme="light"] .primary { background: linear-gradient(135deg,#067858,#075f46); }
html { scroll-padding-top: 24px; }
body { min-width: 0; min-height: 100svh; }
body:has(dialog[open]) { overflow: hidden; }
button, input, select, textarea { min-height: 44px; }
input, select, textarea { min-width: 0; max-width: 100%; font-size: 16px; }
input[type="file"] { white-space: normal; overflow: hidden; }
textarea { resize: vertical; }
button:disabled { cursor: not-allowed; opacity: .5; }
a.primary, a.secondary { min-height: 44px; }
button, a, label { -webkit-tap-highlight-color: transparent; }
button, .primary, .secondary, .ghost { line-height: 1.35; }
h1, h2, h3, p, small, code, output { overflow-wrap: anywhere; }
.content, .view, .panel, .stack, .split, .metric, .financial-grid,
.form-row, .form-row > *, .split > *, .inline-form > *, .currency-stats > *,
.topbar > *, .topbar-actions > *, .panel-title > *, .notice header > *,
.flow-grid > *, .data-grid > *, .decision-grid > *, .session-row > * { min-width: 0; }
.content { margin-left: var(--sidebar-width); padding: 32px clamp(20px, 3vw, 48px) 48px; max-width: 1920px; }
.sidebar { width: var(--sidebar-width); padding: 28px 16px 18px; z-index: 20; gap: 4px; }
.brand { padding: 0 8px 26px; }
.brand-mark { flex-shrink: 0; }
.sidebar nav { gap: 7px; }
.sidebar nav a { min-height: 46px; font-size: .86rem; gap: 10px; padding: 12px 14px; }
.sidebar nav a.active { background: linear-gradient(100deg, rgba(101,224,179,.13), rgba(66,165,255,.05)); }
[data-theme="light"] .sidebar nav a.active { background: #e5f4ed; color: #07553f; }
.sidebar-foot { display: grid; gap: 12px; padding-top: 18px; margin-top: auto; overflow-wrap: anywhere; }
.sidebar-foot .ghost { text-align: left; border: 1px solid var(--line); }
.topbar { gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.topbar-heading { flex: 1 1 240px; }
.topbar h1 { font-size: clamp(1.45rem, 1.05rem + 1.5vw, 2.25rem); line-height: 1.15; margin: 0; }
.topbar .eyebrow { margin-bottom: 8px; }
.topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
.theme-switcher button { min-width: 60px; min-height: 44px; padding: 8px 12px; font-size: .8rem; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; white-space: nowrap; }
.status-pill::before { content: ''; width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: currentColor; }
.metric-grid { grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.metric { padding: 22px; }
.metric strong { font-variant-numeric: tabular-nums; font-size: clamp(1.65rem, 2.2vw, 2rem); }
.panel { padding: 24px; }
.panel-title { gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.panel-title h2 { line-height: 1.4; }
.panel-title > button { flex-shrink: 0; }
.financial-grid { grid-template-columns: repeat(auto-fit,minmax(min(100%,240px),1fr)); }
.currency-card header, .notice header { flex-wrap: wrap; gap: 8px; }
.currency-stats { gap: 14px; }
.currency-stats b { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.split { grid-template-columns: minmax(0,.9fr) minmax(0,1.1fr); }
.form-row { grid-template-columns: repeat(2,minmax(0,1fr)); }
.toolbar { flex-wrap: wrap; align-items: stretch; }
.toolbar select { max-width: 100%; }
.license-toolbar { display: grid; grid-template-columns: minmax(180px,1fr) minmax(130px,.65fr) minmax(160px,.85fr) auto; gap: 10px; }
.license-toolbar select { width: 100%; }
.inline-form { grid-template-columns: minmax(0,1fr) minmax(0,1.4fr) minmax(0,1fr) auto; }
.table-panel, .table-scroll { min-width: 0; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.table-scroll { border-radius: 10px; }
.table-scroll:focus-visible { outline: 2px solid var(--accent2); outline-offset: -2px; }
.business-table { min-width: 620px; }
#licenses-table .business-table { min-width: 1040px; }
#audit-table .business-table { min-width: 760px; }
th { white-space: nowrap; }
td { max-width: 300px; }
.table-cell-value { min-width: 0; overflow-wrap: anywhere; }
.table-cell-value small { line-height: 1.55; }
.actions { flex-wrap: wrap; }
.actions button { min-height: 44px; font-size: .78rem; padding: 10px 12px; }
.pagination { flex-wrap: wrap; gap: 12px; text-align: center; }
.pagination span { min-width: 0; font-size: .85rem; }
.notice { padding: 18px; }
.notice header .tag { align-self: flex-start; }
.notice p, .notice small { overflow-wrap: anywhere; }
.session-row { flex-wrap: wrap; }
.session-row > div { flex: 1 1 160px; }
.session-row > button { flex-shrink: 0; }
.flash { overflow-wrap: anywhere; }
dialog { width: min(520px,calc(100% - 32px)); max-width: calc(100% - 32px); max-height: calc(100dvh - 32px); overflow: auto; padding: 24px; overscroll-behavior: contain; }
dialog#license-dialog { width: min(1040px,calc(100% - 32px)); }
dialog#secret-dialog { width: min(600px,calc(100% - 32px)); }
.dialog-wide { width: 100%; max-width: 100%; max-height: none; padding: 0; overflow: visible; }
#license-detail-title { font-size: 1.15rem; line-height: 1.45; }
.dialog-actions { flex-wrap: wrap; }
#license-chart { min-width: 0; }
#license-chart svg { display: block; height: auto; min-height: 140px; max-height: 280px; }
#license-chart path:first-of-type { stroke: var(--chart-balance); }
#license-chart path:last-of-type { stroke: var(--chart-equity); }
.chart-legend { flex-wrap: wrap; gap: 12px; }
.chart-legend span::before { background: var(--chart-balance); }
.chart-legend span:last-child::before { background: var(--chart-equity); }
.tutorial-toc { grid-template-columns: repeat(5,minmax(0,1fr)); position: static; }
.tutorial-toc a { min-height: 44px; display: flex; align-items: center; font-size: .82rem; }
.tutorial-section { scroll-margin-top: 24px; }
.tutorial-hero { display: grid; grid-template-columns: minmax(0,1fr) minmax(220px,.45fr); }
.tutorial-hero > div:first-child { min-width: 0; flex: 1 1 420px; }
.tutorial-hero-actions { flex: 1 1 260px; }
.callout { flex-wrap: wrap; }
.callout strong { flex: 1 1 150px; }
.callout span { flex: 3 1 240px; min-width: 0; }
.copy-row, .copy-row code { min-width: 0; }
.integration-code { min-width: 0; }
.integration-code > * { min-width: 0; }
.integration-code pre { max-width: 100%; font-size: .8rem; }
.alert-demo-controls button { min-height: 44px; font-size: .8rem; }
.mt5-titlebar { flex-wrap: wrap; }
.mt5-status { width: 100%; overflow-wrap: anywhere; }
.mt5-toolbox { min-width: 0; overflow: auto; }
.mt5-workspace { grid-template-rows: minmax(280px,1fr) auto; }
.mt5-tabs { flex-wrap: wrap; }
.mt5-popup { max-height: calc(100% - 28px); overflow: auto; }
.mt5-ok { min-height: 44px; }
.login-shell { position: relative; min-height: 100svh; padding: max(88px,env(safe-area-inset-top)) max(24px,env(safe-area-inset-right)) max(32px,env(safe-area-inset-bottom)) max(24px,env(safe-area-inset-left)); }
.login-card { padding: 36px; width: min(460px,100%); }
.login-card h1 { font-size: clamp(1.75rem,5vw,2.15rem); }
.privacy-card { width: min(760px,100%); }
.login-theme { top: max(16px,env(safe-area-inset-top)); right: max(24px,env(safe-area-inset-right)); }
.login-card form { margin-top: 24px; }
.login-card .primary { min-height: 48px; }
.privacy-link { display: flex; justify-content: center; align-items: center; min-height: 44px; line-height: 1.5; }
.login-card input:-webkit-autofill { -webkit-text-fill-color: var(--text); -webkit-box-shadow: 0 0 0 1000px var(--panel) inset; caret-color: var(--text); }
.navigation-toggle, .navigation-close { display: none; }
.navigation-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(2,6,14,.64); }
.skip-link { position: fixed; left: 16px; top: 12px; z-index: 60; transform: translateY(-160%); padding: 12px 16px; background: var(--panel); color: var(--text); border: 2px solid var(--accent2); border-radius: 10px; }
.skip-link:focus { transform: translateY(0); }

@media (max-width: 1350px) {
  .license-toolbar, .inline-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .license-toolbar input { grid-column: 1 / -1; }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .tutorial-toc { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (min-width: 1024px) and (max-width: 1180px) {
  .split { grid-template-columns: minmax(0,1fr); }
  .topbar-actions { justify-content: flex-start; }
}
@media (max-width: 1023px) {
  .content { margin-left: 0; padding: 24px max(20px,env(safe-area-inset-right)) max(36px,env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left)); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(320px,calc(100vw - 28px)); height: 100dvh; z-index: 40; padding: max(20px,env(safe-area-inset-top)) 18px max(18px,env(safe-area-inset-bottom)) max(18px,env(safe-area-inset-left)); transform: translateX(-105%); visibility: hidden; transition: transform .2s ease; box-shadow: 16px 0 60px #0005; }
  .navigation-open .sidebar { transform: translateX(0); visibility: visible; }
  .navigation-open { overflow: hidden; }
  .navigation-toggle, .navigation-close { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
  .navigation-toggle { padding: 10px 12px; }
  .menu-icon { font-size: 1.2rem; line-height: 1; }
  .navigation-close { align-self: flex-end; margin: -12px 0 12px; }
  .navigation-close span { font-size: 1.6rem; }
  .sidebar .brand { padding-bottom: 14px; }
  .sidebar nav { grid-template-columns: minmax(0,1fr); }
  .sidebar-foot { display: grid; margin-top: 20px; }
  .topbar { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 16px 12px; align-items: center; }
  .topbar-heading { grid-column: 2; }
  .topbar-actions { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
  .topbar h1 { font-size: clamp(1.3rem, 1rem + 1.6vw, 1.85rem); }
  .split { grid-template-columns: minmax(0,1fr); }
  .tutorial-toc { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .tutorial-hero { grid-template-columns: minmax(0,1fr); }
  .tutorial-hero-actions { min-width: 0; width: 100%; }
}
@media (max-width: 640px) {
  .content { padding-top: 20px; padding-left: max(16px,env(safe-area-inset-left)); padding-right: max(16px,env(safe-area-inset-right)); }
  .panel { padding: 18px; border-radius: 16px; }
  .table-panel { padding: 14px; }
  .metric-grid { gap: 10px; }
  .metric { padding: 16px; border-radius: 14px; }
  .metric span { font-size: .75rem; line-height: 1.45; }
  .form-row, .inline-form, .license-toolbar { grid-template-columns: minmax(0,1fr); }
  .license-toolbar input { grid-column: auto; }
  .toolbar > select { flex: 1 1 170px; }
  .toolbar > button { flex: 1 1 100px; }
  .panel-title > button { flex: 1 1 100%; }
  .table-scroll { overflow: visible; }
  .business-table, #licenses-table .business-table, #audit-table .business-table { display: block; min-width: 0; width: 100%; }
  .business-table thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
  .business-table tbody { display: grid; gap: 14px; }
  .business-table tbody tr { display: block; border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; background: var(--panel); }
  .business-table tbody td { display: grid; grid-template-columns: minmax(0,.8fr) minmax(0,1.2fr); gap: 12px; width: 100%; max-width: none; padding: 10px 0; font-size: .85rem; line-height: 1.5; }
  .business-table tbody td::before { content: attr(data-label); color: var(--muted); font-weight: 600; font-size: .75rem; overflow-wrap: anywhere; }
  .table-cell-value { text-align: left; }
  .actions button { flex: 1 1 100%; }
  .pagination span { flex: 1 1 100%; order: -1; }
  .pagination button { flex: 1; }
  dialog { padding: 20px 16px; max-height: calc(100dvh - 24px); }
  .dialog-actions > button { flex: 1 1 90px; }
  .tutorial-section { grid-template-columns: minmax(0,1fr); gap: 14px; padding: 20px 16px; }
  .tutorial-section h2 { font-size: 1.2rem; }
  .tutorial-toc { padding: 8px; gap: 2px; }
  .tutorial-toc a { padding: 8px; font-size: .76rem; }
  .flow-grid,.data-grid,.decision-grid,.message-legend { grid-template-columns: minmax(0,1fr); }
  .tutorial-hero-actions { flex-basis: 100%; }
  .callout { padding: 14px; }
  .callout strong, .callout span { flex-basis: 100%; }
  .integration-code { padding: 12px; }
  .integration-code pre { padding: 12px; }
  .mt5-chart { padding: 14px; }
  .mt5-titlebar span:last-child { display: none; }
  .mt5-status { padding: 12px; font-size: 11px; }
  .mt5-toolbox pre { font-size: 11px; overflow-wrap: anywhere; }
  .mt5-popup { width: calc(100% - 24px); }
  .login-shell { padding-left: max(16px,env(safe-area-inset-left)); padding-right: max(16px,env(safe-area-inset-right)); }
  .login-card { padding: 28px 24px; border-radius: 22px; }
  .login-theme { right: max(16px,env(safe-area-inset-right)); }
}
@media (max-width: 360px) {
  .metric-grid { grid-template-columns: minmax(0,1fr); }
  .login-card { padding: 24px 20px; }
  .topbar-actions { gap: 10px; }
  .status-pill { font-size: .7rem; padding: 8px; }
  .theme-switcher button { padding: 8px 10px; min-width: 54px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
