:root {
  --bg: #eef3f0;
  --panel: #f8fbf9;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #ffffff;
  --line: rgba(10, 37, 28, 0.1);
  --text: #173229;
  --muted: #627d73;
  --brand: #0d8a69;
  --brand-deep: #0d5c53;
  --accent: #f1a208;
  --danger: #c74a45;
  --shadow: 0 24px 60px rgba(27, 61, 52, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Manrope", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(13, 138, 105, 0.18), transparent 28%),
    radial-gradient(circle at right 10%, rgba(241, 162, 8, 0.18), transparent 24%),
    linear-gradient(180deg, #f5fbf8 0%, #ebf1ef 100%);
  color: var(--text);
  min-height: 100vh;
}

button,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  align-items: start;
}

.sidebar {
  background: linear-gradient(180deg, #14362d 0%, #0f2822 100%);
  color: #f5fff9;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  z-index: 20;
  transform: translateX(0);
  transition: transform 0.28s ease;
}

.brand,
.profile-card,
.nav-item,
.section-card,
.surface-card,
.trend-card,
.hero-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.05);
}

.brand h1 {
  font-size: 1.05rem;
  line-height: 1.15;
}

.brand-mark,
.avatar {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: linear-gradient(135deg, #f1a208, #ffe4a8);
  color: #173229;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.avatar-large {
  width: 88px;
  height: 88px;
  font-size: 1.4rem;
}

.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar .eyebrow {
  color: rgba(245, 255, 249, 0.56);
}

.brand h1,
.hero-card h3,
.trend-card h3,
.surface-card h3,
.section-card h3,
.topbar h2 {
  margin: 0;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  color: inherit;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  min-height: 74px;
}

.profile-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.profile-copy strong,
.profile-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-toggle {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 14px;
  cursor: pointer;
  flex: 0 0 auto;
}

.sidebar-toggle-mobile {
  display: none;
}

.profile-copy span,
.sidebar-footer p {
  color: rgba(245, 255, 249, 0.72);
  margin: 0;
  font-size: 0.92rem;
}

.client-switcher {
  display: grid;
  gap: 8px;
}

.client-switcher label {
  font-size: 0.82rem;
  color: rgba(245, 255, 249, 0.72);
}

.client-switcher select {
  width: 100%;
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.08));
  color: #f5fff9;
  border-radius: 14px;
  padding: 12px 42px 12px 14px;
  appearance: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background-image:
    linear-gradient(45deg, transparent 50%, #f5fff9 50%),
    linear-gradient(135deg, #f5fff9 50%, transparent 50%);
  background-position:
    calc(100% - 20px) calc(50% - 3px),
    calc(100% - 14px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.client-switcher select:focus {
  outline: none;
  border-color: rgba(241, 162, 8, 0.55);
  box-shadow: 0 0 0 3px rgba(241, 162, 8, 0.14);
}

.client-switcher select option {
  color: var(--text);
  background: #ffffff;
}

.sidebar-nav {
  display: grid;
  gap: 10px;
}

.nav-item {
  border-radius: 16px;
  padding: 14px 16px;
  background: transparent;
  color: rgba(245, 255, 249, 0.8);
  cursor: pointer;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: linear-gradient(135deg, rgba(13, 138, 105, 0.36), rgba(241, 162, 8, 0.16));
  color: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.05);
  display: grid;
  gap: 10px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #67f0bf;
  box-shadow: 0 0 0 6px rgba(103, 240, 191, 0.12);
}

.main-panel {
  padding: 34px;
  min-width: 0;
  margin-left: 320px;
  transition: margin-left 0.28s ease;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 18px;
}

.topbar-title {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

body.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}

body.sidebar-collapsed .main-panel {
  margin-left: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  padding: 12px 16px;
  border-radius: 14px;
  color: var(--text);
  cursor: pointer;
}

.ghost-button.is-loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.ghost-button.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(23, 50, 41, 0.22);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}

.refresh-status {
  min-height: 22px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.refresh-status.show {
  opacity: 1;
  transform: translateY(0);
}

.refresh-status.success {
  color: var(--brand-deep);
  background: rgba(13, 138, 105, 0.1);
  border-color: rgba(13, 138, 105, 0.22);
}

.refresh-status.error {
  color: var(--danger);
  background: rgba(199, 74, 69, 0.1);
  border-color: rgba(199, 74, 69, 0.2);
}

.panel-section {
  display: none;
}

.panel-section.is-active {
  display: block;
}

.hero-grid,
.content-grid,
.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 22px;
}

.hero-card,
.trend-card,
.surface-card,
.section-card {
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  border-radius: var(--radius-xl);
  padding: 24px;
}

.hero-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  background:
    linear-gradient(135deg, rgba(13, 138, 105, 0.15), rgba(241, 162, 8, 0.08)),
    var(--surface-strong);
}

.hero-copy p,
.hero-copy h3,
.hero-copy span {
  max-width: 520px;
}

.hero-copy h3 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.hero-stat-stack {
  display: grid;
  gap: 18px;
  min-width: 180px;
}

.hero-stat-label,
.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 6px;
}

.hero-stat-stack strong,
.finance-grid strong {
  font-size: 1.8rem;
}

.kpi-grid,
.site-grid,
.cards-list,
.finance-grid {
  display: grid;
  gap: 16px;
}

.kpi-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 22px;
}

.kpi-card,
.site-card,
.rule-card,
.group-card {
  border-radius: 20px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
}

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

.site-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

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

.list-row {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.8);
}

.list-row strong,
.rule-card strong,
.group-card strong {
  display: block;
  margin-bottom: 4px;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.pill.normal {
  background: rgba(13, 138, 105, 0.12);
  color: var(--brand-deep);
}

.pill.active,
.pill.open,
.pill.error {
  background: rgba(199, 74, 69, 0.12);
  color: var(--danger);
}

.pill.candidate,
.pill.pending {
  background: rgba(241, 162, 8, 0.15);
  color: #8a6000;
}

.pill.closed,
.pill.sent,
.pill.ack {
  background: rgba(17, 108, 226, 0.1);
  color: #116ce2;
}

.table-wrap {
  overflow: auto;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
}

th,
td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

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

#assetsTable td,
#assetsTable th {
  padding-block: 10px;
}

.assets-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.asset-filter {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.82rem;
  cursor: pointer;
}

.alarm-filter,
.notification-filter,
.rule-filter {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.82rem;
  cursor: pointer;
}

.asset-filter.is-active,
.alarm-filter.is-active,
.notification-filter.is-active,
.rule-filter.is-active {
  background: rgba(13, 138, 105, 0.14);
  border-color: rgba(13, 138, 105, 0.24);
  color: var(--brand-deep);
}

.mini-chart {
  display: flex;
  align-items: end;
  gap: 10px;
  min-height: 180px;
  padding-top: 20px;
}

.chart-bar-wrap {
  flex: 1;
  min-width: 0;
}

.chart-bar {
  width: 100%;
  border-radius: 999px 999px 10px 10px;
  background: linear-gradient(180deg, #0d8a69 0%, #f1a208 160%);
  min-height: 16px;
}

.chart-label {
  font-size: 0.64rem;
  color: var(--muted);
  margin-top: 16px;
  white-space: nowrap;
  transform: rotate(-28deg);
  transform-origin: left top;
}

.profile-panel {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.detail-list div {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.detail-list dd {
  margin: 0;
  font-weight: 700;
}

.todo-list {
  display: grid;
  gap: 14px;
}

.profile-forms {
  margin-bottom: 14px;
}

.todo-item {
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
}

.inline-form {
  display: grid;
  gap: 10px;
}

.collapsible-card {
  gap: 0;
  overflow: hidden;
}

.collapse-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--text);
  cursor: pointer;
}

.collapse-icon {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(13, 138, 105, 0.1);
  color: var(--brand-deep);
  font-weight: 800;
  transition: transform 0.2s ease;
}

.collapse-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.24s ease, padding-top 0.24s ease;
  padding-top: 0;
}

.collapse-body > * {
  overflow: hidden;
}

.collapsible-card.is-open .collapse-body {
  grid-template-rows: 1fr;
  padding-top: 12px;
}

.collapsible-card.is-open .collapse-icon {
  transform: rotate(45deg);
}

.todo-item.is-success {
  animation: successPulse 0.7s ease;
  border-color: rgba(13, 138, 105, 0.35);
  box-shadow: 0 0 0 3px rgba(13, 138, 105, 0.08);
}

.text-input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
}

.password-field {
  position: relative;
}

.password-input {
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
}

.login-page {
  display: grid;
  place-items: center;
}

.login-shell {
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 20px;
}

.login-copy h2,
.login-copy p {
  margin: 0;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-button {
  justify-self: start;
}

.finance-card {
  background:
    radial-gradient(circle at top right, rgba(13, 138, 105, 0.12), transparent 35%),
    linear-gradient(135deg, rgba(241, 162, 8, 0.08), rgba(13, 138, 105, 0.08)),
    #ffffff;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

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

  .sidebar {
    width: min(320px, 86vw);
  }

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

  .hero-grid,
  .content-grid,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .sidebar-toggle-mobile {
    display: inline-grid;
    place-items: center;
  }

  .sidebar-toggle:not(.sidebar-toggle-mobile) {
    display: none;
  }

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

@media (max-width: 720px) {
  .main-panel {
    padding: 20px;
  }

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

  .kpi-grid,
  .finance-grid,
  .detail-list {
    grid-template-columns: 1fr;
  }

  .hero-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-title {
    align-items: center;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }
}

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

@keyframes successPulse {
  0% {
    transform: scale(1);
    background: rgba(255, 255, 255, 0.88);
  }
  40% {
    transform: scale(1.01);
    background: rgba(13, 138, 105, 0.1);
  }
  100% {
    transform: scale(1);
    background: rgba(255, 255, 255, 0.88);
  }
}
