:root {
  --bg: #f4efe6;
  --bg-panel: rgba(255, 250, 241, 0.95);
  --bg-strong: #fffdf8;
  --line: rgba(111, 82, 53, 0.14);
  --ink: #1e1a17;
  --muted: #70645a;
  --accent: #1f6b5d;
  --accent-soft: rgba(31, 107, 93, 0.12);
  --warn: #b86c37;
  --shadow: 0 24px 60px rgba(64, 43, 16, 0.12);
  --radius: 22px;
  --radius-sm: 14px;
  --font: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(31, 107, 93, 0.12), transparent 32%),
    radial-gradient(circle at right 20%, rgba(184, 108, 55, 0.1), transparent 24%),
    linear-gradient(180deg, #f7f2e8 0%, #f2ebde 100%);
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login-card {
  width: min(460px, 100%);
  padding: 2.4rem;
  border-radius: 28px;
  background: rgba(255, 251, 245, 0.92);
  box-shadow: var(--shadow);
  border: 1px solid rgba(111, 82, 53, 0.12);
}

.login-card h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(2rem, 3vw, 2.6rem);
}

.login-copy {
  margin: 0 0 1.5rem;
  color: var(--muted);
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 0.85rem;
}

input,
button {
  font: inherit;
}

input {
  width: 100%;
  padding: 0.95rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(111, 82, 53, 0.18);
  background: var(--bg-strong);
}

button {
  cursor: pointer;
  border: none;
}

.login-form button,
.user-card,
.device-card {
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.login-form button {
  padding: 0.95rem 1.2rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #1f6b5d, #2a8f7d);
  color: white;
  font-weight: 700;
  box-shadow: 0 16px 28px rgba(31, 107, 93, 0.22);
}

.login-form button:hover,
.user-card:hover,
.device-card:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.error-text {
  min-height: 1.25rem;
  margin: 0;
  color: #b23636;
}

.app-shell {
  padding: 1.4rem;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

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

.topbar-actions {
  display: flex;
  gap: 0.7rem;
}

.ghost-button {
  padding: 0.8rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(111, 82, 53, 0.12);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-card,
.sidebar,
.panel,
.hero-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 1rem 1.15rem;
  border-radius: 18px;
}

.stat-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.stat-card strong {
  display: block;
  margin-top: 0.4rem;
  font-size: 1.5rem;
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
  min-height: calc(100vh - 220px);
}

.sidebar,
.panel,
.hero-card {
  border-radius: var(--radius);
}

.sidebar,
.panel {
  padding: 1rem;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.pill,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.84rem;
}

.pill {
  background: rgba(111, 82, 53, 0.08);
  color: var(--muted);
}

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

.badge.warn {
  background: rgba(184, 108, 55, 0.13);
  color: var(--warn);
}

.search-box {
  margin-bottom: 0.8rem;
}

.user-list {
  display: grid;
  gap: 0.7rem;
  max-height: calc(100vh - 380px);
  overflow: auto;
}

.user-card,
.device-card {
  width: 100%;
  text-align: left;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(111, 82, 53, 0.1);
}

.user-card.selected,
.device-card.selected {
  background: linear-gradient(135deg, rgba(31, 107, 93, 0.12), rgba(31, 107, 93, 0.03));
  border-color: rgba(31, 107, 93, 0.32);
}

.user-card-top,
.device-head,
.device-foot,
.hero-metrics {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.user-card p,
.device-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.user-card-meta,
.device-grid-metrics {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.content {
  display: grid;
  gap: 1rem;
}

.hero-card {
  padding: 1.4rem;
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1rem;
}

.hero-copy h2 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.7rem, 2vw, 2.3rem);
}

.hero-copy p {
  margin: 0.25rem 0;
  color: var(--muted);
}

.hero-metrics {
  gap: 0.8rem;
}

.hero-metrics > div {
  flex: 1;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.75);
}

.hero-metrics span {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
}

.hero-metrics strong {
  display: block;
  margin-top: 0.4rem;
  font-size: 1.2rem;
}

.split-layout {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 1rem;
}

.device-grid {
  display: grid;
  gap: 0.8rem;
}

.trend-shell,
.table-shell {
  overflow: auto;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(111, 82, 53, 0.1);
}

.trend-shell {
  margin-bottom: 1rem;
  padding: 1rem;
}

.trend-summary {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.trend-card {
  padding: 1rem;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(249, 242, 231, 0.9));
  border: 1px solid rgba(111, 82, 53, 0.12);
}

.trend-card-head,
.trend-card-meta,
.trend-card-foot {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.trend-card-head {
  align-items: baseline;
  margin-bottom: 0.55rem;
}

.trend-card-head p,
.trend-card-meta,
.trend-card-foot {
  margin: 0;
  color: var(--muted);
}

.trend-card-head p {
  font-size: 0.92rem;
}

.trend-card-head strong {
  font-size: 1.1rem;
}

.trend-card-meta {
  font-size: 0.84rem;
  margin-bottom: 0.7rem;
}

.trend-card-foot {
  margin-top: 0.55rem;
  font-size: 0.82rem;
}

.trend-chart-wrap {
  position: relative;
  height: 170px;
}

.trend-canvas {
  width: 100%;
  height: 170px;
  display: block;
}

.trend-grid-line {
  stroke: rgba(111, 82, 53, 0.13);
  stroke-width: 1;
}

.trend-path {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-area {
  opacity: 0.14;
}

.trend-point {
  stroke: white;
  stroke-width: 2;
}

.trend-empty {
  display: grid;
  place-items: center;
  min-height: 170px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

th,
td {
  padding: 0.9rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(111, 82, 53, 0.09);
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: rgba(247, 242, 232, 0.95);
  color: var(--muted);
  font-size: 0.88rem;
  z-index: 1;
}

.empty-state,
.loading-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
}

.empty-state.compact {
  min-height: 120px;
}

.tab-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.tab-button {
  padding: 0.6rem 0.95rem;
  border-radius: 999px;
  background: rgba(111, 82, 53, 0.08);
  color: var(--muted);
}

.tab-button.active {
  background: var(--accent);
  color: white;
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace,
  .split-layout,
  .hero-card,
  .trend-grid {
    grid-template-columns: 1fr;
  }

  .user-list {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 0.9rem;
  }

  .topbar,
  .panel-header,
  .hero-metrics,
  .device-head,
  .device-foot,
  .trend-summary,
  .trend-card-head,
  .trend-card-meta,
  .trend-card-foot {
    flex-direction: column;
    align-items: start;
  }

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