/* EZSoft product UI: Telegram-adapted native controls, Tabler outline icons.
   Shape scale: controls 10px, surfaces 16px, dialogs 20px; brand mark is an unframed SVG.
   Layers: content auto, notification 10, dialogs in browser top layer. */
:root {
  color-scheme: light;
  --paper: #f1f4f8;
  --surface: #fbfcfe;
  --ink: #24324a;
  --muted: #5c697b;
  --line: #d7dfeb;
  --field-line: #7e8ea5;
  --accent: #215dc1;
  --accent-soft: #e8effc;
  --on-accent: #f7f9fd;
  --success: #2a6d53;
  --warning: #7b5918;
  --warning-bg: #fff4da;
  --danger: #b13346;
  --radius-control: 10px;
  --radius-surface: 16px;
  --radius-dialog: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", sans-serif;
  font-synthesis: none;
}
body.dark {
  color-scheme: dark;
  --paper: #141c28;
  --surface: #1b2737;
  --ink: #e6ecf5;
  --muted: #aab6c8;
  --line: #36465e;
  --field-line: #7789a3;
  --accent: #9cbbf2;
  --accent-soft: #263b5c;
  --success: #86d1ad;
  --warning: #f1cb83;
  --warning-bg: #382e1e;
  --danger: #ff9cae;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font-size: 15px; line-height: 1.5; }
button, input, select { font: inherit; }
button, a, input, select { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
a { color: var(--accent); text-underline-offset: 3px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
button:not(:disabled):active { transform: scale(.98); }
.ui-icon { display: inline-block; flex-shrink: 0; width: 20px; height: 20px; background: currentColor; mask: var(--icon) center / contain no-repeat; }
.icon-refresh { --icon: url('/app/icons/refresh.svg'); }
.icon-transfer { --icon: url('/app/icons/arrows-right-left.svg'); }
.icon-journal { --icon: url('/app/icons/list-details.svg'); }
.icon-plug { --icon: url('/app/icons/plug-connected.svg'); }
.icon-plus { --icon: url('/app/icons/plus.svg'); }
.icon-close { --icon: url('/app/icons/x.svg'); }
.icon-down { --icon: url('/app/icons/arrow-down.svg'); }
.icon-right { --icon: url('/app/icons/arrow-right.svg'); }
.shell { max-width: 960px; margin: auto; padding: var(--tg-content-safe-area-inset-top, 0px) 32px 0; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; gap: 12px; align-items: center; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 19px; letter-spacing: -.4px; }
.brand-sub { font-weight: 400; color: var(--muted); }
.brand-mark { display: block; flex-shrink: 0; width: 40px; height: 40px; object-fit: contain; }
.icon-button { border: 0; background: transparent; color: var(--muted); width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-control); }
.icon-button:hover { background: var(--accent-soft); color: var(--accent); }
.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.tab { display: flex; gap: 8px; align-items: center; position: relative; min-height: 48px; margin-bottom: -1px; padding: 12px 0; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }
.section-head { display: flex; gap: 20px; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
h1 { margin: 0 0 8px; font-size: 28px; line-height: 1.2; letter-spacing: -.65px; font-weight: 680; }
h2 { margin: 0 0 12px; font-size: 18px; line-height: 1.35; letter-spacing: -.25px; }
p { margin: 0 0 12px; max-width: 68ch; }
.section-head p { color: var(--muted); font-size: 14px; margin: 0; }
.button { display: inline-flex; gap: 8px; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; border-radius: var(--radius-control); border: 1px solid transparent; font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.button .ui-icon { width: 18px; height: 18px; }
.button.primary { background: #215dc1; color: var(--on-accent); }
.button.primary:hover { background: #194fa9; }
.button.secondary { background: var(--surface); color: var(--ink); border-color: var(--field-line); }
.button.secondary:hover { background: var(--accent-soft); }
.button.ghost { background: transparent; color: var(--accent); padding: 10px 12px; }
.button.ghost:hover { background: var(--accent-soft); }
.button.danger { color: var(--danger); }
.button.compact { min-height: 44px; padding: 9px 12px; font-size: 13px; }
.summary-line { display: flex; gap: 24px; color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.summary-line strong { color: var(--ink); font-size: 15px; font-weight: 650; margin-right: 4px; font-variant-numeric: tabular-nums; }
.connection-notice { display: block; width: 100%; min-height: 44px; text-align: left; color: var(--warning); background: var(--warning-bg); border: 1px solid #c19c543d; padding: 12px 16px; margin-bottom: 16px; border-radius: var(--radius-control); font-size: 13px; }
.routes-list { display: grid; gap: 16px; }
.route { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-surface); overflow: hidden; }
.route-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px 0; }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.status-dot { height: 6px; width: 6px; border-radius: 50%; background: currentColor; }
.status.active, .status.sent { color: var(--success); }
.status.failed, .status.uncertain { color: var(--danger); }
.route-number { font-size: 12px; color: var(--muted); }
.route-path { display: grid; grid-template-columns: 1fr 64px 1fr; align-items: center; padding: 16px 20px; gap: 16px; }
.endpoint { display: flex; align-items: center; gap: 12px; min-width: 0; }
.platform { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 40px; height: 40px; border-radius: var(--radius-control); color: var(--accent); background: var(--accent-soft); font-weight: 700; font-size: 13px; letter-spacing: -.3px; }
.endpoint-content { min-width: 0; }
.endpoint-title { font-size: 15px; font-weight: 620; overflow-wrap: anywhere; }
.endpoint-detail { margin-top: 2px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.route-wire { display: flex; align-items: center; color: var(--muted); }
.route-wire:before { content: ''; height: 1px; width: 100%; background: var(--line); }
.route-wire .ui-icon { width: 18px; height: 18px; margin-left: -7px; }
.route-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding: 4px 8px 4px 20px; }
.route-flags { font-size: 12px; color: var(--muted); }
.route-actions { display: flex; gap: 4px; flex-shrink: 0; }
.empty { padding: 36px 24px; text-align: center; border: 1px dashed var(--field-line); border-radius: var(--radius-surface); }
.empty h2 { font-size: 20px; }
.empty p { margin: 0 auto 20px; color: var(--muted); max-width: 42ch; font-size: 14px; }
.empty-symbol { width: 32px; height: 32px; color: var(--accent); margin-bottom: 16px; }
.filter-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.filter-row select { width: auto; min-width: 175px; margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.jobs-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-surface); overflow: hidden; }
.job { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.job:last-child { border-bottom: 0; }
.job-top { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.job-route { font-size: 12px; color: var(--muted); }
.job-text { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0; }
.job-error { font-size: 13px; color: var(--danger); overflow-wrap: anywhere; margin-top: 10px; }
.job-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.account-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-surface); padding: 24px; margin-bottom: 28px; }
.account-heading { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.account-heading .platform { width: 44px; height: 44px; font-size: 14px; }
.account-heading h2 { margin: 0 0 4px; }
.account-panel p { font-size: 14px; color: var(--muted); }
.account-detail { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 13px; }
.account-detail span { color: var(--muted); }
.account-detail strong { font-weight: 500; text-align: right; }
.account-panel .button { margin-top: 12px; }
.help-block { padding: 0 4px; }
.help-block h2 { font-size: 16px; }
.help-block p { color: var(--muted); font-size: 14px; }
.footer { display: flex; gap: 8px; font-size: 12px; color: var(--muted); padding: 28px 0 24px; }
.footer-brand { margin-left: auto; }
.gate { min-height: 430px; display: flex; align-items: center; justify-content: center; flex-direction: column; text-align: center; padding: 24px; }
.gate h1 { font-size: 24px; }
.gate p { font-size: 14px; color: var(--muted); max-width: 42ch; }
.gate-symbol { width: 36px; height: 36px; color: var(--accent); margin-bottom: 20px; }
.loading-shapes { display: grid; gap: 12px; width: min(100%, 400px); margin-top: 20px; }
.loading-shapes span { height: 76px; border-radius: var(--radius-surface); border: 1px solid var(--line); background: var(--surface); }
.preview-note { background: var(--warning-bg); color: var(--warning); padding: 8px 12px; border-radius: var(--radius-control); font-size: 12px; margin-bottom: 8px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); width: max-content; max-width: min(90vw, 600px); padding: 12px 16px; background: var(--ink); color: var(--surface); border-radius: var(--radius-control); z-index: 10; box-shadow: 0 6px 24px #24324a26; font-size: 14px; }
.toast.error { background: #a32d40; color: #f7f9fd; }
dialog { border: 1px solid var(--line); border-radius: var(--radius-dialog); background: var(--surface); color: var(--ink); padding: 24px; width: min(94vw, 480px); max-height: 90dvh; overflow: auto; box-shadow: 0 24px 100px #1422384d; }
dialog::backdrop { background: #14223880; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 8px; }
.dialog-head h2 { margin: 0; font-size: 22px; }
.dialog-head .icon-button { margin: -10px -10px -4px 0; }
.dialog-intro { font-size: 14px; color: var(--muted); margin-bottom: 24px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 20px 0 8px; }
input:not([type=checkbox]), select { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--field-line); border-radius: var(--radius-control); background: var(--surface); color: var(--ink); font-size: 14px; }
input::placeholder { color: var(--muted); opacity: 1; }
.field-help { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.form-connector { display: flex; color: var(--accent); margin: 16px 0 -12px 12px; }
.check-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-top: 1px solid var(--line); font-weight: 400; }
.check-row strong { font-weight: 600; font-size: 14px; }
.check-row small { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.check-row input { width: 24px; height: 24px; accent-color: #215dc1; flex-shrink: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.form-error { font-size: 13px; color: var(--danger); margin-top: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 767px) {
  .shell { padding-left: 16px; padding-right: 16px; }
  .topbar { height: 64px; }
  .brand { font-size: 17px; }
  .brand-mark { width: 36px; height: 36px; }
  .tabs { gap: 0; justify-content: space-between; margin-bottom: 24px; }
  .tab { font-size: 13px; gap: 6px; padding: 12px 0; }
  .tab .ui-icon { width: 18px; height: 18px; }
  h1 { font-size: 25px; }
  .section-head { gap: 12px; margin-bottom: 20px; }
  .section-head p { font-size: 13px; }
  .section-head .button { padding: 10px 12px; font-size: 13px; }
  .summary-line { gap: 16px; font-size: 12px; margin-bottom: 16px; }
  .summary-line strong { font-size: 14px; }
  .route-top { padding: 12px 16px 0; }
  .route-path { grid-template-columns: 1fr; padding: 12px 16px; gap: 4px; }
  .endpoint { gap: 12px; }
  .route-wire { height: 16px; padding-left: 19px; }
  .route-wire:before { width: 1px; height: 16px; }
  .route-wire .ui-icon { display: none; }
  .route-bottom { padding: 4px 4px 4px 16px; gap: 4px; }
  .route-flags { font-size: 12px; }
  .route-actions { gap: 0; }
  .button.ghost { font-size: 12px; padding: 10px 8px; }
  .empty { padding: 28px 20px; }
  .empty p { font-size: 14px; }
  .account-panel { padding: 20px; }
  .account-detail { font-size: 12px; }
  .job { padding: 16px; }
  .job-top { align-items: flex-start; }
  .job-route { text-align: right; }
  .toast { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); font-size: 13px; }
  .footer { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); font-size: 11px; }
  dialog { width: calc(100vw - 16px); max-height: 92dvh; margin-bottom: 8px; padding: 20px; }
  .dialog-actions .button { flex: 1; }
  .gate { min-height: 420px; }
}
@media (prefers-reduced-motion: no-preference) {
  .button, .tab, .icon-button { transition: background-color .12s, color .12s, transform .12s; }
}
