@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&family=JetBrains+Mono:wght@400;600&display=swap");

html {
  scrollbar-gutter: stable;
}

:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #dbe3ef;
  --accent: #4c66c6;
  --accent-2: #3f57ac;
  --sidebar: #0f172a;
  --sidebar-2: #111c33;
  --sidebar-text: #c7d2fe;
  --sidebar-active: #1e293b;
  --ok: #059669;
  --warn: #dc2626;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "DM Sans", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
  color: var(--ink);
  overflow-x: hidden;
}

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

.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text);
  padding: 1.2rem 0.9rem;
  border-right: 1px solid #1f2a44;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  padding: 0.45rem 0.4rem 0.85rem;
  border-bottom: 1px solid #263352;
}

.logo-chip {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.brand-title {
  margin: 0;
  color: #e2e8f0;
  font-weight: 700;
}

.brand-sub {
  margin: 0.1rem 0 0;
  color: #93a4c3;
  font-size: 0.85rem;
}

.status-pill {
  width: fit-content;
  border-radius: 999px;
  padding: 0.3rem 0.72rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-pill.is-offline {
  background: rgba(220, 38, 38, 0.2);
  color: #fecaca;
}

.status-pill.is-online {
  background: rgba(5, 150, 105, 0.2);
  color: #bbf7d0;
}

.nav-menu {
  display: grid;
  gap: 0.28rem;
}

.nav-link {
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 10px;
  padding: 0.65rem 0.72rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.nav-link:hover {
  background: rgba(148, 163, 184, 0.1);
}

.nav-link.is-active {
  background: var(--sidebar-active);
  border-color: #334155;
  color: #fff;
}

.main-content {
  padding: 1rem 1.1rem 1.6rem;
  display: grid;
  gap: 1rem;
  min-width: 0;
  align-content: start;
  align-items: start;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

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

.topbar h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2.2vw, 1.6rem);
}

.topbar-sub {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.admin-chip {
  min-width: 180px;
}

button.admin-chip {
  background: #8d3d49;
  border: 1px solid #77404a;
}

button.admin-chip.is-offline {
  background: #8d3d49;
  border-color: #77404a;
}

button.admin-chip.is-online {
  background: #2f7f67;
  border-color: #296d59;
}

button.admin-chip.is-issue {
  background: #9d6b2d;
  border-color: #855923;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

h2,
h3,
h4 {
  margin: 0 0 0.72rem;
}

.hint {
  margin: 0 0 0.72rem;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.stack {
  display: grid;
  gap: 0.66rem;
}

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

.full-row {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 0.32rem;
  font-size: 0.86rem;
  color: #475569;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 0.62rem 0.72rem;
  min-height: 42px;
}

select[multiple] {
  min-height: 130px;
  padding: 0.4rem;
}

input[readonly] {
  background: #f8fafc;
  color: #64748b;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, white 45%);
  outline-offset: 1px;
}

button {
  border: 1px solid var(--accent-2);
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  padding: 0.58rem 0.88rem;
  min-height: 40px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset;
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

button:hover {
  background: color-mix(in srgb, var(--accent) 90%, #334155 10%);
  border-color: color-mix(in srgb, var(--accent-2) 82%, #334155 18%);
  box-shadow: 0 2px 8px rgba(63, 87, 172, 0.2);
}

button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.72rem;
  margin-top: 0.9rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.58rem;
}

.toggle input {
  width: 18px;
  height: 18px;
  min-height: auto;
}

.pages {
  display: grid;
  min-width: 0;
  align-content: start;
}

.page {
  display: none;
  gap: 1rem;
  width: 100%;
  min-width: 0;
  align-content: start;
  grid-template-columns: minmax(0, 1fr);
}

.page.is-active {
  display: grid;
}

.page > .card {
  width: 100%;
  min-width: 0;
}

.gate {
  border-style: dashed;
}

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

.kpi-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  background: #f8fbff;
  display: grid;
  gap: 0.3rem;
}

.kpi-card span {
  color: #64748b;
  font-size: 0.85rem;
}

.kpi-card strong {
  font-size: 1.2rem;
}

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

.row-head h2,
.row-head h3 {
  margin: 0;
}

.row-head .action-row {
  margin-top: 0;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  min-width: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
  font-size: 0.82rem;
}

th,
td {
  border-bottom: 1px solid #e5ebf3;
  text-align: left;
  padding: 0.5rem;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  background: #f1f5fb;
  color: #334155;
}

tr:last-child td {
  border-bottom: 0;
}

.result {
  margin: 1rem 0 0;
  padding: 0.65rem;
  min-height: 2.6rem;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.77rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.result.is-error {
  border-color: var(--warn);
}

.simple-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.4rem;
}

.simple-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0.45rem 0.55rem;
  font-size: 0.8rem;
}

.simple-list li.is-empty {
  color: var(--muted);
  font-style: italic;
}

body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(900px, calc(100vw - 2rem));
  margin: 8vh auto 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.35);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.ghost-btn {
  background: #e2e8f0;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

.btn-small {
  min-height: 30px;
  padding: 0.36rem 0.56rem;
  font-size: 0.76rem;
  border-radius: 8px;
}

.btn-danger {
  background: #c65f66;
  border-color: #ad4d54;
  color: #fff;
}

.btn-danger:hover {
  background: #b8545b;
  border-color: #9f474d;
}

.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.36rem;
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid #1f2a44;
  }

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

  .wizard-grid,
  .kpi-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .nav-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .action-row button {
    width: 100%;
  }

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

  .topbar-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

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