/* ==========================================================================
   Components — buttons, forms, cards, badges, tables, overlays, feedback
   ========================================================================== */

/* ------------------------------------------------------------------ buttons */
.btn {
  --btn-bg: var(--surface-solid);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 38px; padding: 0 var(--sp-4);
  border: 1px solid var(--btn-bd); border-radius: var(--radius-sm);
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: var(--fs-sm); font-weight: 600; line-height: 1; white-space: nowrap;
  text-decoration: none !important;
  box-shadow: var(--shadow-xs);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), color var(--dur-fast);
  user-select: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  --btn-bg: var(--primary); --btn-fg: #fff; --btn-bd: transparent;
  background: var(--brand-gradient);
  box-shadow: 0 1px 2px rgba(17, 114, 216, .25), 0 4px 14px rgba(17, 114, 216, .22), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn-primary:hover { background: var(--brand-gradient); filter: brightness(1.06); border-color: transparent; }
.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: transparent; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.06); }
.btn-success { --btn-bg: var(--success); --btn-fg: #fff; --btn-bd: transparent; }
.btn-success:hover { background: var(--success); filter: brightness(1.06); }
.btn-soft { --btn-bg: var(--primary-soft); --btn-fg: var(--primary-text); --btn-bd: transparent; box-shadow: none; }
.btn-soft:hover { background: var(--surface-active); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-danger-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--danger-text); box-shadow: none; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-xs); border-radius: 7px; }
.btn-lg { min-height: 46px; padding: 0 var(--sp-6); font-size: var(--fs-md); border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn .spinner { width: 14px; height: 14px; border-width: 2px; }
.btn.is-busy { color: transparent !important; pointer-events: none; }
.btn.is-busy > :not(.btn-busy) { visibility: hidden; }
.btn-busy { position: absolute; inset: 0; display: grid; place-items: center; color: var(--btn-fg); }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: var(--sp-2); }

/* Icon button (topbar etc.) */
.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: var(--radius-sm); color: var(--text-2);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot {
  position: absolute; top: 6px; right: 5px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--surface-solid);
}

/* -------------------------------------------------------------------- cards */
.card {
  position: relative;
  background: var(--surface);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 1px 0 var(--glass-border);
}
.card-pad { padding: var(--sp-5); }
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border);
}
.card-header h2, .card-header h3 { font-size: var(--fs-md); font-weight: 650; }
.card-header .sub { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
.card-body { padding: var(--sp-5); }
.card-footer { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--sp-2); }
.card-flush .card-body { padding: 0; }
.card-interactive { cursor: pointer; transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur); }
.card-interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.card-interactive:focus-visible { box-shadow: var(--shadow-focus); }
.card-hero {
  overflow: hidden; color: #fff; border: 0;
  background: radial-gradient(600px 240px at 100% 0%, rgba(98, 192, 243, .35), transparent 60%),
              linear-gradient(135deg, var(--navy-850), var(--navy-700) 55%, #12509a);
}
.card-hero h1, .card-hero h2, .card-hero h3 { color: #fff; }
.card-hero .muted { color: rgba(232, 240, 250, .72); }

/* -------------------------------------------------------------- stat cards */
.stat {
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-5); min-height: 118px;
}
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.stat-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.stat-icon {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-text);
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-value { font-family: var(--font-display); font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat-meta { font-size: var(--fs-xs); color: var(--text-3); display: flex; align-items: center; gap: var(--sp-1); flex-wrap: wrap; }
.stat[data-tone="success"] .stat-icon { background: var(--success-soft); color: var(--success-text); }
.stat[data-tone="warning"] .stat-icon { background: var(--warning-soft); color: var(--warning-text); }
.stat[data-tone="danger"] .stat-icon { background: var(--danger-soft); color: var(--danger-text); }
.stat[data-tone="violet"] .stat-icon { background: var(--violet-soft); color: var(--violet-text); }
.stat[data-tone="info"] .stat-icon { background: var(--info-soft); color: var(--info-text); }
.stat-link { cursor: pointer; }
.stat-link:hover { border-color: var(--border-strong); }

/* ------------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: var(--radius-pill);
  font-size: var(--fs-2xs); font-weight: 650; letter-spacing: .01em; white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral-text);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.no-dot::before { display: none; }
.badge-primary, .badge-info { background: var(--info-soft); color: var(--info-text); }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-violet { background: var(--violet-soft); color: var(--violet-text); }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral-text); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  height: 28px; padding: 0 10px; border-radius: var(--radius-pill);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  font-size: var(--fs-xs); font-weight: 500;
}
.chip button { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; color: var(--text-3); }
.chip button:hover { background: var(--surface-3); color: var(--text); }
.chip svg { width: 13px; height: 13px; }

.priority { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.priority svg { width: 14px; height: 14px; }
.priority-low { color: var(--text-3); }
.priority-normal { color: var(--info-text); }
.priority-high { color: var(--warning-text); }
.priority-urgent { color: var(--danger-text); }

/* ------------------------------------------------------------------ avatars */
.avatar {
  --size: 32px;
  position: relative; flex-shrink: 0;
  width: var(--size); height: var(--size); border-radius: 50%;
  display: inline-grid; place-items: center; overflow: hidden;
  background: var(--brand-gradient); color: #fff;
  font-size: calc(var(--size) * .38); font-weight: 650; letter-spacing: .02em;
  box-shadow: 0 0 0 2px var(--surface-solid);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xs { --size: 22px; }
.avatar-sm { --size: 28px; }
.avatar-lg { --size: 44px; }
.avatar-xl { --size: 72px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar + .avatar { margin-left: -8px; }
.avatar-more { background: var(--surface-3); color: var(--text-2); }
.user-cell { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.user-cell .meta { min-width: 0; }
.user-cell .name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-cell .sub { font-size: var(--fs-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -------------------------------------------------------------------- forms */
.form { display: flex; flex-direction: column; gap: var(--sp-4); }
.form-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid-3 { display: grid; gap: var(--sp-4); grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 720px) { .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); } }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label {
  font-size: var(--fs-sm); font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.field .req { color: var(--danger-text); font-weight: 700; }
.field .opt { color: var(--text-3); font-weight: 500; font-size: var(--fs-xs); }
.field-hint { font-size: var(--fs-xs); color: var(--text-3); }
.field-error { font-size: var(--fs-xs); color: var(--danger-text); font-weight: 500; display: none; }
.field.has-error .field-error { display: block; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 9px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-solid); color: var(--text);
  font-size: var(--fs-base); line-height: 1.35;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: .85; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--brand-300); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--shadow-focus); }
.input[disabled], .select[disabled], .textarea[disabled], .input[readonly] { background: var(--surface-2); color: var(--text-2); cursor: not-allowed; }
.input[readonly] { cursor: default; }
.textarea { min-height: 96px; resize: vertical; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236a7b92' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.select[multiple] { background-image: none; padding-right: 12px; min-height: 120px; }
.input-sm, .select-sm { min-height: 34px; padding-top: 6px; padding-bottom: 6px; font-size: var(--fs-sm); }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > svg { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.input-group > .input { padding-left: 36px; }

.check { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: var(--fs-sm); color: var(--text-2); line-height: 1.4; }
.check input { appearance: none; -webkit-appearance: none; flex-shrink: 0; margin: 1px 0 0; width: 18px; height: 18px; border: 1.5px solid var(--border-strong); border-radius: 5px; background: var(--surface-solid); display: grid; place-items: center; cursor: pointer; transition: background var(--dur-fast), border-color var(--dur-fast); }
.check input[type="radio"] { border-radius: 50%; }
.check input:checked { background: var(--primary); border-color: var(--primary); }
.check input:checked::after { content: ""; width: 10px; height: 6px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.check input[type="radio"]:checked::after { width: 8px; height: 8px; border: 0; border-radius: 50%; background: #fff; transform: none; }
.check input:focus-visible { box-shadow: var(--shadow-focus); outline: none; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--fs-sm); color: var(--text-2); }
.switch input { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; transition: background var(--dur); flex-shrink: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-xs); transition: transform var(--dur) var(--ease); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:focus-visible { box-shadow: var(--shadow-focus); outline: none; }

.form-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); flex-wrap: wrap; padding-top: var(--sp-2); }
.form-section { padding-bottom: var(--sp-5); border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: 0; padding-bottom: 0; }
.form-section-title { font-size: var(--fs-md); font-weight: 650; margin-bottom: var(--sp-1); }
.form-section-desc { font-size: var(--fs-sm); color: var(--text-3); margin-bottom: var(--sp-4); }

/* Tag input */
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; min-height: 40px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-solid); cursor: text; }
.tag-input:focus-within { border-color: var(--brand-500); box-shadow: var(--shadow-focus); }
.tag-input input { flex: 1; min-width: 120px; border: 0; background: transparent; padding: 4px 6px; outline: none; }

/* Range */
input[type="range"] { accent-color: var(--primary); width: 100%; }

/* ---------------------------------------------------------------- toolbar */
.toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.toolbar .input-group { flex: 1 1 240px; max-width: 360px; }
.toolbar .select { width: auto; min-width: 140px; }
.toolbar-spacer { flex: 1; }

/* Segmented control */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 10px; border: 1px solid var(--border); }
.segmented button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 7px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); transition: background var(--dur-fast), color var(--dur-fast); }
.segmented button svg { width: 15px; height: 15px; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-xs); }

/* Tabs */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-5); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-3); white-space: nowrap; border-radius: 8px 8px 0 0; transition: color var(--dur-fast); }
.tab:hover { color: var(--text); background: var(--surface-hover); }
.tab[aria-selected="true"] { color: var(--primary-text); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand-gradient); }
.tab .count { min-width: 20px; height: 18px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 10px; display: inline-grid; place-items: center; }
.tab[aria-selected="true"] .count { background: var(--primary-soft); color: var(--primary-text); }

/* ------------------------------------------------------------------- tables */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; font-size: var(--fs-sm); }
.table th {
  position: sticky; top: 0; z-index: 1;
  padding: 10px var(--sp-4); text-align: left; white-space: nowrap;
  font-size: var(--fs-2xs); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th .sort-ind { display: inline-block; margin-left: 4px; opacity: .5; }
.table th[aria-sort="ascending"] .sort-ind, .table th[aria-sort="descending"] .sort-ind { opacity: 1; color: var(--primary-text); }
.table td { padding: 12px var(--sp-4); border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
.table td.strong, .table td .strong { color: var(--text); }
.table tbody tr { transition: background var(--dur-fast); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .check-col { width: 40px; padding-right: 0; }
.table .actions-col { width: 1%; white-space: nowrap; text-align: right; }

/* Responsive list fallback for tables (rendered by ui.dataTable) */
.rlist { display: none; }
.rlist-item { display: flex; flex-direction: column; gap: 6px; padding: var(--sp-4); border-bottom: 1px solid var(--border); cursor: default; }
.rlist-item.clickable { cursor: pointer; }
.rlist-item:last-child { border-bottom: 0; }
.rlist-row { display: flex; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-sm); }
.rlist-row .k { color: var(--text-3); font-size: var(--fs-xs); }
@media (max-width: 760px) {
  .dt-responsive .table-wrap { display: none; }
  .dt-responsive .rlist { display: block; }
}

/* Pagination */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-3); flex-wrap: wrap; }

/* Bulk action bar */
.bulkbar { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-4); background: var(--primary-soft); color: var(--primary-text); font-size: var(--fs-sm); font-weight: 600; border-bottom: 1px solid var(--border); flex-wrap: wrap; }

/* -------------------------------------------------------------- list items */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: var(--sp-3); padding: 12px var(--sp-5); border-bottom: 1px solid var(--border); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; transition: background var(--dur-fast); }
.list-item.clickable:hover { background: var(--surface-hover); }
.list-item .li-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex-shrink: 0; }
.list-item .li-icon svg { width: 17px; height: 17px; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; color: var(--text); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-sub { font-size: var(--fs-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-end { flex-shrink: 0; display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--text-3); }

/* Definition list */
.dl { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 10px var(--sp-4); font-size: var(--fs-sm); margin: 0; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; color: var(--text); font-weight: 500; word-break: break-word; }
@media (max-width: 480px) { .dl { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: 8px; } }

/* -------------------------------------------------------------- progress */
.progress { position: relative; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--brand-gradient); transition: width var(--dur-slow) var(--ease-out); }
.progress-sm { height: 5px; }
.progress[data-tone="success"] > span { background: var(--success); }
.progress[data-tone="warning"] > span { background: var(--warning); }
.progress[data-tone="danger"] > span { background: var(--danger); }

.ring { position: relative; display: inline-grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-label { position: absolute; font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md); }

/* Stepper */
.steps { display: flex; gap: var(--sp-2); list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps li { flex: 1; display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); min-width: 0; }
.steps li::before { content: ""; height: 4px; border-radius: 4px; background: var(--surface-3); transition: background var(--dur); }
.steps li[data-state="done"]::before, .steps li[data-state="current"]::before { background: var(--brand-gradient); }
.steps li[data-state="current"] { color: var(--primary-text); }
.steps li[data-state="done"] { color: var(--text-2); }
.steps li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .steps li span { display: none; } .steps li[data-state="current"] span { display: block; } }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 13px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; display: flex; gap: var(--sp-3); padding-bottom: var(--sp-4); }
.timeline li:last-child { padding-bottom: 0; }
.timeline .tl-dot { position: relative; z-index: 1; flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-solid); border: 2px solid var(--border-strong); color: var(--text-3); }
.timeline .tl-dot svg { width: 13px; height: 13px; }
.timeline .tl-dot[data-tone="success"] { border-color: var(--success); color: var(--success-text); }
.timeline .tl-dot[data-tone="primary"] { border-color: var(--primary); color: var(--primary-text); }
.timeline .tl-dot[data-tone="warning"] { border-color: var(--warning); color: var(--warning-text); }
.timeline .tl-dot[data-tone="danger"] { border-color: var(--danger); color: var(--danger-text); }
.timeline .tl-body { flex: 1; min-width: 0; padding-top: 3px; font-size: var(--fs-sm); color: var(--text-2); }
.timeline .tl-body strong { color: var(--text); }
.timeline .tl-time { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }

/* ---------------------------------------------------------- feedback states */
.spinner { width: 20px; height: 20px; border: 2.5px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }

.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 40%, var(--surface-3) 80%);
  background-size: 800px 100%;
  animation: shimmer 1.4s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.sk-line { height: 12px; margin: 8px 0; }
.sk-title { height: 20px; width: 40%; margin-bottom: 14px; }
.sk-block { height: 120px; }
.sk-circle { width: 36px; height: 36px; border-radius: 50%; }

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2);
  padding: var(--sp-10) var(--sp-6); color: var(--text-3);
}
.empty-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--brand-gradient-soft); color: var(--primary-text); margin-bottom: var(--sp-2); }
.empty-icon svg { width: 26px; height: 26px; }
.empty h3 { font-size: var(--fs-md); color: var(--text); }
.empty p { max-width: 420px; font-size: var(--fs-sm); margin: 0; }
.empty .btn { margin-top: var(--sp-3); }
.empty-sm { padding: var(--sp-6) var(--sp-4); }
.empty-sm .empty-icon { width: 42px; height: 42px; border-radius: 12px; }
.empty-sm .empty-icon svg { width: 20px; height: 20px; }

.alert { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); font-size: var(--fs-sm); background: var(--info-soft); color: var(--text); border: 1px solid transparent; }
.alert > svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; color: var(--info-text); }
.alert-title { font-weight: 650; margin-bottom: 2px; }
.alert p:last-child { margin-bottom: 0; }
.alert-success { background: var(--success-soft); } .alert-success > svg { color: var(--success-text); }
.alert-warning { background: var(--warning-soft); } .alert-warning > svg { color: var(--warning-text); }
.alert-danger { background: var(--danger-soft); } .alert-danger > svg { color: var(--danger-text); }
.alert-neutral { background: var(--surface-2); border-color: var(--border); } .alert-neutral > svg { color: var(--text-3); }

/* ------------------------------------------------------------------ toasts */
.toast-stack { position: fixed; z-index: var(--z-toast); right: var(--sp-5); bottom: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: 12px 14px; border-radius: var(--radius); background: var(--surface-solid); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: var(--fs-sm); color: var(--text);
  animation: fade-up var(--dur) var(--ease-out);
}
.toast > svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.toast-success > svg { color: var(--success); }
.toast-error > svg { color: var(--danger); }
.toast-warning > svg { color: var(--warning); }
.toast-info > svg { color: var(--info); }
.toast .toast-body { flex: 1; min-width: 0; }
.toast .toast-title { font-weight: 650; }
.toast .toast-close { color: var(--text-3); width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; }
.toast .toast-close:hover { background: var(--surface-hover); color: var(--text); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all var(--dur) var(--ease); }
@media (max-width: 560px) { .toast-stack { right: 16px; left: 16px; bottom: 16px; width: auto; } }

/* ------------------------------------------------------------- modal/drawer */
.overlay {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: var(--overlay); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: var(--sp-5);
  animation: fade-in var(--dur) var(--ease);
}
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); animation: fade-up var(--dur-slow) var(--ease-out);
}
.modal-sm { width: min(440px, 100%); }
.modal-lg { width: min(820px, 100%); }
.modal-xl { width: min(1100px, 100%); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6) var(--sp-3); }
.modal-header h2 { font-size: var(--fs-lg); }
.modal-header .sub { font-size: var(--fs-sm); color: var(--text-3); margin-top: 4px; }
.modal-body { padding: var(--sp-2) var(--sp-6) var(--sp-5); overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-xl) var(--radius-xl); flex-wrap: wrap; }
.modal-footer .left { margin-right: auto; }
@media (max-width: 560px) {
  .overlay { padding: 0; place-items: end stretch; }
  .modal, .modal-sm, .modal-lg, .modal-xl { width: 100%; max-height: 92vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .modal-footer { border-radius: 0; }
  .modal-header, .modal-body, .modal-footer { padding-left: var(--sp-4); padding-right: var(--sp-4); }
}

.drawer-overlay { position: fixed; inset: 0; z-index: var(--z-drawer); background: var(--overlay); animation: fade-in var(--dur) var(--ease); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: calc(var(--z-drawer) + 1);
  width: min(720px, 100vw); display: flex; flex-direction: column;
  background: var(--surface-solid); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: drawer-in var(--dur-slow) var(--ease-out);
}
.drawer-sm { width: min(460px, 100vw); }
.drawer-lg { width: min(960px, 100vw); }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border); }
.drawer-header h2 { font-size: var(--fs-lg); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--sp-5) var(--sp-6); }
.drawer-footer { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
@media (max-width: 560px) { .drawer-header, .drawer-body, .drawer-footer { padding-left: var(--sp-4); padding-right: var(--sp-4); } }

/* ---------------------------------------------------------------- dropdown */
.menu {
  position: fixed; z-index: var(--z-dropdown); min-width: 200px; max-width: 320px; padding: 6px;
  background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); animation: fade-up var(--dur) var(--ease-out);
}
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; font-size: var(--fs-sm); color: var(--text-2); text-align: left; text-decoration: none !important; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-hover); color: var(--text); outline: none; }
.menu-item svg { width: 16px; height: 16px; color: var(--text-3); flex-shrink: 0; }
.menu-item.danger { color: var(--danger-text); }
.menu-item.danger svg { color: var(--danger-text); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu-label { padding: 6px 10px 4px; font-size: var(--fs-2xs); font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }

/* Tooltip (title-less, CSS only) */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
  padding: 5px 8px; border-radius: 6px; background: var(--navy-900); color: #fff; font-size: 11px; font-weight: 500;
  white-space: nowrap; pointer-events: none; z-index: 5; box-shadow: var(--shadow);
}

/* ----------------------------------------------------------------- files */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-6); border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); text-align: center; color: var(--text-3); font-size: var(--fs-sm); cursor: pointer; transition: border-color var(--dur-fast), background var(--dur-fast); }
.dropzone:hover, .dropzone.dragover { border-color: var(--brand-500); background: var(--primary-soft); }
.dropzone svg { width: 26px; height: 26px; color: var(--primary-text); }
.file-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.file-item { display: flex; align-items: center; gap: var(--sp-3); padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-solid); font-size: var(--fs-sm); min-width: 0; }
.file-item .fi-icon { width: 32px; height: 32px; border-radius: 8px; background: var(--primary-soft); color: var(--primary-text); display: grid; place-items: center; flex-shrink: 0; }
.file-item .fi-icon svg { width: 16px; height: 16px; }
.file-item .fi-main { flex: 1; min-width: 0; }
.file-item .fi-name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .fi-meta { font-size: var(--fs-xs); color: var(--text-3); }
.file-item .progress { margin-top: 6px; }
.file-item.error { border-color: var(--danger); background: var(--danger-soft); }

/* ----------------------------------------------------------------- charts */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis-label { fill: var(--chart-axis); font-size: 11px; font-family: var(--font-sans); }
.chart .bar { transition: opacity var(--dur-fast); }
.chart .bar:hover, .chart .slice:hover { opacity: .82; }
.chart .line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .14; }
.chart .dot { stroke: var(--surface-solid); stroke-width: 2; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-xs); color: var(--text-2); margin-top: var(--sp-3); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; padding: 8px 10px; border-radius: 8px; background: var(--navy-900); color: #fff; font-size: 11px; line-height: 1.45; box-shadow: var(--shadow); white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); }
.chart-tip b { font-weight: 650; }
.donut-wrap { display: flex; align-items: center; gap: var(--sp-5); flex-wrap: wrap; }
.donut-wrap .chart { width: 160px; flex-shrink: 0; }
.donut-center { font-family: var(--font-display); }

/* ------------------------------------------------------------- kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: var(--sp-4); overflow-x: auto; padding-bottom: var(--sp-3); align-items: start; }
.kanban-col { display: flex; flex-direction: column; min-height: 200px; max-height: calc(100vh - 260px); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.kanban-col-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 12px 14px; font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.kanban-col-body { flex: 1; overflow-y: auto; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 10px; }
.kanban-col.drop-target { border-color: var(--brand-500); background: var(--primary-soft); }
.kanban-card { padding: 12px; background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); cursor: pointer; transition: box-shadow var(--dur-fast), transform var(--dur-fast), border-color var(--dur-fast); }
.kanban-card:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.kanban-card[draggable="true"] { cursor: grab; }
.kanban-card.dragging { opacity: .5; }
.kanban-card .kc-title { font-weight: 600; font-size: var(--fs-sm); color: var(--text); margin-bottom: 8px; }
.kanban-card .kc-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--fs-xs); color: var(--text-3); }

/* ------------------------------------------------------------- calendar */
.cal { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-solid); }
.cal-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-head div { padding: 8px; font-size: var(--fs-2xs); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-cell { min-height: 108px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.other { background: var(--surface-2); }
.cal-cell.other .cal-day { color: var(--text-3); opacity: .6; }
.cal-cell.weekend { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.cal-cell.holiday { background: var(--warning-soft); }
.cal-day { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-cell.today .cal-day { background: var(--primary); color: #fff; }
.cal-ev { display: block; width: 100%; text-align: left; padding: 2px 6px; border-radius: 5px; font-size: 11px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--info-soft); color: var(--info-text); }
.cal-ev:hover { filter: brightness(.96); text-decoration: none; }
.cal-ev[data-tone="success"] { background: var(--success-soft); color: var(--success-text); }
.cal-ev[data-tone="warning"] { background: var(--warning-soft); color: var(--warning-text); }
.cal-ev[data-tone="danger"] { background: var(--danger-soft); color: var(--danger-text); }
.cal-ev[data-tone="violet"] { background: var(--violet-soft); color: var(--violet-text); }
.cal-ev[data-tone="neutral"] { background: var(--neutral-soft); color: var(--neutral-text); }
.cal-more { font-size: 11px; color: var(--text-3); padding: 0 6px; text-align: left; }
@media (max-width: 760px) {
  .cal-cell { min-height: 64px; padding: 3px; }
  .cal-ev { font-size: 0; height: 6px; padding: 0; border-radius: 3px; }
}

/* ------------------------------------------------------------ misc */
.divider-label { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-xs); color: var(--text-3); margin: var(--sp-4) 0; }
.divider-label::before, .divider-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.kv-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-3); }
.kv-tile { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.kv-tile .k { font-size: var(--fs-xs); color: var(--text-3); }
.kv-tile .v { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 700; color: var(--text); margin-top: 2px; }

.comment { display: flex; gap: var(--sp-3); }
.comment-body { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 4px var(--radius) var(--radius) var(--radius); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-sm); }
.comment-head { display: flex; align-items: baseline; gap: var(--sp-2); margin-bottom: 4px; }
.comment-head strong { font-size: var(--fs-sm); }
.comment-head time { font-size: var(--fs-xs); color: var(--text-3); }

.prose { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.65; }
.prose p { margin-bottom: var(--sp-3); }
.prose h3, .prose h4 { margin: var(--sp-4) 0 var(--sp-2); }
.prose ul, .prose ol { margin-bottom: var(--sp-3); }

.notice-banner { display: flex; align-items: center; gap: var(--sp-3); padding: 10px var(--sp-5); font-size: var(--fs-sm); background: var(--warning-soft); color: var(--text); border-bottom: 1px solid var(--border); }
.notice-banner svg { width: 18px; height: 18px; color: var(--warning-text); flex-shrink: 0; }

.loading-screen { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; background: var(--bg); transition: opacity var(--dur-slow) var(--ease); }
.loading-screen.done { opacity: 0; pointer-events: none; }
.loading-inner { display: flex; flex-direction: column; align-items: center; gap: var(--sp-5); }
.loading-inner img { width: 72px; height: auto; animation: pulse-logo 1.6s ease-in-out infinite; }
.loading-inner .loading-text { font-size: var(--fs-sm); color: var(--text-3); }
.loading-bar { width: 140px; height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; position: relative; }
.loading-bar::after { content: ""; position: absolute; inset: 0; width: 40%; border-radius: inherit; background: var(--brand-gradient); animation: loading-slide 1.1s var(--ease) infinite; }
@keyframes loading-slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
@keyframes pulse-logo { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.96); opacity: .85; } }
@media (prefers-reduced-motion: reduce) { .loading-inner img, .loading-bar::after { animation: none; } }
