:root {
  color-scheme: light;
  --ink: #162033;
  --muted: #738096;
  --line: #e8edf4;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --nav: #111b2e;
  --nav-muted: #8a96aa;
  --blue: #356df3;
  --green: #14966a;
  --red: #d04f5b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); }
button { font: inherit; }
[hidden] { display: none !important; }
.app-shell { display: none; min-height: 100vh; }
.app-shell.is-authenticated { display: block; }
.auth-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 18% 12%, #e7efff, transparent 34%), var(--canvas); }
.auth-card { width: min(100%, 420px); padding: 34px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 18px 55px #1c2d4c12; }
.auth-brand { padding: 0 0 31px; color: var(--ink); }
.auth-brand small { color: var(--muted); }
.auth-card h1 { margin-bottom: 7px; font-size: 25px; }
.auth-card .subtitle { margin-bottom: 23px; line-height: 1.5; }
.auth-form { display: grid; gap: 14px; }
.auth-form label { display: grid; gap: 6px; color: #536178; font-size: 11px; font-weight: 650; }
.auth-form input { width: 100%; height: 41px; padding: 0 11px; border: 1px solid #dce3ed; border-radius: 7px; outline: none; background: #fff; color: var(--ink); font: inherit; font-weight: 400; }
.auth-form input:focus { border-color: #7a9af0; box-shadow: 0 0 0 3px #356df31a; }
.primary-button, .secondary-button, .text-button { border: 0; border-radius: 7px; cursor: pointer; font: inherit; }
.primary-button { min-height: 41px; margin-top: 2px; background: var(--blue); color: #fff; font-size: 12px; font-weight: 700; }
.primary-button:hover { background: #285edc; }
.auth-switch { margin: 19px 0 0; color: var(--muted); font-size: 11px; text-align: center; }
.auth-switch button { padding: 0; background: none; color: var(--blue); font-size: inherit; font-weight: 700; }
.form-error { margin: 0; color: #b33c4b; font-size: 11px; line-height: 1.5; }
.heading-actions { display: flex; align-items: center; gap: 8px; }
.secondary-button { min-height: 35px; padding: 0 12px; border: 1px solid #dfe5ef; background: #fff; color: #43516a; font-size: 11px; font-weight: 650; }
.secondary-button:hover { border-color: #b8c8ec; color: var(--blue); }
.text-button { padding: 7px 8px; background: transparent; color: #68758a; font-size: 10px; }
.text-button:hover { color: var(--blue); }
.settings-card { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--line); }
.settings-card > div { display: grid; gap: 7px; min-width: 0; padding: 16px; background: #fff; }
.settings-card span { color: #8490a3; font-size: 10px; }
.settings-card strong { overflow-wrap: anywhere; color: #34435c; font-size: 12px; font-weight: 650; }
.pairing-dialog { width: min(calc(100% - 32px), 480px); padding: 27px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); box-shadow: 0 24px 80px #14223e30; }
.pairing-dialog::backdrop { background: #10192b88; backdrop-filter: blur(2px); }
.pairing-dialog h2 { margin-bottom: 8px; font-size: 20px; }
.pairing-dialog .subtitle { margin-bottom: 17px; line-height: 1.55; }
.dialog-close { position: absolute; top: 10px; right: 12px; }
.dialog-close button { border: 0; background: transparent; color: #8490a3; font-size: 23px; cursor: pointer; }
.pairing-code { margin: 14px 0; padding: 14px; border-radius: 8px; background: #f3f6fc; color: #263756; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 20px; font-weight: 750; letter-spacing: 2px; text-align: center; overflow-wrap: anywhere; }
.pairing-instructions { margin: 19px 0 7px; color: #657289; font-size: 10px; }
.pairing-dialog code { display: block; padding: 10px; border-radius: 6px; background: #111b2e; color: #d7e2fa; font-size: 10px; overflow-wrap: anywhere; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 5; display: flex; width: 248px; flex-direction: column; padding: 25px 17px 18px; background: var(--nav); color: #fff; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 7px 35px; color: #fff; text-decoration: none; }
.brand-mark { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 11px; background: linear-gradient(145deg, #6691ff, #3666e9); box-shadow: 0 5px 14px #356df34d; font-size: 19px; font-weight: 750; }
.brand strong { display: block; font-size: 15px; letter-spacing: -.2px; }
.brand small { display: block; margin-top: 3px; color: #95a1b6; font-size: 9px; font-weight: 700; letter-spacing: 1.2px; }
.nav-label { padding: 0 11px; color: #707e95; font-size: 9px; font-weight: 750; letter-spacing: 1.25px; }
.nav-list { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 43px; padding: 0 11px; border: 0; border-radius: 8px; background: transparent; color: #aab5c7; text-align: left; cursor: pointer; font-size: 13px; }
.nav-item > span:first-child { width: 16px; color: #8795ab; font-size: 16px; text-align: center; }
.nav-item:hover { background: #1b2941; color: #fff; }
.nav-item.is-active { background: #243450; color: #fff; box-shadow: inset 2px 0 #6590ff; }
.nav-item.is-active > span:first-child { color: #80a3ff; }
.nav-count { margin-left: auto; padding: 2px 7px; border-radius: 10px; background: #293954; color: #bfc9d8; font-size: 10px; }
.sidebar-bottom { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 13px 8px 2px; border-top: 1px solid #27344a; color: #a8b3c4; font-size: 10px; }
.sidebar-bottom small { margin-left: auto; color: #77869e; }
.side-dot, .status-dot { width: 7px; height: 7px; border-radius: 50%; background: #22bd81; box-shadow: 0 0 0 3px #22bd8118; }
.main-content { min-height: 100vh; margin-left: 248px; }
.topbar { position: sticky; top: 0; z-index: 4; display: flex; height: 62px; align-items: center; justify-content: space-between; padding: 0 38px; border-bottom: 1px solid var(--line); background: #ffffffed; backdrop-filter: blur(12px); }
.breadcrumbs { display: flex; align-items: center; gap: 10px; color: #8b96a8; font-size: 11px; }
.breadcrumbs strong { color: #455168; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.refresh-label { color: #8490a3; font-size: 10px; }
.connection-indicator { display: flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid #e1efe9; border-radius: 20px; background: #f5fcf8; color: #318b67; font-size: 10px; font-weight: 650; }
.connection-indicator .status-dot { width: 6px; height: 6px; }
.connection-indicator.is-offline { border-color: #f4dcdf; background: #fff7f8; color: #bc4d5b; }
.connection-indicator.is-offline .status-dot { background: #d04f5b; box-shadow: 0 0 0 3px #d04f5b18; }
.page-wrap { width: min(1360px, 100%); margin: 0 auto; padding: 35px 38px 28px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.eyebrow { margin: 0 0 6px; color: #8794a8; font-size: 9px; font-weight: 750; letter-spacing: 1.2px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(23px, 3vw, 28px); letter-spacing: -.8px; }
.subtitle { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.refresh-button { display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px; border: 1px solid #dfe5ef; border-radius: 7px; background: #fff; color: #43516a; cursor: pointer; font-size: 11px; font-weight: 650; box-shadow: 0 1px 2px #11234208; }
.refresh-button:hover { border-color: #b8c8ec; color: var(--blue); }
.refresh-button span { font-size: 15px; }
.alert { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; padding: 13px 15px; border: 1px solid #f3d9dc; border-radius: 9px; background: #fff8f8; color: #9f3744; }
.alert-icon { display: grid; width: 21px; height: 21px; flex: 0 0 21px; place-items: center; border-radius: 50%; background: #fce4e6; font-size: 12px; font-weight: 800; }
.alert strong { display: block; margin: 1px 0 3px; font-size: 11px; }
.alert p { margin: 0; color: #a76870; font-size: 10px; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 29px; }
.metric-card { min-height: 119px; padding: 16px 17px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 3px 12px #1b2a4405; }
.metric-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; color: #68758a; font-size: 10px; font-weight: 600; }
.metric-card > strong { display: block; margin-bottom: 4px; font-size: 25px; letter-spacing: -.7px; }
.metric-card > small { color: #909bad; font-size: 9px; }
.metric-icon { display: grid; width: 26px; height: 26px; place-items: center; border-radius: 8px; font-size: 13px; }
.metric-icon.blue { background: #edf3ff; color: #4a79e8; }
.metric-icon.violet { background: #f2efff; color: #8068dc; }
.metric-icon.amber { background: #fff5e9; color: #d59237; }
.metric-icon.green { background: #e9f8f1; color: #21966a; }
.content-section { margin-bottom: 29px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.section-heading h2 { margin-bottom: 4px; font-size: 15px; letter-spacing: -.25px; }
.section-heading p { margin: 0; color: #8a96a8; font-size: 10px; }
.section-count { display: grid; min-width: 25px; height: 22px; place-items: center; padding: 0 7px; border-radius: 11px; background: #eaf0fb; color: #5973a4; font-size: 10px; font-weight: 700; }
.agent-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.agent-card { padding: 15px 16px 13px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 3px 12px #1b2a4405; }
.agent-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.agent-title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar-mark { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 9px; background: linear-gradient(140deg, #edf2ff, #dce7ff); color: #5272bf; font-size: 13px; font-weight: 750; }
.agent-title { min-width: 0; }
.agent-title h3 { overflow: hidden; margin: 0 0 3px; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.agent-platform { color: #8a96a8; font-size: 9px; }
.badge { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; padding: 5px 8px; border-radius: 15px; font-size: 9px; font-weight: 700; text-transform: capitalize; }
.badge.online { background: #eaf8f1; color: #19895f; }
.badge.online .status-dot { width: 6px; height: 6px; box-shadow: none; }
.badge.offline { background: #fff0f1; color: #bd4c58; }
.badge.offline .status-dot { width: 6px; height: 6px; background: #d55b66; box-shadow: none; }
.badge.pending { background: rgba(201,155,69,.14); color: var(--gold-hover); border: 1px solid var(--gold-border); }
.badge.pending .status-dot { width: 6px; height: 6px; background: var(--gold-hover); box-shadow: none; }
.badge.neutral { background: var(--surface-3,#252b34); color: var(--muted); }
.badge.neutral .status-dot { width: 6px; height: 6px; background: var(--muted); box-shadow: none; }
.badge.error { background: rgba(217,108,112,.12); color: var(--red); border: 1px solid rgba(217,108,112,.28); }
.badge.error .status-dot { width: 6px; height: 6px; background: var(--red); box-shadow: none; }
.agent-metadata { display: flex; gap: 13px; margin: 13px 0 11px 44px; color: #647187; font-size: 9px; }
.identity-details { display: grid; gap: 3px; margin: 0 0 12px 44px; color: #98a3b2; font-size: 8px; }
.identity-line { overflow-wrap: anywhere; }
.bridge-section { padding-top: 10px; border-top: 1px solid #edf0f5; }
.bridge-heading { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 9px; }
.bridge-heading strong { color: #5b687d; }
.muted, .bridge-heading .muted { color: #98a3b2; }
.bridge-row { display: flex; align-items: center; gap: 8px; min-height: 29px; padding: 4px 0; }
.bridge-port { min-width: 42px; color: #34435c; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; font-weight: 700; }
.bridge-row .badge { padding: 4px 7px; }
.bridge-stats { margin-left: auto; color: #8b97a8; font-size: 9px; }
.no-bridges { margin: 0; color: #9aa5b5; font-size: 9px; }
.accounts-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: 0 3px 12px #1b2a4405; }
.accounts-table { width: 100%; border-collapse: collapse; text-align: left; }
.accounts-table th { height: 38px; padding: 0 15px; border-bottom: 1px solid var(--line); background: #fafbfd; color: #8a96a8; font-size: 8px; font-weight: 750; letter-spacing: .65px; white-space: nowrap; }
.accounts-table td { padding: 12px 15px; border-bottom: 1px solid #eff2f6; color: #59677d; font-size: 10px; vertical-align: top; }
.accounts-table tr:last-child td { border-bottom: 0; }
.account-id { color: #2e3d58 !important; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; white-space: nowrap; }
.context-count { color: #33425a; font-weight: 700; }
.context-label { color: #8490a1; }
.business-id-list { max-width: 275px; margin-top: 5px; color: #8c98aa; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 8px; overflow-wrap: anywhere; }
.tag-list, .port-list { display: flex; flex-wrap: wrap; gap: 4px; }
.type-tag { padding: 4px 6px; border-radius: 5px; background: #f0f4fb; color: #5c6e8a; font-size: 8px; }
.port-pill { padding: 4px 6px; border: 1px solid #e5ecf8; border-radius: 5px; color: #5c6e8a; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 8px; }
.campaign-number { color: #34435c; font-weight: 750; }
.campaign-label { color: #8490a1; }
.empty-state { display: grid; min-height: 155px; place-content: center; justify-items: center; padding: 20px; border: 1px dashed #d8e0eb; border-radius: 9px; background: #fbfcfe; text-align: center; }
.empty-state.compact { min-height: 115px; }
.empty-mark { display: grid; width: 30px; height: 30px; margin-bottom: 9px; place-items: center; border-radius: 9px; background: #edf2fb; color: #6680b3; }
.empty-state strong { margin-bottom: 4px; font-size: 11px; }
.empty-state p { max-width: 280px; margin: 0; color: #8995a7; font-size: 9px; line-height: 1.55; }
.page-footer { display: flex; justify-content: space-between; padding: 13px 1px 0; border-top: 1px solid #e6ebf2; color: #939eae; font-size: 9px; }

@media (max-width: 1100px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agent-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .auth-card { padding: 26px 22px; }
  /* Keep the client navigation a sidebar at every viewport. */
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 5; width: 196px; min-height: 100vh; padding: 18px 12px; overflow-y: auto; }
  .brand { padding: 0 5px 22px; }
  .brand-mark { width: 31px; height: 31px; }
  .nav-label { display: block; margin-bottom: 6px; }
  .sidebar-bottom { display: flex; }
  .nav-list { grid-template-columns: 1fr; gap: 4px; }
  .nav-item { justify-content: flex-start; gap: 9px; min-height: 38px; padding: 0 9px; font-size: 11px; }
  .nav-item > span:first-child { width: 16px; font-size: 13px; }
  .nav-count { margin-left: auto; padding: 2px 5px; }
  .main-content { margin-left: 196px; }
  .topbar { height: 49px; padding: 0 16px; }
  .refresh-label { display: none; }
  .page-wrap { padding: 25px 15px 22px; }
  .page-heading { align-items: flex-start; }
  .refresh-button { padding: 8px 10px; }
  .metrics-grid { gap: 8px; margin-bottom: 24px; }
  .metric-card { min-height: 104px; padding: 12px; }
  .metric-top { margin-bottom: 11px; font-size: 9px; }
  .metric-card > strong { font-size: 21px; }
  .accounts-table { min-width: 0; }
  .page-footer { gap: 10px; flex-wrap: wrap; }
  .settings-card { grid-template-columns: 1fr; }
  .heading-actions { align-items: flex-end; flex-direction: column; }
}

.account-bulk{display:flex;align-items:end;gap:12px;flex-wrap:wrap;padding:14px 16px;margin-bottom:12px;border:1px solid var(--border);border-radius:12px;background:#fff}.account-bulk[hidden]{display:none}.account-bulk label,.account-edit-form label{display:grid;gap:5px;font-size:12px;color:var(--muted)}.account-bulk select,.account-bulk input,.account-edit-form input,.account-edit-form select,.account-edit-form textarea{font:inherit;padding:9px 10px;border:1px solid var(--border);border-radius:8px;background:#fff;color:var(--ink)}.account-bulk .check-label,.account-edit-form .check-label{display:flex;align-items:center;gap:8px}.account-row{cursor:pointer}.account-row:hover{background:#f7f9fc}.accounts-table{min-width:1160px}.accounts-table th:first-child,.accounts-table td:first-child{width:34px}.account-dialog{width:min(620px,calc(100vw - 32px));max-height:90vh;overflow:auto;border:1px solid var(--border);border-radius:18px;padding:28px;box-shadow:0 24px 80px #14213d33}.account-dialog::backdrop{background:#17233777}.account-dialog h2{margin:0 0 10px}.account-machine-summary{font-size:13px;line-height:1.6;color:var(--muted);padding:12px;background:#f6f8fb;border-radius:10px}.account-edit-form{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:18px}.account-edit-form .notes-field,.account-edit-form .check-label,.account-edit-form .form-error,.account-edit-form button{grid-column:1/-1}.account-edit-form textarea{resize:vertical}.last-seen-cell{white-space:nowrap;font-size:12px;color:var(--muted)}

.nav-subitem{margin-left:10px;font-size:13px}.keitaro-settings-link{margin-top:24px;padding:18px;border:1px solid var(--border);border-radius:14px;background:#fff}.keitaro-section> .section-heading{align-items:center}.keitaro-list{display:grid;gap:14px}.keitaro-card{padding:20px;border:1px solid var(--border);border-radius:14px;background:#fff}.keitaro-card-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:16px}.keitaro-card-heading h3{margin:0 0 6px}.keitaro-url{font-size:13px;color:var(--muted);overflow-wrap:anywhere}.keitaro-card-meta{display:flex;gap:18px;flex-wrap:wrap;margin:16px 0;color:var(--muted);font-size:13px}.keitaro-actions{display:flex;gap:8px;flex-wrap:wrap}.keitaro-error-code{margin:0 0 12px;color:#ad4819;font-size:13px}.keitaro-safety-note{margin-top:18px;color:var(--muted);font-size:13px}.keitaro-dialog{width:min(620px,calc(100vw - 32px));max-height:90vh;overflow:auto;border:1px solid var(--border);border-radius:18px;padding:28px;box-shadow:0 24px 80px #14213d33}.keitaro-dialog::backdrop{background:#17233777}.keitaro-dialog h2{margin:0 0 16px}.keitaro-key-field,.keitaro-key-hint{grid-column:1/-1}.keitaro-key-hint{margin:0;font-size:12px;color:var(--muted)}.danger-button{border:1px solid #efd0d0;background:#fff;color:#a13f3f;border-radius:9px;padding:9px 12px;cursor:pointer}.keitaro-actions button:disabled{opacity:.65;cursor:wait}
/* Language selector */
.language-switch{display:inline-flex;align-items:center;gap:7px;color:var(--muted,#778199);font-size:12px}
.language-switch button{border:0;background:transparent;color:inherit;padding:5px 3px;cursor:pointer;font-weight:600}
.language-switch button.is-selected{color:var(--text,#19233a)}
.language-switch button:focus-visible{outline:2px solid #7489f5;outline-offset:2px;border-radius:4px}

/* Clear, accessible form controls */
.auth-form label,.account-edit-form>label{display:grid;gap:7px;font-size:13px;font-weight:600;color:var(--text,#26324b)}
.auth-form input,.account-edit-form input:not([type=checkbox]),.account-edit-form select,.account-edit-form textarea,.account-bulk input:not([type=checkbox]),.account-bulk select{
  width:100%;min-height:44px;padding:10px 12px;border:1px solid #cbd3e2;border-radius:9px;background:#fff;color:#172033;font:inherit;line-height:1.35;transition:border-color .15s,box-shadow .15s,background-color .15s
}
.auth-form input:hover,.account-edit-form input:not([type=checkbox]):hover,.account-edit-form select:hover,.account-edit-form textarea:hover,.account-bulk input:not([type=checkbox]):hover,.account-bulk select:hover{border-color:#9daac0}
.auth-form input:focus,.account-edit-form input:not([type=checkbox]):focus,.account-edit-form select:focus,.account-edit-form textarea:focus,.account-bulk input:not([type=checkbox]):focus,.account-bulk select:focus{outline:none;border-color:#536fe8;box-shadow:0 0 0 3px rgba(83,111,232,.16)}
.auth-form input:disabled,.account-edit-form input:disabled,.account-edit-form select:disabled,.account-edit-form textarea:disabled{background:#f0f2f6;color:#8790a1;cursor:not-allowed}
.account-edit-form [aria-invalid=true]{border-color:#d53c54!important;box-shadow:0 0 0 2px rgba(213,60,84,.12)}
.account-edit-form small,.replacement-hint{font-size:12px;font-weight:400;line-height:1.45;color:#748096}
.field-error{font-size:12px;font-weight:500;color:#bf263e}
.keitaro-form{gap:15px}
.account-edit-form.keitaro-form{grid-template-columns:minmax(0,1fr)}
.account-edit-form.keitaro-form>*{grid-column:1}
.campaigns-panel{margin:16px 0;padding:12px;border:1px solid var(--border);border-radius:10px}.campaigns-panel h3{margin:0 0 8px}.campaign-row{display:grid;gap:4px;padding:9px 0;border-top:1px solid var(--line);font-size:12px}.campaign-row span{color:var(--muted);font-size:11px}
.keitaro-form label b{color:#c52a42}
.password-control{position:relative;display:block}
.password-control input{padding-right:48px!important}
.password-toggle{position:absolute;right:7px;top:50%;transform:translateY(-50%);width:34px;height:34px;border:0;border-radius:7px;background:transparent;color:#5f6b82;cursor:pointer}
.password-toggle:hover{background:#eef1f7}
.form-actions{display:flex;justify-content:space-between;gap:12px;margin-top:5px}
.form-actions button{min-height:42px}
.key-configured{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:12px;border:1px solid #d9dfeb;border-radius:9px;background:#f8f9fc}
.key-configured label{width:100%;font-weight:600}
.key-configured strong{font-size:13px}
.key-configured .text-button{margin-left:auto}

/* Dashboard visual polish: compact checklist, resilient long content, responsive tables and dialogs. */
#onboarding-checklist { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.onboarding-item { display: grid; grid-template-columns: 22px minmax(0,1fr) auto; align-items: center; gap: 8px; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.onboarding-icon { display: grid; width: 20px; height: 20px; place-items: center; border-radius: 50%; font-size: 13px; font-weight: 800; }
.onboarding-icon.is-complete { background: #e8f7ef; color: #19895f; }
.onboarding-icon.is-pending { background: #f1f3f7; color: #8b95a6; }
.onboarding-label { min-width: 0; color: var(--ink); font-size: 11px; line-height: 1.35; }
.onboarding-status { justify-self: end; white-space: nowrap; font-size: 10px; font-weight: 700; }
.onboarding-status.is-complete { color: #19895f; }
.onboarding-status.is-pending { color: #8b95a6; }
.onboarding-item { width:100%; font:inherit; text-align:left; cursor:pointer; }
.onboarding-item:hover { border-color:var(--gold-border); }
.onboarding-telegram { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:12px; padding:12px 14px; border:1px dashed var(--line); border-radius:10px; color:var(--muted); font-size:11px; }
.onboarding-telegram strong { color:var(--ink); }
.pairing-expiry { color:var(--muted); font-size:12px; }
.pairing-advanced { margin-top:18px; color:var(--muted); font-size:11px; }
.pairing-advanced summary { cursor:pointer; color:var(--gold-hover); }
.pairing-downloads { display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }
.offline-hint { color: #bd4c58; }
.campaign-row { min-width: 0; overflow-wrap: anywhere; }
.campaign-row strong { display: block; max-width: 100%; overflow-wrap: anywhere; line-height: 1.35; }
.campaign-row strong::first-line { font-weight: 700; }
.campaign-row span { overflow-wrap: anywhere; }
.rule-summary{min-width:0;overflow-wrap:anywhere}.campaign-row:has([data-delete-rule]){display:flex;align-items:center;justify-content:space-between;gap:12px}.campaign-row [data-delete-rule]{flex:0 0 auto;min-height:32px}
@media (max-width: 900px) {
  #onboarding-checklist { grid-template-columns: 1fr; }
  .accounts-table { min-width: 0; table-layout: fixed; }
  .accounts-table th, .accounts-table td { padding: 10px 8px; }
  /* The Account identity is column 2 after the compact table redesign; never hide it. */
  .accounts-table th:nth-child(6), .accounts-table td:nth-child(6) { display: none; }
  .account-id { white-space: normal; overflow-wrap: anywhere; }
  .account-edit-form { grid-template-columns: 1fr; }
  .account-edit-form > * { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .onboarding-item { grid-template-columns: 22px minmax(0,1fr); }
  .onboarding-status { grid-column: 2; justify-self: start; margin-top: -3px; }
  .account-dialog,.keitaro-dialog { width: min(620px, calc(100vw - 20px)); max-height: 86vh; padding: 20px; }
  .account-dialog .dialog-close,.keitaro-dialog .dialog-close { position: sticky; top: -8px; z-index: 2; align-self: flex-end; }
  .account-dialog .form-actions,.keitaro-dialog .form-actions { position: sticky; bottom: -20px; z-index: 2; margin: 12px -20px -20px; padding: 12px 20px; background: #fff; border-top: 1px solid var(--line); }
  .account-dialog .form-actions button,.keitaro-dialog .form-actions button { flex: 1; }
}

/* Structure v2: compact tabs and isolated advanced rule options. */
#automation-section .form-actions { justify-content: flex-start; margin: 0 0 18px; }
.automation-tab { min-height: 34px !important; }
.advanced-rule-options { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 10px; }
.advanced-rule-options summary { cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600; }
.advanced-rule-options label { margin-top: 10px; max-width: 180px; }
@media (max-width: 760px) {
  .topbar { padding: 0 10px; }
  .topbar-right { gap: 8px; }
  .page-wrap { padding: 20px 12px 24px; }
  .page-heading { gap: 10px; }
}

/* UX structure cleanup: keep the existing shell while making content denser. */
.accounts-table { min-width: 0; table-layout: fixed; }
.accounts-table th:nth-child(1), .accounts-table td:nth-child(1) { width: 34px; }
.accounts-table th:nth-child(2), .accounts-table td:nth-child(2) { width: 18%; }
.accounts-table th:nth-child(3), .accounts-table td:nth-child(3) { width: 22%; }
.accounts-table th:nth-child(4), .accounts-table td:nth-child(4) { width: 9%; }
.accounts-table th:nth-child(5), .accounts-table td:nth-child(5) { width: 13%; }
.accounts-table th:nth-child(6), .accounts-table td:nth-child(6) { width: 15%; }
.accounts-table th:nth-child(7), .accounts-table td:nth-child(7) { width: 12%; }
.accounts-table th:nth-child(8), .accounts-table td:nth-child(8) { width: 9%; }
.accounts-table th:nth-child(9), .accounts-table td:nth-child(9) { width: 10%; }
.accounts-table td { overflow-wrap: anywhere; }
.account-actions .text-button { padding: 4px 0; white-space: nowrap; }
#rules-empty { gap: 8px; min-height: 110px; margin-top: 12px; }
#rules-empty strong { font-size: 13px; }
#rules-empty p { font-size: 11px; }
.keitaro-safety-note[hidden] { display: none !important; }
.keitaro-warning { margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--gold-border); border-radius: 9px; background: var(--gold-muted); color: var(--gold-hover); font-size: 13px; }
.account-machine-summary { border:1px solid var(--line) !important; background:var(--surface-3,#1d232b) !important; }
.account-machine-summary.is-detected { border-color:rgba(77,186,136,.28) !important; color:var(--green) !important; background:var(--success-muted,rgba(77,186,136,.12)) !important; }
.account-machine-summary.is-offline { border-color:rgba(217,108,112,.28) !important; color:var(--red) !important; background:var(--danger-muted,rgba(217,108,112,.12)) !important; }
@media (max-width: 760px) {
  .accounts-table th:nth-child(2), .accounts-table td:nth-child(2) { width: 22%; }
  .accounts-table th:nth-child(3), .accounts-table td:nth-child(3) { width: 28%; }
}

/* Dark Gold Theme v1: visual tokens only; layout and dialog behavior remain unchanged. */
:root {
  --ink: #f3f4f6;
  --muted: #a1a8b3;
  --line: #292f38;
  --surface: #12161c;
  --canvas: #0b0d10;
  --nav: #0d1015;
  --nav-muted: #727b89;
  --blue: #b8924a;
  --green: #4dba88;
  --red: #d96c70;
  --gold-hover: #caa55c;
  --gold-muted: rgba(184,146,74,.12);
  --gold-border: rgba(184,146,74,.30);
}
body { background: var(--canvas); color: var(--ink); }
.auth-shell { background: radial-gradient(circle at 18% 12%, rgba(184,146,74,.08), transparent 34%), var(--canvas); }
.auth-card, .metric-card, .agent-card, .settings-card > div, .accounts-table-wrap, .account-bulk, .keitaro-card, .onboarding-item, .empty-state, .campaigns-panel { background: var(--surface); border-color: var(--line); box-shadow: none; }
.auth-brand, h1, h2, h3, .section-heading h2, .metric-card > strong, .onboarding-label { color: var(--ink); }
.subtitle, .section-heading p, .metric-card > small, .account-machine-summary, .settings-card span, .keitaro-url, .keitaro-card-meta, .empty-state p { color: var(--muted); }
.sidebar { background: var(--nav); }
.nav-item { color: var(--muted); }
.nav-item:hover { background: var(--surface-2, #171c23); color: var(--ink); }
.nav-item.is-active { background: var(--gold-muted); color: var(--gold-hover); box-shadow: inset 2px 0 var(--gold-hover); }
.nav-item.is-active > span:first-child { color: var(--gold-hover); }
.nav-count { background: var(--surface-3, #1d232b); color: var(--muted); }
.topbar { background: rgba(18,22,28,.94); border-color: var(--line); }
.breadcrumbs { color: var(--text-muted, #727b89); }
.breadcrumbs strong { color: var(--muted); }
.refresh-label, .language-switch, .language-switch button, .text-button { color: var(--muted); }
.language-switch button:hover, .text-button:hover, a { color: var(--gold-hover); }
.primary-button { background: #b8924a; color: #17120a; }
.primary-button:hover { background: var(--gold-hover); }
.secondary-button, .refresh-button { background: var(--surface); border-color: var(--line); color: var(--ink); }
.secondary-button:hover, .refresh-button:hover { border-color: var(--gold-border); color: var(--gold-hover); background: var(--surface-2, #171c23); }
.danger-button { background: transparent; border-color: rgba(217,108,112,.45); color: var(--red); }
.metric-card, .agent-card, .keitaro-card, .settings-card > div { border-color: var(--line); }
.metric-icon { background: var(--gold-muted); color: var(--gold-hover); }
.accounts-table th { background: var(--surface-2, #171c23); color: var(--muted); }
.accounts-table td { color: var(--muted); border-color: var(--border-soft, #20252d); }
.accounts-table tbody tr:hover { background: var(--gold-muted); }
.account-id, .campaign-number { color: var(--muted); }
input, select, textarea, .auth-form input, .account-edit-form input:not([type=checkbox]), .account-edit-form select, .account-edit-form textarea, .account-bulk input:not([type=checkbox]), .account-bulk select { background: var(--surface-2, #171c23); border-color: var(--line); color: var(--ink); }
input::placeholder, textarea::placeholder { color: #727b89; }
input:focus, select:focus, textarea:focus, .auth-form input:focus, .account-edit-form input:not([type=checkbox]):focus, .account-edit-form select:focus, .account-edit-form textarea:focus { border-color: var(--gold-hover); box-shadow: 0 0 0 3px var(--gold-muted); }
.form-error, .field-error { color: var(--red); }
.badge.online, .connection-detected { background: rgba(77,186,136,.12); border-color: rgba(77,186,136,.28); color: var(--green); }
.badge.offline, .connection-agent_offline { background: rgba(217,108,112,.12); border-color: rgba(217,108,112,.28); color: var(--red); }
#automation-section .automation-tab { background: transparent; border-color: transparent; color: var(--muted); }
#automation-section .automation-tab.is-selected { color: var(--gold-hover); border-bottom: 2px solid var(--gold-hover); border-radius: 0; }
#rules-empty, #action-candidates-empty { background: var(--surface); border-color: var(--line); }
.keitaro-safety-note { color: var(--text-muted, #727b89); }
.dialog-close button { color: var(--muted); }
.dialog-close button:hover { color: var(--gold-hover); }
dialog[open].account-dialog, dialog[open].keitaro-dialog, dialog[open].pairing-dialog { background: var(--surface-2, #171c23); border-color: var(--line); color: var(--ink); box-shadow: 0 24px 80px rgba(0,0,0,.45); }
dialog[open]::backdrop { background: rgba(0,0,0,.72); }
.key-configured { background: var(--surface-3, #1d232b); border-color: var(--line); }
.onboarding-icon.is-complete { background: rgba(77,186,136,.12); color: var(--green); }
.onboarding-icon.is-pending { background: var(--surface-3, #1d232b); color: var(--muted); }
.onboarding-status.is-complete { color: var(--green); }
.onboarding-status.is-pending { color: var(--muted); }
::selection { background: rgba(184,146,74,.28); color: var(--ink); }

/* Brand refresh: reusable SVG symbol replaces the legacy blue lettermark. */
.brand-mark { display: block; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 11px; background: transparent; box-shadow: none; object-fit: contain; }
.auth-brand .brand-mark { width: 40px; height: 40px; flex-basis: 40px; }
@media (max-width: 760px) { .brand-mark { width: 31px; height: 31px; flex-basis: 31px; } }

/* Final polish: keep semantic states clear and remove the remaining light legacy controls. */
.connection-indicator { padding: 5px 8px; background: rgba(77,186,136,.10); border-color: rgba(77,186,136,.24); color: var(--green); }
.metric-icon.blue, .metric-icon.violet, .metric-icon.amber, .metric-icon.green { background: var(--gold-muted); color: var(--gold-hover); }
.language-switch button { color: var(--muted); }
.language-switch button.is-selected { color: var(--gold-hover); }
.language-switch button:hover { color: var(--gold-hover); }
.accounts-table tbody tr { border-color: var(--border-soft, #20252d); }
.status-dot { box-shadow: 0 0 0 3px rgba(77,186,136,.12); }
@media (max-width: 760px) {
  .account-dialog .form-actions, .keitaro-dialog .form-actions { background: var(--surface-2, #171c23); border-color: var(--line); }
}

/* Meta Accounts responsive table: identity stays visible and status labels stay whole. */
.accounts-table { min-width: 0; table-layout: fixed; }
.accounts-table th, .accounts-table td { vertical-align: middle; }
.accounts-table th:nth-child(2), .accounts-table td:nth-child(2) { width: 29%; }
.accounts-table th:nth-child(3), .accounts-table td:nth-child(3) { width: 8%; }
.accounts-table th:nth-child(4), .accounts-table td:nth-child(4) { width: 16%; }
.accounts-table th:nth-child(5), .accounts-table td:nth-child(5) { width: 16%; }
.accounts-table th:nth-child(6), .accounts-table td:nth-child(6) { width: 12%; }
.accounts-table th:nth-child(7), .accounts-table td:nth-child(7) { width: 9%; }
.accounts-table th:nth-child(8), .accounts-table td:nth-child(8) { width: 10%; }
.account-identity { min-width: 0; }
.account-name { display: block; overflow: hidden; color: var(--ink); font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.account-id { display: block; margin-top: 3px; color: #b8a06a; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-weight: 600; letter-spacing: .01em; line-height: 1.25; white-space: nowrap; }
.status-cell, .connection-detected, .connection-not_detected, .connection-agent_offline { white-space: nowrap; }
@media (max-width: 1100px) {
  .accounts-table th:nth-child(6), .accounts-table td:nth-child(6) { display: none; }
  .accounts-table th:nth-child(2), .accounts-table td:nth-child(2) { width: 34%; }
  .accounts-table th:nth-child(3), .accounts-table td:nth-child(3) { width: 10%; }
  .accounts-table th:nth-child(4), .accounts-table td:nth-child(4) { width: 19%; }
  .accounts-table th:nth-child(5), .accounts-table td:nth-child(5) { width: 18%; }
  .accounts-table th:nth-child(7), .accounts-table td:nth-child(7) { width: 10%; }
  .accounts-table th:nth-child(8), .accounts-table td:nth-child(8) { width: 12%; }
}
@media (max-width: 760px) {
  .accounts-table, .accounts-table thead, .accounts-table tbody, .accounts-table tr, .accounts-table td { display: block; }
  .accounts-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .accounts-table tbody { display: grid; gap: 8px; }
  .accounts-table tr { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 7px 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
  .accounts-table td { width: auto !important; padding: 0; border: 0; }
  .accounts-table td:first-child { grid-row: 1 / span 2; width: 20px !important; }
  .accounts-table td:nth-child(2) { grid-column: 2 / -1; }
  .accounts-table td:nth-child(3) { grid-column: 2; grid-row: 2; }
  .accounts-table td:nth-child(3)::before { content: 'GEO '; color: var(--muted); font-size: 10px; }
  .accounts-table td:nth-child(4) { grid-column: 1; grid-row: 3; }
  .accounts-table td:nth-child(4)::before { content: ''; }
  .accounts-table td:nth-child(5) { grid-column: 2; grid-row: 3; }
  .accounts-table td:nth-child(5)::before { content: ''; }
  .accounts-table td:nth-child(6) { display: none; }
  .accounts-table td:nth-child(7) { grid-column: 1; grid-row: 4; }
  .accounts-table td:nth-child(7)::before { content: 'Campaigns '; color: var(--muted); font-size: 10px; }
  .accounts-table td:nth-child(8) { justify-self: end; grid-column: 2; grid-row: 4; }
}

/* Account cards use the same restrained gold treatment as the rest of the product. */
.account-row { transition: background .15s, border-color .15s; }
.account-row:hover { background: var(--gold-muted); }
.account-name { color: var(--ink); }
.account-id { color: #c4a96f !important; font-size: 11px; font-weight: 600; }
.account-actions .text-button { color: var(--gold-hover); font-weight: 650; }
.account-actions .text-button:hover { color: var(--gold-active, #d2af68); }
.accounts-table input[type="checkbox"] { accent-color: var(--gold-hover); }
.accounts-table td.connection-agent_offline, .accounts-table td.connection-not_detected, .accounts-table td.connection-detected, .accounts-table td.status-cell { width: auto; white-space: nowrap; }
.accounts-table td.connection-agent_offline, .accounts-table td.connection-not_detected, .accounts-table td.connection-detected, .accounts-table td.status-cell { background: transparent; }
.accounts-table td.connection-agent_offline::after, .accounts-table td.connection-not_detected::after, .accounts-table td.connection-detected::after, .accounts-table td.status-cell::after { content: ''; }
@media (max-width: 760px) {
  .accounts-table tr { border-color: var(--line); box-shadow: inset 2px 0 var(--gold-border); }
  .accounts-table td.connection-agent_offline,
  .accounts-table td.connection-not_detected,
  .accounts-table td.connection-detected,
  .accounts-table td.status-cell { display: inline-flex; width: max-content !important; max-width: 100%; align-items: center; padding: 4px 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2, #171c23); white-space: nowrap; }
  .accounts-table td.connection-agent_offline { color: var(--red); border-color: rgba(217,108,112,.28); background: var(--danger-muted, rgba(217,108,112,.12)); }
  .accounts-table td.connection-detected { color: var(--green); border-color: rgba(77,186,136,.28); background: var(--success-muted, rgba(77,186,136,.12)); }
  .accounts-table td.status-cell { color: var(--gold-hover); border-color: var(--gold-border); background: var(--gold-muted); }
}

/* Inline account controls stay compact and use the established Dark Gold language. */
.inline-field { white-space: nowrap; }
.inline-select, .inline-timezone { min-height: 30px; max-width: 100%; padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2, #171c23); color: var(--ink); font: inherit; font-size: 11px; }
.geo-combobox { min-height: 30px; width: 58px; max-width: 100%; padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2, #171c23); color: var(--ink); font: inherit; font-size: 11px; text-transform: uppercase; }
.geo-combobox:focus { outline: none; border-color: var(--gold-hover); box-shadow: 0 0 0 2px var(--gold-muted); }
.inline-select:focus, .inline-timezone:focus { outline: none; border-color: var(--gold-hover); box-shadow: 0 0 0 2px var(--gold-muted); }
.inline-name-input { width: min(150px,100%); min-height: 30px; padding: 5px 7px; border: 1px solid var(--gold-border); border-radius: 7px; background: var(--surface-2, #171c23); color: var(--ink); font: inherit; }
.inline-edit-button { display: block; padding: 2px 0; border: 0; background: transparent; color: var(--gold-hover); cursor: pointer; font-size: 10px; }
.inline-toggle { width: 16px; height: 16px; accent-color: var(--gold-hover); }
.inline-save-state { display: block; min-height: 14px; margin-bottom: 2px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.inline-save-state.is-saving { color: var(--gold-hover); }
.inline-save-state.is-saved { color: var(--green); }
.inline-save-state.is-failed { color: var(--red); }
.scheduler-card { display:grid; gap:22px; padding:22px; border:1px solid var(--line); border-radius:14px; background:var(--surface); }
.scheduler-card-header { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.scheduler-card-header strong { display:block; color:var(--ink); font-size:15px; }
.scheduler-state { display:block; margin-top:5px; color:var(--muted); font-size:12px; }
.toggle-control { position:relative; display:inline-flex; align-items:center; cursor:pointer; }
.toggle-control input { position:absolute; width:1px; height:1px; opacity:0; }
.toggle-track { width:44px; height:24px; border-radius:999px; background:var(--surface-2,#272d36); border:1px solid var(--line); transition:.18s ease; }
.toggle-track::after { content:""; display:block; width:18px; height:18px; margin:2px; border-radius:50%; background:var(--muted); transition:.18s ease; }
.toggle-control input:checked + .toggle-track { background:var(--gold-muted); border-color:var(--gold-border); }
.toggle-control input:checked + .toggle-track::after { transform:translateX(20px); background:var(--gold); }
.toggle-control input:focus-visible + .toggle-track { outline:2px solid var(--gold-hover); outline-offset:2px; }
.scheduler-frequency { display:grid; gap:8px; max-width:360px; color:var(--muted); font-size:12px; font-weight:600; }
.scheduler-frequency select { min-height:40px; padding:0 12px; border:1px solid var(--line); border-radius:9px; background:var(--surface-2,#171c23); color:var(--ink); font:inherit; }
.scheduler-frequency select:focus { outline:none; border-color:var(--gold-hover); box-shadow:0 0 0 2px var(--gold-muted); }
.scheduler-status-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.scheduler-status-item { display:grid; gap:6px; padding-top:15px; border-top:1px solid var(--line); }
.scheduler-status-item strong { color:var(--muted); font-size:11px; font-weight:600; }
.scheduler-status-item span { color:var(--ink); font-size:14px; }
.scheduler-card-actions { display:flex; align-items:center; gap:12px; }
@media (max-width:600px) { .scheduler-status-grid { grid-template-columns:1fr; } .scheduler-card { padding:18px; } }
@media (max-width: 760px) {
  .inline-select { max-width: 120px; }
  .inline-timezone { position: absolute; right: 8px; z-index: 3; width: 190px; }
  .account-actions { position: relative; }
}
