/* AutoLive panel — design tokens */
:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --line: #e3e8ee;
  --line-strong: #cfd7e0;
  --text: #17212b;
  --text-2: #3c4856;
  --muted: #6b7785;
  --accent: #0e7c5f;
  --accent-hover: #0a664e;
  --accent-soft: #e5f4ee;
  --warning: #a96a12;
  --warning-soft: #fff4dc;
  --danger: #c23a3a;
  --danger-soft: #fdeceb;
  --info-soft: #eef3fb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 24px 64px rgba(15, 30, 45, .18);
  --sidebar: #121a22;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); }
button, input, select, textarea { font: inherit; letter-spacing: 0; color: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
button, a { touch-action: manipulation; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid rgba(14, 124, 95, .35); outline-offset: 2px; }
p { line-height: 1.6; margin: 0; overflow-wrap: anywhere; }
h1, h2, h3, strong { overflow-wrap: anywhere; }
h1, h2, h3 { margin: 0; font-weight: 650; color: var(--text); }
h1 { font-size: 24px; line-height: 1.3; }
h2 { font-size: 16px; line-height: 1.45; }
h3 { font-size: 14px; line-height: 1.45; }
svg.lucide { width: 18px; height: 18px; flex: 0 0 auto; stroke-width: 1.8; }
.hidden { display: none !important; }
.subtle { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .08em; margin-bottom: 4px; }

/* Form controls */
input, select, textarea { width: 100%; min-width: 0; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); padding: 9px 12px; border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s; }
input, select { min-height: 40px; }
input:hover, select:hover, textarea:hover { border-color: #b5c0cc; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 124, 95, .14); }
input::placeholder, textarea::placeholder { color: #98a3af; }
input:read-only { background: var(--surface-2); color: var(--text-2); }
input[type="checkbox"] { width: 17px; height: 17px; min-height: 17px; margin: 0; padding: 0; accent-color: var(--accent); flex-shrink: 0; }
textarea { resize: vertical; min-height: 110px; line-height: 1.6; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7785' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 550; color: var(--text-2); min-width: 0; }

/* Buttons */
.button { display: inline-flex; justify-content: center; align-items: center; gap: 7px; min-height: 38px; padding: 8px 14px; border: 1px solid var(--line-strong); color: var(--text-2); background: var(--surface); border-radius: var(--radius-sm); font-weight: 600; font-size: 13px; line-height: 1.3; flex-shrink: 0; text-align: center; box-shadow: 0 1px 1px rgba(16, 24, 40, .04); transition: background .15s, border-color .15s; }
.button:hover { background: var(--surface-2); border-color: #b5c0cc; text-decoration: none; }
.button svg { width: 16px; height: 16px; }
.button.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button.danger { color: var(--danger); border-color: #efc4c4; }
.button.danger:hover { background: var(--danger-soft); }
.button.danger:disabled:hover { background: var(--surface); }
.button.full { width: 100%; min-height: 42px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex-shrink: 0; border: 1px solid transparent; border-radius: var(--radius-sm); color: #56636f; background: transparent; transition: background .15s, color .15s; }
.icon-button:hover:not(:disabled) { background: #edf1f5; color: var(--text); }
.icon-button.primary { color: var(--accent); }
.icon-button.primary:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent-hover); }
.icon-button.danger { color: var(--danger); }
.icon-button.danger:hover:not(:disabled) { background: var(--danger-soft); }
.table-button { padding: 5px 10px; min-height: 30px; font-size: 12px; white-space: nowrap; }

/* Feedback */
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-stack > .button { align-self: flex-start; }
.form-stack > .button.full { align-self: stretch; }
.form-error { font-size: 13px; color: var(--danger); font-weight: 450; }
.form-error:empty { display: none; }
.notice { background: var(--accent-soft); border: 1px solid #c7e6d9; border-radius: var(--radius-sm); padding: 11px 14px; color: #1f5a47; font-size: 13px; line-height: 1.6; }
.notice.error { color: #8f2c2c; background: var(--danger-soft); border-color: #f2c9c6; }
.notice.warning { color: #7c5410; background: var(--warning-soft); border-color: #f1dca8; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px 3px 8px; border-radius: 999px; color: #1f6b52; background: var(--accent-soft); line-height: 1.5; overflow-wrap: anywhere; white-space: normal; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.status.neutral { color: #5b6773; background: #eef1f4; }
.status.warning { color: var(--warning); background: var(--warning-soft); }
.status.danger { color: var(--danger); background: var(--danger-soft); }
.status.live { color: #0b6b51; background: #dff3ea; }
.status.live::before { box-shadow: 0 0 0 0 rgba(14, 124, 95, .5); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(14, 124, 95, .45); } 70% { box-shadow: 0 0 0 6px rgba(14, 124, 95, 0); } 100% { box-shadow: 0 0 0 0 rgba(14, 124, 95, 0); } }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 1000; width: max-content; max-width: calc(100vw - 32px); background: #17262f; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(15, 30, 45, .25); overflow-wrap: anywhere; line-height: 1.6; pointer-events: none; }
.toast.error { background: #8d2f2f; }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 56px 16px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty-state > svg { width: 34px; height: 34px; color: #9fb3aa; }
.empty-state h3 { color: var(--text-2); font-size: 16px; }
.empty-state .button { margin-top: 4px; }
.empty-line { padding: 28px 16px; font-size: 13px; text-align: center; color: var(--muted); }

/* Boot & auth */
.boot-view { min-height: 100dvh; display: flex; gap: 14px; align-items: center; justify-content: center; flex-direction: column; color: var(--muted); }
.boot-view > svg { width: 34px; height: 34px; color: var(--accent); }
.boot-view strong { color: var(--text); font-size: 24px; }
.auth-view { width: 100%; max-width: 440px; min-height: 100dvh; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; padding: 40px 20px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 24px; font-weight: 700; margin-bottom: 26px; color: var(--text); }
.auth-brand > svg { color: var(--accent); width: 30px; height: 30px; }
.auth-surface { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px 30px 30px; box-shadow: 0 12px 40px rgba(15, 30, 45, .08); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 24px; background: #eef1f4; border-radius: 10px; }
.auth-tabs button { background: none; border: 0; border-radius: 7px; color: var(--muted); padding: 8px 0; font-weight: 600; }
.auth-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.auth-surface h1 { font-size: 20px; margin-bottom: 20px; }
.auth-surface .notice { margin-bottom: 18px; }
.auth-foot { display: flex; justify-content: center; gap: 22px; margin-top: 24px; font-size: 12px; }
.auth-foot a { color: var(--muted); }
.check-label { flex-direction: row; align-items: center; gap: 8px; line-height: 1.6; font-weight: 450; }
.check-label a { margin: 0 2px; }

/* App shell */
.app-shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; background: var(--sidebar); color: #aab6c2; padding: 24px 14px 16px; }
.brand { display: flex; align-items: center; color: #fff; gap: 10px; padding: 4px 10px; margin-bottom: 30px; }
.brand:hover { text-decoration: none; }
.brand > svg { width: 26px; height: 26px; color: #5fd3a5; }
.brand strong { font-size: 20px; font-weight: 700; }
.workspace-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; color: #6f7d8a; padding: 0 12px; margin-bottom: 8px; }
.navigation { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; background: none; border: 0; border-radius: var(--radius-sm); color: #b4c0cb; text-align: left; white-space: nowrap; font-size: 13.5px; font-weight: 500; transition: background .15s, color .15s; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: rgba(95, 211, 165, .14); color: #e6fbf2; }
.nav-item.active svg { color: #5fd3a5; }
.nav-count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, .08); font-size: 11px; text-align: center; color: #cfe9de; }
.sidebar-foot { margin-top: auto; }
.identity { display: flex; gap: 10px; align-items: center; padding: 12px 10px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, .04); }
.identity > svg { width: 26px; height: 26px; color: #8fa0ae; }
.identity > div { flex: 1; min-width: 0; }
.identity strong { display: block; color: #f1f5f8; font-weight: 600; font-size: 13px; word-break: break-all; }
.identity span { display: block; font-size: 11px; margin-top: 2px; color: #8796a3; }
.sidebar .icon-button { color: #9fb0bd; width: 30px; height: 30px; }
.sidebar .icon-button:hover:not(:disabled) { background: rgba(255, 255, 255, .08); color: #fff; }
.legal-links { display: flex; gap: 16px; padding: 12px 10px 0; font-size: 11px; }
.legal-links a { color: #7a8996; }

.workspace { min-width: 0; padding: 26px 36px 56px; max-width: 1480px; width: 100%; margin: 0 auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 22px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-actions .icon-button { border: 1px solid var(--line-strong); background: var(--surface); width: 38px; height: 38px; }
#connectionNotice { margin: 0 0 18px; }
.page-view > * + * { margin-top: 0; }

/* Shared card surfaces */
.metric, .server-overview, .source-row, .event-list, .account-row, .settings-section, .table-wrap, .link-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.section-heading h2 { font-size: 16px; }

/* Metrics */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric { padding: 16px 18px; position: relative; overflow: hidden; }
.metric > span { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 550; }
.metric > span svg { width: 16px; height: 16px; padding: 6px; box-sizing: content-box; border-radius: 8px; background: #eef1f4; color: #5b6773; }
.metric > strong { display: block; font-size: 30px; font-weight: 700; margin-top: 10px; line-height: 1; font-variant-numeric: tabular-nums; }
.metric strong small { font-weight: 500; font-size: 14px; color: var(--muted); }
.metric:nth-child(1) > span svg { background: var(--accent-soft); color: var(--accent); }
.metric:nth-child(1) strong { color: var(--accent); }
.metric:nth-child(2) > span svg { background: var(--info-soft); color: #3a6ab3; }
.metric:nth-child(3) > span svg { background: var(--warning-soft); color: var(--warning); }
.metric:nth-child(3) strong { color: var(--warning); }

/* Server overview */
.server-overview { margin: 16px 0 0; padding: 16px 20px 18px; }
.server-overview .section-heading { margin: 0 0 14px; gap: 12px; flex-wrap: wrap; }
.server-overview .section-heading h2 { font-size: 14px; }
.server-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
#serverUpdated { margin-left: auto; }
.server-resources { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
.server-resource { min-width: 0; }
.server-resource-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 550; }
.server-resource-label svg { width: 14px; height: 14px; }
.server-resource > strong { display: block; font-size: 15px; font-weight: 650; margin: 6px 0 8px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.server-resource small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.6; overflow-wrap: anywhere; }
.server-progress { display: block; width: 100%; height: 6px; appearance: none; -webkit-appearance: none; border: 0; background: #edf1f4; border-radius: 9px; overflow: hidden; margin: 0 0 8px; }
.server-progress::-webkit-progress-bar { background: #edf1f4; border-radius: 9px; }
.server-progress::-webkit-progress-value { background: var(--accent); border-radius: 9px; }
.server-progress::-moz-progress-bar { background: var(--accent); border-radius: 9px; }
.server-progress.warning::-webkit-progress-value { background: #d1912f; }
.server-progress.danger::-webkit-progress-value { background: #cf4f4f; }
.server-progress.warning::-moz-progress-bar { background: #d1912f; }
.server-progress.danger::-moz-progress-bar { background: #cf4f4f; }
.server-runtime p { font-size: 11.5px; color: var(--muted); margin: 6px 0 0; line-height: 1.6; }
.server-runtime b { font-weight: 600; color: var(--text-2); }

/* Source toolbar */
.section-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin: 26px 0 12px; }
.service-summary { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; }
.filters select { width: 150px; font-size: 13px; min-height: 36px; padding-top: 6px; padding-bottom: 6px; }
.search-field { position: relative; width: 240px; }
.search-field svg { position: absolute; top: 50%; transform: translateY(-50%); left: 11px; width: 15px; height: 15px; color: #8a96a2; pointer-events: none; }
.search-field input { font-size: 13px; min-height: 36px; padding: 7px 12px 7px 34px; }

/* Source cards */
.source-list { display: flex; flex-direction: column; gap: 12px; }
.source-row { padding: 16px 20px; border-left: 4px solid #d5dce3; transition: box-shadow .15s; }
.source-row:hover { box-shadow: 0 2px 4px rgba(16, 24, 40, .05), 0 6px 16px rgba(16, 24, 40, .06); }
.source-row.is-live { border-left-color: var(--accent); }
.source-row.is-waiting { border-left-color: #8fb2e3; }
.source-row.is-problem { border-left-color: #e08a3c; }
.source-row.is-stopped { border-left-color: #c3cbd3; }
.source-main { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 16px; align-items: center; }
.source-identity, .source-target, .source-state, .source-info { min-width: 0; }
.source-identity strong { display: block; font-size: 15.5px; font-weight: 650; color: var(--text); }
.source-identity > a, .source-identity > p { display: block; color: var(--muted); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 100%; margin-top: 2px; }
.source-identity > a:hover { color: var(--accent); }
.source-state { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: right; }
.source-state .subtle { font-size: 11.5px; }
.row-actions { display: flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.row-actions .icon-button { width: 32px; height: 32px; }
.row-actions svg { width: 16px; height: 16px; }
.action-divider { width: 1px; height: 18px; background: var(--line-strong); margin: 0 3px; }
.source-details { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.source-info { display: flex; flex-direction: column; gap: 10px; }
.source-target { display: flex; align-items: center; gap: 10px; }
.source-target > svg { width: 18px; height: 18px; padding: 7px; box-sizing: content-box; border-radius: 9px; background: #fdecea; color: #d0423a; }
.source-target > div { min-width: 0; }
.source-target strong { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-target .subtle { display: block; font-size: 12px; }
.source-mode { margin: 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2); font-size: 12.5px; line-height: 1.7; overflow-wrap: anywhere; }
.source-metadata { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; min-width: 0; font-size: 12px; color: var(--muted); }
.source-metadata > span { overflow-wrap: anywhere; }
.source-metadata .source-title { flex-basis: 100%; color: var(--text-2); font-weight: 550; font-size: 12.5px; }
.source-metadata a { display: inline-flex; align-items: center; gap: 4px; font-weight: 550; }
.source-metadata a svg { width: 13px; height: 13px; }
.source-switches { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); align-self: start; }
.source-panel-title { font-size: 11px; font-weight: 650; letter-spacing: .06em; color: var(--muted); }
.source-mode-select { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.source-mode-select span { font-size: 12px; color: var(--muted); font-weight: 550; }
.source-mode-select select { width: 100%; font-size: 12.5px; min-height: 34px; padding-top: 6px; padding-bottom: 6px; background-color: var(--surface); }
.source-switches .switch-line { font-size: 12.5px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.row-error { font-size: 12.5px; color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); padding: 7px 11px; }
.fixed-stream-conflict { display: flex; flex-direction: column; gap: 4px; }
.fixed-stream-conflict .row-error { margin: 0; }

/* Switch */
.switch-line { display: flex; flex-direction: row; justify-content: space-between; align-items: center; gap: 14px; }
.switch { appearance: none; -webkit-appearance: none; position: relative; width: 36px !important; height: 20px !important; min-height: 20px !important; border: 0; border-radius: 20px; background: #c9d2db; padding: 0; cursor: pointer; transition: background .15s; flex-shrink: 0; }
.switch::before { content: ""; position: absolute; width: 16px; height: 16px; top: 2px; left: 2px; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s ease; }
.switch:checked { background: var(--accent); }
.switch:checked::before { transform: translateX(16px); }
.switch:disabled { opacity: .45; cursor: not-allowed; }
.switch:focus { box-shadow: 0 0 0 3px rgba(14, 124, 95, .18); }

/* Events */
.events-section, .users-section { margin-top: 30px; }
.event-list { overflow: hidden; }
.event-row { display: grid; grid-template-columns: 150px minmax(90px, 160px) minmax(0, 1fr); gap: 16px; padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: 13px; }
.event-row:last-child { border-bottom: 0; }
.event-row:hover { background: var(--surface-2); }
.event-row time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.event-row strong { font-weight: 600; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-row > div { color: var(--text); font-weight: 500; min-width: 0; }
.event-row p { color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 2px; }
.event-list > .empty-line { margin: 0; }

/* Channels */
.inline-form { display: flex; gap: 12px; align-items: end; margin-bottom: 14px; }
.inline-form > label { max-width: 340px; flex: 1; }
.inline-form select { min-width: 120px; }
.inline-form + .form-error { margin: 10px 0; }
.link-box { border-color: #bfe0d2; background: #f2faf6; padding: 16px 18px; margin: 16px 0; box-shadow: none; }
.link-box .section-heading { margin-bottom: 10px; }
.link-box > h3 { margin-bottom: 10px; }
.copy-row { display: flex; align-items: center; gap: 8px; }
.copy-row input { font-size: 12.5px; flex: 1; background: var(--surface); }
.copy-row .icon-button { border: 1px solid var(--line-strong); background: var(--surface); height: 40px; width: 40px; }
.link-box p { margin-top: 10px; }
.account-list { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.account-row { display: grid; grid-template-columns: 44px minmax(160px, 1fr) auto auto; gap: 16px; align-items: center; padding: 16px 20px; }
.account-mark { display: flex; justify-content: center; align-items: center; width: 42px; height: 42px; border-radius: 10px; background: #fdecea; color: #d0423a; }
.account-mark svg { width: 22px; height: 22px; }
.account-identity { min-width: 0; }
.account-identity > strong { display: block; font-size: 14.5px; }
.account-identity > p { font-size: 12px; margin-top: 2px; color: var(--muted); }
.account-row .row-actions { border: 0; background: none; padding: 0; gap: 6px; }
.account-row .row-actions .icon-button { border: 1px solid var(--line-strong); background: var(--surface); width: 36px; height: 36px; }
.account-row .row-actions .icon-button.danger { border-color: #efc4c4; }
.account-row .row-error { grid-column: 2 / -1; margin-top: -4px; }
.account-delete-sources { margin: 0; padding-left: 22px; max-height: 32dvh; overflow-y: auto; overflow-wrap: anywhere; }
.account-delete-sources li { margin: 6px 0; }

/* Settings */
.settings-section { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(260px, 1.4fr); gap: 32px; max-width: 920px; padding: 22px 26px; margin-bottom: 14px; }
.settings-section h2 { margin-bottom: 6px; }
.settings-section > div > .status { margin-top: 12px; }
.settings-section > form { width: 100%; max-width: 465px; }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { font-size: 12px; color: var(--muted); font-weight: 600; padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { font-size: 13px; padding: 13px 16px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td:first-child { min-width: 120px; font-weight: 550; }
td time { white-space: nowrap; font-size: 12px; color: var(--muted); }
.align-right { text-align: right; }
.users-section > p { margin: -6px 0 14px; }

/* Dialogs */
.dialog { width: min(600px, calc(100vw - 28px)); max-height: calc(100dvh - 36px); padding: 0; border: 0; border-radius: 16px; color: var(--text); background: var(--surface); box-shadow: var(--shadow-lg); overflow: hidden; }
.dialog[open] { display: flex; flex-direction: column; }
.dialog > form { display: flex; flex-direction: column; min-height: 0; max-height: inherit; }
.dialog::backdrop { background: rgba(14, 24, 32, .45); backdrop-filter: blur(2px); }
.source-dialog { width: min(680px, calc(100vw - 28px)); }
.log-dialog { width: min(960px, calc(100vw - 28px)); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 22px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.dialog-head h2 { font-size: 16.5px; }
.dialog-body { padding: 20px 22px; overflow-y: auto; min-height: 0; }
.dialog-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 22px; background: var(--surface-2); border-top: 1px solid var(--line); flex-shrink: 0; }
.dialog-foot > .subtle { margin-right: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.span-2 { grid-column: 1 / -1; }
.form-grid > .notice { grid-column: 1 / -1; }
.form-grid > .subtle { margin-top: -6px; padding: 9px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.form-grid > .switch-line { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-weight: 550; }
.source-enable { align-self: end; min-height: 40px; }
.log-toolbar { display: flex; align-items: end; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.log-toolbar label { flex: 1; max-width: 440px; }
.log-toolbar .icon-button { border: 1px solid var(--line-strong); width: 40px; height: 40px; }
.log-content { background: #111a21; color: #d3dde3; font: 12px/1.7 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; margin: 12px 0 0; padding: 16px 18px; height: min(50dvh, 500px); min-height: 200px; overflow: auto; border-radius: 10px; }
.recording-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; padding: 14px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.recording-row strong { flex: 1 1 60%; font-size: 13.5px; }
.recording-row p { flex-basis: 100%; margin: 0; order: 3; }
.cleanup-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.cleanup-row > strong { float: right; font-variant-numeric: tabular-nums; }
.cleanup-row label { display: inline-flex; flex-direction: row; gap: 10px; align-items: center; }
.cleanup-row p { margin: 6px 0; overflow-wrap: anywhere; }

/* Legal pages */
.legal-page { max-width: 760px; margin: 0 auto; padding: 44px 24px 80px; }
.legal-page .auth-brand { justify-content: flex-start; margin-bottom: 32px; }
.legal-page h1 { margin-bottom: 14px; }
.legal-page h2 { margin: 26px 0 10px; }
.legal-page p, .legal-page li { color: var(--text-2); line-height: 1.85; }
.legal-page ul { padding-left: 24px; }
.legal-page > .button { margin-top: 30px; }

/* Responsive */
@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 208px minmax(0, 1fr); }
  .workspace { padding: 24px 24px 44px; }
  .source-details { grid-template-columns: minmax(0, 1fr) 270px; }
  .server-resources { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; }
  .account-row { grid-template-columns: 44px minmax(140px, 1fr) auto; }
  .account-row > .row-actions { grid-column: 2 / -1; }
}
@media (max-width: 960px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .source-main { grid-template-columns: minmax(0, 1fr) auto; }
  .source-main > .row-actions { grid-column: 1 / -1; justify-self: start; }
  .source-details { grid-template-columns: minmax(0, 1fr); }
  .section-toolbar { flex-direction: column; align-items: stretch; }
  .filters { width: 100%; }
  .search-field { width: auto; flex: 1; }
  .settings-section { grid-template-columns: 1fr; gap: 16px; }
  .event-row { grid-template-columns: 140px minmax(0, 1fr); }
  .event-row > div { grid-column: 1 / -1; }
  .inline-form { flex-wrap: wrap; }
  .inline-form > label { min-width: 160px; }
  .desktop-only { display: none; }
}
@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; top: 0; z-index: 20; height: auto; padding: 12px 14px 8px; display: grid; grid-template-columns: 1fr auto; gap: 10px; }
  .brand { padding: 0; margin: 0; }
  .brand strong { font-size: 18px; }
  .brand > svg { width: 22px; height: 22px; }
  .workspace-label, .legal-links { display: none; }
  .navigation { grid-column: 1 / -1; grid-row: 2; flex-direction: row; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .navigation::-webkit-scrollbar { display: none; }
  .nav-item { width: auto; flex-shrink: 0; padding: 8px 11px; font-size: 13px; gap: 7px; }
  .nav-item svg { width: 15px; height: 15px; }
  .nav-count { display: none; }
  .sidebar-foot { margin: 0; grid-column: 2; grid-row: 1; }
  .identity { padding: 0; background: none; gap: 6px; }
  .identity > svg, .identity span { display: none; }
  .identity strong { max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .workspace { padding: 18px 14px 36px; }
  .topbar { gap: 10px; padding-bottom: 16px; }
  h1 { font-size: 21px; }
  .top-actions { gap: 6px; }
  .top-actions > .button { padding: 8px 11px; }
  .metrics { gap: 10px; }
  .metric { padding: 13px 14px; }
  .metric > strong { font-size: 26px; }
  .server-overview { padding: 14px; }
  #serverUpdated { margin-left: 0; width: 100%; }
  .source-row { padding: 14px; }
  .source-main { gap: 10px; }
  .source-identity strong { font-size: 14.5px; }
  .source-main > .row-actions { width: 100%; justify-content: space-between; }
  .row-actions .icon-button { width: 34px; }
  .source-details .detail-secondary { display: none; }
  .account-row { grid-template-columns: 38px minmax(0, 1fr); gap: 10px 12px; padding: 14px; }
  .account-row > .status { grid-column: 2; justify-self: start; }
  .account-row > .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  .account-mark { width: 38px; height: 38px; }
  .account-row .button { font-size: 12px; padding: 7px 10px; min-height: 34px; }
  .settings-section { padding: 18px; }
  .copy-row { flex-wrap: wrap; }
  .copy-row input { flex-basis: calc(100% - 48px); }
  .inline-form > label { max-width: none; }
  #accountForm > label { width: 100%; flex-basis: 100%; }
  .event-row { padding: 11px 14px; gap: 4px 12px; }
  .dialog { max-height: calc(100dvh - 20px); border-radius: 14px; }
  .dialog-head { padding: 14px 16px; }
  .dialog-body { padding: 16px; }
  .dialog-foot { padding: 12px 16px; }
  .form-grid { grid-template-columns: 1fr; gap: 14px; }
  .log-content { padding: 12px; font-size: 11px; }
  .toast { bottom: 16px; }
}
@media (max-width: 380px) {
  .workspace { padding-left: 10px; padding-right: 10px; }
  .nav-item svg { display: none; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .server-resources { grid-template-columns: 1fr; }
  .filters { flex-wrap: wrap; }
  .search-field { min-width: 100%; }
  .filters select { width: 100%; }
  .row-actions .icon-button { width: 30px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* Files page (files-v2) */
.files-intro{display:flex;align-items:center;justify-content:space-between;gap:20px;margin:8px 0 25px}.files-intro h2{font-size:23px;margin:4px 0 8px}.files-server{display:inline-flex;align-items:center;gap:8px;background:#f0f5f2;border:1px solid var(--line);padding:9px 12px;border-radius:7px;font-size:12px;color:#53655c;white-space:nowrap}.files-server svg{width:16px;height:16px}.files-summary{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));border:1px solid var(--line);border-radius:10px;margin-bottom:24px;background:#fff}.files-summary>div{padding:20px 24px;display:flex;flex-direction:column;gap:8px;border-right:1px solid var(--line)}.files-summary>div:last-child{border:0}.files-summary span,.files-summary small{font-size:12px;color:var(--muted)}.files-summary strong{font-size:25px;letter-spacing:-.7px}.files-toolbar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:18px}.files-toolbar .search-field{flex:1;min-width:180px}.files-toolbar select{width:auto;max-width:180px}.files-list-head{display:flex;align-items:center;justify-content:space-between;gap:18px;margin:0 0 12px;font-size:12px}.files-list-head label{display:flex;align-items:center;gap:9px;white-space:nowrap}.files-table-wrap{border:1px solid var(--line);border-radius:9px;background:#fff}.files-table{width:100%;font-size:12px}.files-table th{font-size:11px;background:#f7f9f8;color:#75837c;text-align:left}.files-table th,.files-table td{padding:16px 14px;vertical-align:top;border-bottom:1px solid var(--line)}.files-table tr:last-child td{border-bottom:0}.files-table .file-check{width:44px;min-width:44px}.file-name{min-width:180px;max-width:310px}.file-name>strong{display:block;font-size:14px;margin-bottom:6px}.file-name>.subtle,.file-size>.subtle,.file-status>.subtle{display:block;margin-top:6px;font-size:11px;line-height:1.6}.file-size{min-width:170px}.file-size strong{font-size:14px}.file-date{white-space:nowrap;font-size:11px}.file-name details{margin-top:9px;color:var(--muted);font-size:11px}.file-name summary{cursor:pointer}.file-name details p{overflow-wrap:anywhere;line-height:1.6;margin:8px 0}.file-status{min-width:160px}.file-protected{background:#fbfcfb}.files-selection-bar{position:sticky;bottom:12px;display:flex;justify-content:space-between;align-items:center;gap:16px;padding:15px 20px;margin-top:18px;background:#fff;border:1px solid var(--line);border-radius:9px;box-shadow:0 5px 22px #1534230b}.files-selection-bar>div{display:flex;gap:10px;align-items:center}.files-selection-bar>div:first-child{flex-direction:column;align-items:flex-start;gap:4px}.files-selection-bar strong{font-size:13px}.files-selection-bar span{font-size:11px}.cleanup-confirm-item{display:flex;justify-content:space-between;gap:15px;border-bottom:1px solid var(--line);padding:12px 0;font-size:13px}.cleanup-confirm-item small{display:block;margin-top:4px;color:var(--muted)}.cleanup-confirm-total{font-weight:600;margin:20px 0}.files-page input[type=checkbox]{width:16px;height:16px;min-height:0;accent-color:#476a57;flex-shrink:0}
@media(max-width:1000px){.files-summary>div{padding:16px}.files-table th,.files-table td{padding:14px 10px}.file-size{min-width:135px}.file-status{min-width:140px}}
@media(max-width:680px){.files-intro{align-items:flex-start;flex-direction:column;gap:12px}.files-intro h2{font-size:21px}.files-summary{grid-template-columns:repeat(2,minmax(0,1fr))}.files-summary>div{padding:16px}.files-summary>div:nth-child(2){border-right:0}.files-summary>div:nth-child(-n+2){border-bottom:1px solid var(--line)}.files-summary strong{font-size:22px}.files-toolbar{gap:8px}.files-toolbar .search-field{flex-basis:100%}.files-toolbar select{flex:1;max-width:none;min-width:0;font-size:12px}.files-toolbar .button{width:100%;justify-content:center}.files-list-head{align-items:flex-start;flex-direction:column;gap:8px}.files-table thead{display:none}.files-table,.files-table tbody{display:block}.files-table tr{display:grid;grid-template-columns:26px minmax(0,1fr);padding:16px;border-bottom:1px solid var(--line);gap:10px}.files-table td{display:block;padding:0!important;border:0!important;min-width:0;max-width:none}.files-table .file-check{grid-column:1;grid-row:1;min-width:0}.files-table .file-name{grid-column:2;grid-row:1}.files-table td[data-label]{grid-column:2;white-space:normal}.files-table td[data-label]::before{content:attr(data-label);display:block;color:var(--muted);font-size:10px;margin-bottom:4px}.files-table .file-status{border-top:1px solid var(--line)!important;padding-top:10px!important}.files-selection-bar{align-items:stretch;flex-direction:column;bottom:8px;padding:13px}.files-selection-bar>div:last-child{justify-content:flex-end}.files-selection-bar .button{font-size:12px;padding:9px 12px}.files-table tr:last-child{border-bottom:0}}

.files-list-head label{flex-direction:row}.cleanup-confirm-item{align-items:center}#cleanupConfirmDialog .dialog-body{max-height:65dvh;overflow:auto}
