:root {
  color-scheme: dark;
  --bg: #17191c;
  --bg-soft: #1d2024;
  --panel: #26292e;
  --panel-strong: #2e3237;
  --panel-hover: #373c42;
  --border: #41464d;
  --border-strong: #5a6068;
  --text: #f3f4f6;
  --muted: #a4a9b0;
  --muted-strong: #c9ccd1;
  --accent: #d6b36a;
  --accent-strong: #e5c477;
  --accent-soft: rgba(214, 179, 106, 0.14);
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.12);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  --radius: 18px;
  --radius-small: 12px;
  --sidebar-width: 270px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 82% 0%, rgba(214, 179, 106, 0.08), transparent 32rem),
    linear-gradient(145deg, #141619 0%, var(--bg) 48%, #1b1e22 100%);
  color: var(--text);
}

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

button,
select {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(214, 179, 106, 0.52);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  letter-spacing: -0.02em;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 2vw, 2rem);
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2vw, 1.85rem);
}

h3 {
  margin-bottom: 0.55rem;
  font-size: 1.05rem;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  left: 1rem;
  top: 1rem;
  padding: 0.7rem 1rem;
  border-radius: 0.6rem;
  background: var(--accent);
  color: #04111b;
  font-weight: 800;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

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

.sidebar {
  position: sticky;
  z-index: 40;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(96, 101, 108, 0.42);
  background: rgba(23, 25, 28, 0.94);
  backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 92px;
  padding: 1.2rem 1.3rem;
  border-bottom: 1px solid rgba(96, 101, 108, 0.34);
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(214, 179, 106, 0.58);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(214, 179, 106, 0.22), rgba(181, 142, 72, 0.06));
  color: var(--accent);
  font-size: 1.45rem;
  font-weight: 900;
  box-shadow: inset 0 0 24px rgba(214, 179, 106, 0.09);
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 1.02rem;
}

.brand span {
  margin-top: 0.16rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.navigation {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.nav-item {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  margin: 0.18rem 0;
  padding: 0.65rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted-strong);
  text-align: left;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
}

.nav-item.is-active {
  border-color: rgba(214, 179, 106, 0.24);
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(147, 168, 189, 0.23);
  border-radius: 9px;
  color: currentColor;
  font-size: 0.8rem;
  font-weight: 900;
}

.nav-badge,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0.16rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-badge {
  border: 1px solid rgba(147, 168, 189, 0.24);
  color: var(--muted);
}

.sidebar-footer {
  padding: 1rem 1.1rem 1.25rem;
  border-top: 1px solid rgba(71, 100, 131, 0.32);
}

.connection-state {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.79rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.1);
}

.connection-state.is-online .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.1);
}

.connection-state.is-offline .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.1);
}

.sidebar-footer .button {
  width: 100%;
  margin-top: 0.8rem;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  min-height: 92px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2.4rem);
  border-bottom: 1px solid rgba(71, 100, 131, 0.28);
  background: rgba(8, 17, 30, 0.8);
  backdrop-filter: blur(18px);
}

.menu-button {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel);
  color: var(--text);
  font-size: 1.1rem;
}

.page-heading {
  min-width: 0;
  flex: 1 1 auto;
}

.cpu-monitor {
  flex: 0 0 auto;
  padding: 0.52rem 0.78rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(164, 169, 176, 0.08);
  color: var(--muted-strong);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
}

.cpu-monitor[data-state="normal"] {
  border-color: rgba(74, 222, 128, 0.42);
  background: rgba(74, 222, 128, 0.1);
  color: var(--success);
}

.cpu-monitor[data-state="elevated"] {
  border-color: rgba(251, 191, 36, 0.46);
  background: rgba(251, 191, 36, 0.1);
  color: var(--warning);
}

.cpu-monitor[data-state="high"] {
  border-color: rgba(251, 113, 133, 0.48);
  background: rgba(251, 113, 133, 0.1);
  color: var(--danger);
}

.cpu-monitor[data-state="unavailable"] {
  border-color: rgba(164, 169, 176, 0.36);
  background: rgba(164, 169, 176, 0.08);
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 0.28rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.session-chip {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.52rem 0.72rem;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(16, 28, 45, 0.72);
}

.session-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 900;
}

.session-chip strong,
.session-chip span {
  display: block;
}

.session-chip strong {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
}

.session-chip span {
  margin-top: 0.08rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.main-content {
  width: min(100%, 1680px);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2.5rem);
}

.auth-panel {
  min-height: calc(100vh - 150px);
  display: grid;
  place-items: center;
}

.loading-panel {
  width: fit-content;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted-strong);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.18);
}

.loading-panel p {
  margin: 0;
}

.spinner {
  width: 20px;
  height: 20px;
  margin: 0;
  border: 3px solid rgba(214, 179, 106, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.auth-card {
  width: min(100%, 620px);
  padding: clamp(1.4rem, 4vw, 2.6rem);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(150deg, rgba(46, 50, 55, 0.98), rgba(32, 35, 39, 0.98));
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-card > p:not(.eyebrow) {
  max-width: 510px;
  margin: 1rem auto 1.5rem;
  color: var(--muted-strong);
  line-height: 1.65;
}

.auth-symbol {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  margin: 0 auto 1.2rem;
  border: 1px solid rgba(214, 179, 106, 0.48);
  border-radius: 22px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 2rem;
  font-weight: 900;
}

.auth-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.security-note {
  display: grid;
  gap: 0.24rem;
  margin-top: 1.4rem;
  padding: 1rem;
  border: 1px solid rgba(214, 179, 106, 0.18);
  border-radius: 13px;
  background: rgba(214, 179, 106, 0.06);
  text-align: left;
}

.security-note strong {
  color: var(--accent);
  font-size: 0.82rem;
}

.security-note span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.view {
  animation: view-in 170ms ease;
}

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

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem;
}

.nav-counter {
  min-width: 1.5rem;
  margin-left: auto;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.14);
  color: var(--warning);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.button,
.icon-button,
.text-link {
  border: 0;
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.62rem 0.92rem;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 750;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:not(:disabled):active {
  transform: translateY(1px);
}

.button-primary {
  border-color: rgba(214, 179, 106, 0.35);
  background: linear-gradient(145deg, var(--accent), #41c2f5);
  color: #03131e;
}

.button-primary:hover:not(:disabled) {
  background: #9be4ff;
}

.button-secondary {
  border-color: var(--border);
  background: var(--panel);
  color: var(--text);
}

.button-secondary:hover:not(:disabled),
.button-ghost:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--panel-hover);
}

.button-danger {
  border-color: rgba(251, 113, 133, 0.38);
  background: rgba(251, 113, 133, 0.16);
  color: #ffd6dc;
}

.button-danger:hover:not(:disabled) {
  background: rgba(251, 113, 133, 0.24);
}

.button-ghost {
  border-color: rgba(147, 168, 189, 0.18);
  background: transparent;
  color: var(--muted-strong);
}

.button-small {
  min-height: 34px;
  padding: 0.45rem 0.72rem;
  font-size: 0.8rem;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 1.35rem;
}

.text-link {
  padding: 0;
  background: none;
  color: var(--accent);
  font-weight: 750;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.metric-card,
.panel-card,
.table-card,
.module-banner,
.info-strip,
.process-step {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(150deg, rgba(18, 32, 50, 0.96), rgba(13, 24, 39, 0.96));
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.12);
}

.metric-card {
  min-height: 132px;
  padding: 1.1rem;
}

.metric-card span,
.metric-card small,
.metric-card strong {
  display: block;
}

.metric-card span {
  color: var(--muted-strong);
  font-size: 0.8rem;
}

.metric-card strong {
  margin: 0.55rem 0 0.2rem;
  color: var(--text);
  font-size: clamp(1.75rem, 3vw, 2.35rem);
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
  font-size: 0.72rem;
}

.metric-card.is-warning {
  border-color: rgba(251, 191, 36, 0.34);
}

.metric-card.is-danger {
  border-color: rgba(251, 113, 133, 0.34);
}

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

.panel-card {
  padding: 1.2rem;
}

.panel-card > p:not(.eyebrow),
.module-banner p,
.process-step p {
  color: var(--muted-strong);
  line-height: 1.62;
}

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

.badge-warning {
  background: rgba(251, 191, 36, 0.12);
  color: var(--warning);
}

.badge-plan {
  border: 1px solid rgba(214, 179, 106, 0.2);
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-beta {
  border: 1px solid rgba(96, 165, 250, 0.26);
  background: rgba(96, 165, 250, 0.13);
  color: #60a5fa;
}

.badge-success {
  background: rgba(74, 222, 128, 0.12);
  color: var(--success);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.attention-list {
  display: grid;
  gap: 0.7rem;
}

.attention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.78rem 0;
  border-bottom: 1px solid rgba(71, 100, 131, 0.25);
}

.attention-item:last-child {
  border-bottom: 0;
}

.attention-item span {
  color: var(--muted-strong);
  font-size: 0.84rem;
}

.attention-item strong {
  color: var(--text);
}

.future-card {
  background:
    linear-gradient(145deg, rgba(214, 179, 106, 0.08), rgba(16, 28, 45, 0.95)),
    var(--panel);
}

.toolbar,
.filter-grid {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(11, 23, 38, 0.86);
}

.toolbar {
  grid-template-columns: minmax(170px, 0.35fr) minmax(240px, 1fr) auto;
  align-items: end;
}

.filter-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  align-items: end;
}

.field {
  display: grid;
  gap: 0.38rem;
}

.field > span {
  color: var(--muted-strong);
  font-size: 0.75rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.65rem 0.72rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0a1625;
  color: var(--text);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #62788e;
}

.filter-button {
  align-self: end;
}

.table-card {
  overflow: hidden;
}

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

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

th,
td {
  padding: 0.86rem 1rem;
  border-bottom: 1px solid rgba(71, 100, 131, 0.26);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  color: var(--muted-strong);
}

tbody tr:hover:not(.empty-row) {
  background: rgba(214, 179, 106, 0.035);
}

td strong,
.code-value {
  color: var(--text);
}

.code-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

.empty-row td {
  padding: 2rem 1rem;
  color: var(--muted);
  text-align: center;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.table-footer,
.list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.info-strip {
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border-color: rgba(214, 179, 106, 0.18);
  color: var(--muted-strong);
  font-size: 0.84rem;
  line-height: 1.55;
}

.cards-list,
.timeline {
  display: grid;
  gap: 0.8rem;
}

.rotation-card,
.timeline-item {
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(16, 28, 45, 0.88);
}

.rotation-card {
  padding: 1rem;
}

.rotation-header,
.rotation-actions,
.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

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

.rotation-meta {
  margin: 1rem 0;
}

.meta-item span,
.meta-item strong {
  display: block;
}

.meta-item span {
  color: var(--muted);
  font-size: 0.69rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.meta-item strong {
  margin-top: 0.22rem;
  overflow-wrap: anywhere;
  color: var(--muted-strong);
  font-size: 0.8rem;
}

.timeline-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 0.85rem;
  padding: 1rem;
}

.timeline-marker {
  width: 10px;
  height: 10px;
  margin-top: 0.3rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(214, 179, 106, 0.1);
}

.timeline-marker.is-warn { background: var(--warning); }
.timeline-marker.is-error { background: var(--danger); }
.timeline-marker.is-security { background: #c084fc; }

.timeline-header strong {
  overflow-wrap: anywhere;
  font-size: 0.85rem;
}

.timeline-header time {
  color: var(--muted);
  font-size: 0.72rem;
}

.timeline-item p {
  margin: 0.5rem 0 0;
  color: var(--muted-strong);
  line-height: 1.5;
  font-size: 0.82rem;
}

.module-banner {
  margin-bottom: 1rem;
  padding: clamp(1.2rem, 3vw, 2rem);
  background:
    radial-gradient(circle at 100% 0%, rgba(214, 179, 106, 0.13), transparent 24rem),
    linear-gradient(145deg, rgba(20, 36, 58, 0.98), rgba(11, 23, 38, 0.98));
}

.module-banner h3 {
  margin-top: 1rem;
  font-size: clamp(1.25rem, 2vw, 1.7rem);
}

.module-banner p {
  max-width: 880px;
  margin-bottom: 0;
}

.compact-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.preview-table {
  margin-bottom: 1rem;
}

.feature-list {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.feature-list li {
  position: relative;
  padding-left: 1.15rem;
  color: var(--muted-strong);
  font-size: 0.84rem;
}

.feature-list li::before {
  position: absolute;
  left: 0;
  color: var(--accent);
  content: "•";
}

.process-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.process-step {
  padding: 1.2rem;
}

.process-step > span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  margin-bottom: 1rem;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 900;
}

.planned-empty {
  text-align: center;
}

.planned-empty p {
  margin-bottom: 0;
}

.backup-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.details-drawer {
  position: fixed;
  z-index: 80;
  top: 0;
  right: 0;
  width: min(520px, 94vw);
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-strong);
  background: #0b1726;
  box-shadow: -24px 0 70px rgba(0, 0, 0, 0.36);
  transform: translateX(104%);
  transition: transform 180ms ease;
}

.details-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.drawer-content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.25rem;
}

.drawer-section {
  margin-bottom: 1.2rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid rgba(71, 100, 131, 0.26);
}

.drawer-section:last-child {
  border-bottom: 0;
}

.drawer-section h3 {
  margin-bottom: 0.8rem;
}

.drawer-backdrop {
  position: fixed;
  z-index: 70;
  inset: 0;
  background: rgba(0, 0, 0, 0.54);
  backdrop-filter: blur(3px);
}

.modal {
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: #0d1a2a;
  color: var(--text);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.64);
  backdrop-filter: blur(4px);
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
}

.modal-header {
  border-bottom: 1px solid var(--border);
}

.modal-content {
  max-height: 62vh;
  overflow-y: auto;
  padding: 1.2rem;
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}

.license-create-modal {
  width: min(680px, calc(100vw - 2rem));
}

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

.license-create-fields .field:last-child,
.license-expiry-field {
  grid-column: 1 / -1;
}

.license-expiry-field small {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.license-create-result .card-heading {
  align-items: center;
}

.license-code-list {
  display: grid;
  gap: 0.55rem;
}

.license-code-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.72rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(8, 20, 33, 0.72);
}

.license-code-row code {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
}

.warning-box,
.error-box {
  margin-bottom: 1rem;
  padding: 0.85rem;
  border-radius: 11px;
  line-height: 1.5;
  font-size: 0.82rem;
}

.warning-box {
  border: 1px solid rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.08);
  color: #f9d77e;
}

.error-box {
  border: 1px solid rgba(251, 113, 133, 0.28);
  background: rgba(251, 113, 133, 0.08);
  color: #ffc0ca;
}

.toast-region {
  position: fixed;
  z-index: 120;
  right: 1rem;
  bottom: 1rem;
  width: min(390px, calc(100vw - 2rem));
  display: grid;
  gap: 0.65rem;
}

.toast {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: #132337;
  color: var(--text);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.3);
  font-size: 0.84rem;
  animation: toast-in 180ms ease;
}

.toast.is-error {
  border-color: rgba(251, 113, 133, 0.44);
}

.toast.is-success {
  border-color: rgba(74, 222, 128, 0.4);
}

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

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

.no-data {
  padding: 1.5rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .topbar {
    flex-wrap: wrap;
  }

  .cpu-monitor {
    order: 3;
    flex: 1 0 100%;
  }

  .metric-grid,
  .compact-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .sidebar {
    position: fixed;
    left: 0;
    width: min(var(--sidebar-width), 88vw);
    transform: translateX(-104%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .menu-button {
    display: grid;
    place-items: center;
  }

  .dashboard-grid,
  .form-preview-grid,
  .backup-grid,
  .process-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .topbar {
    min-height: 76px;
    padding: 0.75rem 0.8rem;
  }

  .session-chip {
    max-width: 150px;
  }

  .session-chip strong {
    max-width: 88px;
  }

  .main-content {
    padding: 1rem 0.8rem 2rem;
  }

  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .section-header > .button {
    width: 100%;
  }

  .section-actions,
  .section-actions .button {
    width: 100%;
  }

  .license-create-fields {
    grid-template-columns: 1fr;
  }

  .license-code-row {
    grid-template-columns: 1fr;
  }

  .metric-grid,
  .compact-metrics,
  .toolbar,
  .filter-grid,
  .rotation-meta,
  .details-grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 0.72rem 0.78rem;
  }

  .auth-actions {
    display: grid;
  }

  .auth-actions .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* G4 - logowanie, Passkey i odzyskiwanie */
.auth-card-wide {
  width: min(100%, 760px);
  text-align: left;
}

.auth-card-wide .auth-symbol,
.auth-card-wide > .eyebrow,
.auth-card-wide > h2,
.auth-card-wide > #auth-message {
  text-align: center;
}

.auth-form {
  display: grid;
  gap: 0.9rem;
  margin-top: 1.25rem;
}

.auth-form .auth-actions {
  justify-content: flex-start;
}

.totp-setup {
  display: grid;
  gap: 0.7rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: rgba(18, 20, 23, 0.56);
}

.totp-setup p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.totp-setup code,
.recovery-codes code {
  display: block;
  overflow-wrap: anywhere;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.08em;
}

.recovery-card {
  margin-top: 1.3rem;
  padding: 1.2rem;
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: var(--radius);
  background: rgba(251, 191, 36, 0.075);
}

.recovery-card p {
  color: var(--muted-strong);
  line-height: 1.55;
}

.recovery-codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem 1.5rem;
  padding-left: 1.6rem;
  margin: 1rem 0 1.3rem;
}

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

.security-grid .panel-card {
  padding: 1.2rem;
}

.security-grid .button + .button,
.security-grid form + .button {
  margin-top: 0.8rem;
}

@media (max-width: 800px) {
  .security-grid,
  .recovery-codes {
    grid-template-columns: 1fr;
  }

  .beta-request-layout,
  .beta-request-license-row {
    grid-template-columns: 1fr;
  }
}

/* J4 — zapytania o licencję */
.toolbar-card {
  display: grid;
  grid-template-columns: minmax(190px, 0.38fr) minmax(260px, 1fr);
  align-items: end;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(11, 23, 38, 0.86);
}

.toolbar-summary {
  display: grid;
  justify-items: end;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: right;
}

.toolbar-summary strong {
  color: var(--text);
  font-size: 0.9rem;
}

.beta-requests-toolbar {
  grid-template-columns: minmax(220px, auto) minmax(260px, 1fr);
}

.segmented-control {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.segmented-control .button.is-active {
  border-color: rgba(214, 179, 106, 0.35);
  background: var(--accent-soft);
  color: var(--accent);
}

.field-hint {
  margin: -0.2rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.field-hint code {
  color: var(--accent);
}

.license-request-settings-grid {
  margin-top: 1rem;
}

.numbered-list {
  counter-reset: license-steps;
}

.numbered-list li {
  min-height: 1.8rem;
  padding-left: 2rem;
}

.numbered-list li::before {
  counter-increment: license-steps;
  width: 1.35rem;
  height: 1.35rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  content: counter(license-steps);
  font-size: 0.7rem;
  font-weight: 800;
}

.license-message-list {
  display: grid;
  gap: 0.75rem;
}

.support-row-unread {
  background: rgba(251, 191, 36, 0.055);
}

.support-row-unread td:first-child {
  border-left: 3px solid var(--warning);
}

.support-ticket-message {
  max-width: 260px;
  white-space: pre-wrap;
}

.beta-request-card {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.beta-request-card.is-history {
  opacity: 0.9;
}

.beta-request-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.beta-request-title {
  display: grid;
  gap: 0.35rem;
}

.beta-request-title h3 {
  margin: 0;
}

.beta-request-code {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.device-label-editor {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.device-label-current {
  color: var(--text);
  font-weight: 700;
}

.device-label-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.device-label-controls input {
  width: min(100%, 18rem);
  min-height: 38px;
  padding: 0.55rem 0.68rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0a1625;
  color: var(--text);
}

.beta-request-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
}

.beta-request-form {
  display: grid;
  gap: 0.9rem;
}

.beta-request-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.beta-request-note {
  min-height: 88px;
}

.beta-request-license-row {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: minmax(170px, 0.5fr) minmax(0, 1fr);
}

.beta-request-meta {
  display: grid;
  gap: 0.85rem;
}

.beta-request-status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.license-message {
  padding: 0.85rem;
  border: 1px solid rgba(71, 100, 131, 0.35);
  border-radius: 12px;
  background: rgba(8, 20, 33, 0.7);
}

.license-message.is-admin {
  border-color: rgba(214, 179, 106, 0.34);
  background: rgba(214, 179, 106, 0.06);
}

.license-message.is-system {
  border-style: dashed;
}

.license-message-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.license-message-body {
  margin: 0;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
}

.support-message-read {
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.support-controls,
.support-compose-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.8rem;
}

.support-admin-compose {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(71, 100, 131, 0.26);
}

.support-compose-footer span {
  color: var(--muted);
  font-size: 0.76rem;
}

.license-request-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

@media (max-width: 760px) {
  .toolbar-card {
    grid-template-columns: 1fr;
  }

  .toolbar-summary {
    justify-items: start;
    text-align: left;
  }

  .nav-counter {
    margin-left: 0;
  }
}


/* Pełnoekranowa karta urządzenia — grafitowy, czytelny motyw */
:root {
  --bg: #191b1f;
  --bg-soft: #202329;
  --panel: #2a2e34;
  --panel-strong: #343941;
  --panel-hover: #3d434c;
  --border: #505761;
  --border-strong: #69717d;
  --text: #ffffff;
  --muted: #d0d4da;
  --muted-strong: #eef0f3;
}
body {
  background: linear-gradient(145deg, #16181b 0%, #1b1e22 48%, #202329 100%);
}
.panel-card, .metric-card, .table-card, .toolbar-card, .module-banner, .drawer-section, .device-workspace-section {
  background: var(--panel);
  color: var(--text);
}
.device-code-link {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,.35);
  text-underline-offset: .2rem;
  cursor: pointer;
}
.device-code-link:hover { color: var(--accent-strong); }
.device-workspace-view { width: 100%; }
.device-workspace-toolbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  margin: -1rem -1rem 1.25rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(25, 27, 31, .96);
  backdrop-filter: blur(16px);
}
.device-workspace-toolbar h2 { margin: 0; color: #fff; }
.device-workspace-subtitle { margin: .25rem 0 0; color: var(--muted); }
.device-workspace-content { display: grid; gap: 1rem; }
.device-workspace-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: start;
  padding: 1.25rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel-strong);
}
.device-workspace-hero h3 { margin-bottom: .3rem; font-size: 1.35rem; color: #fff; }
.device-workspace-actions { display: flex; flex-wrap: wrap; gap: .65rem; justify-content: flex-end; }
.device-workspace-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.device-workspace-section {
  padding: 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.device-workspace-section.is-full { grid-column: 1 / -1; }
.device-workspace-section h3 { color: #fff; }
.device-record-list { display: grid; gap: .75rem; }
.device-record {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: #30343b;
}
.device-record-head { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; }
.device-record-head h4 { margin: 0 0 .2rem; color: #fff; }
.device-record p { color: var(--muted); }
.device-record-actions { display: flex; gap: .55rem; flex-wrap: wrap; margin-top: .75rem; }
.device-conversation { display: grid; gap: .75rem; }
.device-message {
  max-width: 88%;
  padding: .9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #30343b;
}
.device-message.is-admin { margin-left: auto; background: #393d44; }
.device-message.is-system { max-width: 100%; background: #24272c; }
.device-message-head { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .82rem; }
.device-message-body { margin: .5rem 0 0; white-space: pre-wrap; color: #fff; }
.device-message-read { margin-top: .45rem; color: var(--muted); font-size: .78rem; }
.device-audit-list { display: grid; gap: .65rem; }
.device-audit-item { padding: .8rem 0; border-bottom: 1px solid var(--border); }
.device-audit-item:last-child { border-bottom: 0; }
.device-workspace-detail {
  margin-top: 1rem;
  padding: 1.2rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #24272c;
}
.device-workspace-detail .drawer-section { margin-bottom: 1rem; }
.device-workspace-loading { padding: 2rem; text-align: center; color: var(--muted); }
@media (max-width: 900px) {
  .device-workspace-grid { grid-template-columns: 1fr; }
  .device-workspace-section.is-full { grid-column: auto; }
  .device-workspace-toolbar { grid-template-columns: 1fr; position: static; margin: 0 0 1rem; }
  .device-workspace-hero { grid-template-columns: 1fr; }
  .device-workspace-actions { justify-content: flex-start; }
}


/* =========================================================
   PANEL ZORIENTOWANY NA URZĄDZENIE — WERSJA PEŁNOEKRANOWA
   ========================================================= */
:root {
  --page-bg: #1d1f23;
  --panel-bg: #2a2d32;
  --panel-bg-strong: #30343a;
  --panel-border: #474c54;
  --text-main: #ffffff;
  --text-soft: #e5e7eb;
  --text-muted-readable: #c4c8cf;
}

html, body {
  background: var(--page-bg);
  color: var(--text-main);
}

.main-content {
  max-width: none;
  width: 100%;
}

.navigation-label {
  display: block;
  margin: 1rem .85rem .35rem;
  color: #bfc4cc;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.details-drawer,
.drawer-backdrop,
#details-drawer,
#drawer-backdrop {
  display: none !important;
}

.device-workspace-view {
  width: 100%;
  max-width: none;
}

.device-workspace-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  margin: -1rem -1rem 0;
  padding: 1rem 1.25rem;
  background: #24272c;
  border-bottom: 1px solid var(--panel-border);
}

.device-workspace-content {
  display: block;
  margin-top: 1rem;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: var(--panel-bg);
}

.device-workspace-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 24rem) auto;
  gap: 1rem;
  align-items: center;
  margin: 0;
  padding: 1.35rem 1.5rem;
  background: var(--panel-bg-strong);
  border: 0;
  border-bottom: 1px solid var(--panel-border);
  border-radius: 0;
}

.device-workspace-hero-main {
  min-width: 0;
}

.device-license-card {
  display: grid;
  gap: .3rem;
  width: 100%;
  min-height: 8.5rem;
  padding: 1rem;
  text-align: left;
  color: var(--text-main);
  background: #34383e;
  border: 1px solid #4d535c;
  border-radius: var(--radius-small);
  cursor: pointer;
}

.device-license-card:hover {
  border-color: var(--accent);
}

.device-license-card strong {
  color: #fff;
  font-size: 1.05rem;
}

.device-license-card span,
.device-license-card small {
  color: var(--text-muted-readable);
}

.device-workspace-grid {
  display: block;
}

.device-workspace-section,
.device-workspace-section.is-full {
  display: block;
  width: 100%;
  margin: 0;
  padding: 1.4rem 1.5rem;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--panel-border);
  border-radius: 0;
  box-shadow: none;
}

.device-workspace-section:last-child {
  border-bottom: 0;
}

.device-workspace-section > h3 {
  margin: 0 0 1rem;
  color: var(--text-main);
  font-size: 1.08rem;
}

.device-workspace-section .details-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.device-record,
.device-message,
.device-audit-item,
.meta-item {
  background: #34383e;
  border-color: #4d535c;
  color: var(--text-main);
}

.device-record p,
.device-message-body,
.device-message-read,
.device-audit-item p,
.meta-item span,
.muted,
small,
.field-hint {
  color: var(--text-muted-readable) !important;
}

.device-workspace-detail {
  width: 100%;
  margin: 1rem 0 0;
  padding: 1.5rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
}

.device-code-link {
  color: #ffffff;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: .18em;
}

.device-code-link:hover,
.device-code-link:focus-visible {
  color: #ffffff;
  background: #4a4f57;
}

.panel-card,
.metric-card,
.table-card,
.toolbar-card,
.module-banner {
  background: #2b2e33;
  border-color: #454a52;
}

body, button, input, select, textarea, table {
  color: var(--text-main);
}

p, td, th, label, span {
  text-shadow: none;
}

@media (max-width: 1100px) {
  .device-workspace-hero {
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem);
  }

  .device-workspace-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .device-workspace-section .details-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .device-workspace-toolbar,
  .device-workspace-hero {
    grid-template-columns: 1fr;
  }

  .device-workspace-section .details-grid {
    grid-template-columns: 1fr;
  }

  .device-workspace-actions {
    justify-content: flex-start;
  }
}
