/* Kerno — sistema de design (claro e escuro) */
@font-face { font-family: 'Inter'; src: url('/static/fonts/inter.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/static/fonts/jetbrains-mono.woff2') format('woff2'); font-weight: 100 800; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #fbfaf8; --side: #f7f5f1; --card: #ffffff; --line: #e6e2da; --line-strong: #d5d0c6;
  --text: #1c1a17; --muted: #6b655c; --hover: #f3f0ea; --selected: #eeeae2;
  --accent: #0f6b4f; --accent-hover: #0b5a42; --accent-text: #ffffff; --accent-soft: #e3f1eb;
  --ok: #0f7a55; --ok-soft: #e2f2ea; --warn: #92550a; --warn-soft: #fbeed8; --danger: #b42318; --danger-soft: #fbe9e7;
  --off: #a8a29a; --shadow: 0 1px 2px rgba(28, 26, 23, .05), 0 8px 24px rgba(28, 26, 23, .06);
  --radius: 10px; --radius-sm: 8px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121411; --side: #0f110e; --card: #1a1d19; --line: #2a2f28; --line-strong: #3a4038;
  --text: #ecebe6; --muted: #9d9b93; --hover: #20241e; --selected: #262b24;
  --accent: #3fbf91; --accent-hover: #55cda2; --accent-text: #052118; --accent-soft: #173229;
  --ok: #46c795; --ok-soft: #15301f; --warn: #e5a54b; --warn-soft: #33270f; --danger: #f9776d; --danger-soft: #391b18;
  --off: #626960; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { font: 14px/1.5 var(--font); background: var(--bg); color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -.015em; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -.005em; }
strong { font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: .92em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 13px;
  font: 600 13px var(--font); color: var(--text); background: var(--card); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-ghost[aria-pressed="true"] { color: var(--accent); }
.btn-icon { width: 36px; padding: 0; }
.btn-lg { min-height: 46px; padding: 0 22px; font-size: 14px; }
.btn-block { width: 100%; }

input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  font: 400 13.5px var(--font); color: var(--text); background: var(--card); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); min-height: 36px; padding: 6px 11px; max-width: 100%; }
select { padding-right: 28px; cursor: pointer; }
textarea { line-height: 1.55; resize: vertical; width: 100%; }
textarea.code { font-family: var(--mono); font-size: 12px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; vertical-align: -2px; margin-right: 6px; }
input[type="file"] { border: 0; background: transparent; padding-left: 0; }
input[type="number"] { width: 7.5rem; }
.input-wide { min-width: min(24rem, 100%); }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; }
.field input, .field select { font-weight: 400; width: 100%; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.form-row > label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

code { font-family: var(--mono); font-size: .88em; background: var(--hover); border-radius: 5px; padding: 1px 5px; overflow-wrap: anywhere; }
pre { font-family: var(--mono); font-size: 12px; line-height: 1.6; background: var(--hover); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; white-space: pre-wrap; word-break: break-all; }
pre:empty { display: none; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--hover); color: var(--muted); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--off); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--selected); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.avatar-lg { width: 54px; height: 54px; font-size: 17px; }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); font-size: 13px; }
.notice-warn { background: var(--warn-soft); color: var(--warn); }
.status-line { font-weight: 600; font-size: 13px; }
.status-line:not(:empty) { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); }

/* ---------- estrutura ---------- */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.sidebar { display: flex; flex-direction: column; gap: 2px; background: var(--side); border-right: 1px solid var(--line); padding: 14px 12px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; }
.nav-caption { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 16px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; font-size: 13.5px; }
.nav-item:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--selected); color: var(--text); font-weight: 600; }
.sidebar-end { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 16px; }
.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.theme-switch button { display: grid; place-items: center; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--selected); color: var(--text); }
.user-card { display: flex; align-items: center; gap: 9px; border-top: 1px solid var(--line); padding-top: 12px; }
.user-card a.who { display: flex; align-items: center; gap: 9px; color: var(--text); min-width: 0; flex: 1; }
.user-card a.who:hover { text-decoration: none; }
.user-card .name { font-weight: 600; font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card .name small { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); }
.byline { font-size: 11px; color: var(--muted); padding: 0 4px; }
.topbar { display: none; }
.content { min-width: 0; overflow-y: auto; }

/* ---------- páginas de conteúdo ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 28px 32px 56px; display: flex; flex-direction: column; gap: 18px; }
.page-narrow { max-width: 780px; }
.page-head p { color: var(--muted); margin-top: 4px; max-width: 68ch; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card > summary { cursor: pointer; font-weight: 600; }
details.card[open] { gap: 12px; }
.card > ol { padding-left: 20px; color: var(--muted); line-height: 1.9; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { font: 600 13.5px var(--font); color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 9px 12px; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.page section { display: flex; flex-direction: column; gap: 14px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.table-wrap:has(table:empty) { display: none; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-wrap td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap tr.head td { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--side); white-space: nowrap; }
.table-wrap td .btn { min-height: 30px; padding: 0 10px; font-size: 12px; margin: 2px 4px 2px 0; }
.table-wrap td select { min-height: 30px; padding-top: 2px; padding-bottom: 2px; font-size: 12.5px; }

dialog { color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; width: min(420px, calc(100vw - 32px)); margin: auto; }
dialog::backdrop { background: rgba(10, 12, 9, .55); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog input { width: 100%; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
#askFields { display: flex; flex-direction: column; gap: 10px; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 60; max-width: min(380px, calc(100vw - 32px)); background: var(--text); color: var(--bg); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); font-size: 13px; }
.toast strong { display: block; }

/* ---------- atendimento (tela principal) ---------- */
.support { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: 100%; }
.list-pane { display: flex; flex-direction: column; min-height: 0; background: var(--card); border-right: 1px solid var(--line); }
.list-head { display: flex; flex-direction: column; gap: 11px; padding: 18px 16px 12px; border-bottom: 1px solid var(--line); }
.list-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.search { position: relative; display: block; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input[type="search"] { width: 100%; min-height: 42px; padding-left: 38px; padding-right: 40px; font-size: 14px; }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font: 11px var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; pointer-events: none; }
.search input:focus ~ kbd { display: none; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { font: 500 12px var(--font); color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px; cursor: pointer; white-space: nowrap; }
.chip:hover { color: var(--text); background: var(--hover); }
.chip b { font-weight: 600; margin-left: 3px; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { color: var(--text); border-color: var(--text); font-weight: 600; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.filters select { width: 100%; min-height: 32px; font-size: 12.5px; padding-top: 3px; padding-bottom: 3px; }
.filters select#companySelect { grid-column: 1 / -1; }
.machine-list { flex: 1; overflow-y: auto; list-style: none; }
.machine { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.machine:hover { background: var(--hover); }
.machine:focus-visible { outline-offset: -3px; }
.machine[aria-current="true"] { background: var(--selected); box-shadow: inset 3px 0 0 var(--accent); }
.machine .info { min-width: 0; flex: 1; }
.machine .line { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; }
.machine .line span:last-child, .machine .meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.machine .meta { display: block; font-size: 12px; color: var(--muted); padding-left: 16px; }
.machine .marks { display: flex; gap: 6px; color: var(--muted); }
.machine .marks .warn { color: var(--warn); }
.list-foot { padding: 12px 16px; text-align: center; font-size: 12.5px; color: var(--muted); }

.detail-pane { overflow-y: auto; min-width: 0; }
.detail { max-width: 860px; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 16px; }
.detail-head { display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }
.detail-head .titles { min-width: 0; flex: 1; }
.detail-head h1 { font-size: 24px; overflow-wrap: anywhere; }
.back { display: none; }
.connect { gap: 14px; }
.connect-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.rd-id { font-family: var(--mono); font-size: 26px; font-weight: 500; letter-spacing: .01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.connect-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.password { font-family: var(--mono); font-size: 13px; background: var(--hover); border-radius: var(--radius-sm); padding: 8px 12px; overflow-wrap: anywhere; user-select: all; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.columns > div { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); white-space: nowrap; }
.kv dd { text-align: right; overflow-wrap: anywhere; }
.disk { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
.meter { height: 6px; border-radius: 3px; background: var(--hover); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter.low i { background: var(--warn); }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 48px 28px; color: var(--muted); height: 100%; }
.empty h2 { color: var(--text); }
.empty p { max-width: 42ch; }
.skeleton { height: 58px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, transparent, var(--hover), transparent); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- acesso (login e offline) ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-aside { background: #0e1f19; color: #e9f3ee; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.auth-aside .brand { color: inherit; padding: 0; }
.auth-aside h2 { font-size: 30px; line-height: 1.25; letter-spacing: -.025em; max-width: 18ch; }
.auth-aside ul { list-style: none; display: flex; flex-direction: column; gap: 13px; margin-top: 24px; color: #b8d3c7; }
.auth-aside li { display: flex; gap: 11px; align-items: center; }
.auth-aside li .icon { color: #4fd1a1; }
.auth-aside small { color: #7fa394; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 24px; position: relative; }
.auth-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 18px; }
.auth-box .brand { display: none; padding: 0; }
.auth-box .btn { min-height: 42px; }
.auth-box input { min-height: 42px; }
.auth-theme { position: absolute; top: 18px; right: 18px; width: 108px; }
.error { background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; font-weight: 500; }

/* ---------- telas menores ---------- */
@media (max-width: 1080px) { .support { grid-template-columns: 310px minmax(0, 1fr); } .detail { padding: 22px 20px 40px; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--side); }
  .topbar .brand { padding: 0; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .18s ease; visibility: hidden; }
  .shell.menu-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow); }
  .scrim { position: fixed; inset: 0; background: rgba(10, 12, 9, .5); z-index: 30; border: 0; }
  .support { grid-template-columns: 1fr; }
  .detail-pane { display: none; }
  .support.show-detail .list-pane { display: none; }
  .support.show-detail .detail-pane { display: block; }
  .back { display: inline-flex; align-self: flex-start; }
  .page { padding: 20px 16px 40px; }
  .form-row > input, .form-row > select { flex: 1 1 100%; }
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-box .brand { display: flex; }
}
@media (min-width: 861px) { .scrim { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Escolha do servidor RustDesk */
.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.choice { display: flex; gap: 6px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.choice > span { display: flex; flex-direction: column; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice:has(input:disabled) { cursor: default; opacity: .65; }
.plain-list { padding-left: 18px; line-height: 1.8; }
details > .stack { margin-top: 10px; }
.status-line:empty, #serverCurrent:empty { display: none; }

/* Telas de Configurações */
.subnav { display: flex; gap: 4px; overflow-x: auto; padding: 4px; background: var(--side); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.subnav a { padding: 7px 14px; border-radius: calc(var(--radius-sm) - 2px); font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap; }
.subnav a:hover { color: var(--text); }
.subnav a[aria-current="page"] { background: var(--card); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
