/* RDP Watch: мінімалістична панель. Сітка 8 px, світла й темна теми, без інлайн-стилів (строгий CSP). */
:root {
  --bg: #f5f6fa; --surface: #fff; --surface-2: #f9fafc; --text: #0f172a; --muted: #64748b; --border: #e3e7ef;
  --primary: #4f46e5; --primary-hover: #4338ca; --primary-active: #3730a3; --primary-soft: #eef0ff; --on-primary: #fff;
  --danger: #dc2626; --danger-bg: #fef0f0; --danger-row: #fff6f6; --ok: #15803d; --ok-bg: #e9f8ef; --warn: #b45309; --warn-bg: #fff5e0;
  --off: #94a3b8; --focus: #4f46e55c; --shadow: 0 1px 2px rgb(15 23 42 / .04), 0 4px 16px rgb(15 23 42 / .04);
  --radius: 8px; --radius-lg: 16px; --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s5: 40px; --s6: 48px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0e15; --surface: #131824; --surface-2: #171d2b; --text: #e7eaf2; --muted: #93a0b5; --border: #232b3b;
  --primary: #7c83ff; --primary-hover: #959bff; --primary-active: #aeb2ff; --primary-soft: #1d2140; --on-primary: #0b0e1f;
  --danger: #ff6b6b; --danger-bg: #3a1c20; --danger-row: #1e1519; --ok: #4ade80; --ok-bg: #112a1c; --warn: #fbbf24; --warn-bg: #33270e;
  --off: #5b667a; --focus: #7c83ff80; --shadow: 0 1px 2px rgb(0 0 0 / .3);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0e15; --surface: #131824; --surface-2: #171d2b; --text: #e7eaf2; --muted: #93a0b5; --border: #232b3b;
    --primary: #7c83ff; --primary-hover: #959bff; --primary-active: #aeb2ff; --primary-soft: #1d2140; --on-primary: #0b0e1f;
    --danger: #ff6b6b; --danger-bg: #3a1c20; --danger-row: #1e1519; --ok: #4ade80; --ok-bg: #112a1c; --warn: #fbbf24; --warn-bg: #33270e;
    --off: #5b667a; --focus: #7c83ff80; --shadow: 0 1px 2px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: 15px/24px Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1 { font-size: 28px; line-height: 32px; letter-spacing: -.02em; margin: 0 0 var(--s1); font-weight: 700; }
h2 { font-size: 16px; line-height: 24px; margin: var(--s3) 0 var(--s1); font-weight: 650; }
p { margin: 0 0 var(--s1); }
a { color: var(--primary); text-underline-offset: 3px; }
code { font: 13px/16px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border); padding: 2px 8px; border-radius: 6px; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s3) 0; }
svg.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--s3); }
main.container { flex: 1; padding-top: var(--s4); padding-bottom: var(--s6); }
.muted { color: var(--muted); } .small { font-size: 13px; line-height: 16px; } .num { text-align: right; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Шапка */
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.topbar__inner { display: flex; align-items: center; gap: var(--s3); min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand__mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--primary); color: var(--on-primary); }
.brand__mark .icon { width: 18px; height: 18px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--radius); color: var(--muted); font-weight: 550; text-decoration: none; transition: background .12s, color .12s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a:active { background: var(--border); }
.nav a[aria-current="page"] { color: var(--primary); background: var(--primary-soft); }
.topbar__tools { display: flex; align-items: center; gap: var(--s1); }
.topbar__tools form { margin: 0; }

/* Кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s1); min-height: 40px; padding: 8px 16px; border-radius: var(--radius); border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; position: relative; transition: background .12s, border-color .12s, box-shadow .12s, transform .05s; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, .nav a:focus-visible, a:focus-visible, .chip:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 1px 2px rgb(79 70 229 / .35); }
.btn--primary:hover { background: var(--primary-hover); } .btn--primary:active { background: var(--primary-active); }
.btn--secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn--secondary:hover { background: var(--surface-2); border-color: var(--off); } .btn--secondary:active { background: var(--border); }
.btn--ghost { background: transparent; color: var(--muted); } .btn--ghost:hover { background: var(--surface-2); color: var(--text); } .btn--ghost:active { background: var(--border); }
.btn--danger { background: var(--danger); color: #fff; } .btn--danger:hover { filter: brightness(.92); } .btn--danger:active { filter: brightness(.85); }
.btn--danger-ghost { background: transparent; color: var(--danger); } .btn--danger-ghost:hover { background: var(--danger-bg); }
.btn--sm { min-height: 32px; padding: 4px 12px; font-size: 14px; }
.btn--icon { width: 40px; padding: 0; } .btn--icon.btn--sm { width: 32px; }
.btn.is-loading { pointer-events: none; color: transparent; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid var(--on-primary); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn--secondary.is-loading::after, .btn--ghost.is-loading::after { border-color: var(--text); border-right-color: transparent; }
.btn--danger.is-loading::after { border-color: #fff; border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.theme-toggle .icon--sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon--sun { display: block; } :root[data-theme="dark"] .theme-toggle .icon--moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon--sun { display: block; } :root:not([data-theme="light"]) .theme-toggle .icon--moon { display: none; }
}

/* Структура сторінки */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s3); }
.page-head p { margin: 0; }
.page-head__meta { display: flex; align-items: center; gap: var(--s1); flex-wrap: wrap; }
.actions { display: flex; gap: var(--s1); flex-wrap: wrap; align-items: center; }
.push-right { margin-left: auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--s3); box-shadow: var(--shadow); }
.card--narrow { max-width: 440px; margin: var(--s4) auto 0; padding: var(--s4); }
.card--wide { max-width: 760px; }
.card h1 + .muted { margin-bottom: var(--s2); }
.section { margin-bottom: var(--s3); }
.section > h2:first-child { margin-top: 0; }
.empty { text-align: center; padding: var(--s6) var(--s3); }
.empty .btn { margin-top: var(--s1); }
.empty__icon { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto var(--s2); border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.empty__icon .icon { width: 24px; height: 24px; }

/* Форми */
.form { display: flex; flex-direction: column; gap: var(--s2); }
.form h2 { margin: var(--s1) 0 0; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: 600; font-size: 14px; }
input[type=text], input[type=password], input[type=search], textarea, select { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; transition: border-color .12s, box-shadow .12s; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--off); }
input:hover, textarea:hover, select:hover { border-color: var(--off); }
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
input:disabled, textarea:disabled, select:disabled { opacity: .5; cursor: not-allowed; background: var(--surface-2); }
.hint { margin: 0; font-size: 13px; line-height: 16px; color: var(--muted); }
.check { display: flex; align-items: center; gap: var(--s1); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s2); }
.alert { display: flex; gap: 12px; padding: 12px 16px; border-radius: var(--radius); margin-bottom: var(--s2); border: 1px solid transparent; }
.alert ul { margin: var(--s1) 0 0; padding-left: var(--s3); }
.alert--ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert--error { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert a { color: inherit; font-weight: 600; }

/* Бейджі й індикатори */
.badge { display: inline-flex; align-items: center; gap: 8px; padding: 2px 12px 2px 10px; border-radius: 999px; font-size: 13px; line-height: 20px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.badge--up { background: var(--ok-bg); color: var(--ok); } .badge--down { background: var(--danger-bg); color: var(--danger); }
.badge--warn { background: var(--warn-bg); color: var(--warn); } .badge--off { color: var(--off); }
.badge--down .dot { animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 55%, transparent); } 100% { box-shadow: 0 0 0 8px transparent; } }

/* Підсумкові картки */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); margin-bottom: var(--s3); }
.stat { display: flex; flex-direction: column; gap: 4px; padding: var(--s2) var(--s3); }
.stat__label { display: flex; align-items: center; gap: var(--s1); color: var(--muted); font-size: 14px; }
.stat__value { font-size: 32px; line-height: 40px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat__value--up { color: var(--ok); } .stat__value--down { color: var(--danger); }
.stat__hint { color: var(--muted); font-size: 13px; line-height: 16px; }
.dot--up { color: var(--ok); } .dot--down { color: var(--danger); } .dot--idle { color: var(--off); }

/* Фільтри */
.toolbar { display: flex; gap: var(--s1); flex-wrap: wrap; align-items: center; margin-bottom: var(--s2); }
.search { position: relative; flex: 1; min-width: 200px; }
.search .icon { position: absolute; left: 12px; top: 12px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 40px; }
.chips { display: flex; gap: var(--s1); flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 16px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; transition: background .12s, border-color .12s; }
.chip:hover { border-color: var(--off); background: var(--surface-2); } .chip:active { background: var(--border); }
.chip[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip__count { color: var(--muted); font-variant-numeric: tabular-nums; } .chip[aria-pressed="true"] .chip__count { color: inherit; }
.no-match { display: none; text-align: center; padding: var(--s5) var(--s3); }
.no-match.is-visible { display: block; }

/* Таблиця */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th.num, .table td.num { text-align: right; }
.table th { padding-top: 12px; padding-bottom: 12px; font-size: 12px; line-height: 16px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 650; white-space: nowrap; background: var(--surface-2); }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-down { background: var(--danger-row); }
.table tbody tr.is-down:hover { background: var(--danger-bg); }
.table tr:last-child td { border-bottom: 0; }
.table tr[hidden] { display: none; }
.host-name { display: block; font-weight: 650; color: var(--text); text-decoration: none; }
.host-name:hover { color: var(--primary); }
.host-addr { display: block; color: var(--muted); font: 13px/16px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin-top: 4px; }
.row-actions { text-align: right; white-space: nowrap; }
.err { display: block; margin-top: 4px; }
.meter { display: inline-flex; align-items: center; gap: var(--s1); }
.meter svg { width: 64px; height: 8px; border-radius: 4px; }
.meter__track { fill: var(--border); } .meter__fill { fill: var(--ok); } .meter__fill--warn { fill: var(--warn); } .meter__fill--bad { fill: var(--danger); }

/* Скелетони: хост, який ще не перевірявся */
.skeleton { display: inline-block; width: 56px; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--border) 25%, var(--surface-2) 50%, var(--border) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; vertical-align: middle; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Деталі хоста */
.uptime-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s2); margin-bottom: var(--s3); }
.strip { display: block; width: 100%; height: 40px; }
.strip rect { fill: var(--ok); } .strip rect.bad { fill: var(--danger); }
.strip-legend { display: flex; justify-content: space-between; margin-top: var(--s1); }

/* Сторінки входу */
.auth-brand { display: flex; justify-content: center; margin: var(--s4) 0 0; }
.auth-brand + .card--narrow { margin-top: var(--s3); }
.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: var(--s1); list-style: none; padding: 0; margin: var(--s2) 0; }
.codes code { display: block; padding: 8px 16px; font-size: 15px; line-height: 24px; letter-spacing: .05em; text-align: center; }
.steps { padding-left: var(--s3); } .steps li { margin-bottom: var(--s1); }

.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; padding: var(--s2) 0; }

@media (max-width: 880px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .nav a span { display: none; } .nav a { padding: 8px 12px; }
}
@media (max-width: 720px) {
  .container { padding: 0 var(--s2); }
  main.container { padding-top: var(--s3); }
  h1 { font-size: 24px; line-height: 32px; }
  .topbar__inner { gap: var(--s1); }
  .brand__text, .logout-label { display: none; }
  .card--narrow { margin-top: var(--s2); padding: var(--s3); }
  .page-head .actions { width: 100%; } .page-head .actions .btn { flex: 1; }
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--s1) 0; margin-bottom: var(--s2); box-shadow: var(--shadow); }
  .table tbody tr.is-down { background: var(--danger-row); }
  .table td { border: 0; padding: 4px 16px; display: flex; justify-content: space-between; align-items: center; gap: var(--s2); text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex: none; }
  .table td.cell-main { display: block; text-align: left; padding-top: 8px; } .table td.cell-main::before { content: none; }
  .table td.row-actions { justify-content: flex-end; } .table td.row-actions::before { content: none; }
  .table--plain tr { padding: 0; border-radius: var(--radius); margin-bottom: var(--s1); }
}
@media (max-width: 420px) { .stats { gap: var(--s1); } .stat { padding: var(--s2); } .stat__value { font-size: 28px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } .btn.is-loading::after { animation-duration: 2s; } .skeleton, .badge--down .dot { animation: none; } }

/* Імпорт хостів */
.formats { margin: var(--s2) 0; padding: var(--s1) var(--s2); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.formats summary { cursor: pointer; font-weight: 600; min-height: 40px; display: flex; align-items: center; }
.formats ul { margin: var(--s1) 0 0; padding-left: 20px; display: grid; gap: 4px; }
.file-pick { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s1); }
.import-summary { display: flex; gap: var(--s1); flex-wrap: wrap; }
.import-table td input[type="checkbox"] { width: 20px; height: 20px; }
.import-table .raw { word-break: break-all; }
