:root {
  --ink: #27302b;
  --muted: #69736a;
  --line: #e1e6de;
  --paper: #f6f8f4;
  --accent: #da633d;
  --green: #3d704b;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.5 var(--font); }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
button:focus-visible, a:focus-visible { outline: 3px solid #e6a685; outline-offset: 3px; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin: 0; }
h1 { font-size: 30px; line-height: 1.25; font-weight: 650; letter-spacing: -.7px; }
h2 { font-size: 18px; font-weight: 600; }
input { width: 100%; min-width: 0; min-height: 44px; border: 1px solid #ccd5c8; border-radius: 8px; padding: 10px 12px; color: var(--ink); background: white; outline: none; font-size: 16px; }
input:focus { border-color: #8d9d83; box-shadow: 0 0 0 3px #e9eee3; }
input::placeholder { color: #828c80; }
label { display: block; font-size: 13px; font-weight: 500; margin: 20px 0 8px; }
.primary, .secondary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border-radius: 8px; padding: 10px 18px; font-size: 14px; font-weight: 550; border: 1px solid transparent; text-align: center; }
.primary { background: var(--accent); color: white; }
.primary:hover { background: #c95633; }
.secondary { border-color: var(--line); background: #f5f7f1; color: #526149; }
.secondary:hover { background: #eaf0e4; }
.shell { min-height: 100dvh; }
.sidebar { width: 200px; display: flex; flex-direction: column; gap: 32px; position: fixed; inset: 0 auto 0 0; border-right: 1px solid var(--line); background: #fcfdfb; padding: 28px 18px; }
.brand { padding: 0 10px; font-size: 22px; font-weight: 750; letter-spacing: -.7px; white-space: nowrap; }
.navigation { display: grid; gap: 6px; }
.nav-item { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 13px; border: 0; background: none; border-radius: 8px; color: var(--muted); text-align: left; }
.nav-item.selected { background: #edf1e7; color: #3f5737; font-weight: 600; }
.nav-count { font-size: 12px; min-width: 22px; text-align: center; }
.logout-button { margin-top: auto; min-height: 44px; text-align: left; padding: 10px 13px; background: none; border: 0; border-radius: 8px; color: var(--muted); }
.logout-button:hover { background: #f0f3eb; }
main { margin-left: 200px; }
.content { max-width: 1320px; margin: 0 auto; padding: 40px 32px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 18px; margin-bottom: 24px; }
.heading-title { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px; }
.network-status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.network-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #a0aa99; }
.network-status.is-ok { color: var(--green); }
.network-status.is-ok::before { background: #699864; }
.network-status.is-warning { color: #a16131; }
.network-status.is-warning::before { background: #c18d40; }
.devices-panel { background: white; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.panel-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 20px; }
.tabs { display: flex; gap: 4px; min-width: 0; }
.tab { border: 0; border-radius: 7px; min-height: 44px; padding: 10px 12px; white-space: nowrap; background: transparent; color: var(--muted); font-size: 13px; }
.tab.active { background: #edf2e6; color: #3f5b34; font-weight: 600; }
.tab span { margin-left: 5px; font-size: 11px; }
#search { max-width: 235px; background: #fafcf8; }
.table-head, .device-row { display: grid; grid-template-columns: minmax(145px, 1.4fr) minmax(120px, .9fr) 115px 220px; align-items: center; gap: 16px; padding: 0 22px; }
.table-head { min-height: 40px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #f8faf6; }
.device-row { min-height: 76px; border-bottom: 1px solid #edf0e9; }
.device-row:last-child { border-bottom: 0; }
.device-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.ip { font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--muted); overflow-wrap: anywhere; }
.status-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; width: fit-content; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--green); font-size: 13px; }
.status-button::before { content: ""; width: 6px; height: 6px; background: #699864; border-radius: 50%; flex-shrink: 0; }
.status-button:hover { background: #f1f6ed; }
.status-button.off { color: #747c70; }
.status-button.off::before { background: #a4ac9c; }
.device-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.action { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; background: white; color: #526149; font-size: 12px; white-space: nowrap; }
.action:hover { background: #f2f6ec; }
.file-missing { color: var(--muted); font-size: 12px; }
.table-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; padding: 10px 18px; border-top: 1px solid var(--line); }
#list-caption { font-size: 12px; color: var(--muted); }
.footer-actions { display: flex; gap: 18px; align-items: center; }
.text-button { display: inline-flex; align-items: center; min-height: 44px; border: 0; padding: 7px 0; background: none; color: #536b47; font-size: 13px; }
.text-button:hover { text-decoration: underline; }
.empty { padding: 42px 20px; color: var(--muted); text-align: center; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.settings-card { min-width: 0; border: 1px solid var(--line); background: white; border-radius: 12px; padding: 25px; }
.settings-card small { display: block; color: var(--muted); font-size: 12px; margin: 7px 0 22px; }
.settings-card dl { display: grid; grid-template-columns: minmax(85px, .6fr) minmax(0, 1fr); gap: 14px 20px; font-size: 13px; margin: 24px 0; }
.settings-card dt { color: var(--muted); }
.settings-card dd { margin: 0; overflow-wrap: anywhere; }
.note { color: var(--muted); font-size: 12px; line-height: 1.7; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.login-page { background: #f6f7f5; }
.login-container { margin: 0; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-form { width: min(100%, 360px); background: white; border: 1px solid var(--line); border-radius: 12px; padding: 32px; }
.login-form h1 { font-size: 26px; }
.login-form .primary { width: 100%; background: #35443a; }
.login-form .primary:hover { background: #25382c; }
.error { min-height: 20px; color: #ad4831; font-size: 13px; margin: 10px 0 15px; }
dialog { width: 420px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); border: 1px solid var(--line); border-radius: 12px; padding: 28px; color: var(--ink); box-shadow: 0 18px 80px #18281c22; overflow-y: auto; }
dialog::backdrop { background: #1d2c2359; }
.icon-button { position: absolute; top: 9px; right: 9px; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 26px; }
.icon-button:hover { background: #f1f4ed; }
.dialog-title { padding-right: 28px; margin-bottom: 18px; font-size: 22px; overflow-wrap: anywhere; line-height: 1.3; }
.dialog-copy { margin: 12px 0; font-size: 13px; color: var(--muted); line-height: 1.7; }
.dialog-actions { display: flex; gap: 10px; margin-top: 22px; }
.dialog-actions > * { flex: 1; }
.qr-image { display: block; width: 255px; height: 255px; max-width: 100%; object-fit: contain; margin: 12px auto; }
.dialog-address { text-align: center; color: var(--muted); font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
.dialog-help { padding-left: 20px; font-size: 14px; line-height: 1.8; }
.dialog-help li + li { margin-top: 9px; }
.toast { position: fixed; bottom: max(22px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); max-width: calc(100vw - 32px); width: max-content; padding: 12px 20px; border-radius: 8px; color: white; background: #344a30; box-shadow: 0 5px 25px #243a2222; font-size: 13px; z-index: 10; overflow-wrap: anywhere; }
.error-toast { background: #a14d36; }
@media (max-width: 1180px) {
  .sidebar { width: 180px; }
  main { margin-left: 180px; }
  .content { padding: 32px 24px; }
  .heading-title { display: grid; gap: 6px; }
  .table-head, .device-row { grid-template-columns: minmax(110px, 1fr) 112px 105px 214px; gap: 10px; padding: 0 16px; }
  .panel-toolbar { padding: 15px 16px; gap: 12px; }
  .tab { padding: 10px; }
  #search { max-width: 190px; }
}
@media (max-width: 1024px) {
  .sidebar { position: static; width: 100%; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px 16px; padding: 14px 24px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; font-size: 21px; }
  .navigation { grid-column: 1 / -1; grid-row: 2; display: flex; gap: 8px; padding-bottom: 12px; }
  .nav-item { justify-content: center; gap: 10px; padding: 10px 16px; }
  .logout-button { grid-column: 2; grid-row: 1; padding: 8px 12px; margin: 0; text-align: center; }
  main { margin-left: 0; }
  .heading-title { display: flex; }
  .table-head, .device-row { grid-template-columns: minmax(130px, 1.3fr) minmax(112px, 1fr) 115px 220px; }
}
@media (max-width: 720px) {
  .sidebar { padding: 10px 18px 0; gap: 8px 12px; }
  .navigation { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding-bottom: 10px; }
  .content { padding: 24px 16px; }
  .page-heading { align-items: flex-start; gap: 16px; margin-bottom: 18px; }
  h1 { font-size: 27px; }
  .heading-title { width: 100%; justify-content: space-between; gap: 8px; }
  .network-status { font-size: 11px; }
  #add-device { width: 100%; }
  .panel-toolbar { flex-direction: column; align-items: stretch; gap: 12px; padding: 14px; }
  .tabs { justify-content: space-between; gap: 2px; }
  .tab { flex: 1; padding: 9px 7px; font-size: 12px; }
  .tab span { margin-left: 3px; font-size: 10px; }
  #search { max-width: none; }
  .table-head { display: none; }
  .device-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name status" "ip status" "actions actions"; gap: 4px 10px; padding: 16px 14px; }
  .device-name { grid-area: name; font-size: 15px; align-self: end; }
  .ip { grid-area: ip; font-size: 12px; }
  .status-button { grid-area: status; font-size: 12px; padding: 8px; }
  .device-actions { grid-area: actions; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
  .action { padding: 9px 5px; width: 100%; font-size: 12px; }
  .file-missing { grid-column: span 2; align-self: center; }
  .table-footer { padding: 8px 14px; gap: 0 10px; }
  .footer-actions { gap: 14px; }
  .text-button { font-size: 12px; }
  .settings-grid { grid-template-columns: 1fr; gap: 16px; }
  .settings-card { padding: 20px; }
  .settings-card dl { column-gap: 12px; }
  .settings-actions > * { flex: 1; }
  .login-container { padding: 16px; }
  .login-form { padding: 26px 22px; }
  dialog { padding: 26px 22px; }
}
@media (max-width: 360px) {
  .heading-title { display: grid; }
  .tab { padding-left: 5px; padding-right: 5px; }
  .tab span { display: none; }
  .table-footer { align-items: flex-start; flex-direction: column; }
  .footer-actions { width: 100%; justify-content: space-between; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-actions > * { flex-basis: 100%; }
  .qr-image { height: auto; aspect-ratio: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
