:root {
  --bg: #f2f4f8;
  --bg-accent: #e6eaf2;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgb(79 70 229 / 10%);
  --accent-glow: rgb(79 70 229 / 22%);
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --ok-border: #a7f3d0;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --border: rgb(15 23 42 / 8%);
  --border-strong: rgb(15 23 42 / 12%);
  --shadow: 0 1px 2px rgb(15 23 42 / 4%), 0 10px 28px rgb(15 23 42 / 6%);
  --shadow-lg: 0 8px 16px rgb(15 23 42 / 5%), 0 24px 48px rgb(15 23 42 / 8%);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 0.75rem;
  --radius-sm: 0.55rem;
  --radius-lg: 1rem;
  --sidebar-width: 17rem;
  --topbar-height: 3.5rem;
  --sidebar-bg: #0b0f19;
  --sidebar-bg-elevated: #121827;
  --sidebar-border: rgb(255 255 255 / 7%);
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #e2e8f0;
  --sidebar-text-active: #f8fafc;
  --sidebar-active-bg: rgb(99 102 241 / 18%);
  --sidebar-active-border: rgb(129 140 248 / 45%);
  --metric-color: #1e1b4b;
  --metric-accent: #6366f1;
  --glass: rgb(255 255 255 / 78%);
  --glass-border: rgb(255 255 255 / 65%);
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 70% at 0% -20%, rgb(99 102 241 / 9%), transparent 55%),
    radial-gradient(ellipse 70% 55% at 100% 0%, rgb(14 165 233 / 7%), transparent 50%),
    linear-gradient(180deg, #f8faff 0%, var(--bg) 46%, var(--bg-accent) 100%);
  background-attachment: fixed;
}

a { color: var(--accent); }

/* —— App shell (sidebar) —— */
.app-body { min-height: 100vh; }

.app-shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background:
    linear-gradient(180deg, var(--sidebar-bg) 0%, #090d15 100%);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  box-shadow: 12px 0 40px rgb(0 0 0 / 18%);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1.15rem 1.1rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand a {
  color: var(--sidebar-text-active);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 1.02rem;
}

.sidebar-close {
  display: none;
  border: 0;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 0.15rem 0.35rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem 0.75rem;
  overflow-y: auto;
  flex: 1;
}

.nav-link,
.nav-sublink {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--sidebar-text);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.58rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.nav-link:hover,
.nav-sublink:hover {
  color: var(--sidebar-text-hover);
  background: rgb(255 255 255 / 4%);
}

.nav-link.is-active,
.nav-sublink.is-active {
  color: var(--sidebar-text-active);
  background: var(--sidebar-active-bg);
  border-color: var(--sidebar-active-border);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 4%);
}

.nav-group .nav-sub {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.15rem 0 0.25rem 0.65rem;
}

.nav-sublink {
  font-size: 0.86rem;
  padding: 0.4rem 0.65rem;
}

.superadmin-box {
  margin-top: 0.35rem;
  padding: 0.65rem 0.55rem 0.55rem;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / 3%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 4%);
}

.superadmin-box-label {
  padding: 0 0.35rem 0.45rem;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: rgb(148 163 184 / 72%);
}

.superadmin-box-links {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.superadmin-box .nav-sublink {
  padding: 0.45rem 0.55rem;
}

.sidebar-footer {
  padding: 0.85rem 0.75rem 1rem;
  border-top: 1px solid var(--sidebar-border);
  display: grid;
  gap: 0.65rem;
  background: rgb(0 0 0 / 12%);
}

.sidebar-user {
  font-size: 0.82rem;
  color: var(--sidebar-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 0.25rem;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-logout-form {
  flex: 1;
  margin: 0;
  min-width: 0;
}

.btn-logout {
  width: 100%;
  min-height: 2.4rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / 4%);
  color: var(--sidebar-text);
  text-decoration: none;
  transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.icon-btn:hover {
  color: var(--sidebar-text-active);
  border-color: var(--sidebar-active-border);
  background: var(--sidebar-active-bg);
}

.icon-btn.is-active {
  color: var(--sidebar-text-active);
  border-color: var(--sidebar-active-border);
  background: var(--sidebar-active-bg);
}

.sidebar .btn-ghost {
  border-color: var(--sidebar-border);
  background: rgb(255 255 255 / 3%);
  color: var(--sidebar-text-hover);
}

.sidebar .btn-ghost:hover {
  border-color: var(--sidebar-active-border);
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
}

.btn-block { width: 100%; }

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

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--topbar-height);
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.mobile-topbar .menu-toggle {
  flex-shrink: 0;
}

.mobile-title {
  flex: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.menu-toggle {
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.28rem;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.menu-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

.mobile-topbar .icon-btn {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--muted);
}

.mobile-topbar .icon-btn:hover,
.mobile-topbar .icon-btn.is-active {
  color: var(--accent);
  border-color: rgb(79 70 229 / 28%);
  background: var(--accent-soft);
}

.sidebar-backdrop {
  display: none;
}

.app-main {
  padding: 1.85rem 1.65rem 2.75rem;
  max-width: 56rem;
  width: 100%;
  margin: 0 auto;
  animation: rise 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.app-main.narrow { max-width: 28rem; }
.app-main.wide {
  max-width: 56rem;
  display: grid;
  gap: 1.25rem;
}

.app-main.wide > h1,
.app-main.wide > .admin-note,
.app-main.wide > .msg,
.app-main.wide > .page-toolbar {
  margin-bottom: 0;
}

.dashboard-hero {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 2rem 1.5rem;
  min-height: calc(100vh - var(--topbar-height));
}

h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--text);
}

h2 {
  margin: 0 0 1rem;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-secondary);
}

/* —— Forms —— */
form.stack { display: grid; gap: 1rem; }
form.stack.compact { max-width: 22rem; }

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  padding: 0.72rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

input[type="radio"],
input[type="checkbox"] {
  width: auto;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: none;
}

select {
  appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  cursor: pointer;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  background: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6rem;
  padding: 0.55rem 1.05rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #fff;
  font: inherit;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 1px 2px rgb(79 70 229 / 18%), 0 8px 20px rgb(79 70 229 / 18%);
  transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.btn:hover {
  background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 2px 4px rgb(79 70 229 / 22%), 0 10px 24px rgb(79 70 229 / 22%);
}
.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn:disabled:hover {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  box-shadow: 0 1px 2px rgb(79 70 229 / 12%);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease;
}

.btn-ghost:hover {
  border-color: rgb(79 70 229 / 28%);
  background: var(--accent-soft);
  color: var(--accent);
}

.msg {
  margin: 0 0 1rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.msg-error {
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.msg-success {
  border: 1px solid var(--ok-border);
  background: var(--ok-bg);
  color: var(--ok);
}

.msg-warning {
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn);
}

.msg-info {
  border: 1px solid rgb(79 70 229 / 22%);
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.sync-error-list {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.9rem;
}

.sync-error-list-title {
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.sync-error-list ul {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.45rem;
}

.sync-error-list li {
  overflow-wrap: anywhere;
}

.sync-error-platform {
  color: var(--muted);
  font-weight: 500;
}

.user-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.user-list li {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.user-list li:last-child { border-bottom: 0; }

.user-list .user-email {
  overflow-wrap: anywhere;
}

.dashboard-main {
  max-width: 56rem;
}

.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 1rem;
}

.client-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  min-height: 8.5rem;
  padding: 1.15rem 1.2rem;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgb(255 255 255 / 96%) 0%, rgb(248 250 252 / 92%) 100%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.client-card-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.35;
  word-break: break-word;
  color: var(--text);
}

.client-card-body {
  display: grid;
  gap: 0.65rem;
}

.client-card-metrics {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.client-card-metric-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.client-card-metrics .client-card-metric-row:first-child {
  padding-top: 0;
}

.client-card-metrics .client-card-metric-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.client-card-metric-platform {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--metric-accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.client-card-metric-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  word-break: break-word;
}

.client-card-metric-values {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
  margin-top: 0.28rem;
}

.client-card-metric {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  font-variant-numeric: tabular-nums;
}

.client-card-metric strong {
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--metric-color);
}

.client-card-metric-unit {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.btn-sm {
  align-self: flex-start;
  min-height: 2.15rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.88rem;
}

.detail-list {
  margin: 0 0 1.5rem;
  padding: 0;
}

.detail-list div {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.detail-list dt {
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.detail-list dd {
  margin: 0;
  font-size: 1rem;
}

.detail-list code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.92em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.15rem 0.4rem;
  border-radius: 0.3rem;
}

.netion-mark {
  margin: 0;
  font-size: clamp(2.8rem, 12vw, 9rem);
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1;
  color: var(--accent);
  opacity: 0.1;
  user-select: none;
  text-align: center;
  padding-left: 0.16em;
  animation: netion-fade 700ms ease-out;
}

@keyframes netion-fade {
  from {
    opacity: 0;
    transform: scale(0.96);
    letter-spacing: 0.28em;
  }
  to {
    opacity: 0.14;
    transform: scale(1);
    letter-spacing: 0.18em;
  }
}

.page-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.page-toolbar h1 {
  margin: 0;
  line-height: 2.6rem;
}

.page-toolbar-actions {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-items: end;
  gap: 0.45rem 0.65rem;
  margin-left: auto;
}

.page-toolbar-actions form {
  margin: 0;
}

.last-sync-label {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.integration-field[hidden] {
  display: none !important;
}

.date-range-dropdown {
  position: relative;
}

.date-range-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.6rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 180ms ease, box-shadow 180ms ease, color 180ms ease;
}

.date-range-trigger:hover,
.date-range-dropdown.is-open .date-range-trigger {
  border-color: rgb(79 70 229 / 28%);
  color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.date-range-trigger-caret {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translateY(-1px);
  transition: transform 160ms ease;
}

.date-range-dropdown.is-open .date-range-trigger-caret {
  transform: rotate(-135deg) translateY(1px);
}

.date-range-panel {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 20;
  width: min(20rem, calc(100vw - 2rem));
  padding: 0.85rem;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 96%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
}

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

.date-range-presets {
  display: grid;
  gap: 0.35rem;
}

.date-range-preset {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
}

.date-range-preset:hover,
.date-range-preset.is-active {
  border-color: var(--border);
  background: var(--bg);
  color: var(--accent);
}

.date-range-custom {
  display: grid;
  gap: 0.65rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.date-range-custom-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.date-range-custom-fields {
  display: grid;
  gap: 0.65rem;
}

.date-range-custom label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.date-range-custom input[type="date"] {
  width: 100%;
}

.credential-mode-fieldset {
  margin: 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.credential-mode-fieldset legend {
  padding: 0 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.credential-mode-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.radio-option {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  color: var(--text);
}

.settings-list {
  display: grid;
  gap: 0.75rem;
}

.settings-card {
  display: block;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: border-color 160ms ease;
}

.settings-card:hover { border-color: #b8c5d3; }
.settings-card strong { display: block; margin-bottom: 0.2rem; }
.settings-card span { color: var(--muted); font-size: 0.9rem; }

.integrations-section {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.integrations-section h2 {
  margin: 0 0 0.35rem;
  font-size: 1.02rem;
}

.integration-list {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.integration-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.integration-item-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.integration-platform {
  color: var(--muted);
  font-size: 0.85rem;
}

.integration-item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.integration-item-actions .link-danger {
  min-height: 2.15rem;
  padding: 0.4rem 0.35rem;
  display: inline-flex;
  align-items: center;
}

.inline-form {
  display: inline;
  margin: 0;
}

.integration-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.75rem;
  margin-top: 1rem;
}

.integration-add-form label {
  grid-column: 1 / -1;
  margin: 0;
}

.integration-add-form select {
  min-height: 2.75rem;
  font-size: 0.95rem;
  color: var(--text);
}

.integration-add-form select:invalid,
.integration-add-form select option[value=""] {
  color: var(--muted);
}

.integration-add-form .btn {
  min-height: 2.75rem;
  padding-inline: 1.15rem;
  white-space: nowrap;
}

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

.data-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  min-width: 28rem;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.data-table th,
.data-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: #f8fafc;
}

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

.data-table code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.88em;
  color: var(--accent);
  background: #eef5fa;
  padding: 0.15rem 0.4rem;
  border-radius: 0.3rem;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.row-actions a {
  text-decoration: none;
  font-weight: 500;
}

.row-actions form { margin: 0; }

.link-danger {
  border: 0;
  background: none;
  padding: 0;
  color: var(--danger);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

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

.empty-state {
  margin: 0;
  color: var(--muted);
}

.hint {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.form-actions .btn-ghost {
  text-decoration: none;
  min-height: 2.6rem;
  padding: 0.55rem 1rem;
}

.admin-note {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  padding: 0.65rem 0.8rem;
}

/* —— Login —— */
body.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 10% -10%, rgb(99 102 241 / 12%), transparent 55%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgb(14 165 233 / 10%), transparent 50%),
    linear-gradient(165deg, #f8faff 0%, #eef2f8 100%);
}

.login-card {
  width: min(100%, 24rem);
  padding: 2.1rem 1.85rem;
  background: rgb(255 255 255 / 92%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: rise 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.login-card h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.55rem, 6vw, 1.95rem);
  font-weight: 800;
  letter-spacing: -0.035em;
}

.login-card .sub {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.login-card .btn { width: 100%; margin-top: 0.25rem; }

.login-footer {
  margin: 1.25rem 0 0;
  text-align: center;
  font-size: 0.9rem;
}

.login-footer a {
  color: var(--muted);
  text-decoration: none;
}

.login-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

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

/* —— Mobile / tablet —— */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform 200ms ease;
    box-shadow: var(--shadow);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-close { display: inline-flex; }

  .mobile-topbar { display: flex; }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgb(16 24 40 / 35%);
    z-index: 30;
  }

  .sidebar-backdrop[hidden] { display: none; }

  .app-main {
    padding: 1.25rem 1rem 2rem;
  }

  .page-toolbar .btn {
    width: 100%;
  }

  .page-toolbar {
    align-items: stretch;
  }

  .page-toolbar-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .last-sync-label {
    text-align: left;
  }

  .date-range-dropdown,
  .date-range-trigger {
    width: 100%;
  }

  .date-range-trigger {
    justify-content: space-between;
  }

  .date-range-panel {
    left: 0;
    right: 0;
    width: auto;
  }
}

@media (max-width: 640px) {
  .login-card { padding: 1.5rem 1.25rem; }

  .data-table {
    font-size: 0.9rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.7rem 0.75rem;
  }

  .row-actions {
    justify-content: flex-start;
  }

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

  .form-actions .btn,
  .form-actions .btn-ghost {
    width: 100%;
  }

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

  .integration-add-form .btn {
    width: 100%;
  }
}
