/* ==========================================================================
   Components — shared UI library for every mockup page
   Naming: plain classes + modifiers (.btn .btn-primary .btn-sm), tone via .tone-*
   ========================================================================== */

/* -------------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  --btn-hover-bg: var(--surface-sunken);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-full);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  transition: background var(--duration-fast), border-color var(--duration-fast),
    color var(--duration-fast), box-shadow var(--duration-fast), transform var(--duration-fast);
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    background: var(--btn-hover-bg);
    text-decoration: none;
  }
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.btn-primary {
  --btn-bg: var(--primary);
  --btn-fg: var(--text-inverse);
  --btn-border: var(--primary);
  --btn-hover-bg: var(--primary-hover);
  box-shadow: var(--shadow-primary);
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    border-color: var(--primary-hover);
  }
}

.btn-secondary {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border);
  box-shadow: var(--shadow-xs);
}

@media (hover: hover) and (pointer: fine) {
  .btn-secondary:hover {
    border-color: var(--border-strong);
  }
}

.btn-soft {
  --btn-bg: var(--primary-soft);
  --btn-fg: var(--primary);
  --btn-border: transparent;
  --btn-hover-bg: var(--blue-100);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-fg: var(--text-secondary);
  --btn-border: transparent;
  --btn-hover-bg: var(--surface-sunken);
}

.btn-danger {
  --btn-bg: var(--surface);
  --btn-fg: var(--tone-red-fg);
  --btn-border: color-mix(in srgb, var(--tone-red-solid) 32%, var(--surface));
  --btn-hover-bg: var(--tone-red-bg);
}

.btn-success {
  --btn-bg: var(--tone-green-fg);
  --btn-fg: var(--text-inverse);
  --btn-border: var(--tone-green-fg);
  --btn-hover-bg: color-mix(in srgb, var(--tone-green-fg) 85%, var(--navy-900));
}

.btn-sm {
  height: 34px;
  padding: 0 14px;
  gap: 6px;
  font-size: var(--text-sm);
}

.btn-sm .icon {
  width: 14px;
  height: 14px;
}

.btn-lg {
  height: 46px;
  padding: 0 22px;
  font-size: var(--text-md);
}

.btn-icon {
  width: 40px;
  padding: 0;
}

.btn-icon.btn-sm {
  width: 34px;
}

.btn-block {
  width: 100%;
}

.btn .count {
  height: 18px;
  min-width: 18px;
  padding: 0 5px;
  font-size: 12px;
}

.btn-primary .count {
  background: var(--blue-800);
  color: var(--text-inverse);
}

.btn.is-loading .icon {
  animation: spin 0.9s linear infinite;
}

/* Round icon button (topbar, card actions) */
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  transition: background var(--duration-fast), color var(--duration-fast);
}

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover {
    background: var(--surface-sunken);
    color: var(--text);
    text-decoration: none;
  }
}

.icon-btn .icon {
  width: 20px;
  height: 20px;
}

.icon-btn-sm {
  width: 32px;
  height: 32px;
}

.icon-btn-sm .icon {
  width: 16px;
  height: 16px;
}

/* -------------------------------------------------------------------------
   Form controls
   ------------------------------------------------------------------------- */
.input,
.select,
.textarea {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-base);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast), background var(--duration-fast);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

@media (hover: hover) and (pointer: fine) {
  .input:hover,
  .select:hover,
  .textarea:hover {
    border-color: var(--text-secondary);
  }
}

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

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--surface-muted);
  color: var(--text-muted);
  cursor: not-allowed;
}

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

.select.w-full,
.field > .select {
  width: 100%;
}

.textarea {
  height: auto;
  min-height: 120px;
  padding: 10px 12px;
  line-height: 1.6;
  resize: vertical;
}

.input-sm,
.select-sm {
  height: 34px;
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.search > .icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search .input {
  padding-left: 36px;
}

.search-pill .input {
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--surface-muted);
}

.search-pill > .icon {
  left: 16px;
}

.search-pill .input {
  padding-left: 42px;
}

.search-pill .input:focus {
  background: var(--surface);
}

.input::-webkit-search-cancel-button {
  cursor: pointer;
}

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

.label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--slate-700);
}

.help {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.5;
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .input {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-addon {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-left: 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
}

.check {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  cursor: pointer;
}

.check input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Toggle switch: <label class="switch"><input type="checkbox" role="switch"><span class="switch-track"></span>…</label> */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-track {
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--slate-300);
  transition: background var(--duration) var(--ease-out);
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-thumb);
  transition: transform var(--duration) var(--ease-out);
}

.switch input:checked + .switch-track {
  background: var(--primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(16px);
}

.switch input:focus-visible + .switch-track {
  box-shadow: var(--focus-ring);
}

.switch input:disabled + .switch-track {
  opacity: 0.55;
}

.switch:has(input:disabled) {
  cursor: not-allowed;
}

/* Range */
.range {
  width: 100%;
  accent-color: var(--primary);
}

/* -------------------------------------------------------------------------
   Cards
   ------------------------------------------------------------------------- */
.card {
  min-width: 0;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

/* Panel besar pembungkus seksi (header halaman + KPI, tabel baris-kartu), seperti referensi. */
.panel {
  min-width: 0;
  padding: var(--panel-pad);
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xs);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 20px;
}

.panel-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-tight);
}

.panel-note {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* Label seksi kapital kecil (inspektur, kolom diagram) — dipakai hemat. */
.caps-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-muted);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-header > div {
  min-width: 0;
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-snug);
  color: var(--text);
}

.card-subtitle {
  margin-top: 2px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.card-link {
  flex: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--primary);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.card-flush {
  padding: 0;
  overflow: hidden;
}

.card-flush > .card-header {
  margin: 0;
  padding: 18px 22px 14px;
}

.card-flush > .card-footer {
  margin: 0;
  padding: 12px 22px;
}

.card-section + .card-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.card-muted {
  background: var(--surface-muted);
  box-shadow: none;
}

.card-interactive {
  transition: box-shadow var(--duration), border-color var(--duration), transform var(--duration);
}

@media (hover: hover) and (pointer: fine) {
  .card-interactive:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
  }
}

/* Small heading used inside cards / drawers to label a group */
.section-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* -------------------------------------------------------------------------
   KPI card
   ------------------------------------------------------------------------- */
.kpi {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.kpi-main {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.kpi-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 50%;
  background: var(--tone-bg, var(--tone-blue-bg));
  color: var(--tone-fg, var(--tone-blue-fg));
}

.kpi-icon .icon {
  width: 24px;
  height: 24px;
}

.kpi-icon.is-solid {
  background: var(--tone-solid, var(--primary));
  color: var(--text-inverse);
  box-shadow: 0 8px 16px -8px var(--tone-solid, var(--primary));
}

.kpi-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}

.kpi-value {
  margin-top: 2px;
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  line-height: 1.15;
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
}

.kpi-value small {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0;
}

.kpi-trend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.kpi-trend .icon {
  width: 14px;
  height: 14px;
}

.kpi-trend .trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 700;
  color: var(--tone-green-fg);
}

.kpi-trend .trend.is-down {
  color: var(--tone-red-fg);
}

.kpi-trend .trend.is-neutral {
  color: var(--slate-600);
}

/* KPI kartu (referensi): ikon bulat bernada, label, angka besar, catatan. Kartu boleh berupa tautan. */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.kpi-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
  height: 100%;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

@media (hover: hover) and (pointer: fine) {
  a.kpi-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    text-decoration: none;
  }
}

.kpi-card-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: var(--tone-bg, var(--tone-blue-bg));
  color: var(--tone-fg, var(--tone-blue-fg));
}

.kpi-card-icon .icon {
  width: 20px;
  height: 20px;
}

.kpi-card-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.kpi-card-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.kpi-card-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  line-height: 1.15;
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.kpi-card-value small {
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  letter-spacing: 0;
}

.kpi-card-value.is-text {
  font-size: var(--text-lg);
  line-height: 1.35;
  letter-spacing: var(--tracking-snug);
}

.kpi-card-note {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Compact stat (mini KPI used in page headers) */
.stat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.stat .icon-tile {
  width: 40px;
  height: 40px;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------------
   Chips, badges, status, score
   ------------------------------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  background: var(--tone-bg, var(--tone-slate-bg));
  color: var(--tone-fg, var(--tone-slate-fg));
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}

.chip .icon {
  width: 13px;
  height: 13px;
}

.chip-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--tone-solid, currentColor);
}

.chip-outline {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--slate-600);
}

.chip-lg {
  height: 28px;
  padding: 0 12px;
  font-size: 12.5px;
}

.chip-sm {
  height: 20px;
  padding: 0 8px;
  font-size: 11.5px;
}

/* Filter chip (button) */
button.chip,
a.chip {
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast);
}

@media (hover: hover) and (pointer: fine) {
  button.chip:hover,
  a.chip:hover {
    text-decoration: none;
    border-color: var(--border-strong);
  }
}

.chip-filter {
  height: 40px;
  padding: 0 18px;
  background: var(--surface);
  border: 1px solid var(--border) !important;
  color: var(--text);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}

@media (hover: hover) and (pointer: fine) {
  .chip-filter:hover {
    border-color: var(--border-strong) !important;
  }
}

.chip-filter[aria-pressed="true"] {
  background: var(--primary-soft);
  border-color: var(--blue-200) !important;
  color: var(--primary);
}

.chip-filter .chip-count {
  color: var(--text-muted);
  font-weight: 700;
}

.chip-filter[aria-pressed="true"] .chip-count {
  color: var(--primary);
}

/* Count badge (tabs, headers) */
.count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--slate-100);
  color: var(--slate-600);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.count.is-strong {
  background: var(--primary);
  color: var(--text-inverse);
}

/* Status: dot + label */
.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--tone-fg, var(--slate-600));
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--tone-solid, var(--slate-400));
}

/* Job match score */
.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 40px;
  height: 26px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: var(--tone-slate-bg);
  color: var(--tone-slate-fg);
}

.score.is-high { background: var(--tone-green-bg); color: var(--tone-green-fg); }
.score.is-good { background: var(--tone-teal-bg); color: var(--tone-teal-fg); }
.score.is-mid { background: var(--tone-amber-bg); color: var(--tone-amber-fg); }
.score.is-low { background: var(--tone-slate-bg); color: var(--tone-slate-fg); }
.score.is-risk { background: var(--tone-red-bg); color: var(--tone-red-fg); }

/* Locked / safety marker */
.lock-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  background: var(--tone-green-bg);
  color: var(--tone-green-fg);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.lock-chip .icon {
  width: 13px;
  height: 13px;
}

/* -------------------------------------------------------------------------
   Avatars & icon tiles
   ------------------------------------------------------------------------- */
.avatar {
  --size: 36px;
  display: inline-grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  flex: none;
  border-radius: 50%;
  background: var(--tone-bg, var(--tone-blue-bg));
  color: var(--tone-fg, var(--tone-blue-fg));
  font-size: calc(var(--size) * 0.36);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
  user-select: none;
}

.avatar-xs { --size: 24px; }
.avatar-sm { --size: 30px; }
.avatar-lg { --size: 44px; }
.avatar-xl { --size: 56px; }

.avatar-square {
  border-radius: var(--radius-md);
}

/* Inisial di atas warna: pakai nada `fg` (≥ 5:1 dengan putih), bukan `solid` yang hanya untuk titik dan isian. */
.avatar-solid {
  background: var(--tone-fg, var(--primary));
  color: var(--text-inverse);
}

.avatar-group {
  display: inline-flex;
  align-items: center;
}

.avatar-group .avatar {
  box-shadow: 0 0 0 2px var(--surface);
}

.avatar-group .avatar + .avatar {
  margin-left: -8px;
}

.icon-tile {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  background: var(--tone-bg, var(--tone-blue-bg));
  color: var(--tone-fg, var(--tone-blue-fg));
}

.icon-tile .icon {
  width: 18px;
  height: 18px;
}

.icon-tile.is-solid {
  background: var(--tone-solid, var(--primary));
  color: var(--text-inverse);
}

.icon-tile-sm {
  width: 32px;
  height: 32px;
}

.icon-tile-sm .icon {
  width: 15px;
  height: 15px;
}

.icon-tile-lg {
  width: 52px;
  height: 52px;
}

.icon-tile-lg .icon {
  width: 22px;
  height: 22px;
}

.icon-tile.is-round {
  border-radius: 50%;
}

/* -------------------------------------------------------------------------
   Lists
   ------------------------------------------------------------------------- */
.list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 10px 0;
}

.list-divided > .list-item + .list-item {
  border-top: 1px solid var(--border);
}

.list-item-body {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-sub {
  margin-top: 2px;
  overflow: hidden;
  font-size: 12.5px;
  color: var(--text-secondary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-meta {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}

a.list-item,
button.list-item {
  width: 100%;
  margin: 0 -10px;
  padding-left: 10px;
  padding-right: 10px;
  width: calc(100% + 20px);
  border-radius: var(--radius-md);
  color: inherit;
  transition: background var(--duration-fast);
}

@media (hover: hover) and (pointer: fine) {
  a.list-item:hover,
  button.list-item:hover {
    background: var(--slate-50);
    text-decoration: none;
  }
}

/* Key–value description list */
.kv {
  display: grid;
  grid-template-columns: minmax(110px, 38%) 1fr;
  gap: 10px 16px;
  font-size: 13.5px;
}

.kv dt {
  color: var(--text-secondary);
}

.kv dd {
  min-width: 0;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* Date block (Upcoming follow-ups) */
.date-block {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  line-height: 1;
}

.date-block-month {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
}

.date-block-day {
  margin-top: 5px;
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.date-block.is-today {
  background: var(--primary);
}

.date-block.is-today .date-block-month,
.date-block.is-today .date-block-day {
  color: var(--text-inverse);
}

/* -------------------------------------------------------------------------
   Progress & meters
   ------------------------------------------------------------------------- */
.progress {
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--slate-100);
}

.progress-bar {
  display: block;
  width: var(--value, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--tone-solid, var(--primary));
}

.progress-sm {
  height: 6px;
}

.meter-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.meter-label strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------------
   Pipeline chevrons
   ------------------------------------------------------------------------- */
.pipeline-bar {
  display: flex;
  height: 20px;
}

.pipeline-seg {
  flex: 1;
  min-width: 0;
  background: var(--seg, var(--primary));
  clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 50%, calc(100% - 11px) 100%, 0 100%, 11px 50%);
}

.pipeline-seg + .pipeline-seg {
  margin-left: -7px;
}

.pipeline-seg:first-child {
  border-radius: 7px 0 0 7px;
  clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 50%, calc(100% - 11px) 100%, 0 100%);
}

.pipeline-stats {
  display: grid;
  grid-template-columns: repeat(var(--stages, 5), minmax(0, 1fr));
  margin: 18px 0 0;
}

.pipeline-stat {
  min-width: 0;
  padding: 2px 10px;
  border-left: 1px solid var(--border);
}

.pipeline-stat:first-child {
  padding-left: 0;
  border-left: 0;
}

.pipeline-stat dt {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pipeline-stat dd {
  margin: 0;
}

.pipeline-count {
  margin-top: 8px !important;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.pipeline-value {
  margin-top: 4px !important;
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.pipeline-total {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.pipeline-total-label {
  font-size: 13.5px;
  color: var(--text-secondary);
}

.pipeline-total-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------------
   Tabs & segmented control  (JS: [data-tabs] on the tablist)
   ------------------------------------------------------------------------- */
.tabs {
  position: relative; /* contain .sr-only text so it can't create page-level overflow */
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  transition: color var(--duration-fast), background var(--duration-fast), border-color var(--duration-fast);
}

@media (hover: hover) and (pointer: fine) {
  .tab:hover {
    border-color: var(--border-strong);
    color: var(--text);
    text-decoration: none;
  }
}

.tab[aria-selected="true"],
.tab[aria-current="true"] {
  border-color: var(--blue-200);
  background: var(--primary-soft);
  color: var(--primary);
}

.tab[aria-selected="true"] .count {
  background: var(--surface);
  color: var(--primary);
}

.tab .icon {
  width: 16px;
  height: 16px;
}

.card-flush > .tabs {
  padding: 16px 20px 0;
}

.tab-panel:focus-visible {
  outline: 2px solid var(--blue-200);
  outline-offset: 4px;
  border-radius: var(--radius-md);
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
}

.segmented [role="tab"] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--duration-fast), color var(--duration-fast), box-shadow var(--duration-fast);
}

@media (hover: hover) and (pointer: fine) {
  .segmented [role="tab"]:hover {
    color: var(--text);
  }
}

.segmented [role="tab"][aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs), 0 0 0 1px var(--border);
}

.segmented .icon {
  width: 15px;
  height: 15px;
}

/* Vertical tab list (settings sub-navigation) */
.vtabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.vtabs [role="tab"] {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--slate-600);
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.vtabs [role="tab"] .icon {
  color: var(--icon-muted);
}

@media (hover: hover) and (pointer: fine) {
  .vtabs [role="tab"]:hover {
    background: var(--slate-100);
    color: var(--text);
  }
}

.vtabs [role="tab"][aria-selected="true"] {
  background: var(--primary-soft);
  color: var(--primary);
}

.vtabs [role="tab"][aria-selected="true"] .icon {
  color: var(--primary);
}

/* -------------------------------------------------------------------------
   Toolbar / filter bar
   ------------------------------------------------------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.toolbar .search {
  flex: 1 1 240px;
  max-width: 340px;
}

.toolbar-spacer {
  flex: 1;
}

.toolbar-note {
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* -------------------------------------------------------------------------
   Table
   ------------------------------------------------------------------------- */
.table-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-base);
}

.table th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}

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

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

.table tbody tr {
  transition: background var(--duration-fast);
}

@media (hover: hover) and (pointer: fine) {
  .table tbody tr:hover {
    background: var(--surface-muted);
  }
}

.table th:first-child,
.table td:first-child {
  padding-left: 22px;
}

.table th:last-child,
.table td:last-child {
  padding-right: 22px;
}

.table .text-right {
  text-align: right;
}

.table-compact td {
  padding-top: 10px;
  padding-bottom: 10px;
}

.cell-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.cell-title {
  font-weight: 600;
  color: var(--text);
}

.cell-title a,
a.cell-title {
  color: var(--text);
}

.cell-sub {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.row-link {
  color: var(--text);
  font-weight: 600;
  text-align: left;
}

@media (hover: hover) and (pointer: fine) {
  .row-link:hover {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
  }
}

.table-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-secondary);
}

.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

tr.is-flagged td {
  background: color-mix(in srgb, var(--tone-red-bg) 50%, var(--surface));
}

/* Tabel baris-kartu (referensi): tetap <table> semantik, setiap baris tampil sebagai kartu membulat. */
.table-rows {
  border-spacing: 0 8px;
  margin-top: -8px;
}

.table-rows th {
  padding: 4px 16px 2px;
  border: 0;
  background: none;
}

.table-rows td {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.table-rows tbody tr:last-child td {
  border-bottom: 1px solid var(--border);
}

.table-rows td:first-child {
  border-left: 1px solid var(--border);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.table-rows td:last-child {
  border-right: 1px solid var(--border);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

@media (hover: hover) and (pointer: fine) {
  .table-rows tbody tr:hover {
    background: none;
  }

  .table-rows tbody tr:hover td {
    border-color: var(--border-strong);
  }
}

.table-rows .row-end {
  width: 48px;
  text-align: right;
}

.table-rows .cr-state {
  white-space: nowrap;
}

.filter-empty {
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  text-align: center;
}

.row-chevron {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--icon-muted);
}

@media (hover: hover) and (pointer: fine) {
  .row-chevron:hover {
    background: var(--surface-sunken);
    color: var(--text);
  }
}

/* Meter sebaris: batang + persen (keberhasilan, pemakaian anggaran). Warna dari .tone-*. */
.meter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.meter .progress {
  flex: 1 0 64px;
  max-width: 96px;
  height: 6px;
}

/* -------------------------------------------------------------------------
   Callout / banner
   ------------------------------------------------------------------------- */
.callout {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 1px solid color-mix(in srgb, var(--tone-solid, var(--primary)) 22%, transparent);
  border-radius: var(--radius-xl);
  background: var(--tone-bg, var(--primary-soft));
  color: var(--text);
}

.callout-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  background: var(--tone-solid, var(--primary));
  color: var(--text-inverse);
}

.callout-body {
  flex: 1;
  min-width: 0;
}

.callout-title {
  font-size: 14px;
  font-weight: 700;
}

.callout-text {
  margin-top: 2px;
  font-size: 13px;
  color: var(--slate-600);
}

.callout-actions {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  gap: 8px;
}

.callout-sm {
  padding: 10px 14px;
  gap: 10px;
  font-size: 13px;
}

.callout-sm .callout-icon {
  width: 30px;
  height: 30px;
}

.callout-sm .callout-icon .icon {
  width: 16px;
  height: 16px;
}

/* -------------------------------------------------------------------------
   Timeline
   ------------------------------------------------------------------------- */
.timeline {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 18px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  top: 34px;
  bottom: 2px;
  left: 15px;
  width: 2px;
  border-radius: 2px;
  background: var(--border);
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-marker {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--tone-bg, var(--tone-slate-bg));
  color: var(--tone-fg, var(--tone-slate-fg));
}

.timeline-marker .icon {
  width: 15px;
  height: 15px;
}

.timeline-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
}

.timeline-meta {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.timeline-text {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* -------------------------------------------------------------------------
   Kanban  (JS: [data-kanban] board, [data-kanban-col] column, [data-kanban-list] drop zone)
   ------------------------------------------------------------------------- */
.kanban {
  position: relative;
  display: grid;
  grid-auto-columns: minmax(268px, 1fr);
  grid-auto-flow: column;
  align-items: start;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: thin;
}

.kanban-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
}

.kanban-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 2px;
}

.kanban-col-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
}

.kanban-col-title::before {
  content: "";
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 3px;
  background: var(--seg, var(--primary));
}

.kanban-col-header .count {
  background: var(--surface);
}

.kanban-col-header .icon-btn {
  margin-left: auto;
}

.kanban-col-sub {
  padding: 0 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.kanban-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 64px;
  border-radius: var(--radius-md);
  transition: background var(--duration-fast), outline-color var(--duration-fast);
  outline: 2px dashed transparent;
  outline-offset: 3px;
}

.kanban-list.is-over {
  background: color-mix(in srgb, var(--primary) 5%, transparent);
  outline-color: var(--blue-300);
}

.kanban-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  cursor: grab;
  transition: box-shadow var(--duration), border-color var(--duration), opacity var(--duration);
}

@media (hover: hover) and (pointer: fine) {
  .kanban-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
  }
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card.is-dragging {
  opacity: 0.45;
}

.kanban-card-title {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.35;
}

.kanban-card-sub {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.kanban-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.kanban-card-meta .icon {
  width: 13px;
  height: 13px;
}

.kanban-card-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.kanban-more {
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}

@media (hover: hover) and (pointer: fine) {
  .kanban-more:hover {
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    color: var(--text);
    text-decoration: none;
  }
}

.kanban-col.is-collapsed {
  opacity: 0.85;
}

/* -------------------------------------------------------------------------
   Calendar (month grid)
   ------------------------------------------------------------------------- */
.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--border);
}

.calendar-weekday {
  padding: 10px 12px;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.calendar-day {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  min-height: 116px;
  padding: 8px;
  background: var(--surface);
}

.calendar-day.is-muted {
  background: var(--surface-muted);
}

.calendar-day.is-muted .calendar-date {
  color: var(--text-muted);
}

.calendar-date {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.calendar-day.is-today .calendar-date {
  background: var(--primary);
  color: var(--text-inverse);
}

.calendar-event {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--tone-bg, var(--primary-soft));
  color: var(--tone-fg, var(--primary));
  font-size: 11.5px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.calendar-event::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--tone-solid, var(--primary));
}

.calendar-event > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

button.calendar-event {
  width: 100%;
}

@media (hover: hover) and (pointer: fine) {
  button.calendar-event:hover {
    filter: brightness(0.97);
  }
}

/* -------------------------------------------------------------------------
   Log block (bot run traces)
   ------------------------------------------------------------------------- */
.log {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--slate-700);
}

.log-line {
  display: grid;
  grid-template-columns: 62px 18px minmax(0, 1fr);
  align-items: baseline;
  gap: 8px;
  white-space: pre-wrap;
}

.log-time {
  color: var(--text-muted);
}

.log-mark {
  font-weight: 700;
}

.log-ok .log-mark { color: var(--tone-green-fg); }
.log-warn .log-mark { color: var(--tone-amber-fg); }
.log-err .log-mark { color: var(--tone-red-fg); }
.log-info .log-mark { color: var(--tone-blue-fg); }

/* -------------------------------------------------------------------------
   Dropdown  (JS: [data-dropdown] > [data-dropdown-trigger] + [data-dropdown-menu])
   ------------------------------------------------------------------------- */
.dropdown {
  position: relative;
  display: inline-flex;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: var(--z-dropdown);
  min-width: 210px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in var(--duration) var(--ease-out);
}

.dropdown-menu.align-left {
  left: 0;
  right: auto;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--text-base);
  text-align: left;
  white-space: nowrap;
}

.dropdown-item .icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.dropdown-item:focus-visible {
  background: var(--slate-100);
  text-decoration: none;
  outline: none;
}

@media (hover: hover) and (pointer: fine) {
  .dropdown-item:hover {
    background: var(--slate-100);
    text-decoration: none;
    outline: none;
  }
}

.dropdown-item[aria-checked="true"] {
  color: var(--primary);
  font-weight: 600;
}

.dropdown-item[aria-checked="true"] .icon {
  color: var(--primary);
}

.dropdown-item.is-danger {
  color: var(--tone-red-fg);
}

.dropdown-sep {
  height: 1px;
  margin: 6px 0;
  background: var(--border);
}

.dropdown-header {
  padding: 8px 10px 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

/* Notification panel inside dropdown */
.notif-menu {
  width: 360px;
  max-width: calc(100vw - 24px);
  padding: 0;
}

.notif-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  color: inherit;
}

.notif-item.is-unread {
  background: var(--primary-soft);
}

.notif-item + .notif-item {
  border-top: 1px solid var(--border);
}

.notif-item:focus-visible {
  background: var(--slate-50);
  text-decoration: none;
  outline: none;
}

@media (hover: hover) and (pointer: fine) {
  .notif-item:hover {
    background: var(--slate-50);
    text-decoration: none;
    outline: none;
  }
}

.notif-item-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  white-space: normal;
}

.notif-item-time {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.notif-menu-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
}

/* -------------------------------------------------------------------------
   Dialogs: modal & drawer  (native <dialog>; JS: [data-open="id"], [data-close])
   ------------------------------------------------------------------------- */
dialog.modal,
dialog.drawer {
  padding: 0;
  border: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

dialog.modal::backdrop,
dialog.drawer::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(2px);
}

dialog.modal {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  border-radius: var(--radius-xl);
}

dialog.modal.modal-lg {
  width: min(820px, calc(100vw - 32px));
}

dialog.modal[open] {
  display: flex;
  flex-direction: column;
  animation: modal-in var(--duration-slow) var(--ease-out);
}

dialog.drawer {
  width: min(560px, calc(100vw - 24px));
  height: calc(100dvh - 24px);
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  margin: 12px 12px 12px auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
}

dialog.drawer[open] {
  display: flex;
  flex-direction: column;
  animation: drawer-in var(--duration-slow) var(--ease-out);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
}

/* Wrapper filled from a <template> by app.js — transparent to the dialog's flex layout */
[data-dialog-content] {
  display: contents;
}

.dialog-header .icon-btn {
  margin: -6px -10px 0 auto;
}

.dialog-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-snug);
}

.dialog-subtitle {
  margin-top: 4px;
  font-size: var(--text-base);
  color: var(--text-secondary);
}

.dialog-body {
  flex: 1;
  min-height: 0;
  padding: 22px 28px 28px;
  overflow-y: auto;
}

.dialog-body:focus-visible {
  outline-offset: -3px;
}

.dialog-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

.dialog-footer .footer-note {
  margin-right: auto;
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* Toast (BotOps.toast di app.js) bergaya Sonner: .ui-toaster dan .ui-toast di ui.css. */

/* -------------------------------------------------------------------------
   Empty state
   ------------------------------------------------------------------------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 13.5px;
  text-align: center;
}

.empty .icon-tile {
  margin-bottom: 6px;
}

.empty-title {
  color: var(--text);
  font-size: 14.5px;
  font-weight: 700;
}

/* -------------------------------------------------------------------------
   Stepper (outreach sequence, daily flow)
   ------------------------------------------------------------------------- */
.stepper {
  position: relative;
  display: flex;
  overflow-x: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step {
  position: relative;
  flex: 1;
  min-width: 170px;
  padding-right: 16px;
}

.step::before {
  content: "";
  position: absolute;
  top: 17px;
  left: 44px;
  right: 10px;
  height: 2px;
  border-radius: 2px;
  background: var(--border-strong);
}

.step:last-child::before {
  display: none;
}

.step-marker {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--tone-bg, var(--primary-soft));
  color: var(--tone-fg, var(--primary));
  font-size: 13px;
  font-weight: 800;
}

.step-marker .icon {
  width: 16px;
  height: 16px;
}

.step-title {
  margin-top: 10px;
  font-size: 13.5px;
  font-weight: 700;
}

.step-meta {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* -------------------------------------------------------------------------
   Legend, chart (HTML axes + stretched SVG plot)
   ------------------------------------------------------------------------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-item::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c, var(--primary));
}

.legend-item.is-line::before {
  height: 3px;
  border-radius: 2px;
}

.chart {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 26px;
  height: var(--chart-h, 236px);
}

.chart-y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin: -7px 0;
  color: var(--text-muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.chart-plot {
  position: relative;
  min-width: 0;
}

.chart-gridlines {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.chart-gridlines span {
  height: 0;
  border-top: 1px dashed var(--slate-200);
}

.chart-gridlines span:last-child {
  border-top-style: solid;
  border-color: var(--slate-300);
}

.chart-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-area {
  stroke: none;
}

.chart-line {
  fill: none;
  stroke: var(--c, var(--primary));
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.chart-line.is-dashed {
  stroke-dasharray: 5 5;
  stroke-width: 2;
}

.chart-point {
  position: absolute;
  width: 11px;
  height: 11px;
  border: 2.5px solid var(--c, var(--primary));
  border-radius: 50%;
  background: var(--surface);
  transform: translate(-50%, -50%);
}

.chart-point.is-small {
  width: 8px;
  height: 8px;
  border-width: 2px;
}

.chart-tip {
  position: absolute;
  z-index: 2;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  transform: translate(calc(-100% - 14px), -50%);
}

.chart-tip strong {
  display: block;
  color: var(--primary);
  font-size: 13.5px;
  font-weight: 800;
}

.chart-tip span {
  color: var(--text-muted);
}

.chart-x {
  display: flex;
  justify-content: space-between;
  grid-column: 2;
  padding-top: 8px;
  color: var(--text-muted);
  font-size: 11.5px;
  white-space: nowrap;
}

/* Donut (conic-gradient) */
.donut {
  --size: 132px;
  position: relative;
  display: grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  flex: none;
  border-radius: 50%;
  background: var(--donut);
}

.donut::after {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  background: var(--surface);
}

.donut-center {
  position: relative;
  z-index: 1;
  text-align: center;
  line-height: 1.2;
}

.donut-center strong {
  display: block;
  font-size: 22px;
  font-weight: 800;
}

.donut-center span {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Horizontal bars (simple bar list) */
.bar-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.9fr) minmax(0, 2fr) 40px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.bar-row .progress {
  height: 8px;
}

.bar-row-value {
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------------
   Rule item (locked safety rules) & setting rows
   ------------------------------------------------------------------------- */
.rule {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
}

.rule + .rule {
  border-top: 1px solid var(--border);
}

.rule-body {
  flex: 1;
  min-width: 0;
}

.rule-title {
  font-size: 14px;
  font-weight: 700;
}

.rule-text {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-secondary);
}

.setting-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 16px 0;
}

.setting-row + .setting-row {
  border-top: 1px solid var(--border);
}

.setting-row-body {
  flex: 1 1 280px;
  min-width: 0;
}

.setting-row-title {
  font-size: 14px;
  font-weight: 600;
}

.setting-row-text {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* -------------------------------------------------------------------------
   Message preview (email / WhatsApp drafts)
   ------------------------------------------------------------------------- */
.message {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.message-head {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 6px 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.message-head dt {
  color: var(--text-muted);
}

.message-head dd {
  min-width: 0;
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.message-body {
  padding: 16px;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-line;
}

.message-body[contenteditable="true"]:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--blue-200);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.wa-bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 12px 12px 12px 4px;
  background: var(--wa-bubble-bg);
  color: var(--wa-bubble-fg);
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-line;
}

/* Checklist (guardrails) */
.checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--slate-700);
}

.checklist .icon {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  color: var(--tone-green-fg);
}

.checklist li.is-warn .icon {
  color: var(--tone-amber-fg);
}

.checklist li.is-fail .icon {
  color: var(--tone-red-fg);
}

/* Approval card state */
[data-approval-item] {
  transition: opacity var(--duration), background var(--duration);
}

[data-approval-item].is-approved,
[data-approval-item].is-rejected,
[data-approval-item].is-answered {
  background: var(--surface-muted);
}

[data-approval-item].is-rejected .approval-preview,
[data-approval-item].is-approved .approval-preview {
  opacity: 0.65;
}

/* Divider with text */
.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.divider-text::before,
.divider-text::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Keyboard key */
.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--slate-600);
  font-family: var(--font-mono);
  font-size: 11.5px;
}

/* -------------------------------------------------------------------------
   Umpan balik tekan — berlaku untuk sentuh dan mouse (hover hanya untuk mouse).
   Memakai properti `scale` agar tidak bentrok dengan `transform` komponen; transisi diulang lengkap di sini.
   ------------------------------------------------------------------------- */
.icon-btn,
.row-chevron,
.topnav-link,
.nav-link {
  transition: background var(--duration-fast), color var(--duration-fast), scale var(--duration-fast) var(--ease-out);
}

button.chip,
a.chip {
  transition: background var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast),
    scale var(--duration-fast) var(--ease-out);
}

a.kpi-card {
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast), scale var(--duration-fast) var(--ease-out);
}

.icon-btn:active,
.row-chevron:active,
.topnav-link:active,
.nav-link:active,
button.chip:active,
a.chip:active {
  scale: 0.95;
}

a.kpi-card:active {
  scale: 0.985;
}

a.list-item:active,
button.list-item:active,
.dropdown-item:active {
  background: var(--surface-sunken);
}

/* -------------------------------------------------------------------------
   Animations
   ------------------------------------------------------------------------- */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes drawer-in {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: none; }
}

@keyframes sheet-in {
  from { transform: translateY(100%); }
  to { transform: none; }
}

/* -------------------------------------------------------------------------
   Responsive adjustments for components
   ------------------------------------------------------------------------- */
/* Perangkat sentuh: tinggi tombol minimal 44px (target sentuh); kontrol header punya ukuran tetap sendiri. */
@media (pointer: coarse) {
  .btn {
    min-height: 44px;
  }

  .btn-icon {
    min-width: 44px;
  }

  .topbar .btn {
    min-height: 0;
  }
}
/* Tabel baris-kartu .is-stack di ponsel: setiap baris menjadi kartu bertumpuk, label kolom dari data-label. */
@media (max-width: 767px) {
  .table-rows.is-stack,
  .table-rows.is-stack tbody,
  .table-rows.is-stack tr,
  .table-rows.is-stack td {
    display: block;
  }

  .table-rows.is-stack {
    margin-top: 0;
    border-spacing: 0;
  }

  .table-rows.is-stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .table-rows.is-stack tr {
    position: relative;
    margin-bottom: 10px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
  }

  .table-rows.is-stack td,
  .table-rows.is-stack td:first-child,
  .table-rows.is-stack td:last-child,
  .table-rows.is-stack tbody tr:last-child td {
    padding: 8px 0;
    border: 0;
    border-radius: 0;
    background: none;
  }

  .table-rows.is-stack td[data-label] {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 12px;
    border-top: 1px solid var(--border);
    text-align: right;
  }

  .table-rows.is-stack td[data-label]::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: var(--text-sm);
    text-align: left;
  }

  .table-rows.is-stack td:first-child {
    padding-right: 40px;
  }

  .table-rows.is-stack td.row-end {
    position: absolute;
    top: 10px;
    right: 6px;
    width: auto;
    padding: 0;
  }

  .table-rows.is-stack .cell-main {
    min-width: 0;
  }
}

@media (max-width: 767px) {
  .panel {
    padding: 20px 16px;
    border-radius: var(--radius-xl);
  }

  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  /* KPI ringkas di ponsel: ikon kecil sebaris label, angka dan catatan di bawahnya (isi .kpi-card-body ikut grid kartu). */
  .kpi-card {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-content: start;
    align-items: center;
    gap: 2px 8px;
    padding: 12px;
  }

  .kpi-card-body {
    display: contents;
  }

  .kpi-card-icon {
    width: 28px;
    height: 28px;
  }

  .kpi-card-icon .icon {
    width: 15px;
    height: 15px;
  }

  .kpi-card-label {
    line-height: 1.3;
  }

  .kpi-card-value,
  .kpi-card-note {
    grid-column: 1 / -1;
  }

  .kpi-card-value {
    margin-top: 6px;
    font-size: var(--text-2xl);
  }

  /* Chip saring satu baris yang digeser horizontal sampai tepi layar/panel; chip yang terpotong di tepi menandakan masih ada.
     contain: inline-size — lebar intrinsik grup tidak ikut deretan chip, jadi pembungkus grid/flex tidak ikut melebar (luber). */
  [data-chip-group] {
    flex: 1 1 100%;
    flex-wrap: nowrap;
    min-width: 0;
    margin-inline: -16px;
    padding: 2px 16px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-padding-inline: 16px;
    scrollbar-width: none;
    contain: inline-size;
  }

  [data-chip-group]::-webkit-scrollbar {
    display: none;
  }

  [data-chip-group] > .chip {
    flex: none;
  }

  .card {
    padding: 16px;
  }

  .card-flush {
    padding: 0;
  }

  .card-flush > .card-header {
    padding: 16px 16px 12px;
  }

  .table th:first-child,
  .table td:first-child {
    padding-left: 16px;
  }

  .table th:last-child,
  .table td:last-child {
    padding-right: 16px;
  }

  .table-footer,
  .card-flush > .card-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .kpi-trend {
    gap: 4px;
  }

  .pipeline-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    row-gap: 16px;
  }

  .pipeline-stat:nth-child(3n + 1) {
    padding-left: 0;
    border-left: 0;
  }

  .pipeline-stat dt::before {
    content: "";
    width: 8px;
    height: 8px;
    flex: none;
    border-radius: 3px;
    background: var(--seg, var(--primary));
  }

  .callout {
    flex-wrap: wrap;
  }

  .callout-actions {
    width: 100%;
  }

  /* Drawer menjadi sheet bawah: naik dari bawah dengan sudut atas membulat, menyisakan sedikit halaman di atasnya. */
  dialog.drawer {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: calc(100dvh - var(--safe-top) - 24px);
    margin: auto 0 0;
    padding-bottom: var(--safe-bottom);
    border: 0;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  }

  dialog.drawer[open] {
    animation-name: sheet-in;
  }

  .dialog-header,
  .dialog-body,
  .dialog-footer {
    padding-left: 18px;
    padding-right: 18px;
  }

  .calendar-day {
    min-height: 84px;
    padding: 6px 4px;
  }
}
