:root {
  --bg: #eceff3;
  --bg-soft: #f6f7f9;
  --surface: #ffffff;
  --ink: #1a1f26;
  --muted: #6b7280;
  --line: #d9dee6;
  --metal-1: #8b939e;
  --metal-2: #5c6570;
  --metal-3: #2f3640;
  --metal-glow: linear-gradient(135deg, #c5ccd6 0%, #8b939e 42%, #4b5563 100%);
  --metal-soft: linear-gradient(180deg, #f8f9fb 0%, #e8ebf0 100%);
  --warn: #b45309;
  --warn-soft: #fff7ed;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --ok: #3f4b59;
  --ok-soft: #eef1f5;
  --shadow: 0 10px 30px rgba(31, 41, 55, 0.06);
  --radius: 16px;
  --font: "DM Sans", sans-serif;
  --display: "DM Sans", sans-serif;
  --fw-light: 300;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-weight: var(--fw-regular);
  font-optical-sizing: auto;
  color: var(--ink);
  background: var(--bg);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
  font-size: 0.82rem;
}

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

.small {
  font-size: 0.88rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: var(--fw-medium);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* LOGIN — split screen */
.login-view {
  min-height: 100vh;
  background: #fff;
}

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

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.75rem 2rem 1.5rem;
  background: #fff;
  animation: rise 0.45s ease both;
}

.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--display);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.04em;
  font-size: 0.95rem;
  color: #1f2933;
}

.login-brand-mark {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.login-form {
  width: min(440px, 100%);
  margin: 2rem auto;
  display: grid;
  gap: 0.85rem;
}

.login-kicker {
  margin: 0;
  color: #f08a24;
  font-size: 0.72rem;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-form h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.8rem, 3vw, 2.35rem);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.04em;
  line-height: 1.15;
  color: #1c2430;
}

.login-lead {
  margin: 0 0 0.4rem;
  color: #6b7280;
  font-weight: var(--fw-light);
  line-height: 1.55;
  font-size: 0.98rem;
}

.field {
  display: grid;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: var(--fw-medium);
  color: #374151;
}

.field-control {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: #f3f6f9;
  border: 1px solid #d7dee7;
  border-radius: 12px;
  padding: 0.15rem 0.85rem;
  color: #8b95a5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.field-control svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.field-control input {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0.85rem 0;
}

.field-control input:focus {
  box-shadow: none;
}

.field-control:focus-within {
  background: #fff;
  border-color: #f08a24;
  box-shadow: 0 0 0 3px rgba(240, 138, 36, 0.15);
  color: #5b6573;
}

.btn-login {
  margin-top: 0.35rem;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 0.95rem 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  background: #152033;
  color: #fff;
  font-weight: var(--fw-medium);
  font-size: 0.98rem;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.12s ease;
}

.btn-login:hover {
  background: #0f1724;
  transform: translateY(-1px);
}

.btn-login:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.login-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.login-pills span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: #eef3f8;
  color: #4b5563;
  font-size: 0.78rem;
  font-weight: var(--fw-medium);
}

.login-pills span::before {
  content: "✓";
  color: #f08a24;
  font-size: 0.75rem;
}

.login-hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(240, 138, 36, 0.22), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.08), transparent 42%),
    linear-gradient(160deg, #101826 0%, #152033 55%, #0c121c 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 2.5rem;
  animation: rise 0.55s ease both;
}

.login-hero-glow {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, transparent 40%, rgba(240, 138, 36, 0.12) 100%);
  pointer-events: none;
}

.login-hero-logo {
  position: absolute;
  right: -8%;
  top: 8%;
  width: min(78%, 520px);
  opacity: 0.88;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.35));
  animation: logoFloat 16s ease-in-out infinite alternate;
  user-select: none;
}

.login-hero-copy {
  position: relative;
  z-index: 1;
  max-width: 420px;
}

.login-hero-copy h2 {
  margin: 0 0 0.75rem;
  font-family: var(--display);
  font-size: clamp(1.55rem, 2.6vw, 2.1rem);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.login-hero-copy p {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-weight: var(--fw-light);
  line-height: 1.55;
  font-size: 0.95rem;
}

.login-hero-copy small {
  display: inline-block;
  margin-top: 1.1rem;
  color: #f08a24;
  font-weight: var(--fw-medium);
  letter-spacing: 0.02em;
}

@keyframes logoFloat {
  from {
    transform: rotate(-6deg) translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: rotate(-2deg) translate3d(-2%, 2%, 0) scale(1.04);
  }
}

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

.card,
.kpi-card,
.action-card {
  animation: rise 0.45s ease both;
}

.login-logo,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.login-logo-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex: 0 0 44px;
}

.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--display);
  font-weight: var(--fw-semibold);
  background: var(--metal-glow);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.login-logo strong,
.sidebar-brand strong,
.page-head h1,
.card-head h2,
.side-head h2,
.action-card h3,
.kpi-card strong {
  font-family: var(--display);
  font-weight: var(--fw-semibold);
}

.login-logo strong,
.sidebar-brand strong {
  display: block;
  font-size: 0.95rem;
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
}

.login-logo small,
.sidebar-brand small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: var(--fw-light);
}

@media (max-width: 960px) {
  .login-split {
    grid-template-columns: 1fr;
  }

  .login-hero {
    min-height: 320px;
    order: -1;
    padding: 1.5rem;
  }

  .login-hero-logo {
    width: min(58%, 280px);
    top: 10%;
    right: -4%;
    opacity: 0.75;
  }

  .login-panel {
    padding: 1.25rem 1.25rem 1.5rem;
  }

  .login-form {
    margin: 1.5rem 0;
  }
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--metal-1);
  box-shadow: 0 0 0 3px rgba(139, 147, 158, 0.2);
}

.error-text {
  margin: 0;
  color: var(--danger);
  font-weight: var(--fw-medium);
}

.page-sub {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-weight: var(--fw-light);
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.88rem;
  font-weight: var(--fw-medium);
}

/* BUTTONS */
.btn {
  border: none;
  border-radius: 12px;
  padding: 0.72rem 1rem;
  font-weight: var(--fw-medium);
  letter-spacing: -0.01em;
  transition: transform 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
}

.btn-metal {
  color: #fff;
  background: var(--metal-glow);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 8px 18px rgba(47, 54, 64, 0.18);
}

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

.btn-warn {
  background: var(--warn);
  color: #fff;
}

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

.link-btn {
  border: none;
  background: none;
  color: var(--metal-2);
  font-weight: var(--fw-medium);
  padding: 0;
}

.link-btn:hover {
  color: var(--metal-3);
  text-decoration: underline;
}

/* SHELL */
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
  position: relative;
  isolation: isolate;
  background: var(--bg);
}

.app-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.app-logo-bg {
  position: absolute;
  right: -8%;
  bottom: -12%;
  width: min(70vw, 760px);
  height: auto;
  opacity: 0.1;
  transform: rotate(-12deg);
  animation: logoFloat 22s ease-in-out infinite alternate;
  user-select: none;
}

.sidebar,
.main {
  position: relative;
  z-index: 1;
}

.sidebar {
  background: rgba(251, 252, 253, 0.92);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--line);
  padding: 1.25rem 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-logo-img,
.login-logo-img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex: 0 0 42px;
}

.avatar-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  padding: 4px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.15rem 0.45rem 0.35rem;
}

.sidebar-brand-text {
  min-width: 0;
  display: grid;
  gap: 0.05rem;
}

.sidebar-brand-text strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  flex: 1;
  min-height: 0;
}

.nav-group {
  display: grid;
  gap: 0.2rem;
}

.nav-label {
  margin: 0 0 0.15rem;
  padding: 0 0.75rem;
  font-size: 0.66rem;
  font-weight: var(--fw-medium);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a0a8b4;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  border: none;
  background: transparent;
  color: #6d7582;
  border-radius: 12px;
  padding: 0.68rem 0.75rem;
  font-weight: var(--fw-regular);
  font-size: 0.94rem;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item span {
  line-height: 1.2;
}

.nav-item:hover:not(:disabled) {
  background: #f1f3f6;
  color: var(--ink);
}

.nav-item.active {
  background: #eceff3;
  color: var(--metal-3);
  font-weight: var(--fw-medium);
}

.nav-item:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.nav-item-danger:hover:not(:disabled) {
  background: #f8efef;
  color: var(--danger);
}

.nav-ico {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  opacity: 0.9;
}

.nav-item.active .nav-ico {
  opacity: 1;
}

.sidebar-foot {
  border-radius: 14px;
  padding: 0.95rem 1rem;
  background: #f3f5f8;
  border: 1px solid #e4e8ee;
  margin-top: auto;
}

.sidebar-foot strong {
  display: block;
  font-size: 0.88rem;
  font-weight: var(--fw-medium);
  margin-bottom: 0.25rem;
}

.sidebar-foot p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
  font-weight: var(--fw-light);
}

.main {
  min-width: 0;
  background: transparent;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.35rem;
  background: rgba(246, 247, 249, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.top-search {
  flex: 1;
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  color: var(--muted);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.search-ico {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  opacity: 0.75;
}

.top-search input {
  border: none;
  padding: 0.45rem 0;
  box-shadow: none;
  background: transparent;
}

.top-search input:focus {
  box-shadow: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.date-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid #cfd5de;
  background: #fff;
  color: var(--metal-2);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
  font-weight: var(--fw-regular);
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: var(--fw-semibold);
  font-size: 0.78rem;
  background: var(--metal-glow);
}

.content {
  padding: 1.25rem 1.35rem 2rem;
  display: grid;
  gap: 1rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
}

.page-head h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: var(--fw-semibold);
  letter-spacing: -0.035em;
}

.count-chip {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-weight: var(--fw-medium);
  color: var(--metal-2);
  white-space: nowrap;
}

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

.kpi-card,
.card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.kpi-card {
  padding: 1rem 1.05rem;
}

.kpi-top {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-weight: var(--fw-regular);
  font-size: 0.88rem;
  margin-bottom: 0.55rem;
}

.kpi-ico {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--metal-soft);
  color: var(--metal-2);
  font-size: 0.8rem;
}

.kpi-card strong {
  display: block;
  font-size: 1.85rem;
  font-weight: var(--fw-semibold);
  letter-spacing: -0.04em;
  margin-bottom: 0.2rem;
}

.kpi-selected {
  font-size: 1.05rem !important;
  line-height: 1.3;
}

.kpi-card small {
  color: var(--muted);
  font-weight: var(--fw-light);
}

.trend-up {
  color: var(--metal-2) !important;
  font-weight: var(--fw-regular);
}

.workspace {
  display: grid;
  grid-template-columns: 1.6fr 0.9fr;
  gap: 0.85rem;
  align-items: start;
}

.card {
  padding: 1rem 1.1rem;
}

.card-head,
.side-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: start;
  margin-bottom: 0.85rem;
}

.card-head h2,
.side-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: var(--fw-semibold);
}

.table-wrap {
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: var(--fw-medium);
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line);
}

.data-table td {
  padding: 0.85rem 0.4rem;
  border-bottom: 1px solid #eef1f4;
  vertical-align: middle;
  font-weight: var(--fw-regular);
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}

.data-table tbody tr:hover,
.data-table tbody tr.active {
  background: #f3f5f8;
}

.device-title {
  font-weight: var(--fw-medium);
  font-family: var(--display);
  letter-spacing: -0.02em;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.76rem;
  font-weight: var(--fw-medium);
  background: var(--ok-soft);
  color: var(--ok);
}

.status-pill.off {
  background: #f3f4f6;
  color: #6b7280;
}

.side-empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 1rem;
  font-weight: var(--fw-light);
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin: 0 0 1rem;
}

.meta-grid div {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
}

.meta-grid dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.2rem;
  font-weight: var(--fw-medium);
}

.meta-grid dd {
  margin: 0;
  font-weight: var(--fw-medium);
  font-size: 0.92rem;
}

.side-actions {
  display: grid;
}

.actions-panel {
  margin-top: 0.15rem;
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.75rem;
}

.action-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.95rem;
  display: grid;
  gap: 0.5rem;
  background: linear-gradient(180deg, #fff 0%, #f7f8fa 100%);
}

.action-card h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: var(--fw-medium);
}

.action-card.danger-zone {
  border-color: #f0c7c3;
  background: linear-gradient(180deg, #fff 0%, var(--danger-soft) 160%);
}

.response-panel {
  margin-top: 1rem;
}

.response-panel h3 {
  margin: 0 0 0.5rem;
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: var(--fw-medium);
}

.code-block {
  margin: 0;
  padding: 0.85rem;
  border-radius: 12px;
  background: #232833;
  color: #d7dde6;
  overflow: auto;
  font-size: 0.82rem;
  line-height: 1.45;
  max-height: 260px;
}

.empty-state {
  color: var(--muted);
  line-height: 1.5;
  margin: 0.75rem 0 0;
  font-weight: var(--fw-light);
}

.toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  background: var(--metal-3);
  color: #fff;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-width: min(360px, calc(100vw - 2rem));
  animation: rise 0.25s ease both;
}

.toast.error {
  background: var(--danger);
}

.toast.ok {
  background: var(--metal-2);
}

@media (max-width: 1100px) {
  .kpi-row,
  .workspace {
    grid-template-columns: 1fr 1fr;
  }
}

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

  .sidebar {
    position: relative;
    height: auto;
  }

  .kpi-row,
  .workspace {
    grid-template-columns: 1fr;
  }

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