/* CloudDesk platform UI — design tokens and core primitives */

:root {
  --cd-brand: #4f6ef7;
  --cd-brand-strong: #3a56dd;
  --cd-brand-soft: #eef1fe;

  --cd-bg: #f4f6fb;
  --cd-surface: #ffffff;
  --cd-surface-muted: #f8fafc;
  --cd-border: #e2e7f0;
  --cd-border-strong: #cdd5e3;

  --cd-text: #101828;
  --cd-text-soft: #475467;
  --cd-muted: #667085;
  --cd-faint: #98a2b3;

  --cd-success: #12b76a;
  --cd-success-soft: #e7f8ef;
  --cd-warning: #f79009;
  --cd-warning-soft: #fef4e6;
  --cd-danger: #f04438;
  --cd-danger-soft: #fdeceb;
  --cd-info: #1570ef;
  --cd-info-soft: #eaf3ff;

  --cd-ink: #131a2b;
  --cd-ink-soft: #1c2438;
  --cd-ink-text: #cfd6e6;
  --cd-ink-muted: #8b95ad;

  --cd-radius-sm: 8px;
  --cd-radius: 12px;
  --cd-radius-lg: 18px;
  --cd-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --cd-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
  --cd-shadow-lg: 0 24px 48px rgba(16, 24, 40, 0.14);
  --cd-font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --cd-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --cd-sidebar: 264px;
}

html[data-theme="dark"] {
  --cd-bg: #0b1020;
  --cd-surface: #131a2b;
  --cd-surface-muted: #182033;
  --cd-border: #253049;
  --cd-border-strong: #33415e;
  --cd-text: #eef2fa;
  --cd-text-soft: #c3cbdd;
  --cd-muted: #96a1ba;
  --cd-faint: #77839c;
  --cd-brand-soft: #1e2545;
  --cd-success-soft: #0f2c22;
  --cd-warning-soft: #322310;
  --cd-danger-soft: #33191a;
  --cd-info-soft: #12233f;
  --cd-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--cd-font);
  background: var(--cd-bg);
  color: var(--cd-text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cd-brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 0.4rem; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75rem; }
small { font-size: 0.82rem; }
code, pre, .mono { font-family: var(--cd-mono); font-size: 0.85rem; }
hr { border: none; border-top: 1px solid var(--cd-border); margin: 1.25rem 0; }

.muted { color: var(--cd-muted); }
.faint { color: var(--cd-faint); }
.soft { color: var(--cd-text-soft); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mono-small { font-family: var(--cd-mono); font-size: 0.78rem; }
.truncate { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 0.35rem; }
.row { display: flex; align-items: center; gap: 0.6rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.gap-sm { gap: 0.4rem; } .gap { gap: 0.75rem; } .gap-lg { gap: 1.25rem; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.hide { display: none !important; }

/* ---------- buttons ---------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.95rem;
  border-radius: var(--cd-radius-sm);
  border: 1px solid var(--cd-border-strong);
  background: var(--cd-surface);
  color: var(--cd-text);
  font-size: 0.86rem;
  font-weight: 560;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--cd-surface-muted); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-loading { opacity: 0.65; pointer-events: none; }
.btn-primary { background: var(--cd-brand); border-color: var(--cd-brand); color: #fff; }
.btn-primary:hover { background: var(--cd-brand-strong); border-color: var(--cd-brand-strong); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--cd-text-soft); }
.btn-ghost:hover { background: var(--cd-surface-muted); color: var(--cd-text); }
.btn-danger { background: var(--cd-danger); border-color: var(--cd-danger); color: #fff; }
.btn-danger:hover { background: #d92d20; border-color: #d92d20; }
.btn-danger-ghost { color: var(--cd-danger); background: var(--cd-danger-soft); border-color: transparent; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.79rem; }
.btn-lg { padding: 0.7rem 1.3rem; font-size: 0.95rem; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: 0.5rem; flex-wrap: wrap; }

.spinner {
  width: 0.85rem; height: 0.85rem; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: cd-spin 0.7s linear infinite; display: none;
}
.btn.is-loading .spinner { display: inline-block; }
@keyframes cd-spin { to { transform: rotate(360deg); } }

/* ---------- form controls ---------------------------------------------- */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.field > label { font-weight: 560; font-size: 0.85rem; color: var(--cd-text-soft); }
.field .hint { font-size: 0.78rem; color: var(--cd-muted); }
.field .error { font-size: 0.78rem; color: var(--cd-danger); }
.field.required > label::after { content: " *"; color: var(--cd-danger); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="number"], input[type="date"], input[type="url"], select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: var(--cd-radius-sm);
  border: 1px solid var(--cd-border-strong);
  background: var(--cd-surface);
  color: var(--cd-text);
  font-family: inherit;
  font-size: 0.88rem;
}
textarea { min-height: 108px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--cd-brand);
  box-shadow: 0 0 0 3px var(--cd-brand-soft);
}
input[readonly] { background: var(--cd-surface-muted); color: var(--cd-muted); }
.checkbox { display: flex; align-items: flex-start; gap: 0.55rem; font-size: 0.86rem; color: var(--cd-text-soft); }
.checkbox input { margin-top: 0.2rem; }
.input-affix { position: relative; }
.input-affix input { padding-right: 4.6rem; }
.input-affix .affix-btn {
  position: absolute; right: 0.4rem; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; color: var(--cd-muted); font-size: 0.78rem;
  cursor: pointer; font-family: inherit; padding: 0.25rem 0.4rem; border-radius: 6px;
}
.input-affix .affix-btn:hover { background: var(--cd-surface-muted); color: var(--cd-text); }
.strength { display: flex; gap: 0.3rem; margin-top: 0.35rem; }
.strength span { height: 4px; flex: 1; border-radius: 99px; background: var(--cd-border); }
.strength[data-score="1"] span:nth-child(1) { background: var(--cd-danger); }
.strength[data-score="2"] span:nth-child(-n+2) { background: var(--cd-warning); }
.strength[data-score="3"] span:nth-child(-n+3) { background: var(--cd-info); }
.strength[data-score="4"] span { background: var(--cd-success); }

/* ---------- badges, chips ---------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.15rem 0.55rem; border-radius: 999px;
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.01em;
  background: var(--cd-surface-muted); color: var(--cd-text-soft);
  border: 1px solid var(--cd-border);
}
.badge-success { background: var(--cd-success-soft); color: #067647; border-color: transparent; }
.badge-warning { background: var(--cd-warning-soft); color: #b54708; border-color: transparent; }
.badge-danger { background: var(--cd-danger-soft); color: #b42318; border-color: transparent; }
.badge-info { background: var(--cd-info-soft); color: #175cd3; border-color: transparent; }
.badge-brand { background: var(--cd-brand-soft); color: var(--cd-brand-strong); border-color: transparent; }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.7rem; border-radius: 999px; font-size: 0.8rem;
  border: 1px solid var(--cd-border); background: var(--cd-surface); color: var(--cd-text-soft);
}
.chip:hover { text-decoration: none; border-color: var(--cd-border-strong); }
.chip.is-active { background: var(--cd-brand); border-color: var(--cd-brand); color: #fff; }
.severity-info { color: var(--cd-info); }
.severity-warning { color: var(--cd-warning); }
.severity-critical { color: var(--cd-danger); }

/* ---------- cards and stats ------------------------------------------- */

.card {
  background: var(--cd-surface);
  border: 1px solid var(--cd-border);
  border-radius: var(--cd-radius);
  box-shadow: var(--cd-shadow-sm);
}
.card-header {
  padding: 0.95rem 1.15rem;
  border-bottom: 1px solid var(--cd-border);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.card-header h2, .card-header h3 { margin: 0; }
.card-body { padding: 1.15rem; }
.card-footer {
  padding: 0.8rem 1.15rem; border-top: 1px solid var(--cd-border);
  background: var(--cd-surface-muted); border-radius: 0 0 var(--cd-radius) var(--cd-radius);
}
.card-link { display: block; color: inherit; }
.card-link:hover { text-decoration: none; border-color: var(--cd-brand); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.stat-card { padding: 1.1rem 1.15rem; background: var(--cd-surface); border: 1px solid var(--cd-border); border-radius: var(--cd-radius); }
.stat-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--cd-muted); font-weight: 600; }
.stat-value { font-size: 1.65rem; font-weight: 680; margin: 0.25rem 0 0.15rem; letter-spacing: -0.02em; }
.stat-meta { font-size: 0.8rem; color: var(--cd-muted); display: flex; align-items: center; gap: 0.35rem; }
.stat-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--cd-brand-soft); color: var(--cd-brand-strong); }
.stat-icon svg { width: 18px; height: 18px; }

.progress { height: 7px; border-radius: 99px; background: var(--cd-border); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: var(--cd-brand); }
.progress.is-success > span { background: var(--cd-success); }
.progress.is-warning > span { background: var(--cd-warning); }
.progress.is-danger > span { background: var(--cd-danger); }
.progress-hero { height: 10px; }

.trend { display: flex; align-items: flex-end; gap: 4px; height: 72px; }
.trend span { flex: 1; background: linear-gradient(180deg, var(--cd-brand), #8ba1ff); border-radius: 4px 4px 2px 2px; min-height: 6px; }
.trend-legend { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--cd-faint); margin-top: 0.5rem; }

/* ---------- tables ----------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
table.table thead th {
  text-align: left; padding: 0.7rem 1rem; background: var(--cd-surface-muted);
  color: var(--cd-muted); font-weight: 600; font-size: 0.76rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--cd-border); white-space: nowrap;
}
table.table tbody td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--cd-border); vertical-align: middle; }
table.table tbody tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: var(--cd-surface-muted); }
table.table td.actions { text-align: right; white-space: nowrap; }
table.table .primary-cell { font-weight: 580; }
table.table th a { color: inherit; }
.table-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.75rem; padding: 0.9rem 1.15rem; border-bottom: 1px solid var(--cd-border);
}
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.filters select, .filters input[type="search"] { width: auto; min-width: 150px; }

/* ---------- avatars ---------------------------------------------------- */

.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--cd-brand); color: #fff; font-size: 0.78rem; font-weight: 650;
  letter-spacing: 0.02em; flex: 0 0 auto; overflow: hidden;
}
.avatar-sm { width: 26px; height: 26px; font-size: 0.68rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }
.avatar-xl { width: 76px; height: 76px; font-size: 1.5rem; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -8px; border: 2px solid var(--cd-surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- lists, timelines, key-value ------------------------------- */

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 0.8rem 1.15rem; border-bottom: 1px solid var(--cd-border); display: flex; gap: 0.8rem; align-items: flex-start; }
.list > li:last-child { border-bottom: none; }
.list > li:hover { background: var(--cd-surface-muted); }
.list-compact > li { padding: 0.55rem 1.15rem; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 0.25rem; }
.timeline li { position: relative; padding: 0 0 1rem 1.4rem; border-left: 1px solid var(--cd-border); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -0.32rem; top: 0.35rem;
  width: 0.6rem; height: 0.6rem; border-radius: 50%;
  background: var(--cd-surface); border: 2px solid var(--cd-brand);
}
.timeline li.is-warning::before { border-color: var(--cd-warning); }
.timeline li.is-critical::before { border-color: var(--cd-danger); }
.timeline .when { font-size: 0.76rem; color: var(--cd-faint); }

.kv { display: grid; grid-template-columns: minmax(140px, 34%) 1fr; gap: 0.45rem 1rem; font-size: 0.87rem; }
.kv dt { color: var(--cd-muted); }
.kv dd { margin: 0; color: var(--cd-text); word-break: break-word; }

.skeleton { background: linear-gradient(90deg, var(--cd-surface-muted), var(--cd-border), var(--cd-surface-muted)); background-size: 200% 100%; animation: cd-shimmer 1.3s infinite; border-radius: 6px; height: 0.9rem; }
.skeleton.line { margin-bottom: 0.6rem; }
.skeleton.w-40 { width: 40%; } .skeleton.w-60 { width: 60%; } .skeleton.w-80 { width: 80%; }
@keyframes cd-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- application shell ----------------------------------------- */

.app-shell { display: grid; grid-template-columns: var(--cd-sidebar) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  background: var(--cd-ink);
  color: var(--cd-ink-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 1.05rem 1.15rem; border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: #fff; font-weight: 660; font-size: 1rem; letter-spacing: -0.01em;
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand svg { width: 26px; height: 26px; }
.sidebar-brand .brand-sub { display: block; font-size: 0.68rem; font-weight: 500; color: var(--cd-ink-muted); letter-spacing: 0.04em; text-transform: uppercase; }
.sidebar-workspace {
  margin: 0.9rem 0.85rem 0.35rem; padding: 0.7rem 0.75rem;
  background: rgba(255, 255, 255, 0.05); border-radius: var(--cd-radius-sm);
  display: flex; align-items: center; gap: 0.6rem;
}
.sidebar-workspace .avatar { background: rgba(255, 255, 255, 0.14); }
.sidebar-workspace .meta { min-width: 0; }
.sidebar-workspace .name { color: #fff; font-weight: 600; font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-workspace .plan { font-size: 0.7rem; color: var(--cd-ink-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: 0.6rem 0.6rem 1.2rem; }
.sidebar-section { margin-top: 1rem; }
.sidebar-section > span {
  display: block; padding: 0 0.55rem 0.35rem;
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--cd-ink-muted);
}
.sidebar-link {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.5rem 0.6rem; border-radius: var(--cd-radius-sm);
  color: var(--cd-ink-text); font-size: 0.87rem; font-weight: 520;
  text-decoration: none; margin-bottom: 0.1rem;
}
.sidebar-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }
.sidebar-link.is-active { background: var(--cd-brand); color: #fff; }
.sidebar-link svg { width: 17px; height: 17px; opacity: 0.9; }
.sidebar-link .count { margin-left: auto; font-size: 0.72rem; background: rgba(255, 255, 255, 0.14); border-radius: 999px; padding: 0.05rem 0.45rem; }
.sidebar-foot { padding: 0.85rem; border-top: 1px solid rgba(255, 255, 255, 0.07); font-size: 0.74rem; color: var(--cd-ink-muted); }
.sidebar-foot a { color: var(--cd-ink-text); }

.app-main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.65rem 1.4rem;
  background: var(--cd-surface);
  border-bottom: 1px solid var(--cd-border);
}
.topbar-search { flex: 1 1 auto; max-width: 460px; position: relative; }
.topbar-search input { padding-left: 2.1rem; background: var(--cd-surface-muted); }
.topbar-search .icon { position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%); color: var(--cd-faint); }
.topbar-search .icon svg { width: 15px; height: 15px; }
.topbar-actions { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; }
.icon-btn {
  position: relative; display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: var(--cd-radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--cd-text-soft); cursor: pointer;
}
.icon-btn:hover { background: var(--cd-surface-muted); color: var(--cd-text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot {
  position: absolute; top: 4px; right: 4px; min-width: 17px; height: 17px; padding: 0 3px;
  border-radius: 999px; background: var(--cd-danger); color: #fff;
  font-size: 0.62rem; font-weight: 700; display: grid; place-items: center;
}
.menu-toggle { display: none; }
.user-chip { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.5rem 0.25rem 0.25rem; border-radius: 999px; border: 1px solid var(--cd-border); background: var(--cd-surface); cursor: pointer; }
.user-chip:hover { background: var(--cd-surface-muted); }
.user-chip .who { font-size: 0.82rem; font-weight: 570; }
.user-chip .who span { display: block; font-size: 0.7rem; color: var(--cd-muted); font-weight: 500; }

.dropdown { position: relative; }
.dropdown-panel {
  position: absolute; right: 0; top: calc(100% + 0.45rem); z-index: 60;
  min-width: 290px; background: var(--cd-surface); border: 1px solid var(--cd-border);
  border-radius: var(--cd-radius); box-shadow: var(--cd-shadow-lg); display: none; overflow: hidden;
}
.dropdown-panel.is-open { display: block; }
.dropdown-panel.wide { width: 370px; }
.dropdown-header { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--cd-border); display: flex; align-items: center; justify-content: space-between; }
.dropdown-body { max-height: 330px; overflow-y: auto; }
.dropdown-footer { padding: 0.55rem 0.9rem; border-top: 1px solid var(--cd-border); background: var(--cd-surface-muted); text-align: center; font-size: 0.82rem; }
.dropdown-item { display: flex; gap: 0.65rem; padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--cd-border); color: inherit; }
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--cd-surface-muted); text-decoration: none; }
.dropdown-item .title { font-weight: 570; font-size: 0.85rem; }
.dropdown-item .body { font-size: 0.79rem; color: var(--cd-muted); }
.dropdown-item .when { font-size: 0.72rem; color: var(--cd-faint); }
.dropdown-item.is-unread { background: var(--cd-brand-soft); }
.dropdown-form { margin: 0; }

.page { padding: 1.5rem 1.4rem 3rem; max-width: 1440px; width: 100%; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-header .lead { color: var(--cd-muted); font-size: 0.9rem; max-width: 70ch; }
.breadcrumbs { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--cd-muted); margin-bottom: 0.55rem; }
.breadcrumbs a { color: var(--cd-muted); }
.breadcrumbs .sep { color: var(--cd-faint); }
.breadcrumbs .current { color: var(--cd-text-soft); font-weight: 550; }

.grid { display: grid; gap: 1.15rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.grid-cards { display: grid; gap: 1.15rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.span-2 { grid-column: span 2; }

/* ---------- public marketing site ------------------------------------- */

.public-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--cd-surface); }
.public-header {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 1.5rem;
  padding: 0.85rem 2rem; border-bottom: 1px solid var(--cd-border); background: var(--cd-surface);
}
.public-brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 660; font-size: 1.05rem; color: var(--cd-text); }
.public-brand:hover { text-decoration: none; }
.public-brand svg { width: 28px; height: 28px; }
.public-nav { display: flex; gap: 1.35rem; font-size: 0.88rem; }
.public-nav a { color: var(--cd-text-soft); font-weight: 520; }
.public-nav a:hover { color: var(--cd-brand); text-decoration: none; }
.public-header .actions { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.public-body { flex: 1 1 auto; }
.site-footer { background: var(--cd-ink); color: var(--cd-ink-text); padding: 3rem 2rem 1.5rem; margin-top: 4rem; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 2rem; max-width: 1180px; margin: 0 auto; }
.site-footer h4 { color: #fff; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.07em; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; font-size: 0.87rem; }
.site-footer a { color: var(--cd-ink-text); }
.site-footer a:hover { color: #fff; }
.footer-note { max-width: 1180px; margin: 2.5rem auto 0; padding-top: 1.2rem; border-top: 1px solid rgba(255,255,255,0.08); display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; font-size: 0.8rem; color: var(--cd-ink-muted); }

.hero { padding: 4.5rem 2rem 3.5rem; max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: 1.05fr 1fr; gap: 3rem; align-items: center; }
.hero h1 { font-size: 2.7rem; line-height: 1.1; letter-spacing: -0.03em; }
.hero p.lead { font-size: 1.08rem; color: var(--cd-text-soft); max-width: 46ch; }
.eyebrow { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.76rem; font-weight: 620; text-transform: uppercase; letter-spacing: 0.09em; color: var(--cd-brand); background: var(--cd-brand-soft); padding: 0.3rem 0.7rem; border-radius: 999px; }
.hero-art { background: var(--cd-ink); border-radius: var(--cd-radius-lg); padding: 1.1rem; box-shadow: var(--cd-shadow-lg); color: var(--cd-ink-text); }
.hero-art .mock-bar { display: flex; gap: 0.35rem; margin-bottom: 0.9rem; }
.hero-art .mock-bar span { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,0.2); }
.hero-art .mock-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }
.hero-art .mock-card { background: rgba(255,255,255,0.06); border-radius: 10px; padding: 0.8rem; }
.hero-art .mock-card strong { display: block; font-size: 1.25rem; color: #fff; }
.hero-art .mock-card span { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--cd-ink-muted); }
.hero-art .mock-rows { margin-top: 0.7rem; display: flex; flex-direction: column; gap: 0.45rem; }
.hero-art .mock-row { height: 10px; border-radius: 99px; background: rgba(255,255,255,0.1); }
.hero-art .mock-row.w1 { width: 88%; } .hero-art .mock-row.w2 { width: 64%; } .hero-art .mock-row.w3 { width: 76%; }

.section { max-width: 1180px; margin: 0 auto; padding: 3.5rem 2rem; }
.section-head { max-width: 62ch; margin-bottom: 2rem; }
.section-head h2 { font-size: 1.85rem; letter-spacing: -0.02em; }
.section-alt { background: var(--cd-bg); }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; }
.feature .icon-wrap { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--cd-brand-soft); color: var(--cd-brand-strong); margin-bottom: 0.75rem; }
.feature .icon-wrap svg { width: 20px; height: 20px; }
.feature h3 { font-size: 1rem; }
.feature p { color: var(--cd-muted); font-size: 0.9rem; }
.logo-row { display: flex; flex-wrap: wrap; gap: 2.5rem; align-items: center; opacity: 0.75; font-weight: 650; color: var(--cd-muted); }
.logo-row span { font-size: 1.05rem; letter-spacing: -0.01em; }

.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 1.5rem; }
.plan { border: 1px solid var(--cd-border); border-radius: var(--cd-radius-lg); padding: 1.6rem; background: var(--cd-surface); display: flex; flex-direction: column; }
.plan.is-highlight { border-color: var(--cd-brand); box-shadow: var(--cd-shadow-lg); position: relative; }
.plan.is-highlight::before { content: "Most popular"; position: absolute; top: -0.7rem; left: 1.5rem; background: var(--cd-brand); color: #fff; font-size: 0.7rem; font-weight: 620; padding: 0.2rem 0.6rem; border-radius: 999px; }
.plan .price { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; }
.plan .price small { font-size: 0.85rem; font-weight: 500; color: var(--cd-muted); display: block; }
.plan ul { list-style: none; padding: 0; margin: 1.2rem 0; display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.88rem; }
.plan li { display: flex; gap: 0.5rem; align-items: flex-start; color: var(--cd-text-soft); }
.plan li svg { width: 16px; height: 16px; color: var(--cd-success); flex: 0 0 auto; margin-top: 0.15rem; }

.prose { max-width: 74ch; }
.prose h2 { margin-top: 2rem; }
.prose h3 { margin-top: 1.5rem; }
.prose p, .prose li { color: var(--cd-text-soft); }
.prose ul { padding-left: 1.2rem; }

/* ---------- flash messages, banners, modals --------------------------- */

.flash-stack { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.25rem; }
.flash {
  display: flex; gap: 0.7rem; align-items: flex-start;
  padding: 0.75rem 0.95rem; border-radius: var(--cd-radius-sm);
  border: 1px solid var(--cd-border); background: var(--cd-surface); font-size: 0.88rem;
  box-shadow: var(--cd-shadow-sm);
}
.flash svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 0.1rem; }
.flash-success { background: var(--cd-success-soft); border-color: transparent; color: #05603a; }
.flash-error { background: var(--cd-danger-soft); border-color: transparent; color: #912018; }
.flash-warning { background: var(--cd-warning-soft); border-color: transparent; color: #93370d; }
.flash-info { background: var(--cd-info-soft); border-color: transparent; color: #1849a9; }
.flash .close { margin-left: auto; background: none; border: none; cursor: pointer; color: inherit; opacity: 0.6; font-size: 1rem; line-height: 1; }
.flash .close:hover { opacity: 1; }

.banner { display: flex; gap: 0.8rem; padding: 0.9rem 1.1rem; border-radius: var(--cd-radius); background: var(--cd-brand-soft); color: var(--cd-brand-strong); font-size: 0.88rem; align-items: flex-start; }
.banner-warning { background: var(--cd-warning-soft); color: #93370d; }
.banner-danger { background: var(--cd-danger-soft); color: #912018; }
.banner svg { width: 18px; height: 18px; flex: 0 0 auto; }
.banner .title { font-weight: 620; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, 0.55); z-index: 90; display: none; align-items: flex-start; justify-content: center; padding: 6vh 1rem 1rem; overflow-y: auto; }
.modal-backdrop.is-open { display: flex; }
.modal { background: var(--cd-surface); border-radius: var(--cd-radius-lg); width: 100%; max-width: 620px; box-shadow: var(--cd-shadow-lg); border: 1px solid var(--cd-border); }
.modal-header { padding: 1.05rem 1.25rem; border-bottom: 1px solid var(--cd-border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { margin: 0; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 0.9rem 1.25rem; border-top: 1px solid var(--cd-border); display: flex; justify-content: flex-end; gap: 0.6rem; background: var(--cd-surface-muted); border-radius: 0 0 var(--cd-radius-lg) var(--cd-radius-lg); }

.toast-host { position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 120; display: flex; flex-direction: column; gap: 0.6rem; }
.toast { background: var(--cd-ink); color: #fff; padding: 0.7rem 1rem; border-radius: var(--cd-radius-sm); font-size: 0.86rem; box-shadow: var(--cd-shadow-lg); min-width: 240px; }
.toast.is-success { background: #05603a; }
.toast.is-error { background: #912018; }

/* ---------- empty states, pagination, tabs ---------------------------- */

.empty-state { padding: 3rem 1.5rem; text-align: center; }
.empty-state .art { width: 56px; height: 56px; border-radius: 16px; background: var(--cd-brand-soft); color: var(--cd-brand-strong); display: grid; place-items: center; margin: 0 auto 1rem; }
.empty-state .art svg { width: 26px; height: 26px; }
.empty-state h3 { margin-bottom: 0.35rem; }
.empty-state p { color: var(--cd-muted); max-width: 46ch; margin: 0 auto 1.1rem; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.8rem 1.15rem; border-top: 1px solid var(--cd-border); font-size: 0.84rem; color: var(--cd-muted); flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 0.25rem; align-items: center; }
.pagination .pages a, .pagination .pages span {
  min-width: 32px; height: 32px; display: grid; place-items: center; padding: 0 0.45rem;
  border-radius: var(--cd-radius-sm); border: 1px solid var(--cd-border); color: var(--cd-text-soft); background: var(--cd-surface);
}
.pagination .pages a:hover { border-color: var(--cd-brand); color: var(--cd-brand); text-decoration: none; }
.pagination .pages .is-current { background: var(--cd-brand); border-color: var(--cd-brand); color: #fff; }
.pagination .pages .ellipsis { border-color: transparent; background: transparent; }

.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--cd-border); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs a { padding: 0.6rem 0.9rem; font-size: 0.87rem; color: var(--cd-muted); border-bottom: 2px solid transparent; font-weight: 540; }
.tabs a:hover { color: var(--cd-text); text-decoration: none; }
.tabs a.is-active { color: var(--cd-brand); border-bottom-color: var(--cd-brand); }
.tabs .count { font-size: 0.75rem; color: var(--cd-faint); margin-left: 0.3rem; }

/* ---------- report surfaces, diagnostics, error pages ----------------- */

pre.code-block, .code-block {
  background: var(--cd-ink); color: #e6ebf5; border-radius: var(--cd-radius);
  padding: 1rem; overflow-x: auto; font-family: var(--cd-mono); font-size: 0.8rem;
  line-height: 1.6; margin: 0; white-space: pre-wrap; word-break: break-word;
}
.report-body { background: var(--cd-surface); padding: 1.5rem; }
.report-body table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin: 1rem 0; }
.report-body th { text-align: left; padding: 0.5rem 0.6rem; background: var(--cd-bg); border-bottom: 1px solid var(--cd-border); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--cd-muted); }
.report-body td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--cd-border); }
.report-meta { display: flex; flex-wrap: wrap; gap: 1.5rem; padding: 0.85rem 1.15rem; background: var(--cd-surface-muted); border-bottom: 1px solid var(--cd-border); font-size: 0.8rem; color: var(--cd-muted); }
.raw-preview { font-family: var(--cd-mono); font-size: 0.8rem; white-space: pre-wrap; word-break: break-word; margin: 0; }
.text-preview { background: var(--cd-surface-muted); border-radius: var(--cd-radius-sm); padding: 0.9rem; font-family: var(--cd-mono); font-size: 0.78rem; white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; margin: 0; }

.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li { display: flex; gap: 0.7rem; padding: 0.7rem 0; border-bottom: 1px solid var(--cd-border); align-items: flex-start; }
.check-list li:last-child { border-bottom: none; }
.check-status { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; font-size: 0.72rem; font-weight: 700; background: var(--cd-success-soft); color: #067647; }
.check-status.warning { background: var(--cd-warning-soft); color: #b54708; }
.check-status.critical { background: var(--cd-danger-soft); color: #b42318; }

.error-page { min-height: 100vh; display: grid; place-items: center; padding: 3rem 1.5rem; }
.error-card { max-width: 520px; text-align: center; }
.error-code { font-size: 3.4rem; font-weight: 700; letter-spacing: -0.04em; color: var(--cd-brand); }

/* ---------- deterministic tone classes (CSP-safe, no inline styles) ---- */

.avatar.tone-0, .tone-bg-0 { background: #4f6ef7; }
.avatar.tone-1, .tone-bg-1 { background: #0ea5e9; }
.avatar.tone-2, .tone-bg-2 { background: #10b981; }
.avatar.tone-3, .tone-bg-3 { background: #f59e0b; }
.avatar.tone-4, .tone-bg-4 { background: #ef4444; }
.avatar.tone-5, .tone-bg-5 { background: #8b5cf6; }
.avatar.tone-6, .tone-bg-6 { background: #0f766e; }
.avatar { color: #fff; }

.file-icon {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--cd-surface-muted); color: var(--cd-text-soft);
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  border: 1px solid var(--cd-border); flex: 0 0 auto;
}
.file-icon.ext-pdf { background: #fdeceb; color: #b42318; border-color: transparent; }
.file-icon.ext-csv { background: #e7f8ef; color: #067647; border-color: transparent; }
.file-icon.ext-txt, .file-icon.ext-md { background: #eaf3ff; color: #175cd3; border-color: transparent; }
.file-icon.ext-json { background: #fef4e6; color: #b54708; border-color: transparent; }
.file-icon.ext-png, .file-icon.ext-jpg { background: #f3e8ff; color: #7c3aed; border-color: transparent; }
.file-icon.ext-zip { background: #eef1fe; color: var(--cd-brand-strong); border-color: transparent; }

.project-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: 0 0 auto; }

.stat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.stat-icon.tone { background: var(--cd-success-soft); color: #067647; }
.card-subtitle { font-size: 0.82rem; color: var(--cd-muted); }

.dropdown-button {
  display: block; width: 100%; border: 0; background: none; text-align: left;
  cursor: pointer; font-family: inherit; font-size: 0.87rem; color: var(--cd-text);
  padding: 0.55rem 0.9rem; margin: 0;
}
.dropdown-button:hover { background: var(--cd-surface-muted); }
#search-suggestions { left: 0; right: auto; width: 100%; min-width: 0; }
.brand-logo { display: block; flex: 0 0 auto; }
.footer-brand { margin-bottom: 0.75rem; }
.footer-name { color: #fff; }
.items-start { align-items: start; }
.items-center { align-items: center; }
.mw-560 { max-width: 560px; margin-left: auto; margin-right: auto; }
.mw-720 { max-width: 720px; margin-left: auto; margin-right: auto; }
.error-logo { margin: 0 auto 1rem; }








@media (max-width: 1080px) {
  .grid-main-side { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 80; transform: translateX(-100%);
    transition: transform 0.2s ease; box-shadow: var(--cd-shadow-lg);
  }
  body.is-nav-open .sidebar { transform: translateX(0); }
  .menu-toggle { display: grid; }
  .public-header { padding: 0.75rem 1.1rem; gap: 1rem; }
  .public-nav { display: none; }
  .page { padding: 1.1rem 1rem 3rem; }
  .topbar { padding: 0.6rem 1rem; }
  .hero { padding: 2.5rem 1.2rem; }
  .hero h1 { font-size: 2rem; }
  .section { padding: 2.25rem 1.2rem; }
  .site-footer { padding: 2.25rem 1.2rem 1.25rem; }
}
@media (max-width: 560px) {
  .footer-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.4rem; }
  .user-chip .who { display: none; }
}





