:root {
  --sidebar-w: 260px;
  --bg: #f3f6f4;
  --bg-deep: #e6ece8;
  --surface: #ffffff;
  --ink: #14201b;
  --ink-soft: #3d4f47;
  --muted: #6b7c74;
  --line: #d5ddd8;
  --line-soft: #e8eeea;
  --brand: #0d6b5c;
  --brand-2: #14917c;
  --brand-ink: #06352e;
  --brand-soft: #d8f0ea;
  --brand-glow: rgba(13, 107, 92, 0.18);
  --danger: #b42318;
  --danger-soft: #fce8e6;
  --ok: #067647;
  --ok-soft: #e3f6ec;
  --warn: #b54708;
  --warn-soft: #fef0c7;
  --shadow-sm: 0 1px 2px rgba(20, 32, 27, 0.05);
  --shadow: 0 10px 30px rgba(20, 32, 27, 0.08);
  --radius: 16px;
  --radius-sm: 11px;
  --font: "Manrope", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(20, 145, 124, 0.08), transparent 60%),
    radial-gradient(700px 380px at 100% 0%, rgba(61, 90, 128, 0.07), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

#app {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-shell::before {
  content: "";
  position: absolute;
  inset: -20% auto auto -10%;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(20, 145, 124, 0.2), transparent 70%);
  animation: float 8s ease-in-out infinite;
}

.login-shell::after {
  content: "";
  position: absolute;
  right: -8%;
  bottom: -15%;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(61, 90, 128, 0.14), transparent 70%);
  animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(18px);
  }
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(213, 221, 216, 0.9);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  animation: rise 0.45s var(--ease);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--brand-2), var(--brand-ink));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 24px var(--brand-glow);
  margin-bottom: 18px;
}

.login-card h1 {
  margin: 0;
  font-size: 1.85rem;
  letter-spacing: -0.04em;
  font-weight: 800;
}

.login-card .subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.login-form {
  margin-top: 28px;
  display: grid;
  gap: 14px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, #0f2f29 0%, #123832 48%, #0d2823 100%);
  color: #e8f4f0;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  z-index: 40;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
}

.sidebar-brand .brand-mark {
  width: 40px;
  height: 40px;
  margin: 0;
  font-size: 0.95rem;
}

.sidebar-brand strong {
  display: block;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.sidebar-brand span {
  display: block;
  font-size: 0.78rem;
  color: rgba(232, 244, 240, 0.62);
  margin-top: 2px;
}

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

.nav-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(232, 244, 240, 0.78);
  text-align: left;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  transition: background 0.18s var(--ease), color 0.18s var(--ease),
    transform 0.18s var(--ease);
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.nav-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.nav-ico {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  opacity: 0.9;
}

.nav-ico svg {
  width: 18px;
  height: 18px;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 8px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  background: rgba(243, 246, 244, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(213, 221, 216, 0.7);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  font-weight: 800;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.content {
  padding: 22px 24px 48px;
  animation: rise 0.35s var(--ease);
}

.menu-btn,
.icon-btn {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  place-items: center;
  box-shadow: var(--shadow-sm);
}

.menu-btn svg,
.icon-btn svg {
  width: 20px;
  height: 20px;
}

.backdrop {
  display: none;
}

label {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--ink-soft);
}

input[type="password"],
input[type="text"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-weight: 700;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease,
    box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  color: #fff;
  box-shadow: 0 8px 18px var(--brand-glow);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  background: var(--surface);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  background: var(--bg-deep);
  color: var(--ink);
}

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

.btn-danger:hover {
  filter: brightness(0.97);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.86rem;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-foot .btn {
  width: 100%;
  justify-content: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: #e8f4f0;
  padding: 10px 12px;
}

.sidebar-foot .btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.flash {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.92rem;
  margin-bottom: 16px;
  animation: rise 0.3s var(--ease);
}

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

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

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.stat-card .label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.stat-card .value {
  margin-top: 6px;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.auto-pill {
  display: inline-flex;
  align-items: center;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  border: 1px solid #b7ddd4;
}


.panel + .panel {
  margin-top: 14px;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.group-card {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 16px;
  background: linear-gradient(180deg, #fff, #f8fbf9);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease),
    border-color 0.18s ease;
}

.group-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: #c9d8d1;
}

.group-card h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.meta {
  color: var(--muted);
  font-size: 0.8rem;
  font-family: var(--mono);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 700;
}

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

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

.badge-off {
  background: var(--bg-deep);
  color: var(--muted);
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

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

.form-grid {
  display: grid;
  grid-template-columns: 1fr 160px auto;
  gap: 10px;
  align-items: end;
}

.form-inline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.field-help {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.section-title {
  margin: 24px 0 10px;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 520px;
}

.table th,
.table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

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

.table th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f7faf8;
}

.empty {
  color: var(--muted);
  padding: 36px 16px;
  text-align: center;
  line-height: 1.5;
}

.mono {
  font-family: var(--mono);
  font-size: 0.84rem;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--ink-soft);
  user-select: none;
}

.switch input {
  width: 42px;
  height: 24px;
  appearance: none;
  background: #c9d4ce;
  border-radius: 999px;
  position: relative;
  outline: none;
  transition: background 0.2s ease;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s var(--ease);
  box-shadow: var(--shadow-sm);
}

.switch input:checked {
  background: var(--brand);
}

.switch input:checked::after {
  transform: translateX(18px);
}

.back-link {
  border: 0;
  background: transparent;
  color: var(--brand);
  font-weight: 700;
  padding: 0;
  margin-bottom: 10px;
}

.back-link:hover {
  text-decoration: underline;
}

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--sidebar-w), 86vw);
    transform: translateX(-105%);
    transition: transform 0.28s var(--ease);
    box-shadow: var(--shadow);
  }

  .app-shell.nav-open .sidebar {
    transform: none;
  }

  .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 20, 16, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s var(--ease);
    z-index: 30;
  }

  .app-shell.nav-open .backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .menu-btn {
    display: grid;
  }

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

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

  .content,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar h1 {
    font-size: 1.1rem;
  }

  .topbar p {
    display: none;
  }
}

@media (max-width: 560px) {
  .topbar-actions .btn-label {
    display: none;
  }

  .login-card {
    padding: 28px 22px;
  }
}
