:root {
  --body-bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #111827;
  --muted: #64748b;
  --border: #dbe3ef;
  --brand: #146c94;
  --brand-dark: #0f3f5b;
  --accent: #22a699;
  --danger: #dc3545;
  --warning: #f0ad4e;
  --shadow-sm: 0 8px 22px rgba(15, 23, 42, .07);
  --shadow-md: 0 18px 46px rgba(15, 23, 42, .12);
  --sidebar-width: 284px;
}

[data-theme="dark"] {
  --body-bg: #0f141a;
  --surface: #151c24;
  --surface-soft: #101820;
  --ink: #edf2f7;
  --muted: #94a3b8;
  --border: #243244;
  --shadow-sm: 0 8px 22px rgba(0, 0, 0, .22);
  --shadow-md: 0 18px 46px rgba(0, 0, 0, .32);
}

* {
  letter-spacing: 0;
}

body {
  background: var(--body-bg);
  color: var(--ink);
  font-size: .95rem;
}

[data-theme="dark"] .text-muted {
  color: var(--muted) !important;
}

[data-theme="dark"] .app-sidebar {
  background: #0b1016;
}

[data-theme="dark"] .topbar {
  background: rgba(21, 28, 36, .9);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .input-group-text {
  background-color: #111821;
  color: var(--ink);
  border-color: var(--border);
}

[data-theme="dark"] .form-control::placeholder {
  color: #64748b;
}

[data-theme="dark"] .table-hover tbody tr:hover {
  background: #111821;
}

[data-theme="dark"] .modal-content {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}

a {
  text-decoration: none;
}

.app-body {
  min-height: 100vh;
}

.app-shell {
  min-height: 100vh;
  display: flex;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: #101820;
  color: #e5eef7;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  box-shadow: var(--shadow-md);
}

.brand-block {
  padding: 1.15rem;
  border-bottom: 1px solid rgba(255,255,255,.09);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: .85rem;
  color: #fff;
}

.brand-mark:hover {
  color: #fff;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1f8a70;
  color: #fff;
  box-shadow: 0 10px 24px rgba(31, 138, 112, .25);
  flex: 0 0 auto;
}

.brand-title {
  display: block;
  font-weight: 800;
  line-height: 1.1;
}

.brand-subtitle {
  display: block;
  color: #9fb3c8;
  font-size: .78rem;
  margin-top: .18rem;
}

.sidebar-nav {
  padding: .75rem;
  overflow-y: auto;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  color: #b8c7d8;
  padding: .78rem .9rem;
  border-radius: 8px;
  margin-bottom: .2rem;
  transition: background-color .15s ease, color .15s ease, transform .15s ease;
}

.sidebar-link i {
  width: 1.25rem;
  text-align: center;
}

.sidebar-link:hover,
.sidebar-link.active {
  color: #fff;
  background: rgba(255,255,255,.105);
}

.sidebar-link.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.09);
  padding: 1rem;
}

.mini-label,
.topbar-kicker {
  text-transform: uppercase;
  font-size: .68rem;
  font-weight: 700;
  color: var(--muted);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: .7rem;
  min-width: 0;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e6f5f3;
  color: #0f766e;
  font-weight: 800;
  flex: 0 0 auto;
}

.app-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  min-height: 72px;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1.35rem;
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 800;
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding: 1rem 0 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .82rem;
}

.app-footer a {
  color: var(--brand);
  font-weight: 700;
}

[data-theme="dark"] .app-footer a {
  color: #43c6b8;
}

.login-footer-credit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: rgba(255,255,255,.58);
  font-size: .82rem;
}

.login-footer-credit a {
  color: #43c6b8;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .65rem;
}

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

.secure-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border: 1px solid #bee3dc;
  background: #edfdfa;
  color: #0f766e;
  padding: .38rem .65rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.content-wrap {
  padding: 1.35rem;
}

.page-hero {
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(20, 108, 148, .96), rgba(31, 138, 112, .92)),
    #146c94;
  color: #fff;
  box-shadow: var(--shadow-md);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.page-hero .text-muted,
.page-hero .mini-label {
  color: rgba(255,255,255,.72) !important;
}

.hero-actions {
  display: flex;
  gap: .65rem;
  flex-wrap: wrap;
}

.hero-actions .btn {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-color: rgba(255,255,255,.25);
}

.hero-actions .btn:hover {
  background: #fff;
  color: var(--brand-dark);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .75rem;
}

.panel-title h2,
.panel-title h1 {
  margin: 0;
}

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

.page-heading h1 {
  margin: 0;
  font-weight: 850;
}

.page-heading p {
  margin: .25rem 0 0;
  color: var(--muted);
}

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-soft);
  color: var(--brand);
}

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

.metric-card {
  transition: transform .15s ease, box-shadow .15s ease;
}

.metric-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.metric-value {
  font-size: 1.7rem;
  font-weight: 850;
  line-height: 1.1;
}

.table-responsive {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.table-hover tbody tr:hover {
  background: #f8fbfd;
}

.table {
  --bs-table-bg: transparent;
}

.table thead th {
  background: var(--surface-soft);
  color: #475569;
  font-size: .75rem;
  text-transform: uppercase;
  font-weight: 800;
  border-bottom-color: var(--border);
  white-space: nowrap;
}

.table td,
.table th {
  vertical-align: middle;
  padding: .9rem;
}

.form-control,
.form-select {
  border-color: var(--border);
  border-radius: 8px;
  min-height: 42px;
}

.input-group-text {
  border-color: var(--border);
  background: var(--surface-soft);
}

.input-group .form-control {
  min-width: 0;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem rgba(20, 108, 148, .14);
}

.btn {
  border-radius: 8px;
  font-weight: 700;
}

.btn-primary {
  --bs-btn-bg: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-dark);
  --bs-btn-hover-border-color: var(--brand-dark);
}

.btn-outline-dark {
  --bs-btn-color: #1f2937;
  --bs-btn-border-color: var(--border);
  --bs-btn-hover-bg: #101820;
  --bs-btn-hover-border-color: #101820;
}

.badge {
  border-radius: 999px;
  padding: .45rem .62rem;
}

.status-pill,
.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  border-radius: 999px;
  padding: .38rem .62rem;
  font-size: .76rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill span {
  width: .48rem;
  height: .48rem;
  border-radius: 50%;
  display: inline-block;
}

.status-pill.good { background: #e8f7ef; color: #146c43; }
.status-pill.good span { background: #198754; }
.status-pill.warn { background: #fff7e6; color: #946200; }
.status-pill.warn span { background: #f0ad4e; }
.status-pill.bad { background: #fdecef; color: #b02a37; }
.status-pill.bad span { background: #dc3545; }
.status-pill.off { background: #eef2f7; color: #475569; }
.status-pill.off span { background: #94a3b8; }
.status-pill.info { background: #e8f4ff; color: #0b5ed7; }
.status-pill.info span { background: #0d6efd; }

.risk-badge {
  background: #eef2f7;
  color: #334155;
}

.risk-badge.risk-low { background: #e8f7ef; color: #146c43; }
.risk-badge.risk-medium { background: #fff7e6; color: #946200; }
.risk-badge.risk-high { background: #fff0e6; color: #b45309; }
.risk-badge.risk-critical { background: #fdecef; color: #b02a37; }

.filter-bar {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: .9rem;
  margin-bottom: 1rem;
}

.live-status-toolbar {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: .85rem 1rem;
}

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

.section-card-header {
  padding: 1rem 1rem .75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.section-card-body {
  padding: 1rem;
}

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

.empty-state i {
  font-size: 2.1rem;
  color: var(--brand);
  display: block;
  margin-bottom: .75rem;
}

.empty-state p {
  max-width: 420px;
  margin: .25rem auto 0;
}

.info-list {
  display: grid;
  gap: .65rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid #edf1f7;
  padding-bottom: .65rem;
}

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

.info-row span:first-child {
  color: var(--muted);
}

.code-chip {
  display: inline-block;
  background: #101418;
  color: #dbeafe;
  border-radius: 8px;
  padding: .38rem .55rem;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.public-key-snippet {
  display: inline-block;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.assigned-server-list {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  max-width: 420px;
}

.assigned-server-chip {
  display: inline-grid;
  gap: .08rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: .42rem .55rem;
  min-width: 150px;
}

.assigned-server-chip span:nth-child(2),
.assigned-server-chip span:nth-child(3) {
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.15;
}

.assigned-server-chip:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
}

.custom-command-permission {
  align-items: flex-start;
  border: 1px solid #f1b6bd;
  border-radius: 8px;
  background: #fff5f6;
  color: #842029;
  display: flex;
  gap: .55rem;
  padding: .65rem .75rem;
}

[data-theme="dark"] .custom-command-permission {
  background: #2a1116;
  border-color: #842029;
}

.copy-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1080;
}

.premium-tabs {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .35rem;
  box-shadow: var(--shadow-sm);
}

.premium-tabs .nav-link {
  border-radius: 8px;
  color: #475569;
  font-weight: 800;
}

.premium-tabs .nav-link.active {
  background: #101820;
  color: #fff;
}

.sticky-save-bar {
  position: sticky;
  bottom: 1rem;
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
  pointer-events: none;
}

.sticky-save-bar .btn {
  pointer-events: auto;
  box-shadow: var(--shadow-md);
}

.modal-content {
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.modal-header,
.modal-footer {
  border-color: var(--border);
}

.soft-alert {
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .75rem;
}

.action-grid .btn {
  min-height: 78px;
  padding: .85rem;
}

.action-grid .btn:hover .risk-badge {
  background: rgba(255,255,255,.18);
  color: #fff;
}

pre.command-output {
  max-height: 360px;
  overflow: auto;
  background: #101418;
  color: #e9eef5;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid #202a34;
}

pre.command-output.is-error {
  background: #2a1116;
  color: #ffdce2;
  border-color: #842029;
}

pre.command-output.is-success {
  background: #0f241b;
  color: #d6f5e3;
  border-color: #146c43;
}

.risk-critical { border-left: 4px solid var(--danger); }
.risk-high { border-left: 4px solid #fd7e14; }
.risk-medium { border-left: 4px solid var(--warning); }
.risk-low { border-left: 4px solid #198754; }

.login-body {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(16, 24, 32, .94), rgba(20, 108, 148, .88)),
    url("https://images.unsplash.com/photo-1558494949-ef010cbdcc31?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 460px;
}

.login-copy {
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem;
}

.login-copy h1 {
  font-size: 4rem;
  font-weight: 850;
  max-width: 760px;
  line-height: 1;
}

.login-copy p {
  color: #d9e6ef;
  max-width: 620px;
  font-size: 1.05rem;
}

.login-panel-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(18px);
}

.login-card {
  width: 100%;
  max-width: 420px;
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 8px;
  background: rgba(255,255,255,.95);
  box-shadow: var(--shadow-md);
}

.login-logo {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e6f5f3;
  color: #0f766e;
  font-size: 1.35rem;
}

.login-feature {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  padding: .5rem .75rem;
  border-radius: 999px;
  margin: .25rem .25rem .25rem 0;
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
  }

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

  body.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .46);
    z-index: 1030;
  }

  .app-main {
    margin-left: 0;
  }

  .topbar {
    padding: .75rem 1rem;
  }

  .topbar-actions .secure-pill {
    display: none;
  }

  .content-wrap {
    padding: 1rem;
  }

  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-copy {
    display: none;
  }

  .login-panel-wrap {
    min-height: 100vh;
  }
}

@media (max-width: 1199.98px) {
  .login-copy h1 {
    font-size: 3rem;
  }
}

@media (max-width: 575.98px) {
  .topbar-title {
    font-size: .92rem;
  }

  .table td,
  .table th {
    padding: .75rem;
  }

  .metric-value {
    font-size: 1.35rem;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .live-status-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-actions {
    width: 100%;
  }

  .hero-actions .btn {
    flex: 1 1 auto;
  }
}
