:root {
  color-scheme: light;
  --background: #f2f3f6;
  --background-soft: #f8f8fa;
  --surface: rgba(255, 255, 255, .78);
  --surface-solid: #fff;
  --surface-elevated: rgba(255, 255, 255, .94);
  --surface-hover: rgba(246, 246, 249, .96);
  --border: rgba(38, 42, 55, .11);
  --border-strong: rgba(38, 42, 55, .18);
  --text-primary: #202124;
  --text-secondary: #70727a;
  --text-tertiary: #9a9ca4;
  --accent: #6754d9;
  --accent-hover: #5946ca;
  --accent-soft: #eeebff;
  --success: #2a9a66;
  --success-soft: #e9f7f0;
  --warning: #c48a23;
  --warning-soft: #fff4dc;
  --danger: #d44b55;
  --danger-soft: #fff0f1;
  --info: #3879bd;
  --info-soft: #eaf3fd;
  --radius-sm: 7px;
  --radius-md: 11px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-sm: 0 1px 2px rgba(26, 28, 35, .04), 0 4px 14px rgba(26, 28, 35, .04);
  --shadow-md: 0 16px 44px rgba(26, 28, 35, .11), 0 2px 8px rgba(26, 28, 35, .06);
  --shadow-window: 0 28px 80px rgba(28, 30, 38, .16), 0 4px 16px rgba(28, 30, 38, .08);
  --sidebar-width: 248px;
  --topbar-height: 82px;
  --focus-ring: 0 0 0 3px rgba(103, 84, 217, .18);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--text-primary); background: var(--background); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; }
.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; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, summary { -webkit-tap-highlight-color: transparent; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; display: block; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* Reusable controls */
.button, .icon-button {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .08s ease;
}
.button { min-height: 34px; padding: 7px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; }
.button-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.button-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button-secondary { color: var(--text-primary); background: var(--surface-solid); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.button-secondary:hover, .button-ghost:hover { background: var(--surface-hover); }
.button-ghost { color: var(--text-secondary); background: transparent; }
.button-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button-danger-soft { color: var(--danger); background: var(--danger-soft); border-color: rgba(212,75,85,.2); }
.button-danger-soft:hover { background: #ffe4e6; border-color: rgba(212,75,85,.3); }
.button:active, .icon-button:active { transform: translateY(1px); }
.button:focus-visible, .icon-button:focus-visible, .input:focus, .select:focus, .toggle input:focus-visible + span { outline: none; box-shadow: var(--focus-ring); }
.button:disabled, .icon-button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button.is-loading { color: transparent; pointer-events: none; position: relative; }
.button.is-loading::after { content: ""; position: absolute; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-button { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; color: var(--text-secondary); background: var(--surface-solid); border-color: var(--border); }
.field { display: grid; gap: 7px; }
.field label { color: var(--text-primary); font-size: 12px; font-weight: 600; }
.input, .select { width: 100%; min-height: 38px; color: var(--text-primary); background: rgba(255,255,255,.9); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 10px; outline: none; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
.input:hover, .select:hover { border-color: rgba(38,42,55,.28); }
.input:focus, .select:focus { background: #fff; border-color: rgba(103,84,217,.65); }
.input:disabled, .select:disabled { color: var(--text-tertiary); background: #f1f1f3; cursor: not-allowed; }
.toggle { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span:first-of-type { width: 34px; height: 20px; padding: 2px; border-radius: 999px; background: #c8cad0; transition: background .18s ease; }
.toggle span:first-of-type::after { content: ""; display: block; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .18s ease; }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(14px); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.badge { min-height: 20px; display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 999px; font-size: 9px; font-weight: 650; letter-spacing: .02em; white-space: nowrap; }
.badge-neutral { color: var(--text-tertiary); background: rgba(116,118,128,.09); }
.badge-accent { color: var(--accent); background: var(--accent-soft); }
.alert { padding: 9px 11px; border: 1px solid; border-radius: var(--radius-sm); font-size: 12px; line-height: 1.45; }
.alert-danger { color: #9e343d; background: var(--danger-soft); border-color: rgba(212,75,85,.2); }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.table { width: 100%; border-collapse: collapse; background: var(--surface-solid); font-size: 13px; }
.table th, .table td { padding: 11px 13px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { color: var(--text-secondary); font-size: 11px; font-weight: 650; background: var(--background-soft); }
.table tr:last-child td { border-bottom: 0; }
.dropdown { position: relative; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-menu { position: absolute; z-index: 20; padding: 6px; background: var(--surface-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.dropdown:not([open]) .dropdown-menu { display: none; }
.dropdown-item { width: 100%; min-height: 34px; padding: 7px 9px; display: flex; align-items: center; gap: 9px; border: 0; border-radius: var(--radius-sm); color: var(--text-primary); background: transparent; text-align: left; cursor: pointer; font-size: 12px; }
.dropdown-item:hover { background: var(--surface-hover); }
.dropdown-danger { color: var(--danger); }
.tooltip { position: relative; }
.tooltip:hover::after { content: attr(data-tooltip); position: absolute; left: 50%; bottom: calc(100% + 7px); transform: translateX(-50%); padding: 5px 7px; color: #fff; background: rgba(29,30,34,.9); border-radius: 5px; font-size: 10px; white-space: nowrap; pointer-events: none; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; padding: 20px; display: grid; place-items: center; background: rgba(22,23,28,.3); backdrop-filter: blur(3px); }
.modal, .confirm-dialog { width: min(100%, 480px); padding: 20px; background: var(--surface-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.modal-actions { margin-top: 20px; display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 60; max-width: 360px; padding: 11px 14px; color: var(--text-primary); background: var(--surface-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); font-size: 12px; }

/* Private login window */
.login-page { overflow: hidden; background: #eef0f4; }
.login-page::before, .login-page::after { content: ""; position: fixed; border-radius: 50%; filter: blur(10px); pointer-events: none; }
.login-page::before { width: 520px; height: 520px; left: -180px; top: -260px; background: radial-gradient(circle, rgba(112,92,210,.1), transparent 67%); }
.login-page::after { width: 580px; height: 580px; right: -220px; bottom: -310px; background: radial-gradient(circle, rgba(88,135,190,.08), transparent 68%); }
.login-stage { min-height: 100vh; padding: 24px; display: grid; place-items: center; position: relative; z-index: 1; }
.login-window { width: min(100%, 388px); overflow: hidden; background: rgba(255,255,255,.8); border: 1px solid rgba(255,255,255,.85); border-radius: var(--radius-xl); box-shadow: var(--shadow-window); backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px); }
.window-bar { height: 42px; padding: 0 15px; display: flex; align-items: center; gap: 7px; background: rgba(247,247,249,.8); border-bottom: 1px solid var(--border); }
.window-control { width: 11px; height: 11px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.07); }
.control-red { background: #ff5f57; }
.control-yellow { background: #febc2e; }
.control-green { background: #28c840; }
.login-content { padding: 31px 38px 27px; display: grid; gap: 17px; }
.login-heading { margin-bottom: 4px; display: grid; justify-items: center; }
.app-icon { width: 39px; height: 39px; display: grid; place-items: center; color: #fff; background: linear-gradient(150deg, #8170e3, #5c48c8); border-radius: 10px; box-shadow: 0 5px 14px rgba(94,74,202,.2); font-size: 18px; font-weight: 750; }
.login-heading h1 { margin: 13px 0 3px; font-size: 20px; line-height: 1.2; letter-spacing: -.025em; }
.login-heading p { margin: 0; color: var(--text-secondary); font-size: 12px; }
.login-submit { width: 100%; margin-top: 2px; }
.restricted-label { margin: -1px 0 0; color: var(--text-tertiary); text-align: center; font-size: 10px; letter-spacing: .04em; }

/* Desktop app shell */
.app-page { min-height: 100vh; background: radial-gradient(circle at 85% 0, rgba(111,94,200,.05), transparent 32%), var(--background); }
.app-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; width: var(--sidebar-width); padding: 18px 12px 14px; display: flex; flex-direction: column; background: rgba(246,246,248,.78); border-right: 1px solid var(--border); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); }
.app-identity { height: 59px; padding: 7px 9px 12px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid var(--border); }
.app-identity .app-icon { width: 35px; height: 35px; border-radius: 9px; font-size: 16px; flex: 0 0 auto; }
.app-identity > span:last-child { min-width: 0; display: grid; gap: 2px; }
.app-identity strong { overflow: hidden; font-size: 13px; font-weight: 680; white-space: nowrap; text-overflow: ellipsis; }
.app-identity small { color: var(--text-tertiary); font-size: 9px; letter-spacing: .01em; }
.sidebar-nav { padding-top: 14px; display: grid; gap: 3px; }
.sidebar-footer { margin-top: auto; padding-top: 11px; border-top: 1px solid var(--border); }
.sidebar-item { min-height: 37px; padding: 8px 10px; display: flex; align-items: center; gap: 10px; color: var(--text-secondary); border: 1px solid transparent; border-radius: var(--radius-sm); font-size: 12px; font-weight: 550; transition: color .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease; }
.sidebar-item .icon { width: 17px; height: 17px; color: #7c7e87; }
.sidebar-item > span:nth-child(2) { flex: 1; }
.sidebar-item:hover { color: var(--text-primary); background: rgba(255,255,255,.58); }
.sidebar-item.is-active { color: #4d3cb2; background: rgba(255,255,255,.9); border-color: rgba(74,61,153,.11); box-shadow: var(--shadow-sm); }
.sidebar-item.is-active .icon { color: var(--accent); }
.app-main { min-height: 100vh; margin-left: var(--sidebar-width); }
.page-header { min-height: var(--topbar-height); padding: 16px clamp(24px, 4vw, 50px); display: flex; align-items: center; justify-content: space-between; gap: 22px; background: rgba(249,249,251,.65); border-bottom: 1px solid var(--border); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.page-title-group { display: flex; align-items: center; gap: 11px; }
.page-title-group h1 { margin: 0; font-size: 19px; font-weight: 680; letter-spacing: -.02em; }
.page-title-group p { margin: 3px 0 0; color: var(--text-secondary); font-size: 10px; }
.mobile-menu { display: none; }
.account-trigger { min-width: 174px; padding: 5px 7px 5px 5px; display: flex; align-items: center; gap: 9px; border: 1px solid transparent; border-radius: var(--radius-md); cursor: pointer; transition: background .15s ease, border-color .15s ease; }
.account-trigger:hover, .account-menu[open] .account-trigger { background: rgba(255,255,255,.75); border-color: var(--border); }
.avatar { width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 auto; color: #5742bd; background: var(--accent-soft); border: 1px solid rgba(103,84,217,.1); border-radius: 50%; font-size: 12px; font-weight: 700; }
.account-copy { min-width: 0; flex: 1; display: grid; gap: 1px; }
.account-copy strong { max-width: 110px; overflow: hidden; font-size: 11px; font-weight: 650; white-space: nowrap; text-overflow: ellipsis; }
.account-copy small { color: var(--text-tertiary); font-size: 9px; }
.chevron { width: 14px; height: 14px; color: var(--text-tertiary); transition: transform .15s ease; }
.account-menu[open] .chevron { transform: rotate(180deg); }
.account-dropdown { top: calc(100% + 7px); right: 0; width: 220px; }
.dropdown-identity { padding: 8px 9px 10px; margin-bottom: 4px; display: grid; gap: 2px; border-bottom: 1px solid var(--border); }
.dropdown-identity strong { font-size: 11px; }
.dropdown-identity small { overflow: hidden; color: var(--text-tertiary); font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.account-dropdown form { margin: 0; }
.page-content { width: min(100%, 1240px); padding: 30px clamp(24px, 4vw, 50px) 50px; }
.metrics-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.metric-card { min-height: 145px; padding: 17px 18px; }
.metric-card-header { display: flex; align-items: flex-start; justify-content: space-between; }
.metric-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 8px; }
.metric-icon .icon { width: 16px; height: 16px; }
.metric-purple { color: #6750c8; background: #eeeaff; }
.metric-blue { color: #3476b5; background: #e9f3fd; }
.metric-orange { color: #bd752b; background: #fff1e2; }
.metric-green { color: #278c5e; background: #e8f7ef; }
.metric-red { color: #c84b56; background: #ffebed; }
.metric-cyan { color: #25858d; background: #e7f7f8; }
.metric-card > p { margin: 16px 0 3px; color: var(--text-secondary); font-size: 11px; }
.metric-card > strong { font-size: 27px; line-height: 1; font-weight: 650; letter-spacing: -.035em; }
.empty-state { min-height: 126px; margin-top: 17px; padding: 22px 24px; display: flex; align-items: center; gap: 17px; }
.empty-state-icon { width: 45px; height: 45px; display: grid; place-items: center; flex: 0 0 auto; color: var(--accent); background: var(--accent-soft); border-radius: 13px; font-size: 17px; font-weight: 700; }
.empty-state > div { flex: 1; }
.empty-state h2 { margin: 0 0 5px; font-size: 15px; font-weight: 650; }
.empty-state p { margin: 0; color: var(--text-secondary); font-size: 11px; line-height: 1.55; }

/* WhatsApp connection settings */
.whatsapp-page { max-width: 1000px; }
.breadcrumbs { margin-bottom: 14px; display: flex; align-items: center; gap: 7px; color: var(--text-tertiary); font-size: 10px; }
.breadcrumbs b { font-weight: 400; }
.breadcrumbs strong { color: var(--text-secondary); font-weight: 600; }
.whatsapp-card { overflow: hidden; }
.whatsapp-card-header { min-height: 87px; padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--border); }
.whatsapp-title { display: flex; align-items: center; gap: 13px; }
.whatsapp-icon { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; background: linear-gradient(145deg, #39b978, #21965c); border-radius: 11px; box-shadow: 0 6px 15px rgba(35,154,95,.2); }
.whatsapp-icon .icon { width: 22px; height: 22px; }
.whatsapp-title h2 { margin: 0 0 4px; font-size: 15px; font-weight: 680; }
.whatsapp-title p { margin: 0; color: var(--text-secondary); font-size: 10px; }
.connection-badge { min-height: 25px; padding: 5px 9px; display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); background: rgba(116,118,128,.08); border: 1px solid var(--border); border-radius: 999px; font-size: 9px; font-weight: 650; white-space: nowrap; }
.connection-badge i { width: 7px; height: 7px; background: var(--text-tertiary); border-radius: 50%; }
.connection-badge[data-status="CONNECTED"] { color: var(--success); background: var(--success-soft); border-color: rgba(42,154,102,.16); }
.connection-badge[data-status="CONNECTED"] i { background: var(--success); box-shadow: 0 0 0 3px rgba(42,154,102,.1); }
.connection-badge[data-status="CONNECTING"], .connection-badge[data-status="RECONNECTING"], .connection-badge[data-status="QR_REQUIRED"] { color: var(--warning); background: var(--warning-soft); border-color: rgba(196,138,35,.16); }
.connection-badge[data-status="CONNECTING"] i, .connection-badge[data-status="RECONNECTING"] i, .connection-badge[data-status="QR_REQUIRED"] i { background: var(--warning); }
.connection-badge[data-status="LOGGED_OUT"], .connection-badge[data-status="ERROR"] { color: var(--danger); background: var(--danger-soft); border-color: rgba(212,75,85,.16); }
.connection-badge[data-status="LOGGED_OUT"] i, .connection-badge[data-status="ERROR"] i { background: var(--danger); }
.connection-state { width: 100%; min-width: 0; min-height: 180px; padding: 28px 24px; display: flex; align-items: center; gap: 17px; overflow: hidden; }
.connection-state[data-current-state="CONNECTING"], .connection-state[data-current-state="RECONNECTING"] { min-height: 230px; flex-direction: column; justify-content: center; text-align: center; }
.connection-state[data-current-state="QR_REQUIRED"] { min-height: 0; padding-block: 28px 32px; flex-direction: column; text-align: center; }
.connection-state[data-current-state="CONNECTED"] { flex-wrap: wrap; }
.state-copy { min-width: 0; flex: 1; }
.connection-state[data-current-state="CONNECTING"] .state-copy, .connection-state[data-current-state="RECONNECTING"] .state-copy, .connection-state[data-current-state="QR_REQUIRED"] .state-copy { flex: 0 1 auto; }
.connection-state h3 { margin: 0 0 5px; font-size: 14px; font-weight: 650; }
.connection-state p { margin: 0; color: var(--text-secondary); font-size: 11px; line-height: 1.55; }
.connection-state small { display: block; margin-top: 8px; color: var(--text-tertiary); font-size: 9px; }
.state-symbol { width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 13px; font-size: 17px; font-weight: 700; }
.state-neutral { color: var(--text-secondary); background: rgba(116,118,128,.09); }
.state-progress { color: var(--warning); background: var(--warning-soft); }
.state-connected { color: var(--success); background: var(--success-soft); }
.state-danger { color: var(--danger); background: var(--danger-soft); }
.state-glyph { line-height: 1; }
.loading-ring { width: 18px; height: 18px; display: block; border: 2px solid rgba(196,138,35,.25); border-top-color: var(--warning); border-radius: 50%; animation: spin .8s linear infinite; }
.state-instructions { margin-top: 6px !important; color: var(--text-tertiary) !important; font-size: 9px !important; }
.state-qr { width: 100%; max-width: 430px; min-width: 0; display: grid; justify-items: center; gap: 9px; }
.state-qr > p { color: var(--text-primary); font-size: 10px; font-weight: 580; }
.state-qr > p span { padding-inline: 3px; color: var(--text-tertiary); }
.state-qr > small { margin: 0; }
.qr-frame { width: min(240px, 100%); max-width: 100%; aspect-ratio: 1 / 1; padding: 11px; display: grid; place-items: center; overflow: hidden; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.qr-frame img, .qr-placeholder { width: 100%; max-width: 218px; height: auto; aspect-ratio: 1 / 1; }
.qr-frame img { display: block; object-fit: contain; }
.qr-placeholder { display: grid; place-items: center; background: var(--background-soft); border-radius: var(--radius-sm); }
.state-meta { width: 100%; margin-left: 61px; padding: 12px 14px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; background: rgba(249,249,251,.7); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.state-meta > div { min-width: 0; display: grid; gap: 3px; }
.state-meta span { color: var(--text-tertiary); font-size: 9px; }
.state-meta strong { overflow: hidden; font-size: 10px; font-weight: 620; white-space: nowrap; text-overflow: ellipsis; }
.state-action { flex: 0 0 auto; }
.security-note { margin: 11px 3px 0; color: var(--text-tertiary); font-size: 9px; }
.security-note span { margin-right: 4px; color: var(--success); }
.confirm-dialog { border: 1px solid var(--border); color: var(--text-primary); }
.confirm-dialog::backdrop { background: rgba(22,23,28,.32); backdrop-filter: blur(3px); }
.confirm-dialog h2 { margin: 14px 0 7px; font-size: 16px; }
.confirm-dialog > p { margin: 0; color: var(--text-secondary); font-size: 11px; line-height: 1.6; }
.confirm-icon { width: 36px; height: 36px; display: grid; place-items: center; color: var(--danger); background: var(--danger-soft); border-radius: 10px; font-weight: 750; }
.toast-danger { color: #9e343d; border-color: rgba(212,75,85,.22); }

/* Multi-connection WhatsApp manager */
.connections-page-header { margin-bottom: 16px; display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.connections-page-header h2 { margin: 0 0 5px; font-size: 18px; font-weight: 680; letter-spacing: -.02em; }
.connections-page-header p { margin: 0; color: var(--text-secondary); font-size: 11px; }
.connections-card { overflow: visible; }
.connections-table-wrap { width: 100%; overflow: visible; }
.connections-table { width: 100%; border-collapse: collapse; }
.connections-table th, .connections-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.connections-table th { color: var(--text-tertiary); background: rgba(249,249,251,.65); font-size: 9px; font-weight: 650; letter-spacing: .02em; }
.connections-table td { color: var(--text-secondary); font-size: 11px; }
.connections-table td strong { color: var(--text-primary); font-weight: 630; }
.connections-table tr:last-child td { border-bottom: 0; }
.connections-table th:last-child, .connections-table td:last-child { width: 50px; padding-inline: 8px; text-align: right; }
.connection-actions { position: relative; }
.row-actions { display: inline-block; text-align: left; }
.row-actions > summary { letter-spacing: 1px; font-size: 10px; }
.row-actions-menu { top: calc(100% + 5px); right: 0; width: 165px; }
.connections-empty { min-height: 300px; padding: 38px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.connections-empty .empty-state-icon { margin-bottom: 14px; }
.connections-empty .empty-state-icon .icon { width: 21px; height: 21px; }
.connections-empty h2 { margin: 0 0 5px; font-size: 15px; }
.connections-empty p { margin: 0 0 18px; color: var(--text-secondary); font-size: 11px; }

.connection-modal { width: min(94vw, 520px); max-height: min(90vh, 720px); padding: 0; overflow: hidden; color: var(--text-primary); background: var(--surface-elevated); border: 1px solid rgba(255,255,255,.8); border-radius: var(--radius-xl); box-shadow: var(--shadow-window); animation: modal-in .16s ease-out; }
.connection-modal::backdrop { background: rgba(22,23,28,.34); backdrop-filter: blur(4px); animation: backdrop-in .16s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.modal-window-bar { height: 43px; padding: 0 12px 0 15px; display: flex; align-items: center; justify-content: space-between; background: rgba(247,247,249,.86); border-bottom: 1px solid var(--border); }
.modal-window-controls { display: flex; gap: 7px; }
.modal-window-controls i { width: 10px; height: 10px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.07); }
.modal-window-controls i:nth-child(1) { background: #ff5f57; }
.modal-window-controls i:nth-child(2) { background: #febc2e; }
.modal-window-controls i:nth-child(3) { background: #28c840; }
.modal-close { width: 29px; height: 29px; color: var(--text-tertiary); background: transparent; border-color: transparent; font-size: 19px; font-weight: 350; }
.connection-modal-content { max-height: calc(90vh - 43px); padding: 23px 27px 27px; overflow-y: auto; }
.modal-heading { margin-bottom: 21px; }
.modal-heading h2 { margin: 0 0 5px; font-size: 18px; letter-spacing: -.02em; }
.modal-heading p { margin: 0; color: var(--text-secondary); font-size: 10px; }
.modal-stage { display: grid; gap: 16px; }
.connection-tabs { padding: 3px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; background: rgba(116,118,128,.09); border-radius: var(--radius-sm); }
.connection-tab { min-height: 32px; padding: 6px 10px; color: var(--text-secondary); background: transparent; border: 0; border-radius: 5px; cursor: pointer; font-size: 11px; font-weight: 600; }
.connection-tab.is-active { color: var(--text-primary); background: var(--surface-solid); box-shadow: 0 1px 4px rgba(30,32,40,.1); }
#phone-field small { color: var(--text-tertiary); font-size: 9px; }
.modal-primary-action { width: 100%; margin-top: 2px; }
.modal-centered { min-height: 300px; align-content: center; justify-items: center; text-align: center; }
.modal-centered h3 { margin: 0; font-size: 15px; }
.modal-centered > p { max-width: 360px; margin: -8px 0 0; color: var(--text-secondary); font-size: 10px; line-height: 1.55; }
.modal-centered > small { margin-top: -7px; color: var(--text-tertiary); font-size: 9px; }
.modal-qr-frame { width: min(238px, 100%); }
.pairing-instructions { color: var(--text-primary) !important; font-weight: 580; }
.pairing-instructions span { padding-inline: 3px; color: var(--text-tertiary); }
.pairing-symbol { width: 42px; height: 42px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); border-radius: 12px; font-size: 22px; }
.pairing-code { padding: 11px 16px; color: var(--text-primary); background: var(--background-soft); border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer; font: 700 24px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.pairing-help { margin-top: 0 !important; }
.rename-dialog .field { margin-top: 17px; text-align: left; }

/* Error state */
.error-page { min-height: 100vh; display: grid; place-items: center; background: var(--background); }
.error-page main { width: min(100% - 40px, 430px); padding: 34px; display: grid; justify-items: center; text-align: center; background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.error-page .app-icon, .error-page .brand-mark { margin-bottom: 20px; }
.error-page .brand-mark { width: 39px; height: 39px; display: grid; place-items: center; color: #fff; background: var(--accent); border-radius: 10px; }
.error-page .eyebrow { margin: 0; color: var(--text-tertiary); font-size: 10px; }
.error-page h1 { margin: 8px 0 24px; font-size: 20px; }
.error-page .primary-button { min-height: 34px; padding: 7px 14px; color: #fff; background: var(--accent); border-radius: var(--radius-sm); font-size: 12px; }

@media (max-width: 880px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  :root { --topbar-height: 68px; }
  .app-sidebar { display: none; }
  .app-main { margin-left: 0; }
  .page-header { position: sticky; top: 0; z-index: 10; padding: 11px 15px; }
  .page-title-group h1 { font-size: 16px; }
  .page-title-group p { display: none; }
  .mobile-menu { display: block; }
  .mobile-menu-panel { top: calc(100% + 8px); left: 0; width: min(286px, calc(100vw - 30px)); padding: 7px; }
  .mobile-menu-panel .sidebar-item { min-height: 39px; }
  .account-trigger { min-width: auto; padding: 3px; }
  .account-copy, .account-trigger .chevron { display: none; }
  .account-dropdown { right: 0; width: min(220px, calc(100vw - 30px)); }
  .page-content { padding: 18px 15px 34px; }
  .metrics-grid { grid-template-columns: 1fr; gap: 10px; }
  .metric-card { min-height: 118px; }
  .empty-state { align-items: flex-start; flex-wrap: wrap; padding: 19px; }
  .empty-state .badge { margin-left: 62px; }
  .login-stage { padding: 14px; }
  .login-window { border-radius: var(--radius-lg); }
  .login-content { padding: 27px 24px 24px; }
  .table-wrap { border-radius: var(--radius-sm); }
  .toast { right: 12px; bottom: 12px; left: 12px; max-width: none; }
  .whatsapp-card-header { padding: 17px; align-items: flex-start; }
  .whatsapp-title p { max-width: 220px; }
  .connection-state { min-height: 190px; padding: 22px 17px; align-items: flex-start; flex-wrap: wrap; }
  .connection-state[data-current-state="CONNECTING"], .connection-state[data-current-state="RECONNECTING"] { min-height: 220px; align-items: center; }
  .connection-state[data-current-state="QR_REQUIRED"] { padding: 24px 16px 28px; align-items: center; flex-wrap: nowrap; }
  .connection-state[data-current-state="CONNECTED"] .state-copy { width: calc(100% - 61px); flex: 0 0 calc(100% - 61px); }
  .state-action { margin-left: 61px; }
  .connection-state[data-current-state="CONNECTED"] .state-action { margin-left: 61px; }
  .state-meta { margin-left: 0; grid-template-columns: 1fr; }
  .state-qr { max-width: 100%; }
  .qr-frame { width: min(230px, 100%); }
  .confirm-dialog { width: calc(100% - 28px); }
  .connections-page-header { align-items: stretch; flex-direction: column; }
  .connections-page-header .button { align-self: flex-start; }
  .connections-card { background: transparent; border: 0; box-shadow: none; backdrop-filter: none; }
  .connections-table thead { display: none; }
  .connections-table, .connections-table tbody { display: block; }
  .connections-table tr { margin-bottom: 10px; padding: 13px 14px; display: grid; grid-template-columns: 1fr auto; gap: 9px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
  .connections-table td { padding: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0; font-size: 10px; }
  .connections-table td::before { content: attr(data-label); color: var(--text-tertiary); font-size: 9px; }
  .connections-table td:first-child { grid-column: 1; grid-row: 1; display: block; }
  .connections-table td:first-child::before { display: none; }
  .connections-table td:nth-child(2), .connections-table td:nth-child(3), .connections-table td:nth-child(4) { grid-column: 1 / -1; }
  .connections-table td.connection-actions { grid-column: 2; grid-row: 1; width: auto; }
  .connections-table td.connection-actions::before { display: none; }
  .row-actions-menu { right: 0; width: 180px; }
  .connections-empty { min-height: 280px; }
  .connection-modal { width: calc(100% - 24px); max-height: calc(100vh - 24px); border-radius: var(--radius-lg); }
  .connection-modal-content { max-height: calc(100vh - 67px); padding: 20px 18px 23px; }
  .modal-centered { min-height: 340px; }
  .modal-qr-frame { width: min(226px, 100%); }
  .pairing-code { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
