/* Linear-inspired dashboard skin on top of Material */

:root {
  --md-text-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --md-code-font: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  --bg: #08090a;
  --bg-elev: #0e0f11;
  --bg-hover: #131416;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.10);
  --text: #f7f8f8;
  --text-muted: #8a8f98;
  --text-faint: #62666d;
  --accent: #5e6ad2;
  --accent-soft: rgba(94, 106, 210, 0.14);
  --status-live: #4cb782;
  --status-pending: #f2994a;
  --status-disabled: #62666d;
}

[data-md-color-scheme="slate"] {
  --md-default-bg-color: var(--bg);
  --md-default-fg-color: var(--text);
  --md-default-fg-color--light: var(--text-muted);
  --md-default-fg-color--lighter: var(--text-faint);
  --md-primary-fg-color: var(--bg);
  --md-primary-bg-color: var(--text);
  --md-accent-fg-color: var(--accent);
  --md-typeset-a-color: var(--accent);
  --md-code-bg-color: var(--bg-elev);
  --md-code-fg-color: var(--text);
}

body, .md-typeset {
  font-feature-settings: "ss01", "cv11";
  letter-spacing: -0.005em;
  font-size: 14px;
}

/* ---------- Header: thin, no shadow, no tabs ---------- */
.md-header {
  background: var(--bg) !important;
  box-shadow: none;
  border-bottom: 1px solid var(--border);
  height: 48px;
}
.md-header__inner {
  padding: 0 1.5rem;
  height: 48px;
}
.md-header__title {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-left: 0.5rem;
}
.md-header__topic:first-child {
  font-weight: 600;
}
.md-tabs {
  display: none !important;
}
.md-search__form {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  height: 30px;
}
.md-search__input {
  font-size: 0.85rem;
}

/* ---------- Sidebar nav: tighter, denser ---------- */
.md-sidebar {
  width: 13rem;
}
.md-sidebar--primary {
  background: var(--bg);
  border-right: 1px solid var(--border);
}
.md-sidebar__scrollwrap {
  margin: 0;
}
.md-nav {
  font-size: 0.85rem;
}
.md-nav__title {
  display: none;
}
.md-nav__item {
  padding: 0;
}
.md-nav__link {
  padding: 0.5rem 0.75rem;
  margin: 0.05rem 0.5rem;
  border-radius: 6px;
  color: var(--text-muted);
  letter-spacing: -0.005em;
  font-weight: 500;
  transition: background 0.1s ease, color 0.1s ease;
}
.md-nav__link:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.md-nav__link--active,
.md-nav__link--active:focus {
  background: var(--bg-hover);
  color: var(--text) !important;
  font-weight: 600;
}

/* Hide right TOC sidebar */
.md-sidebar--secondary {
  display: none !important;
}

/* ---------- Main content area: dashboard-shaped ---------- */
.md-main__inner {
  margin-top: 0;
  max-width: none;
}
.md-content {
  max-width: 64rem;
  padding: 1.5rem 2rem 4rem;
  margin: 0 auto;
}
.md-content__inner {
  margin: 0;
  padding: 0;
}
.md-content__inner:before {
  display: none;
}
.md-content__button {
  display: none !important;
}
.md-typeset h1 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem !important;
  color: var(--text);
}
.md-typeset h1 + p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 2rem !important;
}
.md-typeset h2 {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-top: 2.5rem;
  border: none;
  padding: 0;
}
.md-typeset h3 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 1.5rem;
}

/* ---------- Card grid (functional) ---------- */
.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elev);
  margin: 0.75rem 0 2rem;
}
.action-card {
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  transition: background 0.1s ease;
  position: relative;
  min-height: 96px;
}
.action-card:hover {
  background: var(--bg-hover);
}
.action-card h3 {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.action-card h3 .twemoji,
.action-card h3 svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}
.action-card p {
  margin: 0 !important;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.5;
  flex: 1;
}
.action-card .meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--text-faint);
  font-family: var(--md-code-font);
  margin-top: auto;
}
.action-card .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-disabled);
  flex-shrink: 0;
}
.action-card .dot.live { background: var(--status-live); box-shadow: 0 0 0 3px rgba(76, 183, 130, 0.18); }
.action-card .dot.pending { background: var(--status-pending); }
.action-card .actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.action-card .run {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 5px;
  background: var(--accent);
  color: white !important;
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: opacity 0.1s ease;
}
.action-card .run:hover {
  opacity: 0.9;
}
.action-card .run.disabled {
  background: transparent;
  color: var(--text-faint) !important;
  border: 1px solid var(--border);
  pointer-events: none;
}

/* ---------- Stat row ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin: 0.75rem 0 2rem;
  background: var(--bg-elev);
}
.stat {
  padding: 1rem 1.2rem;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.stat:last-child { border-right: none; }
.stat .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 500;
}
.stat .value {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  font-feature-settings: "tnum";
}
.stat .delta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--md-code-font);
}

/* ---------- Tables: data-table style ---------- */
.md-typeset table:not([class]) {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.82rem;
  background: var(--bg-elev);
  box-shadow: none;
  margin: 0.75rem 0 2rem;
}
.md-typeset table:not([class]) th,
.md-typeset table:not([class]) td {
  padding: 0.55rem 0.85rem;
  border-color: var(--border);
}
.md-typeset table:not([class]) th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}
.md-typeset table:not([class]) tr:hover td {
  background: var(--bg-hover);
}

/* ---------- Code blocks ---------- */
.md-typeset code {
  font-size: 0.8em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
}
.md-typeset pre > code {
  font-size: 0.82em;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
}
.md-typeset .highlight {
  margin: 0.5rem 0 1.5rem;
}

/* ---------- Footer: minimal ---------- */
.md-footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.md-footer-meta {
  background: var(--bg);
  font-size: 0.75rem;
  color: var(--text-faint);
}
.md-footer-nav {
  display: none;
}

/* ---------- Greeting block (dashboard hero) ---------- */
.greeting {
  margin: 0.5rem 0 1.75rem;
  padding: 0.25rem 0;
}
.greeting__title {
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  background: linear-gradient(135deg, var(--text) 30%, color-mix(in srgb, var(--accent) 70%, var(--text)));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
}
.greeting__sub {
  margin-top: 0.35rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ---------- User pill (Cloudflare Access identity) ---------- */
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  padding: 0.25rem 0.5rem 0.25rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 16rem;
  height: 30px;
}
.user-pill__avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-hover) center/cover no-repeat;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
}
.user-pill__avatar--monogram {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #000));
  color: white;
}
.user-pill__text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  color: var(--text);
}
.user-pill__logout {
  color: var(--text-faint);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0 0.25rem;
  border: none !important;
  transition: color 0.1s ease;
}
.user-pill__logout:hover {
  color: var(--text);
}
.user-pill--anonymous {
  opacity: 0.6;
}

/* ---------- Profile page ---------- */
.profile {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  margin: 0.75rem 0 2rem;
  overflow: hidden;
}
.profile__head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.4rem;
  border-bottom: 1px solid var(--border);
}
.profile__avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-hover) center/cover no-repeat;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 600;
  flex-shrink: 0;
}
.profile__avatar--monogram {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #000));
  color: white;
}
.profile__title { flex: 1; min-width: 0; }
.profile__name {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.profile__email {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: var(--md-code-font);
  margin-top: 0.15rem;
  word-break: break-all;
}
.profile__logout {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--text-muted) !important;
  text-decoration: none;
  background: var(--bg);
  transition: color 0.1s ease, border-color 0.1s ease;
}
.profile__logout:hover {
  color: var(--text) !important;
  border-color: var(--border-strong);
}
.profile__grid {
  padding: 0.5rem 0;
}
.profile__row {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 1rem;
  padding: 0.5rem 1.4rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.profile__row:last-child { border-bottom: none; }
.profile__key {
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
  font-weight: 500;
  align-self: center;
}
.profile__val {
  color: var(--text);
  font-family: var(--md-code-font);
  word-break: break-all;
}
.profile[data-state="loading"] .profile__name::after {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-left: 0.5rem;
  border: 2px solid var(--text-faint);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.profile[data-state="anonymous"] {
  opacity: 0.7;
}
.raw-wrap pre {
  margin: 0.5rem 0 2rem;
  max-height: 24rem;
  overflow: auto;
}

/* ---------- Misc cleanup ---------- */
.md-typeset a {
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.1s ease;
}
.md-typeset a:hover {
  border-bottom-color: var(--accent);
}
.md-typeset hr {
  border-color: var(--border);
  margin: 2rem 0;
}
.md-typeset .admonition {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: 0.85rem;
}
