:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #251f38;
  --muted: #756f84;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: #ffffff;
  --line: #e8e3f0;
  --purple: #7650d8;
  --purple-light: #8c68e6;
  --pink: #dc70bd;
  --green: #16845b;
  --red: #c53e55;
  --amber: #9a6517;
  background: #f7f6fb;
  color: var(--ink);
}

* { box-sizing: border-box; }

body { margin: 0; min-height: 100vh; background: #f7f6fb; overflow-x: hidden; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.ambient { position: fixed; width: 36rem; height: 36rem; border-radius: 999px; filter: blur(115px); opacity: 0.11; pointer-events: none; }
.ambient-one { top: -18rem; left: -10rem; background: var(--purple); }
.ambient-two { right: -16rem; bottom: -20rem; background: var(--pink); }

.brand { display: flex; align-items: center; gap: 0.68rem; font-size: 0.93rem; font-weight: 760; letter-spacing: -0.02em; color: var(--ink); white-space: nowrap; }
.brand-large { font-size: 1.08rem; }
.brand-icon { width: 36px; height: 36px; object-fit: contain; flex: 0 0 auto; }
.brand-large .brand-icon { width: 44px; height: 44px; }

.connect-view { min-height: 100vh; display: grid; place-items: center; padding: 2rem; position: relative; z-index: 1; }
.connect-card { width: min(100%, 530px); padding: 2.7rem; border: 1px solid var(--line); border-radius: 26px; background: var(--panel-strong); box-shadow: 0 26px 70px rgba(54, 40, 83, 0.14); }
.eyebrow { margin: 0 0 0.65rem; color: var(--purple); font-size: 0.72rem; font-weight: 780; letter-spacing: 0.14em; text-transform: uppercase; }
.connect-card .eyebrow { margin-top: 2.8rem; }
.connect-card h1 { margin: 0; max-width: 440px; font-size: clamp(2.15rem, 6vw, 3.25rem); line-height: 1.02; letter-spacing: -0.055em; }
.connect-copy { color: var(--muted); line-height: 1.65; margin: 1.25rem 0 2rem; }
form { display: grid; gap: 0.7rem; }
label { color: #4f4862; font-size: 0.78rem; font-weight: 680; margin-top: 0.45rem; }
input { width: 100%; border: 1px solid #ded8e8; border-radius: 12px; padding: 0.9rem 1rem; background: #fbfaff; color: var(--ink); outline: none; transition: border-color 160ms, box-shadow 160ms, background 160ms; }
input:focus { border-color: var(--purple); background: #fff; box-shadow: 0 0 0 3px rgba(118, 80, 216, 0.13); }
.primary-button, .secondary-button { border-radius: 12px; font-weight: 720; transition: transform 150ms, border-color 150ms, background 150ms, box-shadow 150ms; }
.primary-button { margin-top: 0.75rem; padding: 0.95rem 1.05rem; border: 0; display: flex; justify-content: space-between; color: #fff; background: linear-gradient(100deg, var(--purple), var(--pink)); box-shadow: 0 10px 24px rgba(118, 80, 216, 0.2); }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 13px 28px rgba(118, 80, 216, 0.26); }
.primary-button:disabled, .secondary-button:disabled { cursor: wait; opacity: 0.62; transform: none; }
.form-error { min-height: 1.2em; margin: 0.15rem 0 0; color: var(--red); font-size: 0.78rem; }
.security-note { display: flex; align-items: center; gap: 0.65rem; margin-top: 1.5rem; color: var(--muted); font-size: 0.76rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 290px minmax(0, 1fr); position: relative; z-index: 1; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 2rem 1.25rem; border-right: 1px solid var(--line); background: rgba(255, 255, 255, 0.88); backdrop-filter: blur(22px); display: flex; flex-direction: column; box-shadow: 8px 0 30px rgba(55, 43, 80, 0.025); }
.sidebar-label { margin: 3.2rem 0 0.9rem 0.9rem; color: #9891a6; font-size: 0.67rem; font-weight: 760; letter-spacing: 0.13em; text-transform: uppercase; }
nav { display: grid; gap: 0.35rem; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 0.75rem; padding: 0.78rem 0.9rem; border: 1px solid transparent; border-radius: 11px; color: var(--muted); background: transparent; text-align: left; }
.nav-item:hover { color: var(--ink); background: #f6f3fc; }
.nav-item.active { color: #4b337f; border-color: #ded4f3; background: #f0eafb; }
.nav-icon { width: 1.15rem; color: var(--purple); text-align: center; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 0.85rem; }
.service-state { display: flex; align-items: center; gap: 0.55rem; padding: 0 0.65rem; color: var(--muted); font-size: 0.72rem; }
.status-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--amber); box-shadow: 0 0 10px rgba(154, 101, 23, 0.3); }
.status-dot.online { background: var(--green); box-shadow: 0 0 10px rgba(22, 132, 91, 0.28); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 10px rgba(197, 62, 85, 0.28); }
.sign-out { border: 1px solid var(--line); border-radius: 10px; padding: 0.72rem; color: var(--muted); background: #fff; }
.sign-out:hover { color: var(--ink); border-color: #cfc6df; background: #faf8fd; }

main { width: 100%; max-width: 1480px; margin: 0 auto; padding: 2.2rem clamp(1.25rem, 4vw, 4rem) 4rem; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; margin-bottom: 2.2rem; }
.topbar h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.55rem); letter-spacing: -0.045em; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; flex-wrap: wrap; }
.last-updated { color: var(--muted); font-size: 0.72rem; }
.secondary-button { border: 1px solid #ded8e8; padding: 0.72rem 1rem; color: #4f4862; background: #fff; box-shadow: 0 3px 10px rgba(53, 41, 77, 0.035); }
.secondary-button:hover { border-color: #bdaee0; color: #4b337f; background: #faf8ff; }
.privacy-button { color: #5c438f; background: #f5f0ff; border-color: #ded3f5; }
.privacy-button.details-visible { color: #fff; background: var(--purple); border-color: var(--purple); box-shadow: 0 6px 16px rgba(118, 80, 216, 0.18); }
.global-error { margin: -0.75rem 0 1.5rem; padding: 0.9rem 1rem; border: 1px solid #f0bec8; border-radius: 12px; color: #a72f44; background: #fff2f5; font-size: 0.82rem; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.metric-card { min-height: 175px; padding: 1.25rem; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); box-shadow: 0 8px 28px rgba(61, 47, 88, 0.055); display: flex; flex-direction: column; }
.metric-card p { margin: 0; color: #514a63; font-size: 0.78rem; font-weight: 630; }
.metric-card strong { margin: auto 0 0.65rem; font-size: 2.45rem; line-height: 1; letter-spacing: -0.05em; }
.metric-card span { color: var(--muted); font-size: 0.7rem; }
.accent-card { color: #fff; border-color: transparent; background: linear-gradient(145deg, #815bdc, #6942c3); box-shadow: 0 12px 30px rgba(104, 66, 195, 0.22); }
.accent-card p, .accent-card span { color: rgba(255, 255, 255, 0.82); }

.data-panel { margin-top: 1rem; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: 0 8px 28px rgba(61, 47, 88, 0.045); overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.4rem; border-bottom: 1px solid var(--line); }
.panel-heading h3 { margin: 0; font-size: 1.05rem; letter-spacing: -0.02em; }
.panel-heading .eyebrow { margin-bottom: 0.3rem; }
.record-count { color: var(--muted); font-size: 0.7rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 0.9rem 1.4rem; border-bottom: 1px solid var(--line); text-align: left; }
th { color: #8a8497; background: #fcfbfe; font-size: 0.66rem; font-weight: 740; letter-spacing: 0.08em; text-transform: uppercase; }
td { color: #514a62; font-size: 0.76rem; }
tbody tr:hover { background: #faf8fd; }
.status-pill { display: inline-flex; padding: 0.28rem 0.52rem; border-radius: 999px; font-size: 0.65rem; font-weight: 740; background: #f2eff6; }
.status-pill.positive { color: #116b49; background: #e7f6ef; }
.status-pill.negative { color: #ab3046; background: #fdecef; }
.status-pill.neutral { color: #875710; background: #fff4dd; }
.empty-state { margin: 0; padding: 3.5rem 1.4rem; color: var(--muted); text-align: center; font-size: 0.8rem; }

@media (max-width: 1100px) {
  .header-actions { max-width: 560px; }
  .last-updated { width: 100%; text-align: right; }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 82px minmax(0, 1fr); }
  .sidebar { padding-inline: 0.8rem; }
  .sidebar .brand > span:last-child, .sidebar-label, .nav-item > span:last-child, .service-state span:last-child { display: none; }
  .sidebar .brand, .nav-item { justify-content: center; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 650px) {
  .connect-view { padding: 1rem; }
  .connect-card { padding: 1.6rem; border-radius: 20px; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 1rem; flex-direction: row; align-items: center; }
  .sidebar nav { display: flex; margin-left: auto; }
  .sidebar-bottom, .sidebar-label { display: none; }
  .nav-item { width: auto; }
  main { padding: 1.4rem 1rem 3rem; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; max-width: none; justify-content: flex-start; }
  .last-updated { width: 100%; text-align: left; }
  .secondary-button { flex: 1; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 145px; }
}
