/* ==========================================================================
   AdQuill design system
   Space Grotesk (headings) + DM Sans (body), self hosted.
   Every rule lives here: templates never contain inline style attributes.
   ========================================================================== */

:root {
  /* Brand */
  --aq-brand: #1b5cff;
  --aq-brand-700: #1247cc;
  --aq-brand-600: #0e45d6;
  --aq-brand-300: #8fb0ff;
  --aq-brand-050: #eef3ff;
  --aq-accent: #ff7a18;
  --aq-accent-600: #e2620a;
  --aq-accent-050: #fff3e9;

  /* Ink and surface */
  --aq-ink: #0b1220;
  --aq-ink-800: #141c2e;
  --aq-ink-700: #1d2740;
  --aq-surface: #ffffff;
  --aq-surface-2: #f8fafd;
  --aq-bg: #f4f7fc;
  --aq-line: #e3e9f2;
  --aq-line-strong: #cdd7e6;

  /* Text */
  --aq-text: #0f172a;
  --aq-muted: #55657f;
  --aq-subtle: #8a99b3;

  /* Status */
  --aq-success: #128a45;
  --aq-success-bg: #e8f7ee;
  --aq-warning: #b45309;
  --aq-warning-bg: #fef3e2;
  --aq-danger: #c62828;
  --aq-danger-bg: #fdecec;
  --aq-info: #0e7490;
  --aq-info-bg: #e4f6fb;

  /* Shape */
  --aq-r-xs: 6px;
  --aq-r-sm: 9px;
  --aq-r: 13px;
  --aq-r-lg: 18px;
  --aq-r-xl: 26px;
  --aq-r-pill: 999px;

  /* Elevation */
  --aq-sh-xs: 0 1px 2px rgba(16, 24, 40, 0.06);
  --aq-sh-sm: 0 2px 6px -1px rgba(16, 24, 40, 0.08);
  --aq-sh: 0 8px 24px -8px rgba(16, 24, 40, 0.14);
  --aq-sh-lg: 0 28px 56px -20px rgba(16, 24, 40, 0.22);
  --aq-ring: 0 0 0 3px rgba(27, 92, 255, 0.28);

  /* Typography */
  --aq-font-head: "Space Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
  --aq-font-body: "DM Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --aq-font-mono: "SFMono-Regular", ui-monospace, "Menlo", "Consolas", monospace;

  /* Layout */
  --aq-sidebar-w: 266px;
  --aq-topbar-h: 66px;
  --aq-content-max: 1440px;

  /* Motion */
  --aq-t-fast: 140ms;
  --aq-t: 200ms;
  --aq-t-slow: 320ms;
  --aq-ease: cubic-bezier(0.2, 0.7, 0.3, 1);

  /* Stacking */
  --aq-z-base: 10;
  --aq-z-sticky: 20;
  --aq-z-dropdown: 30;
  --aq-z-modal: 40;
  --aq-z-toast: 50;
}

/* --------------------------------------------------------------------------
   Reset
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* The hidden attribute has to win over the display rule of a class, otherwise
   an element that is switched off with hidden stays visible. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--aq-font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--aq-text);
  background: var(--aq-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--aq-font-head);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.5em;
  letter-spacing: -0.015em;
  color: var(--aq-ink);
}

h1 { font-size: clamp(1.9rem, 1.3rem + 2vw, 2.75rem); }
h2 { font-size: clamp(1.45rem, 1.1rem + 1.2vw, 2rem); }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.02rem; }
h5 { font-size: 0.92rem; }
h6 { font-size: 0.82rem; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--aq-brand);
  text-decoration: none;
  transition: color var(--aq-t) var(--aq-ease);
}

a:hover { color: var(--aq-brand-600); }

img, svg, video, canvas { max-width: 100%; height: auto; display: block; }

ul, ol { margin: 0 0 1rem; padding-left: 1.15rem; }

hr {
  border: 0;
  border-top: 1px solid var(--aq-line);
  margin: 1.5rem 0;
}

code, pre, kbd { font-family: var(--aq-font-mono); font-size: 0.86em; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--aq-brand);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection {
  background: var(--aq-brand);
  color: #fff;
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

.aq-u-hidden { display: none !important; }
.aq-u-block { display: block; }
.aq-u-flex { display: flex; }
.aq-u-inline-flex { display: inline-flex; }
.aq-u-grid { display: grid; }
.aq-u-between { justify-content: space-between; }
.aq-u-center { align-items: center; }
.aq-u-start { align-items: flex-start; }
.aq-u-end { justify-content: flex-end; }
.aq-u-wrap { flex-wrap: wrap; }
.aq-u-gap-1 { gap: 4px; }
.aq-u-gap-2 { gap: 8px; }
.aq-u-gap-3 { gap: 12px; }
.aq-u-gap-4 { gap: 16px; }
.aq-u-gap-5 { gap: 24px; }
.aq-u-gap-6 { gap: 32px; }
.aq-u-grow { flex: 1 1 auto; min-width: 0; }
.aq-u-mt-0 { margin-top: 0; }
.aq-u-mt-2 { margin-top: 8px; }
.aq-u-mt-3 { margin-top: 12px; }
.aq-u-mt-4 { margin-top: 16px; }
.aq-u-mt-5 { margin-top: 24px; }
.aq-u-mt-6 { margin-top: 32px; }
.aq-u-mb-0 { margin-bottom: 0; }
.aq-u-mb-2 { margin-bottom: 8px; }
.aq-u-mb-3 { margin-bottom: 12px; }
.aq-u-mb-4 { margin-bottom: 16px; }
.aq-u-mb-5 { margin-bottom: 24px; }
.aq-u-mb-6 { margin-bottom: 32px; }
.aq-u-text-center { text-align: center; }
.aq-u-text-right { text-align: right; }
.aq-u-text-left { text-align: left; }
.aq-u-muted { color: var(--aq-muted); }
.aq-u-subtle { color: var(--aq-subtle); }
.aq-u-small { font-size: 0.82rem; }
.aq-u-tiny { font-size: 0.75rem; }
.aq-u-strong { font-weight: 600; }
.aq-u-mono { font-family: var(--aq-font-mono); }
.aq-u-nowrap { white-space: nowrap; }
.aq-u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aq-u-full { width: 100%; }
.aq-u-w-auto { width: auto; }
.aq-u-pos-rel { position: relative; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.aq-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--aq-r-sm);
  font-family: var(--aq-font-body);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  transition: background-color var(--aq-t) var(--aq-ease), border-color var(--aq-t) var(--aq-ease),
    color var(--aq-t) var(--aq-ease), box-shadow var(--aq-t) var(--aq-ease);
}

.aq-btn:active { transform: translateY(1px); }
.aq-btn[disabled], .aq-btn.is-disabled { opacity: 0.55; pointer-events: none; }

.aq-btn--primary {
  background: var(--aq-brand);
  border-color: var(--aq-brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(27, 92, 255, 0.35);
}

.aq-btn--primary:hover { background: var(--aq-brand-600); border-color: var(--aq-brand-600); color: #fff; }

.aq-btn--accent {
  background: var(--aq-accent);
  border-color: var(--aq-accent);
  color: #fff;
}

.aq-btn--accent:hover { background: var(--aq-accent-600); border-color: var(--aq-accent-600); color: #fff; }

.aq-btn--dark {
  background: var(--aq-ink);
  border-color: var(--aq-ink);
  color: #fff;
}

.aq-btn--dark:hover { background: var(--aq-ink-700); border-color: var(--aq-ink-700); color: #fff; }

.aq-btn--secondary {
  background: var(--aq-surface);
  border-color: var(--aq-line-strong);
  color: var(--aq-text);
}

.aq-btn--secondary:hover { border-color: var(--aq-brand); color: var(--aq-brand); background: var(--aq-brand-050); }

.aq-btn--ghost { background: transparent; color: var(--aq-muted); }
.aq-btn--ghost:hover { background: var(--aq-bg); color: var(--aq-text); }

.aq-btn--danger { background: var(--aq-danger); border-color: var(--aq-danger); color: #fff; }
.aq-btn--danger:hover { background: #a81f1f; border-color: #a81f1f; color: #fff; }

.aq-btn--success { background: var(--aq-success); border-color: var(--aq-success); color: #fff; }
.aq-btn--success:hover { background: #0d7038; color: #fff; }

.aq-btn--sm { min-height: 34px; padding: 0 12px; font-size: 0.82rem; }
.aq-btn--lg { min-height: 50px; padding: 0 26px; font-size: 1rem; }
.aq-btn--xs { min-height: 28px; padding: 0 9px; font-size: 0.74rem; border-radius: var(--aq-r-xs); }
.aq-btn--block { width: 100%; }

.aq-btn--icon {
  width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: var(--aq-r-sm);
}

.aq-btn svg { width: 17px; height: 17px; flex: none; }

.aq-btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.aq-card {
  background: var(--aq-surface);
  border: 1px solid var(--aq-line);
  border-radius: var(--aq-r);
  box-shadow: var(--aq-sh-xs);
}

.aq-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--aq-line);
}

.aq-card__title {
  font-family: var(--aq-font-head);
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--aq-ink);
}

.aq-card__subtitle { font-size: 0.82rem; color: var(--aq-muted); margin: 2px 0 0; }
.aq-card__body { padding: 20px; }
.aq-card__body--flush { padding: 0; }
.aq-card__foot {
  padding: 14px 20px;
  border-top: 1px solid var(--aq-line);
  background: var(--aq-surface-2);
  border-radius: 0 0 var(--aq-r) var(--aq-r);
}

.aq-card--dark {
  background: var(--aq-ink);
  border-color: var(--aq-ink-700);
  color: #d8e0f0;
}
.aq-card--dark .aq-card__title { color: #fff; }
.aq-card--dark .aq-card__head { border-color: rgba(255, 255, 255, 0.1); }

/* --------------------------------------------------------------------------
   Stats
   -------------------------------------------------------------------------- */

.aq-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 16px;
}

.aq-stat {
  background: var(--aq-surface);
  border: 1px solid var(--aq-line);
  border-radius: var(--aq-r);
  padding: 18px 20px;
  box-shadow: var(--aq-sh-xs);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.aq-stat__label {
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--aq-subtle);
}

.aq-stat__value {
  font-family: var(--aq-font-head);
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--aq-ink);
  letter-spacing: -0.02em;
}

.aq-stat__value--sm { font-size: 1.4rem; }
.aq-stat__delta { font-size: 0.82rem; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.aq-stat__delta--up { color: var(--aq-success); }
.aq-stat__delta--down { color: var(--aq-danger); }
.aq-stat__delta--flat { color: var(--aq-subtle); }
.aq-stat__hint { font-size: 0.8rem; color: var(--aq-muted); }

.aq-stat__icon {
  width: 38px;
  height: 38px;
  border-radius: var(--aq-r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--aq-brand-050);
  color: var(--aq-brand);
  flex: none;
}
.aq-stat__icon svg { width: 19px; height: 19px; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.aq-table-wrap {
  overflow-x: auto;
  border-radius: 0 0 var(--aq-r) var(--aq-r);
  -webkit-overflow-scrolling: touch;
}

.aq-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.aq-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--aq-subtle);
  padding: 12px 16px;
  background: var(--aq-surface-2);
  border-bottom: 1px solid var(--aq-line);
  white-space: nowrap;
}

.aq-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--aq-line);
  vertical-align: middle;
}

.aq-table tbody tr:last-child td { border-bottom: 0; }
.aq-table tbody tr { transition: background-color var(--aq-t-fast) var(--aq-ease); }
.aq-table tbody tr:hover { background: var(--aq-surface-2); }
.aq-table--compact td { padding: 9px 14px; }
.aq-table--compact th { padding: 9px 14px; }
.aq-table__actions { display: flex; gap: 6px; justify-content: flex-end; }

.aq-table__num { font-variant-numeric: tabular-nums; font-weight: 600; }
.aq-table__muted { color: var(--aq-muted); font-size: 0.84rem; }

/* --------------------------------------------------------------------------
   Badges and pills
   -------------------------------------------------------------------------- */

.aq-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--aq-r-pill);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  background: var(--aq-bg);
  color: var(--aq-muted);
  border: 1px solid var(--aq-line);
  white-space: nowrap;
}

.aq-badge--success { background: var(--aq-success-bg); color: var(--aq-success); border-color: transparent; }
.aq-badge--warning { background: var(--aq-warning-bg); color: var(--aq-warning); border-color: transparent; }
.aq-badge--danger { background: var(--aq-danger-bg); color: var(--aq-danger); border-color: transparent; }
.aq-badge--info { background: var(--aq-info-bg); color: var(--aq-info); border-color: transparent; }
.aq-badge--brand { background: var(--aq-brand-050); color: var(--aq-brand-700); border-color: transparent; }
.aq-badge--dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.aq-form { display: flex; flex-direction: column; gap: 18px; }

.aq-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.aq-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--aq-text);
}

.aq-label .aq-req { color: var(--aq-danger); margin-left: 2px; }

.aq-input,
.aq-select,
.aq-textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--aq-line-strong);
  border-radius: var(--aq-r-sm);
  background: var(--aq-surface);
  font-size: 0.92rem;
  color: var(--aq-text);
  transition: border-color var(--aq-t) var(--aq-ease), box-shadow var(--aq-t) var(--aq-ease);
}

.aq-textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
.aq-input::placeholder, .aq-textarea::placeholder { color: var(--aq-subtle); }

.aq-input:hover, .aq-select:hover, .aq-textarea:hover { border-color: var(--aq-subtle); }

.aq-input:focus, .aq-select:focus, .aq-textarea:focus {
  outline: none;
  border-color: var(--aq-brand);
  box-shadow: var(--aq-ring);
}

.aq-input[readonly], .aq-input[disabled], .aq-select[disabled] {
  background: var(--aq-surface-2);
  color: var(--aq-muted);
  cursor: not-allowed;
}

.aq-select {
  appearance: none;
  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='%2355657f' stroke-width='2.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 12px center;
  padding-right: 38px;
}

.aq-help { font-size: 0.79rem; color: var(--aq-muted); }
.aq-error { font-size: 0.79rem; color: var(--aq-danger); font-weight: 500; }
.aq-input.is-invalid, .aq-select.is-invalid, .aq-textarea.is-invalid { border-color: var(--aq-danger); }

.aq-field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

.aq-check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 0.89rem;
  min-height: 44px;
}

.aq-check input[type="checkbox"],
.aq-check input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--aq-brand);
  cursor: pointer;
  flex: none;
  margin: 0;
}

.aq-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 4px 12px;
}

.aq-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.aq-switch input { position: absolute; opacity: 0; pointer-events: none; }

.aq-switch__track {
  width: 42px;
  height: 24px;
  border-radius: var(--aq-r-pill);
  background: var(--aq-line-strong);
  position: relative;
  transition: background-color var(--aq-t) var(--aq-ease);
  flex: none;
}

.aq-switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--aq-sh-xs);
  transition: transform var(--aq-t) var(--aq-ease);
}

.aq-switch input:checked + .aq-switch__track { background: var(--aq-brand); }
.aq-switch input:checked + .aq-switch__track::after { transform: translateX(18px); }
.aq-switch input:focus-visible + .aq-switch__track { box-shadow: var(--aq-ring); }

.aq-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px dashed var(--aq-line-strong);
  border-radius: var(--aq-r-sm);
  background: var(--aq-surface-2);
}

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */

.aq-alert {
  display: flex;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--aq-r-sm);
  border: 1px solid var(--aq-line);
  background: var(--aq-surface-2);
  font-size: 0.88rem;
  line-height: 1.55;
}

.aq-alert svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.aq-alert__title { font-weight: 600; margin-bottom: 2px; }
.aq-alert--success { background: var(--aq-success-bg); border-color: rgba(18, 138, 69, 0.2); color: #0d5c30; }
.aq-alert--warning { background: var(--aq-warning-bg); border-color: rgba(180, 83, 9, 0.2); color: #8a4106; }
.aq-alert--danger { background: var(--aq-danger-bg); border-color: rgba(198, 40, 40, 0.2); color: #97201f; }
.aq-alert--info { background: var(--aq-info-bg); border-color: rgba(14, 116, 144, 0.2); color: #0a5c73; }

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */

.aq-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--aq-line);
  overflow-x: auto;
  scrollbar-width: thin;
}

.aq-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 15px;
  border: 0;
  background: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--aq-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--aq-t) var(--aq-ease), border-color var(--aq-t) var(--aq-ease);
}

.aq-tab:hover { color: var(--aq-text); }
.aq-tab.is-active { color: var(--aq-brand); border-bottom-color: var(--aq-brand); }
.aq-tab__count {
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: var(--aq-r-pill);
  background: var(--aq-bg);
  color: var(--aq-muted);
}

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */

.aq-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-top: 1px solid var(--aq-line);
  flex-wrap: wrap;
}

.aq-pagination__info { font-size: 0.84rem; color: var(--aq-muted); }
.aq-pagination__list { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }

.aq-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--aq-line);
  border-radius: var(--aq-r-xs);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--aq-muted);
  background: var(--aq-surface);
  transition: all var(--aq-t) var(--aq-ease);
}

.aq-page:hover { border-color: var(--aq-brand); color: var(--aq-brand); }
.aq-page.is-active { background: var(--aq-brand); border-color: var(--aq-brand); color: #fff; }
.aq-page.is-disabled { opacity: 0.4; pointer-events: none; }

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */

.aq-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--aq-muted);
}

.aq-empty__icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: var(--aq-r);
  background: var(--aq-brand-050);
  color: var(--aq-brand);
  display: flex;
  align-items: center;
  justify-content: center;
}
.aq-empty__icon svg { width: 24px; height: 24px; }
.aq-empty__title { font-family: var(--aq-font-head); font-size: 1.05rem; font-weight: 600; color: var(--aq-ink); margin-bottom: 4px; }
.aq-empty__text { font-size: 0.88rem; max-width: 420px; margin: 0 auto 16px; }

/* --------------------------------------------------------------------------
   Progress and charts
   -------------------------------------------------------------------------- */

.aq-progress {
  height: 8px;
  border-radius: var(--aq-r-pill);
  background: var(--aq-bg);
  overflow: hidden;
}

.aq-progress__bar {
  height: 100%;
  border-radius: var(--aq-r-pill);
  background: var(--aq-brand);
  transition: width var(--aq-t-slow) var(--aq-ease);
}

.aq-progress__bar--success { background: var(--aq-success); }
.aq-progress__bar--warning { background: var(--aq-warning); }
.aq-progress__bar--danger { background: var(--aq-danger); }

.aq-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 180px;
  padding-top: 10px;
}

.aq-bars__col {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.aq-bars__bar {
  width: 100%;
  max-width: 34px;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--aq-brand-300), var(--aq-brand));
  min-height: 3px;
  transition: height var(--aq-t-slow) var(--aq-ease);
}

.aq-bars__label { font-size: 0.7rem; color: var(--aq-subtle); white-space: nowrap; }
.aq-bars__value { font-size: 0.72rem; font-weight: 600; color: var(--aq-muted); }

.aq-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.8rem; color: var(--aq-muted); }
.aq-legend__item { display: inline-flex; align-items: center; gap: 6px; }
.aq-legend__swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--aq-brand); }
.aq-legend__swatch--accent { background: var(--aq-accent); }
.aq-legend__swatch--muted { background: var(--aq-line-strong); }

.aq-sparkline { width: 100%; height: 46px; }

/* --------------------------------------------------------------------------
   Dropdown and modal
   -------------------------------------------------------------------------- */

.aq-dropdown { position: relative; }

.aq-dropdown__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 210px;
  background: var(--aq-surface);
  border: 1px solid var(--aq-line);
  border-radius: var(--aq-r-sm);
  box-shadow: var(--aq-sh);
  padding: 6px;
  z-index: var(--aq-z-dropdown);
  display: none;
}

.aq-dropdown.is-open .aq-dropdown__menu { display: block; }

.aq-dropdown__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  background: none;
  border-radius: var(--aq-r-xs);
  font-size: 0.88rem;
  color: var(--aq-text);
  cursor: pointer;
  text-align: left;
  transition: background-color var(--aq-t-fast) var(--aq-ease);
}

.aq-dropdown__item:hover { background: var(--aq-bg); color: var(--aq-text); }
.aq-dropdown__item svg { width: 16px; height: 16px; color: var(--aq-subtle); }
.aq-dropdown__item--danger { color: var(--aq-danger); }
.aq-dropdown__item--danger svg { color: var(--aq-danger); }
.aq-dropdown__sep { height: 1px; background: var(--aq-line); margin: 5px 4px; }

.aq-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.55);
  backdrop-filter: blur(2px);
  z-index: var(--aq-z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.aq-modal {
  background: var(--aq-surface);
  border-radius: var(--aq-r-lg);
  box-shadow: var(--aq-sh-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.aq-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--aq-line);
}

.aq-modal__title { font-family: var(--aq-font-head); font-size: 1.05rem; font-weight: 600; margin: 0; }
.aq-modal__body { padding: 22px; }
.aq-modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--aq-line);
  background: var(--aq-surface-2);
}

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */

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

.aq-sidebar {
  background: var(--aq-ink);
  color: #b9c4d8;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: var(--aq-z-sticky);
}

.aq-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: #fff;
  font-family: var(--aq-font-head);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.aq-sidebar__logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--aq-brand), #6d8bff);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex: none;
}
.aq-sidebar__logo svg { width: 19px; height: 19px; }
.aq-sidebar__tag { font-size: 0.68rem; color: #6f7f9b; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }

.aq-nav { padding: 14px 12px 24px; flex: 1 1 auto; }

.aq-nav__group {
  margin: 18px 0 6px;
  padding: 0 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5c6b87;
}

.aq-nav__link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--aq-r-sm);
  color: #b9c4d8;
  font-size: 0.89rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background-color var(--aq-t-fast) var(--aq-ease), color var(--aq-t-fast) var(--aq-ease);
}

.aq-nav__link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.aq-nav__link svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.aq-nav__link.is-active { background: var(--aq-brand); color: #fff; }
.aq-nav__link.is-active svg { opacity: 1; }
.aq-nav__badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--aq-r-pill);
  background: var(--aq-accent);
  color: #fff;
}

.aq-sidebar__foot {
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.75rem;
  color: #5c6b87;
}

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

.aq-topbar {
  height: var(--aq-topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--aq-line);
  position: sticky;
  top: 0;
  z-index: var(--aq-z-sticky);
}

.aq-topbar__title { font-family: var(--aq-font-head); font-size: 1.05rem; font-weight: 600; margin: 0; }
.aq-topbar__crumb { font-size: 0.78rem; color: var(--aq-subtle); }

.aq-search {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 340px;
  flex: 1 1 auto;
}

.aq-search svg { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--aq-subtle); pointer-events: none; }
.aq-search input {
  width: 100%;
  min-height: 40px;
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--aq-line);
  border-radius: var(--aq-r-sm);
  background: var(--aq-surface-2);
  font-size: 0.88rem;
  transition: border-color var(--aq-t) var(--aq-ease), box-shadow var(--aq-t) var(--aq-ease);
}
.aq-search input:focus { outline: none; border-color: var(--aq-brand); box-shadow: var(--aq-ring); background: #fff; }

.aq-iconbtn {
  width: 40px;
  height: 40px;
  border-radius: var(--aq-r-sm);
  border: 1px solid var(--aq-line);
  background: var(--aq-surface);
  color: var(--aq-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all var(--aq-t) var(--aq-ease);
}
.aq-iconbtn:hover { border-color: var(--aq-brand); color: var(--aq-brand); }
.aq-iconbtn svg { width: 18px; height: 18px; }

.aq-iconbtn__dot {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--aq-accent);
  border: 2px solid var(--aq-surface);
}

.aq-userchip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px 5px 5px;
  border: 1px solid var(--aq-line);
  border-radius: var(--aq-r-pill);
  background: var(--aq-surface);
  cursor: pointer;
  transition: border-color var(--aq-t) var(--aq-ease);
}
.aq-userchip:hover { border-color: var(--aq-brand); }
.aq-userchip__meta { text-align: left; line-height: 1.25; }
.aq-userchip__name { font-size: 0.84rem; font-weight: 600; }
.aq-userchip__role { font-size: 0.72rem; color: var(--aq-subtle); text-transform: capitalize; }

.aq-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--aq-brand), #6d8bff);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  flex: none;
  text-transform: uppercase;
}
.aq-avatar--lg { width: 46px; height: 46px; font-size: 1rem; }
.aq-avatar--sm { width: 26px; height: 26px; font-size: 0.68rem; }

.aq-content {
  padding: 24px 22px 48px;
  max-width: var(--aq-content-max);
  width: 100%;
  flex: 1 1 auto;
}

.aq-pagehead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.aq-pagehead__title { font-family: var(--aq-font-head); font-size: 1.45rem; font-weight: 600; margin: 0 0 3px; }
.aq-pagehead__sub { font-size: 0.88rem; color: var(--aq-muted); margin: 0; }

/* --------------------------------------------------------------------------
   Sidebar responsive
   -------------------------------------------------------------------------- */

.aq-sidebar-toggle { display: none; }

@media (max-width: 1024px) {
  .aq-shell { grid-template-columns: 1fr; }

  .aq-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 272px;
    transform: translateX(-100%);
    transition: transform var(--aq-t) var(--aq-ease);
  }

  .aq-shell.aq-nav-open .aq-sidebar { transform: translateX(0); }
  .aq-shell.aq-nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(11, 18, 32, 0.5);
    z-index: 19;
  }

  .aq-sidebar-toggle { display: inline-flex; }
  .aq-content { padding: 18px 16px 40px; }
  .aq-topbar { padding: 0 16px; }
}

@media (max-width: 640px) {
  .aq-search { display: none; }
  .aq-stat-grid { grid-template-columns: 1fr; }
  .aq-card__head { flex-wrap: wrap; }
  .aq-pagehead { flex-direction: column; }
}

/* --------------------------------------------------------------------------
   Ad zones (served on publisher pages)
   -------------------------------------------------------------------------- */

.aq-zone {
  position: relative;
  box-sizing: border-box;
}

.aq-zone-banner { margin: 16px auto; }
.aq-zone-inline { margin: 18px 0; }

.aq-zone-float {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: var(--aq-z-dropdown);
  background: #fff;
  border-radius: var(--aq-r-sm);
  box-shadow: var(--aq-sh);
  padding: 8px;
  max-width: 330px;
}

.aq-zone-sticky {
  position: fixed;
  left: 0;
  right: 0;
  z-index: var(--aq-z-dropdown);
  background: #fff;
  box-shadow: var(--aq-sh);
  padding: 6px 12px;
  text-align: center;
}
.aq-zone-sticky-top { top: 0; }
.aq-zone-sticky-bottom { bottom: 0; }
.aq-zone-sticky-left { left: 0; top: 0; bottom: 0; width: 330px; overflow: auto; }
.aq-zone-sticky-right { right: 0; top: 0; bottom: 0; width: 330px; overflow: auto; }

.aq-zone-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--aq-z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 18, 32, 0.78);
  padding: 20px;
}

.aq-zone-popunder { z-index: 1; background: rgba(11, 18, 32, 0.35); }
.aq-zone-fullscreen { background: rgba(11, 18, 32, 0.94); }

.aq-zone-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: #fff;
  color: var(--aq-ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--aq-sh-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.aq-ad { display: block; position: relative; overflow: hidden; }
.aq-ad-overlay { position: absolute; inset: 0; z-index: 2; }
.aq-ad-overlay:focus-visible { outline: 2px solid var(--aq-brand); }

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */

.aq-code {
  display: block;
  padding: 13px 15px;
  background: var(--aq-ink);
  color: #c9d6ef;
  border-radius: var(--aq-r-sm);
  font-family: var(--aq-font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.aq-code--inline {
  display: inline-block;
  padding: 2px 7px;
  background: var(--aq-bg);
  color: var(--aq-ink);
  border: 1px solid var(--aq-line);
  border-radius: var(--aq-r-xs);
}

.aq-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--aq-line-strong);
  border-radius: var(--aq-r-xs);
  background: var(--aq-surface);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--aq-muted);
  cursor: pointer;
  transition: all var(--aq-t) var(--aq-ease);
}
.aq-copy:hover { border-color: var(--aq-brand); color: var(--aq-brand); }
.aq-copy svg { width: 14px; height: 14px; }

.aq-divider { height: 1px; background: var(--aq-line); margin: 20px 0; }

.aq-kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 8px 16px; font-size: 0.88rem; }
.aq-kv__k { color: var(--aq-muted); }
.aq-kv__v { font-weight: 600; word-break: break-word; }

.aq-timeline { list-style: none; margin: 0; padding: 0; }
.aq-timeline__item {
  position: relative;
  padding: 0 0 20px 26px;
  border-left: 2px solid var(--aq-line);
}
.aq-timeline__item:last-child { border-left-color: transparent; padding-bottom: 0; }
.aq-timeline__item::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--aq-brand);
  border: 2px solid var(--aq-surface);
}
.aq-timeline__time { font-size: 0.76rem; color: var(--aq-subtle); }

.aq-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.aq-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--aq-r-pill);
  border: 1px solid var(--aq-line-strong);
  background: var(--aq-surface);
  font-size: 0.82rem;
  color: var(--aq-text);
}
.aq-chip button {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--aq-subtle);
  line-height: 1;
  font-size: 1rem;
}
.aq-chip button:hover { color: var(--aq-danger); }

.aq-scroll-y { max-height: 340px; overflow-y: auto; }

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */

@media print {
  .aq-sidebar, .aq-topbar, .aq-btn, .aq-pagination { display: none !important; }
  .aq-shell { grid-template-columns: 1fr; }
  .aq-content { padding: 0; }
  .aq-card { border: 1px solid #ccc; box-shadow: none; }
}
