/* OwnRustDesk GUI – neutral greys like the RustDesk client (flutter/lib/common.dart, 1.5.3):
   light: page white, side panel/cards #EFEFF2 · dark: page #18191E, side panel/cards #24252B.
   The accent defaults to RustDesk blue; an own brand colour replaces it (lib.js applyBranding). */
:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #efeff2;
  --border: #dcdce1;
  --text: #212121;
  --muted: #6e6e76;
  --accent: #0071ff;
  --accent-2: #005fd6;
  --accent-soft: #e5f0ff;
  --on-accent: #fff;           /* text on accent-coloured buttons */
  --accent-nav: #0071ff;       /* accent in the side panel */
  --brand-glow: #0071ff22;     /* login page background glow */
  --danger: #c2410c;
  --danger-soft: #fdeee6;
  --warn: #b45309;
  --warn-soft: #fef6e4;
  --ok: #15803d;
  --ok-soft: #e8f6ec;
  --sidebar: #efeff2;
  --sidebar-text: #3c3c43;
  --sidebar-strong: #111111;
  --sidebar-muted: #8a8a92;
  --sidebar-active: #e0e0e4;
  --sidebar-line: #dcdce1;
  --log-bg: #24252b;
  --log-text: #e0e0e0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 1px 3px rgba(0, 0, 0, .07);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18191e; --surface: #24252b; --surface-2: #2d2e35; --border: #3a3b42; --text: #e8e8ea; --muted: #9c9ca3;
    --accent: #0071ff; --accent-2: #3389ff; --accent-soft: #1b2a40; --on-accent: #fff; --accent-nav: #3389ff; --brand-glow: #0071ff1f;
    --danger: #fb923c; --danger-soft: #3a2622; --warn: #fbbf24; --warn-soft: #3a3120; --ok: #4ade80; --ok-soft: #1f3326;
    --sidebar: #24252b; --sidebar-text: #c8c8cd; --sidebar-strong: #ffffff; --sidebar-muted: #8b8b92; --sidebar-active: #2d2e35; --sidebar-line: #303137;
    --log-bg: #121316; --log-text: #dcdcdc; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #18191e; --surface: #24252b; --surface-2: #2d2e35; --border: #3a3b42; --text: #e8e8ea; --muted: #9c9ca3;
  --accent: #0071ff; --accent-2: #3389ff; --accent-soft: #1b2a40; --on-accent: #fff; --accent-nav: #3389ff; --brand-glow: #0071ff1f;
  --danger: #fb923c; --danger-soft: #3a2622; --warn: #fbbf24; --warn-soft: #3a3120; --ok: #4ade80; --ok-soft: #1f3326;
  --sidebar: #24252b; --sidebar-text: #c8c8cd; --sidebar-strong: #ffffff; --sidebar-muted: #8b8b92; --sidebar-active: #2d2e35; --sidebar-line: #303137;
  --log-bg: #121316; --log-text: #dcdcdc; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-text); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--sidebar-line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; color: var(--sidebar-strong); font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--accent-nav), var(--accent)); display: grid; place-items: center; color: #fff; flex: none; }
.brand-logo-img { width: 30px; height: 30px; object-fit: contain; flex: none; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.brand-name.long { font-size: 13px; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); padding: 14px 12px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: var(--sidebar-text);
  text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--sidebar-active); color: var(--sidebar-strong); }
.nav-link.active { background: var(--sidebar-active); color: var(--sidebar-strong); box-shadow: inset 3px 0 0 var(--accent-nav); }
.sidebar-footer { margin-top: auto; padding: 12px 10px 0; font-size: 12px; color: var(--sidebar-muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; font-weight: 650; }
.topbar .user { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.menu-toggle { display: none; }
.content { padding: 24px 28px 48px; max-width: 1500px; width: 100%; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .menu-toggle { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .topbar .user span.name { display: none; }
}

/* ---------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card-title { font-size: 15px; font-weight: 650; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-sub { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 8px; padding: 7px 13px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .tab:focus-visible, .nav-link:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); color: var(--on-accent); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.icon-btn { padding: 6px; }

/* ---------------------------------------------------------------- forms */
input[type=text], input[type=password], input[type=search], input[type=number], input[type=email], input[type=datetime-local], select, textarea {
  width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 10px; font: inherit;
}
textarea { resize: vertical; font-family: inherit; }
input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 13px; }
.field .help { color: var(--muted); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; margin: 4px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar select { width: auto; min-width: 160px; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); font-weight: 650; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.empty { text-align: center; color: var(--muted); padding: 28px; }
.table td.actions { white-space: nowrap; text-align: right; }
.table td.actions .btn + .btn { margin-left: 4px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.pager .muted { margin-right: auto; }

/* ---------------------------------------------------------------- pills etc */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill-bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 6px; font-size: 12px; margin: 1px 3px 1px 0; border: 1px solid var(--border); }
.tag-swatch { width: 9px; height: 9px; border-radius: 3px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.dot-on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot-off { background: #9e9e9e; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-info { background: var(--accent-soft); color: var(--accent); }
.secret-box { display: flex; gap: 10px; align-items: center; background: var(--surface-2); border: 1px dashed var(--border); padding: 10px 12px; border-radius: 8px; word-break: break-all; }
.secret-box code { flex: 1; }
pre.log { background: var(--log-bg); color: var(--log-text); padding: 14px; border-radius: 8px; overflow: auto; max-height: 65vh; white-space: pre-wrap; word-break: break-all; margin: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------------------------------------------------------------- tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 9px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------------------------------------------------------------- modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 16, 26, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.35); border: 1px solid var(--border); }
.modal-wide { width: min(960px, 100%); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 36px)); }
.toast { padding: 11px 15px; border-radius: 9px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0,0,0,.18); transition: opacity .3s, transform .3s; border-left: 4px solid var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-warn { border-left-color: var(--warn); }
.toast-out { opacity: 0; transform: translateY(6px); }

/* ---------------------------------------------------------------- login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, var(--brand-glow), transparent), var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.auth-card .brand { color: var(--text); padding: 0 0 18px; font-size: 18px; }
.auth-card .btn-primary { width: 100%; padding: 10px; margin-top: 4px; }
.auth-wide { width: min(560px, 100%); }

/* ---------------------------------------------------------------- address book */
.ab-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 16px; align-items: start; }
.ab-layout > *, .grid > *, .tab-content, .tabs-root { min-width: 0; }
@media (max-width: 1000px) { .ab-layout { grid-template-columns: 1fr; } }
.ab-list { display: flex; flex-direction: column; gap: 4px; }
.ab-item { text-align: left; border: 1px solid var(--border); background: var(--surface); padding: 10px 12px; border-radius: 9px; cursor: pointer; font: inherit; color: var(--text); }
.ab-item:hover { border-color: var(--accent); }
.ab-item.active { border-color: var(--accent); background: var(--accent-soft); }
.ab-item .ab-name { font-weight: 600; display: block; }
.ab-item .ab-meta { font-size: 12px; color: var(--muted); }

.svc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.svc-head h2 { font-size: 16px; }
.qr { width: 220px; height: 220px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 8px; }
.opt-row { display: grid; grid-template-columns: 1.2fr 1fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }

/* ---- own client: branding form + preview of the RustDesk start page ---- */
.color-hex { width: 110px !important; font-family: var(--mono); text-transform: uppercase; }
.color-hex::placeholder { text-transform: none; font-family: inherit; }
.color-hex.invalid { border-color: var(--danger) !important; background: var(--danger-soft); }
.stack-sm > * + * { margin-top: 6px; }
.brand-logo { width: 72px; height: 72px; object-fit: contain; border: 1px solid var(--border); border-radius: 10px; background: repeating-conic-gradient(#0000000d 0 25%, transparent 0 50%) 0 0 / 14px 14px; padding: 4px; }
.brand-preview { --bp-bg: #ffffff; --bp-side: #efeff2; --bp-text: #212121; --bp-muted: #757575; --bp-line: #dcdcdc;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bp-bg); color: var(--bp-text); font-size: 13px; max-width: 720px; }
.brand-preview.bp-dark { --bp-bg: #18191e; --bp-side: #24252b; --bp-text: #e8e8ea; --bp-muted: #9c9ca3; --bp-line: #3f3f3f; }
.bp-bar { display: flex; align-items: center; gap: 8px; padding: 7px 12px; background: var(--bp-side); border-bottom: 1px solid var(--bp-line); font-weight: 600; }
.bp-logo { width: 18px; height: 18px; object-fit: contain; }
.bp-body { display: grid; grid-template-columns: minmax(180px, 40%) 1fr; min-height: 220px; }
.bp-side { background: var(--bp-side); padding: 14px; border-right: 1px solid var(--bp-line); }
.bp-main { padding: 14px; }
.bp-label { color: var(--bp-muted); font-size: 12px; margin-top: 4px; }
.bp-id { font-size: 22px; font-weight: 600; letter-spacing: .5px; margin: 2px 0 8px; }
.bp-pw { font-family: var(--mono); margin-bottom: 12px; }
.bp-card { color: #fff; border-radius: 6px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.bp-outline { align-self: center; border: 1px solid #fff; border-radius: 8px; padding: 3px 14px; margin-top: 2px; }
.bp-input { border: 1px solid var(--bp-line); border-radius: 6px; padding: 7px 9px; color: var(--bp-muted); margin: 6px 0 8px; }
.bp-right { justify-content: flex-end; margin-bottom: 12px; }
.bp-btn { color: #fff; border-radius: 8px; padding: 5px 14px; font-weight: 600; }
.bp-tab { border-bottom: 2px solid; padding: 3px 2px; font-weight: 600; }
.bp-tab-off { color: var(--bp-muted); padding: 3px 2px; margin-left: 10px; }
.bp-setting { justify-content: space-between; margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--bp-line); }
.bp-switch { width: 30px; height: 16px; border-radius: 8px; position: relative; display: inline-block; }
.bp-switch > span { position: absolute; right: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; }
@media (max-width: 600px) { .bp-body { grid-template-columns: 1fr; } .bp-side { border-right: 0; border-bottom: 1px solid var(--bp-line); } }

[hidden] { display: none !important; }
