/* ==========================================================================
   Components — reusable UI primitives
   ========================================================================== */

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transition: all 0.2s var(--ease);
}
.btn .ico { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn--primary {
  color: var(--on-primary);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  box-shadow: 0 10px 22px -14px var(--primary), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.btn--primary:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 14px 26px -14px var(--primary);
}

.btn--ghost {
  color: var(--text-2);
  border-color: var(--line-strong);
  background: var(--surface);
}
.btn--ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--muted);
  background: var(--surface-2);
}

.btn--soft {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 18%, transparent);
  background: var(--primary-soft);
}
.btn--soft:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 18%, var(--surface)); }

.btn--danger {
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  box-shadow: 0 10px 22px -14px rgba(220, 38, 38, 0.7);
}
.btn--danger:hover:not(:disabled) { filter: brightness(1.05); }

.btn--subtle {
  height: 34px;
  padding: 0 12px;
  color: var(--muted);
  border-color: var(--line);
  background: transparent;
}
.btn--subtle:hover:not(:disabled) { color: var(--text); background: var(--well); }

.btn--sm { height: 36px; padding: 0 13px; font-size: var(--fs-xs); }
.btn--xs { height: 30px; padding: 0 10px; font-size: 11px; gap: 5px; }
.btn--xs .ico { width: 14px; height: 14px; }
.btn--icon { width: 42px; padding: 0; }
.btn--block { width: 100%; }

.btn.is-loading { pointer-events: none; }
.btn.is-loading .btn__label { opacity: 0.55; }
.btn__spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Cards & panels ─────────────────────────────────────── */
.card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.card--pad { padding: var(--sp-5); }
.card--flush { overflow: hidden; }
.card--accent {
  background:
    linear-gradient(150deg, color-mix(in srgb, var(--primary) 7%, var(--surface)) 0%, var(--surface) 52%),
    var(--surface);
  border-color: color-mix(in srgb, var(--primary) 17%, var(--line));
}
.card--dark {
  color: #e9f7f0;
  border-color: rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(90% 80% at 100% 0%, rgba(52, 211, 153, 0.18), transparent 60%),
    linear-gradient(145deg, #0d2b20 0%, #071c15 56%, #05130e 100%);
  box-shadow: 0 26px 50px -32px rgba(5, 30, 20, 0.8);
}
.card--dark .card__title { color: #f1fbf6; }
.card--dark .card__sub,
.card--dark p { color: rgba(225, 245, 235, 0.66); }

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: var(--sp-5) var(--sp-5) 0;
}
.card--pad .card__head { padding: 0 0 var(--sp-4); }
.card__title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 720;
  letter-spacing: -0.02em;
}
.card__title .ico { color: var(--primary); }
.card__sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: 1.45;
}
.card__actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.card__body { padding: var(--sp-5); }
.card__body--flush { padding: 0; }
.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px var(--sp-5);
  border-top: 1px solid var(--line-faint);
  background: var(--surface-2);
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* ── Badges / status ────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 23px;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: 10.5px;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.badge .dot { width: 5px; height: 5px; }
.badge--neutral { color: var(--muted); background: var(--well); }
.badge--good { color: var(--good); background: var(--good-soft); }
.badge--warn { color: var(--warn); background: var(--warn-soft); }
.badge--bad { color: var(--bad); background: var(--bad-soft); }
.badge--info { color: var(--info); background: var(--info-soft); }
.badge--accent { color: var(--accent); background: var(--accent-soft); }
.badge--hadir { color: var(--status-hadir); background: var(--status-hadir-bg); }
.badge--telat { color: var(--status-telat); background: var(--status-telat-bg); }
.badge--sakit { color: var(--status-sakit); background: var(--status-sakit-bg); }
.badge--izin { color: var(--status-izin); background: var(--status-izin-bg); }
.badge--alpa { color: var(--status-alpa); background: var(--status-alpa-bg); }
.badge--pla { color: var(--status-pla); background: var(--status-pla-bg); }
.badge--bolos { color: var(--status-bolos); background: var(--status-bolos-bg); }
.badge--belum { color: var(--status-belum); background: var(--status-belum-bg); }
.badge--outline {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
}
.badge--lg { min-height: 28px; padding: 4px 11px; font-size: var(--fs-xs); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 23px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.tag--primary { border-color: transparent; background: var(--primary-soft); color: var(--primary); }
.tag--accent { border-color: transparent; background: var(--accent-soft); color: var(--accent); }

/* ── Chips ──────────────────────────────────────────────── */
.chips {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 1px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 650;
  white-space: nowrap;
  transition: all 0.18s var(--ease);
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip.is-active,
.chip[aria-pressed="true"] {
  color: var(--on-primary);
  border-color: transparent;
  background: var(--text);
  box-shadow: var(--shadow-sm);
}
.chip__count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--well);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 800;
}
.chip.is-active .chip__count { background: rgba(255, 255, 255, 0.16); color: var(--bg); }

/* ── Avatar ─────────────────────────────────────────────── */
.avatar {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, #0f766e, #065f46);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 760;
  letter-spacing: 0.01em;
  user-select: none;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.avatar--circle { border-radius: 50%; }
.avatar--xs { width: 26px; height: 26px; border-radius: 9px; font-size: 9.5px; }
.avatar--sm { width: 32px; height: 32px; border-radius: 10px; font-size: 10.5px; }
.avatar--md { width: 44px; height: 44px; border-radius: 14px; font-size: var(--fs-sm); }
.avatar--lg { width: 58px; height: 58px; border-radius: 18px; font-size: var(--fs-lg); }
.avatar--xl { width: 76px; height: 76px; border-radius: 23px; font-size: var(--fs-2xl); }
.avatar--emerald { background: linear-gradient(145deg, #10b981, #047857); }
.avatar--cobalt { background: linear-gradient(145deg, #6366f1, #4338ca); }
.avatar--ocean { background: linear-gradient(145deg, #06b6d4, #0e7490); }
.avatar--amber { background: linear-gradient(145deg, #f59e0b, #b45309); }
.avatar--rose { background: linear-gradient(145deg, #f43f5e, #be123c); }
.avatar--violet { background: linear-gradient(145deg, #a855f7, #7e22ce); }
.avatar--slate { background: linear-gradient(145deg, #64748b, #334155); }
.avatar__img { width: 100%; height: 100%; object-fit: cover; }

/* ── Stat cards ─────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-4);
}
.stat-card {
  position: relative;
  display: grid;
  gap: 13px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.stat-card::after {
  content: "";
  position: absolute;
  right: -24px;
  top: -34px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--tone, var(--primary)) 12%, transparent), transparent 68%);
  pointer-events: none;
}
.stat-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.stat-card__label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 650;
}
.stat-card__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 12px;
  background: color-mix(in srgb, var(--tone, var(--primary)) 12%, transparent);
  color: var(--tone, var(--primary));
}
.stat-card__icon .ico { width: 18px; height: 18px; }
.stat-card__value {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-family: var(--font-display);
  font-size: clamp(27px, 2.4vw, 34px);
  font-weight: 780;
  letter-spacing: -0.04em;
  line-height: 1;
}
.stat-card__value small {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
}
.stat-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: var(--fs-xs);
}
.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 750;
}
.trend--up { color: var(--good); }
.trend--down { color: var(--bad); }
.trend--flat { color: var(--muted); }
.trend .ico { width: 12px; height: 12px; }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.data-table {
  width: 100%;
  min-width: 720px;
  font-size: var(--fs-sm);
}
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-faint);
  color: var(--text-2);
  vertical-align: middle;
}
.data-table tbody tr {
  transition: background 0.15s;
}
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr.is-clickable { cursor: pointer; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .center { text-align: center; }

.cell-main {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.cell-main__text { display: grid; gap: 2px; min-width: 0; }
.cell-main__text b {
  overflow: hidden;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-main__text small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-main__text--wrap b {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.3;
}
.cell-stack { display: grid; gap: 2px; }
.cell-stack b { color: var(--text); font-size: var(--fs-sm); font-weight: 650; }
.cell-stack small { color: var(--muted); font-size: 10.5px; }

.table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.table-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  transition: all 0.15s;
}
.table-btn:hover { color: var(--text); border-color: var(--line); background: var(--surface); }
.table-btn--danger:hover { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); background: var(--bad-soft); }
.table-btn .ico { width: 15px; height: 15px; }

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.table-toolbar__left,
.table-toolbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.table-toolbar__left { flex: 1; min-width: 220px; }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  min-width: min(300px, 100%);
  flex: 1;
}
.search-box .ico {
  position: absolute;
  left: 12px;
  color: var(--faint);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 37px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface-2);
  outline: none;
  font-size: var(--fs-sm);
  transition: all 0.18s;
}
.search-box input:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow-glow);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-xs);
  color: var(--muted);
}
.pagination__pages { display: flex; align-items: center; gap: 4px; }
.page-btn {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  transition: all 0.15s;
}
.page-btn:hover:not(:disabled) { border-color: var(--line-strong); color: var(--text); }
.page-btn.is-active { border-color: transparent; background: var(--primary); color: var(--on-primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.table-empty {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 50px 20px;
  text-align: center;
  color: var(--muted);
}
.table-empty .ico { width: 30px; height: 30px; color: var(--faint); }

/* ── Form controls ──────────────────────────────────────── */
.field { display: grid; gap: 6px; min-width: 0; }
.field__label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 700;
}
.field__label .req { color: var(--bad); }
.field__hint { color: var(--faint); font-size: 10.5px; line-height: 1.4; }
.field__error { color: var(--bad); font-size: 10.5px; font-weight: 600; }

.input,
.select,
.textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  outline: none;
  font-size: var(--fs-sm);
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.input::placeholder,
.textarea::placeholder { color: var(--faint); }
.input:hover,
.select:hover,
.textarea:hover { border-color: var(--muted); }
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}
.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}
.select {
  appearance: none;
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
.input--lg { min-height: 50px; font-size: var(--fs-lg); }
.input--error,
.select--error,
.textarea--error { border-color: var(--bad); }
.input--error:focus,
.select--error:focus,
.textarea--error:focus { box-shadow: 0 0 0 4px var(--bad-soft); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .field--wide { grid-column: 1 / -1; }
.form-section {
  display: grid;
  gap: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.form-section:first-child { padding-top: 0; border-top: 0; }
.form-section__title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 720;
}
.form-section__title .ico { color: var(--primary); }

/* Switch */
.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.switch__copy { display: grid; gap: 2px; }
.switch__copy b { font-size: var(--fs-sm); font-weight: 650; }
.switch__copy small { color: var(--muted); font-size: 10.5px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  position: relative;
  width: 42px;
  height: 24px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--line-strong);
  transition: background 0.2s;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform 0.2s var(--ease-spring);
}
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--primary); outline-offset: 3px; }

/* Segmented */
.segmented {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface-2);
}
.segmented__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 13px;
  border-radius: var(--r-full);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 650;
  transition: all 0.18s;
}
.segmented__btn:hover { color: var(--text); }
.segmented__btn.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.segmented__btn .ico { width: 14px; height: 14px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface-2);
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-full);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 650;
  white-space: nowrap;
  transition: all 0.18s;
}
.tab:hover { color: var(--text); }
.tab.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.tab .ico { width: 14px; height: 14px; }

/* ── Modal ──────────────────────────────────────────────── */
.modal {
  width: min(760px, calc(100vw - 26px));
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.modal--sm { width: min(460px, calc(100vw - 26px)); }
.modal--lg { width: min(980px, calc(100vw - 26px)); }
.modal__inner {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: calc(100dvh - 40px);
}
.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}
.modal__title {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 760;
  letter-spacing: -0.03em;
}
.modal__sub { margin-top: 3px; color: var(--muted); font-size: var(--fs-xs); }
.modal__close { margin: -4px -4px 0 0; }
.modal__body { min-height: 0; padding: 20px 22px; overflow-y: auto; overscroll-behavior: contain; }
.modal__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.modal__foot .foot-note { margin-right: auto; color: var(--muted); font-size: 10.5px; }

/* ── Drawer ─────────────────────────────────────────────── */
.drawer {
  width: min(540px, calc(100vw - 20px));
  height: calc(100dvh - 20px);
  max-height: none;
  margin: 10px 10px 10px auto;
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.drawer--wide { width: min(680px, calc(100vw - 20px)); }
.drawer__inner { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; }
.drawer__head {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(90% 100% at 0% 0%, color-mix(in srgb, var(--primary) 9%, transparent), transparent 70%),
    var(--surface);
}
.drawer__close { position: absolute; top: 16px; right: 16px; }
.drawer__body { padding: 20px 22px 28px; overflow-y: auto; }
.drawer__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

/* ── Confirm dialog ─────────────────────────────────────── */
.confirm {
  width: min(430px, calc(100vw - 26px));
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
}
.confirm__inner { display: grid; gap: 14px; padding: 22px; }
.confirm__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--bad-soft);
  color: var(--bad);
}
.confirm__icon .ico { width: 22px; height: 22px; }
.confirm__title { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 760; }
.confirm__msg { color: var(--muted); font-size: var(--fs-sm); line-height: 1.55; }
.confirm__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ── Finder ─────────────────────────────────────────────── */
.finder {
  width: min(660px, calc(100vw - 24px));
  margin-top: 12vh;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.finder__bar {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--line);
}
.finder__bar .ico { color: var(--faint); }
.finder__bar input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  font-size: var(--fs-lg);
}
.finder__list { max-height: 56vh; overflow-y: auto; padding: 8px; }
.finder__group {
  padding: 10px 10px 4px;
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.finder__opt {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 11px;
  text-align: left;
  transition: background 0.15s;
}
.finder__opt:hover,
.finder__opt.is-focused { background: var(--well); }
.finder__opt__text { display: grid; gap: 2px; min-width: 0; flex: 1; }
.finder__opt__text b { font-size: var(--fs-sm); font-weight: 650; }
.finder__opt__text small { color: var(--muted); font-size: 10.5px; }
.finder__empty { padding: 30px 18px; text-align: center; color: var(--muted); font-size: var(--fs-sm); }

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(520px, calc(100vw - 26px));
  padding: 11px 16px;
  border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
  border-radius: var(--r-full);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-sm);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px) scale(0.98);
  transition: all 0.28s var(--ease-spring);
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast .ico { width: 17px; height: 17px; }
.toast--good { background: var(--good); color: #fff; border-color: transparent; }
.toast--bad { background: var(--bad); color: #fff; border-color: transparent; }
.toast--warn { background: var(--warn); color: #1f1300; border-color: transparent; }

/* ── Progress / meter ───────────────────────────────────── */
.progress {
  position: relative;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--well);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 65%, #34d399));
  transition: width 0.6s var(--ease);
}
.progress--sm { height: 5px; }
.progress--lg { height: 11px; }
.progress__bar--accent { background: linear-gradient(90deg, var(--accent), #818cf8); }
.progress__bar--warn { background: linear-gradient(90deg, var(--warn), #fbbf24); }
.progress__bar--bad { background: linear-gradient(90deg, var(--bad), #f87171); }

/* ── Charts / legends ───────────────────────────────────── */
.legend { display: grid; gap: 8px; }
.legend__item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.legend__item b { margin-left: auto; color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.legend__swatch { width: 8px; height: 8px; border-radius: 3px; background: var(--c); flex: none; }
.chart-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1px;
  text-align: center;
  pointer-events: none;
}
.chart-center b {
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 780;
  letter-spacing: -0.04em;
  line-height: 1;
}
.chart-center small { color: var(--muted); font-size: 9.5px; font-weight: 650; }
.chart-frame { position: relative; display: grid; place-items: center; }

.sparkline { width: 100%; height: auto; overflow: visible; }
.bars { display: flex; align-items: flex-end; gap: 5px; height: 48px; }
.bars__bar {
  flex: 1;
  min-width: 4px;
  border-radius: 4px 4px 2px 2px;
  background: color-mix(in srgb, var(--primary) 74%, transparent);
  transition: background 0.15s;
}
.bars__bar:hover { background: var(--primary); }

/* ── Timeline ───────────────────────────────────────────── */
.timeline { display: grid; gap: 0; }
.timeline__item {
  position: relative;
  display: grid;
  grid-template-columns: 58px 18px minmax(0, 1fr);
  gap: 10px;
  min-height: 62px;
  padding-bottom: 8px;
}
.timeline__item:last-child { min-height: 0; padding-bottom: 0; }
.timeline__time {
  padding-top: 6px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.timeline__rail { position: relative; display: grid; justify-items: center; }
.timeline__rail::before {
  content: "";
  position: absolute;
  top: 16px;
  bottom: -8px;
  width: 1px;
  background: var(--line);
}
.timeline__item:last-child .timeline__rail::before { display: none; }
.timeline__dot {
  position: relative;
  z-index: 1;
  width: 9px;
  height: 9px;
  margin-top: 8px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--line-strong);
  box-shadow: 0 0 0 1px var(--line-strong);
}
.timeline__item.is-active .timeline__dot {
  background: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), 0 0 0 5px var(--primary-soft);
}
.timeline__item.is-done .timeline__dot { background: var(--good); box-shadow: 0 0 0 1px var(--good); }
.timeline__body {
  display: grid;
  gap: 3px;
  padding: 5px 0 12px;
  min-width: 0;
}
.timeline__body b { font-size: var(--fs-sm); font-weight: 650; }
.timeline__body small { color: var(--muted); font-size: 10.5px; }
.timeline__body .row { margin-top: 4px; }

/* ── Callout / empty ────────────────────────────────────── */
.callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: 1.5;
}
.callout .ico { margin-top: 1px; color: var(--info); flex: none; }
.callout--warn { border-color: color-mix(in srgb, var(--warn) 25%, var(--line)); background: var(--warn-soft); color: color-mix(in srgb, var(--warn) 70%, var(--text)); }
.callout--info { border-color: color-mix(in srgb, var(--info) 22%, var(--line)); background: var(--info-soft); color: color-mix(in srgb, var(--info) 68%, var(--text)); }
.callout--good { border-color: color-mix(in srgb, var(--good) 22%, var(--line)); background: var(--good-soft); color: color-mix(in srgb, var(--good) 68%, var(--text)); }

.empty {
  display: grid;
  place-items: center;
  gap: 9px;
  padding: 38px 18px;
  text-align: center;
  color: var(--muted);
}
.empty__icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background: var(--well);
  color: var(--faint);
}
.empty b { color: var(--text); font-size: var(--fs-sm); }
.empty p { max-width: 36ch; font-size: var(--fs-xs); line-height: 1.5; }

/* ── Skeleton ───────────────────────────────────────────── */
.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--well) 25%, color-mix(in srgb, var(--well) 50%, var(--surface)) 37%, var(--well) 63%);
  background-size: 480px 100%;
  animation: shimmer 1.5s infinite linear;
}
.skeleton--line { height: 12px; }
.skeleton--title { height: 22px; width: 42%; }
.skeleton--card { height: 118px; border-radius: var(--r-xl); }

/* ── Misc ───────────────────────────────────────────────── */
.divider-text {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.divider-text::before,
.divider-text::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.kv { display: grid; gap: 10px; }
.kv__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line-faint);
  font-size: var(--fs-xs);
}
.kv__row:last-child { padding-bottom: 0; border-bottom: 0; }
.kv__row dt { color: var(--muted); flex: none; }
.kv__row dd { color: var(--text); font-weight: 600; text-align: right; }

.avatar-stack { display: flex; }
.avatar-stack .avatar {
  margin-left: -8px;
  border: 2px solid var(--surface);
  box-shadow: none;
}
.avatar-stack .avatar:first-child { margin-left: 0; }

.meter-row { display: grid; gap: 6px; }
.meter-row__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: var(--fs-xs);
}
.meter-row__head span { color: var(--muted); }
.meter-row__head b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }

.scroll-y { overflow-y: auto; overscroll-behavior: contain; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .form-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .drawer { width: 100vw; height: 100dvh; margin: 0; border-radius: 0; max-height: 100dvh; }
  .modal { border-radius: 22px; }
  .modal__body { padding: 18px; }
  .table-toolbar { padding: 12px 14px; }
  .pagination { padding: 10px 14px; }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-card { padding: 15px; }
  .modal__head, .modal__foot { padding-left: 16px; padding-right: 16px; }
  .modal__body { padding: 16px; }
  .drawer__head, .drawer__body, .drawer__foot { padding-left: 16px; padding-right: 16px; }
  .btn { height: 40px; padding: 0 14px; }
}
