:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #17202b;
  --muted: #667085;
  --line: #d7dee7;
  --accent: #f79009;
  --accent-2: #14746f;
  --blue: #2e90fa;
  --side: #101820;
  --side-soft: #1c2935;
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
  --shadow: 0 12px 30px rgba(23, 32, 43, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1118;
  --panel: #111a24;
  --panel-soft: #172231;
  --ink: #e6edf5;
  --muted: #9aa7b7;
  --line: #263445;
  --side: #070b10;
  --side-soft: #162130;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  font-size: 14px;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.brand,
.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-block {
  margin-bottom: 6px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 8px;
  background: transparent;
}

.brand h1,
.brand p,
.brand-block h1,
.brand-block p,
.topbar h2,
.topbar p,
.panel h3 {
  margin: 0;
}

.brand h1,
.brand-block h1 {
  font-size: 18px;
}

.brand p,
.brand-block p {
  color: #aab6c2;
  margin-top: 3px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  background: var(--side);
  color: #f6f8fa;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item,
.ghost,
.secondary,
.primary,
.icon-button,
.theme-toggle,
.text-button,
.command-link {
  border: 0;
  border-radius: 7px;
  min-height: 38px;
}

.nav-item {
  text-align: left;
  color: #d8e0e8;
  background: transparent;
  padding: 10px 12px;
}

.nav-item.active,
.nav-item:hover {
  background: var(--side-soft);
  color: #ffffff;
}

.session {
  margin-top: auto;
  color: #a9b4c0;
  display: grid;
  gap: 10px;
}

.workspace {
  padding: 24px;
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
}

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h2 {
  font-size: 26px;
}

.topbar p {
  color: var(--muted);
  margin-top: 4px;
}

.toolbar-select {
  width: min(260px, 100%);
}

.panel,
.metric,
.dash-card,
.dash-hero {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--ink);
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.stack {
  display: grid;
  gap: 18px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.dash-hero {
  grid-column: span 6;
  min-height: 220px;
  padding: 22px;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  background:
    radial-gradient(circle at 80% 18%, rgba(247, 144, 9, 0.2), transparent 32%),
    linear-gradient(135deg, var(--panel), var(--panel-soft));
  animation: dashboard-pop 360ms ease-out both;
}

.dash-hero span,
.dash-card span {
  color: var(--muted);
  font-weight: 600;
}

.dash-hero strong {
  display: block;
  margin-top: 10px;
  font-size: 56px;
  line-height: 1;
}

.dash-hero p,
.dash-card p {
  margin: 10px 0 0;
  color: var(--muted);
}

.dash-card {
  grid-column: span 2;
  padding: 18px;
  text-align: left;
  position: relative;
  overflow: hidden;
  animation: dashboard-pop 360ms ease-out both;
}

.dash-card:nth-of-type(2) {
  animation-delay: 40ms;
}

.dash-card:nth-of-type(3) {
  animation-delay: 80ms;
}

.dash-card:nth-of-type(4) {
  animation-delay: 120ms;
}

.dash-card::after {
  content: "";
  position: absolute;
  inset: auto 14px 14px auto;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  opacity: 0.18;
  background: currentColor;
}

.dash-card strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
}

.dash-card.teal {
  color: var(--accent-2);
}

.dash-card.blue {
  color: var(--blue);
}

.dash-card.orange {
  color: var(--accent);
}

.chart-panel {
  grid-column: span 4;
  align-self: start;
}

.activity-panel {
  grid-column: span 4;
}

.donut,
.mini-donut {
  --value: 0;
  --ring: var(--accent);
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--ring) calc(var(--value) * 1%), rgba(148, 163, 184, 0.22) 0);
  position: relative;
}

.donut {
  width: 150px;
  height: 150px;
  animation: ring-pop 520ms ease-out both;
}

.donut::before,
.mini-donut::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: inherit;
  background: var(--panel);
}

.donut span,
.donut small,
.mini-donut span {
  position: relative;
  z-index: 1;
}

.donut span {
  font-size: 30px;
  font-weight: 800;
}

.donut small {
  margin-top: 36px;
  color: var(--muted);
}

.command-rings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.mini-ring {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.mini-donut {
  width: 78px;
  height: 78px;
}

.mini-donut span {
  font-weight: 800;
}

.mini-ring p {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.bar-chart,
.activity-list,
.bucket-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 74px minmax(90px, 1fr) 32px;
  gap: 10px;
  align-items: center;
}

.bar-row span {
  color: var(--muted);
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  transform-origin: left center;
  animation: bar-grow 520ms ease-out both;
}

.activity-item,
.bucket,
.software-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  background: var(--panel-soft);
}

.activity-item {
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
}

.activity-item span,
.activity-item em {
  color: var(--muted);
  font-style: normal;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 14px;
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.metric strong {
  font-size: 26px;
  line-height: 1.15;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
  align-items: end;
}

.form-grid.compact {
  grid-template-columns: minmax(220px, 420px) 150px;
}

.command-grid {
  grid-template-columns: 1.1fr 1.3fr 1fr 120px;
}

.smtp-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.inline-warning {
  margin-top: 12px;
  border: 1px solid #f6c768;
  border-radius: 7px;
  background: rgba(247, 176, 37, 0.12);
  color: var(--ink);
  padding: 10px 12px;
  font-size: 13px;
}

.rule-grid {
  grid-template-columns: minmax(220px, 1.3fr) minmax(160px, 0.7fr) minmax(190px, 1fr) minmax(230px, 1.2fr) minmax(130px, 0.5fr) auto;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
  min-height: 40px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(247, 144, 9, 0.16);
}

.wide {
  grid-column: 1 / -1;
}

.inline-form {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(240px, 420px) auto;
  gap: 12px;
  align-items: end;
}

.toggle-row,
.check-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-content: center;
}

.toggle-row label,
.check-group label,
.toggle-single {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.toggle-row input,
.check-group input,
.toggle-single input {
  width: auto;
  min-height: auto;
}

.check-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: var(--panel-soft);
}

.check-group > span {
  width: 100%;
  color: var(--muted);
  font-weight: 700;
}

.primary {
  background: var(--accent);
  color: #111827;
  font-weight: 700;
  padding: 0 16px;
}

.primary:hover {
  filter: brightness(0.96);
}

.secondary,
.theme-toggle,
.text-button,
.icon-button {
  background: rgba(247, 144, 9, 0.12);
  color: var(--accent);
  padding: 0 13px;
}

.compact-button {
  min-height: 34px;
  padding: 0 11px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.text-button,
.command-link {
  min-height: 30px;
  padding: 0 8px;
  background: transparent;
  color: var(--blue);
  text-align: left;
}

.command-link {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-name-link {
  border: 0;
  background: transparent;
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
  font-weight: 700;
  width: 100%;
  text-align: left;
}

.device-hero-icon {
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: #07111d;
  background: linear-gradient(135deg, #f79009, #2dd4bf);
  font-weight: 900;
}

.hostname-cell {
  text-align: left;
}

.ghost {
  background: transparent;
  color: #d8e0e8;
  border: 1px solid #334454;
}

.theme-toggle {
  border: 1px solid #334454;
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  justify-self: start;
  border-radius: 7px;
}

.login-theme-toggle {
  justify-self: end;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button {
  min-width: 42px;
  font-size: 18px;
}

.table-wrap {
  overflow-x: visible;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  table-layout: fixed;
}

.devices-table {
  min-width: 0;
  table-layout: fixed;
}

.devices-table th,
.devices-table td {
  padding: 10px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.devices-table th:nth-child(1),
.devices-table td:nth-child(1) {
  width: 9%;
}

.devices-table th:nth-child(2),
.devices-table td:nth-child(2) {
  width: 16%;
}

.devices-table th:nth-child(3),
.devices-table td:nth-child(3) {
  width: 12%;
}

.devices-table th:nth-child(4),
.devices-table td:nth-child(4),
.devices-table th:nth-child(5),
.devices-table td:nth-child(5),
.devices-table th:nth-child(6),
.devices-table td:nth-child(6) {
  width: 8%;
}

.devices-table th:nth-child(7),
.devices-table td:nth-child(7) {
  width: 12%;
}

.devices-table th:nth-child(8),
.devices-table td:nth-child(8),
.devices-table th:nth-child(9),
.devices-table td:nth-child(9),
.devices-table th:nth-child(10),
.devices-table td:nth-child(10) {
  width: 9%;
}

.devices-table th:nth-child(11),
.devices-table td:nth-child(11) {
  width: 7%;
  text-align: right;
}

th,
td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: normal;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #fee4e2;
  color: var(--danger);
}

.status.ok {
  background: #dcfae6;
  color: var(--ok);
}

.status.warn {
  background: #fef0c7;
  color: var(--warn);
}

.status.danger {
  background: #fee4e2;
  color: var(--danger);
}

.severity {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #e0f2fe;
  color: #026aa2;
  font-weight: 700;
}

.severity.warning {
  background: #fef0c7;
  color: var(--warn);
}

.severity.high {
  background: #ffead5;
  color: #c4320a;
}

.severity.critical {
  background: #fee4e2;
  color: var(--danger);
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.bucket {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bucket span {
  color: var(--muted);
}

.software-list {
  max-height: 52vh;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 7, 18, 0.58);
  z-index: 20;
}

.modal {
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-head h3 {
  margin: 0;
}

.modal-actions span {
  color: var(--muted);
}

.code-block {
  margin: 0;
  max-height: 52vh;
  overflow: auto;
  padding: 14px;
  border-radius: 8px;
  background: #07111d;
  color: #e6edf5;
  white-space: pre-wrap;
}

.alert {
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff4ed;
  color: var(--danger);
  border: 1px solid #ffd7c2;
}

.alert.ok {
  background: #ecfdf3;
  color: var(--ok);
  border-color: #abefc6;
}

.empty-state {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
}

.device-detail {
  animation: surface-in 180ms ease-out;
}

.device-hero {
  min-height: 178px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
  background:
    linear-gradient(135deg, rgba(247, 144, 9, 0.14), rgba(20, 116, 111, 0.14)),
    var(--panel);
  overflow: hidden;
  position: relative;
}

.device-hero::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -110px;
  width: 260px;
  height: 260px;
  border-radius: 999px;
  border: 36px solid rgba(247, 144, 9, 0.16);
}

.device-hero > * {
  position: relative;
  z-index: 1;
}

.device-hero .text-button {
  grid-column: 1 / -1;
  width: max-content;
}

.device-hero-main {
  display: flex;
  align-items: center;
  gap: 18px;
}

.device-hero-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 10px;
}

.device-hero-actions span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.device-hero-icon {
  width: 74px;
  height: 74px;
}

.device-hero-icon svg,
.info-tile > span svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.device-hero-icon.server {
  background: linear-gradient(135deg, #14746f, #2dd4bf);
}

.device-hero-icon.notebook {
  background: linear-gradient(135deg, #f79009, #fdb022);
}

.device-hero-icon.workstation {
  background: linear-gradient(135deg, #2563eb, #2dd4bf);
}

.device-hero-main span,
.hardware-card span,
.usage-card span,
.info-tile small {
  color: var(--muted);
  font-weight: 700;
}

.device-hero-main h3 {
  margin: 4px 0;
  font-size: 32px;
}

.device-hero-main p,
.hardware-card p,
.usage-card p,
.info-tile p {
  margin: 0;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 14px;
}

.info-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.info-tile > span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(247, 144, 9, 0.14);
  color: var(--accent);
}

.info-tile.tile-ok > span {
  background: #dcfae6;
  color: var(--ok);
}

.info-tile.tile-warn > span {
  background: #fef0c7;
  color: var(--warn);
}

.info-tile.tile-danger > span {
  background: #fee4e2;
  color: var(--danger);
}

.info-tile strong {
  display: block;
  margin: 3px 0;
  font-size: 18px;
}

.owner-tile {
  min-width: 0;
}

.owner-tile > div {
  min-width: 0;
  width: 100%;
}

.owner-tile-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
  margin: 5px 0 4px;
}

.owner-tile-row input {
  min-height: 36px;
  padding: 8px 9px;
}

.save-owner-button {
  width: 38px;
  height: 36px;
  background: var(--accent);
  color: #ffffff;
}

.save-owner-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hardware-layout {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 260px;
  gap: 16px;
}

.hardware-card,
.usage-card {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 8px;
  padding: 16px;
}

.hardware-card strong {
  display: block;
  margin: 8px 0;
  font-size: 22px;
}

.usage-card {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.big-ring {
  --value: 0;
  width: 126px;
  height: 126px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent) calc(var(--value) * 1%), rgba(148, 163, 184, 0.22) 0);
  position: relative;
  animation: ring-pop 520ms ease-out both;
}

.big-ring::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: inherit;
  background: var(--panel-soft);
}

.big-ring strong {
  position: relative;
  z-index: 1;
  font-size: 24px;
}

.detail-table table {
  min-width: 0;
}

.software-grid,
.chip-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.software-box {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.software-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}

.software-row:last-child {
  border-bottom: 0;
}

.app-dot {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.32);
}

.software-chip,
.info-chip,
.soft-count {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: var(--panel-soft);
  color: var(--ink);
}

.software-chip {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes surface-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes dashboard-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes ring-pop {
  from {
    opacity: 0;
    transform: scale(0.88) rotate(-10deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes bar-grow {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

@media (max-width: 1180px) {
  .dash-hero,
  .chart-panel,
  .activity-panel {
    grid-column: span 12;
  }

  .dash-card {
    grid-column: span 4;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .dash-card,
  .dash-hero,
  .chart-panel,
  .activity-panel {
    grid-column: span 12;
  }

  .dash-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-grid,
  .form-grid.compact,
  .command-grid,
  .smtp-grid,
  .rule-grid,
  .inline-form,
  .metric-grid,
  .command-rings,
  .detail-grid,
  .hardware-layout {
    grid-template-columns: 1fr;
  }
}
