:root {
  --bg: #f3efe9;
  --surface: #fffaf5;
  --surface-2: #efe6db;
  --text: #1a1410;
  --text-muted: #6e5f52;
  --border: #e0d4c6;
  --accent: #ff6a00;
  --accent-hover: #ff8124;
  --accent-soft: rgba(255, 106, 0, 0.12);

  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --crit: #dc2626;
  --crit-soft: #fee2e2;
  --neutral: #78716c;
  --neutral-soft: #e7e5e4;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(40, 24, 10, 0.06), 0 4px 14px rgba(40, 24, 10, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --bg-glow: radial-gradient(ellipse at 12% 0%, rgba(255, 106, 0, 0.1), transparent 42%),
    radial-gradient(ellipse at 100% 100%, rgba(255, 106, 0, 0.06), transparent 40%);
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #1a1a1a;
  --text: #e8e8e8;
  --text-muted: #b0b0b0;
  --border: #2a2a2a;
  --accent: #ff6a00;
  --accent-hover: #ff8124;
  --accent-soft: rgba(255, 106, 0, 0.16);

  --ok: #3ecf6a;
  --ok-soft: #102418;
  --warn: #f0a020;
  --warn-soft: #2e2108;
  --crit: #ff6b5a;
  --crit-soft: #301410;
  --neutral: #9a9a9a;
  --neutral-soft: #222222;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 8px 28px rgba(0, 0, 0, 0.35);
  --bg-glow: radial-gradient(ellipse at 20% 0%, rgba(255, 106, 0, 0.14), transparent 45%),
    radial-gradient(ellipse at 90% 100%, rgba(255, 106, 0, 0.07), transparent 40%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 0.25rem;
}

h2 {
  font-size: 1.1rem;
  margin: 2rem 0 0.75rem;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: 64px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
}

.brand:hover {
  text-decoration: none;
}

.brand-logo {
  position: relative;
  display: inline-block;
  line-height: 0;
}

.brand-logo-img {
  display: block;
  height: 44px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
}

.brand-logo-lg .brand-logo-img {
  height: 72px;
  max-width: 280px;
}

.brand-logo-light {
  display: none;
}

[data-theme="light"] .brand-logo-dark {
  display: none;
}

[data-theme="light"] .brand-logo-light {
  display: block;
}

[data-theme="dark"] .brand-logo-dark {
  display: block;
}

[data-theme="dark"] .brand-logo-light {
  display: none;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-right: auto;
}

.tabs a {
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 500;
}

.tabs a:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.tabs a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.page-head-actions select {
  min-width: 160px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.subtitle {
  color: var(--text-muted);
  margin: 0;
}

.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  filter: none;
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  color: var(--crit);
  border-color: var(--crit);
  background: transparent;
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.messages {
  list-style: none;
  margin: 0 auto;
  padding: 0.75rem 1.5rem 0;
  max-width: 1400px;
}

.messages li {
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.messages li.warning {
  background: var(--warn-soft);
  border-color: var(--warn);
}

.messages li.error {
  background: var(--crit-soft);
  border-color: var(--crit);
}

.messages li.success {
  background: var(--ok-soft);
  border-color: var(--ok);
}

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
}

.totals {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 0.9rem 1.25rem;
  margin-bottom: 1.25rem;
}

.totals div {
  display: flex;
  flex-direction: column;
}

.totals .value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
}

.totals .caption {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.value.ok {
  color: var(--ok);
}

.value.crit {
  color: var(--crit);
}

.value.warn {
  color: var(--warn);
}

.filters {
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.filter-row {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  align-items: flex-start;
}

.filter-group {
  min-width: 220px;
}

.filter-group > span {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.88rem;
  user-select: none;
}

.chip input {
  margin: 0;
}

.chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.filter-group select {
  min-width: 180px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.board-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.board-meta .btn.is-off {
  opacity: 0.75;
  border-style: dashed;
}

.client-live-meta {
  justify-content: flex-end;
}

.refresh-stamp {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.refresh-stamp strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.tile {
  display: flex;
  flex-direction: column;
  padding: 0;
  color: var(--text);
  border-left: 4px solid var(--neutral);
  overflow: hidden;
  min-width: 0;
}

.tile.ok {
  border-left-color: var(--ok);
}

.tile.warn {
  border-left-color: var(--warn);
}

.tile.crit {
  border-left-color: var(--crit);
}

.tile-summary:hover {
  background: var(--surface-2);
}

.tile.is-open .tile-chevron {
  transform: rotate(90deg);
}

.tile-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "logo identity actions chevron"
    "status status status status";
  gap: 0.75rem 0.85rem;
  align-items: center;
  padding: 1rem 1.15rem;
  width: 100%;
  cursor: pointer;
}

.tile-actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
  cursor: default;
}

.tile-actions .btn {
  white-space: nowrap;
}

.logo-box {
  grid-area: logo;
  width: 88px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
  padding: 5px;
}

.logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: transparent;
}

.logo-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: #fff;
  background: hsl(var(--logo-hue, 24) 70% 42%);
  border-radius: 4px;
}

.logo-preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.logo-preview .logo-box {
  width: 96px;
  height: 64px;
}

.tile-identity {
  grid-area: identity;
  min-width: 0;
}

.tile-title {
  font-weight: 700;
  font-size: 1.45rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tile-status {
  grid-area: status;
  min-width: 0;
}

.tile-status .status-head {
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.25;
}

.tile-status .status-detail {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.tile-status .bar {
  margin-top: 0.5rem;
}

.tile-chevron {
  grid-area: chevron;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  justify-self: end;
  align-self: start;
  margin-top: 0.45rem;
  pointer-events: none;
}

.status-head.ok {
  color: var(--ok);
}

.status-head.warn {
  color: var(--warn);
}

.status-head.crit {
  color: var(--crit);
}

.status-head.unknown,
.status-head.empty {
  color: var(--neutral);
}

.bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--neutral);
  transition: width 0.3s ease;
}

.bar.ok span {
  background: var(--ok);
}

.bar.warn span {
  background: var(--warn);
}

.bar.crit span {
  background: var(--crit);
}

.tile-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border);
  min-width: 0;
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.device-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.device-item:last-child {
  border-bottom: none;
  padding-bottom: 0.25rem;
}

.device-item-main {
  min-width: 0;
}

.device-item-name {
  font-weight: 600;
  word-break: break-word;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.device-item-note {
  margin-top: 0.2rem;
  font-size: 0.85rem;
  padding-left: 1.75rem;
}

.device-item-meta {
  display: grid;
  grid-template-columns:
    minmax(4.5rem, 6.5rem)
    minmax(7.5rem, 9.5rem)
    minmax(6.5rem, 8rem)
    minmax(5rem, 7rem);
  align-items: center;
  column-gap: 0.65rem;
  margin-top: 0.4rem;
  font-size: 0.88rem;
  padding-left: 1.75rem;
}

.device-item-meta .meta-type {
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-item-meta .meta-state {
  justify-self: start;
}

.device-item-meta .meta-when {
  justify-self: start;
}

.device-item-actions {
  flex-shrink: 0;
  padding-bottom: 0.05rem;
}

.device-item-actions .btn {
  white-space: nowrap;
}

@media (max-width: 520px) {
  .device-item-meta {
    grid-template-columns: 1fr 1fr;
    row-gap: 0.35rem;
    padding-left: 0;
  }

  .device-item-note {
    padding-left: 0;
  }
}

.tile-more {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.6rem;
}

.device-history-cell {
  padding: 0 !important;
  border-bottom: none !important;
}

.device-history-cell:empty {
  display: none;
}

.device-history {
  margin: 0.35rem 0 0.85rem;
  padding: 0.75rem 0.9rem;
  background: var(--surface-2);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.device-history-head {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
}

.history-table {
  width: 100%;
  font-size: 0.85rem;
}

.history-table th,
.history-table td {
  padding: 0.4rem 0.45rem;
}

.device-history-empty {
  margin: 0.4rem 0 0.75rem;
  padding: 0 0.25rem;
}

.zabbix-current-problems {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--down, #c44) 35%, var(--border));
  background: color-mix(in srgb, var(--down, #c44) 8%, var(--surface-2));
}

.zabbix-current-problems-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.zabbix-problem-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  line-height: 1.35;
}

.zabbix-problem-list li + li {
  margin-top: 0.2rem;
}

.history-problem {
  max-width: 28rem;
  word-break: break-word;
}

.type-icon {
  display: inline-block;
  width: 1.35rem;
  height: 1.35rem;
  vertical-align: middle;
  flex-shrink: 0;
}

.type-icon-lg {
  width: 2.75rem;
  height: 2.75rem;
}

.type-icon-builtin {
  background-color: currentColor;
  -webkit-mask: var(--type-icon) center / contain no-repeat;
  mask: var(--type-icon) center / contain no-repeat;
  opacity: 0.85;
}

.type-icon-img {
  object-fit: contain;
  object-position: center;
}

.type-icon-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  background: transparent;
}

.type-icon-cell {
  width: 2.5rem;
}

.type-cell {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.chip-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.chip-with-icon .type-icon {
  width: 1.1rem;
  height: 1.1rem;
}


.icon-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.65rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
  text-align: center;
}

.icon-pick input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.icon-pick:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.icon-pick .type-icon {
  width: 1.75rem;
  height: 1.75rem;
}

.icon-pick-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.agent-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
  align-items: center;
}

.inline-form {
  display: inline;
  margin: 0;
}


@media (max-width: 900px) {
  .tile-summary {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "logo identity chevron"
      "actions actions actions"
      "status status status";
  }

  .tile-actions {
    justify-content: flex-start;
  }
}

.btn.pending {
  color: var(--text-muted);
  cursor: default;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 2rem 0 0.75rem;
}

.section-head h2 {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.section-count {
  font-size: 0.85rem;
  font-weight: 500;
}

@media (max-width: 780px) {
  .tiles {
    grid-template-columns: 1fr;
  }
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--surface-2);
}

.muted {
  color: var(--text-muted);
}

.nowrap {
  white-space: nowrap;
}

.right {
  text-align: right;
}

.pill {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--neutral-soft);
  color: var(--neutral);
}

.pill.up {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill.down {
  background: var(--crit-soft);
  color: var(--crit);
}

.pill.degraded {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill.unknown {
  background: var(--neutral-soft);
  color: var(--neutral);
}

.tag-critical {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--crit);
  border: 1px solid var(--crit);
  border-radius: 4px;
  padding: 0 0.3rem;
  margin-left: 0.4rem;
}

.form-card {
  max-width: 680px;
  padding: 1.5rem;
}

.config-filters {
  margin-bottom: 1rem;
}

.config-filters .filter-row {
  align-items: flex-end;
}

.config-filters label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.config-filters select,
.config-filters input[type="search"],
.config-filters input[type="text"] {
  min-width: 160px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.table-filters th {
  padding-top: 0.35rem;
  padding-bottom: 0.65rem;
  font-weight: 500;
  vertical-align: bottom;
  background: var(--surface-2);
}

.table-filters input {
  width: 100%;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}

.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  margin-top: 0.85rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pagination-meta {
  font-size: 0.9rem;
  min-width: 7rem;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pagination-pages .btn[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

.pagination-current {
  font-size: 0.9rem;
  padding: 0 0.35rem;
  white-space: nowrap;
}

.pagination-size {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pagination-size label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pagination-size select {
  min-width: 4.5rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.bulk-bar {
  margin-bottom: 1rem;
  padding: 0.9rem 1.15rem;
}

.bulk-bar-main {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.bulk-check-all {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
  padding-bottom: 0.45rem;
}

.bulk-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding-bottom: 0.15rem;
}

.bulk-agent {
  min-width: 260px;
}

.bulk-agent select {
  min-width: 260px;
}

.col-check {
  width: 2.2rem;
  text-align: center;
}

.form-card-wide {
  max-width: 960px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 1.25rem;
  align-items: start;
}

.form-row-span {
  grid-column: 1 / -1;
}

@media (max-width: 780px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-row {
  margin-bottom: 1.1rem;
}

.form-row label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 0.3rem;
}

.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="email"],
.form-row input[type="password"],
.form-row input[type="file"],
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.form-row textarea {
  min-height: 90px;
  resize: vertical;
}

.form-row .helptext {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.install-steps {
  margin: 0.35rem 0 0;
  padding-left: 1.25rem;
  line-height: 1.55;
}

.install-steps li {
  margin: 0.45rem 0;
}

.install-steps ul,
.agent-install-list {
  margin: 0.35rem 0 0.15rem;
  padding-left: 1.25rem;
}

.install-steps code,
.agent-install-body code {
  font-size: 0.9em;
}

.agent-install-panel {
  margin-bottom: 1.25rem;
  padding: 0;
  overflow: hidden;
}

.agent-install-summary {
  cursor: pointer;
  list-style: none;
  padding: 0.85rem 1.1rem;
  font-weight: 600;
  font-size: 1.02rem;
  user-select: none;
}

.agent-install-summary::-webkit-details-marker {
  display: none;
}

.agent-install-summary::before {
  content: "▸ ";
  color: var(--text-muted);
  font-weight: 700;
}

.agent-install-panel[open] > .agent-install-summary::before {
  content: "▾ ";
}

.agent-install-body {
  padding: 0 1.1rem 1.1rem;
  border-top: 1px solid var(--border, rgba(127, 127, 127, 0.25));
}

.agent-install-body p {
  margin: 0.75rem 0 0.35rem;
}

.agent-install-next {
  margin-top: 1.1rem !important;
}

.agent-install-label {
  margin: 1rem 0 0.35rem !important;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cmd-box {
  display: block;
  margin: 0.4rem 0 0.2rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border, rgba(127, 127, 127, 0.3));
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  font-style: italic;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: all;
  cursor: text;
  color: var(--text);
}
.form-row.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-row.checkbox label {
  margin: 0;
}

.errorlist {
  list-style: none;
  margin: 0.3rem 0 0;
  padding: 0;
  color: var(--crit);
  font-size: 0.85rem;
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

body.login-page {
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255, 106, 0, 0.18), transparent 45%),
    radial-gradient(ellipse at 80% 90%, rgba(255, 106, 0, 0.08), transparent 40%),
    #0a0a0a;
  color: #e8e8e8;
}

body.login-page .login-card {
  background: #111;
  border-color: #2a2a2a;
  color: #e8e8e8;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

body.login-page .login-card label {
  color: #b0b0b0;
}

body.login-page .login-card .form-row input[type="text"],
body.login-page .login-card .form-row input[type="password"] {
  background: #1a1a1a;
  border-color: #333;
  color: #f2f2f2;
}

body.login-page .login-brand {
  border-bottom-color: #2a2a2a;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 0 1.75rem 1.75rem;
  overflow: hidden;
}

.login-brand {
  margin: 0 -1.75rem 1.5rem;
  background: transparent;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: center;
  padding: 1.25rem 1rem 0.75rem;
}

.login-brand-img {
  display: block;
  width: min(100%, 320px);
  height: auto;
}

.login-card .btn-primary {
  width: 100%;
  margin-top: 0.5rem;
}

body.tv {
  overflow-x: hidden;
  overflow-y: auto;
}

.tv-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem 0;
}

.tv-head h1 {
  font-size: 2rem;
}

.brand-tv {
  color: var(--text);
}

.tv-clock {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tv-refresh {
  text-align: center;
  margin: 0 0 1rem;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.tv-refresh strong {
  color: var(--text);
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
  margin-left: 0.25rem;
}

.tv-main {
  max-width: none;
  padding: 0.75rem 1.75rem 2.75rem;
}

/* TV board: stały odstęp 1rem przez padding 0.5rem z każdej strony komórki.
   Bez CSS `gap` — Tizen/Samsung go często ignoruje. */
.tv-board-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(13rem, 17rem);
  grid-template-areas:
    "devices agents backups types"
    "clients clients clients types";
  align-items: stretch;
}

.tv-cell {
  box-sizing: border-box;
  min-width: 0;
  padding: 0.5rem;
}

.tv-cell-devices { grid-area: devices; }
.tv-cell-agents { grid-area: agents; }
.tv-cell-backups { grid-area: backups; }
.tv-cell-types { grid-area: types; }
.tv-cell-clients { grid-area: clients; }

.tv-cell > .tv-stat {
  height: 100%;
}

.tv-stat {
  padding: 1rem 1.2rem 1.1rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tv-stat .bar {
  margin-top: 0.75rem;
  height: 10px;
  width: 100%;
}

.tv-stat-detail {
  margin-top: 0.45rem;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-muted);
  min-height: 1.6em;
  line-height: 1.25;
}

.tv-stat-label {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.tv-stat-value {
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.tv-stat-value.ok {
  color: var(--ok);
}

.tv-stat-value.warn {
  color: var(--warn);
}

.tv-stat-value.crit {
  color: var(--crit);
}

.tv-stat-value.unknown,
.tv-stat-value.empty {
  color: var(--neutral);
}

.tv-types-rail {
  display: flex;
  flex-direction: column;
  padding: 0.15rem 0.25rem 0.25rem;
  min-width: 0;
}

.tv-type-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-width: 0;
}

.tv-type-row + .tv-type-row {
  margin-top: 0.7rem;
}

.tv-type-row .tv-type-name {
  font-size: 1.35rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.tv-type-row .tv-type-name .type-icon {
  width: 1.25em;
  height: 1.25em;
  flex-shrink: 0;
  margin-right: 0.4rem;
}

.tv-type-row .tv-type-count {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  text-align: right;
  min-width: 2.8rem;
  margin-left: 0.75rem;
}

.tv-type-row.ok .tv-type-count {
  color: var(--ok);
}

.tv-type-row.warn .tv-type-count {
  color: var(--warn);
}

.tv-type-row.crit .tv-type-count {
  color: var(--crit);
}

.tv-type-row.unknown .tv-type-count,
.tv-type-row.empty .tv-type-count {
  color: var(--neutral);
}

/* Klienci: ta sama logika paddingu co komórki u góry → równa szerokość kolumn */
.tv .tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0; /* nadpisuje .tiles { gap: 1rem } — inaczej odstęp się podwaja */
  margin: -0.5rem;
}

.tv .tiles > * {
  box-sizing: border-box;
  min-width: 0;
  margin: 0.5rem;
}

.tv .tile {
  border-left-width: 6px;
  cursor: default;
  min-height: 8rem;
}

.tv-cell-clients > .empty-state {
  margin: 0;
}

.tv .tile-summary {
  padding: 1.15rem 1.4rem;
  cursor: default;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "logo identity"
    "status status";
}

.tv .tile-summary:hover {
  background: transparent;
}

.tv .tile-actions,
.tv .tile-chevron,
.tv .tile-hit {
  display: none;
}

.tv .logo-box {
  width: 110px;
  height: 72px;
}

.tv .logo-initials {
  font-size: 1.35rem;
}

.tv .tile-title {
  font-size: 1.75rem;
}

.tv .status-head {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.2;
}

.tv .status-detail {
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.25;
  margin-top: 0.2rem;
}

.tv .tile-status {
  width: 100%;
  max-width: none;
}

.tv .tile-status .bar {
  margin-top: 0.45rem;
  height: 10px;
  width: 100%;
}

.logo-box-lg {
  width: 96px;
  height: 64px;
}

.logo-box-sm {
  width: 56px;
  height: 36px;
}

.client-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.client-hero h1 {
  margin: 0;
}

.tv-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding: 0.65rem 2rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  background: var(--bg);
}

.tv-busy {
  max-width: 32rem;
  margin: 4rem auto;
  padding: 2rem;
  text-align: center;
}

.tv-busy h2 {
  margin-top: 0;
}

.tv-busy form {
  margin-top: 1.25rem;
}

.tv-board-loading {
  padding: 3rem;
  text-align: center;
  font-size: 1.1rem;
}
