/* Buttons */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 20px; border-radius: var(--r-sm); border: 1px solid transparent;
  font-weight: 500; font-size: var(--t-sm); white-space: nowrap;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.25s var(--ease);
}
.btn:active { scale: 0.98; }
.btn-primary { background: var(--btn-bg); color: var(--btn-fg); }
.btn-primary:hover { background: color-mix(in oklab, var(--btn-bg) 88%, var(--bg)); }
.btn-ghost { border-color: var(--border-strong); background: transparent; }
.btn-ghost:hover { background: color-mix(in srgb, var(--text) 8%, transparent); border-color: var(--text); }
.btn-danger { background: var(--bad); color: #2b0505; }
[data-theme='light'] .btn-danger { color: #fff; }
.btn-sm { min-height: 36px; padding: 0 14px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm); color: var(--muted);
  transition: background 0.14s, color 0.14s;
}
.icon-btn:hover:not([disabled]) { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
.icon-btn[disabled] { opacity: 0.35; cursor: not-allowed; }

/* Badges, tags, statuses */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 7px; border: 1px solid currentColor; font-family: var(--mono); font-size: 0.625rem; font-weight: 500; letter-spacing: 0.1em; white-space: nowrap; }
.badge-live { color: var(--amber); background: var(--void); }
.badge-live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-concept { color: var(--moon); background: var(--void); }
.tag { display: inline-block; padding: 2px 8px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: var(--t-xs); color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; font-weight: 500; white-space: nowrap; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--tone); }
.status-good { --tone: var(--good); }
.status-warn { --tone: var(--warn); }
.status-bad { --tone: var(--bad); }
.status-info { --tone: var(--info); }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label { font-size: var(--t-sm); font-weight: 500; }
.req { color: var(--bad); }
input:not([type='checkbox'], [type='radio'], [type='range']), select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; background: var(--bg-2); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); font-size: var(--t-sm); transition: border-color 0.14s, box-shadow 0.14s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
textarea { resize: vertical; }
input[type='checkbox'], input[type='radio'], input[type='range'], progress { accent-color: var(--accent); }
.hint { color: var(--muted); }
.error { color: var(--bad); min-height: 0; }
.error:empty { display: none; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--bad); }
.field-check { flex-direction: row-reverse; justify-content: flex-end; align-items: center; }
.field-check input { width: 18px; height: 18px; }

/* Toasts */
.toasts { position: fixed; right: var(--s4); bottom: var(--s4); z-index: 1000; display: flex; flex-direction: column; gap: var(--s2); width: min(360px, calc(100vw - 2 * var(--s4))); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; font-size: var(--t-sm);
  background: var(--card-2); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  animation: toast-in 0.24s var(--ease);
}
.toast .icon { margin-top: 2px; }
.toast-success .icon { color: var(--good); }
.toast-error .icon { color: var(--bad); }
.toast-info .icon { color: var(--info); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: 0.2s; }

/* Modals */
.modal {
  width: min(560px, calc(100vw - 24px)); max-height: min(86dvh, 760px); margin: auto; background: var(--card); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal[open] { display: flex; flex-direction: column; animation: modal-in 0.22s var(--ease); }
.modal-sm { width: min(420px, calc(100vw - 24px)); }
.modal-lg { width: min(820px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(4, 6, 12, 0.62); backdrop-filter: blur(6px); animation: fade-in 0.2s; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: var(--t-lg); letter-spacing: -0.012em; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--s2); padding: 14px 20px; border-top: 1px solid var(--border); }

/* Skeletons */
.skeleton { border-radius: var(--r-md); background: linear-gradient(100deg, var(--card) 30%, var(--card-2) 50%, var(--card) 70%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.sk-title { height: 34px; width: 40%; margin-bottom: var(--s4); }
.sk-block { height: 180px; margin-bottom: var(--s4); }
.sk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s4); }

/* Data table */
.table-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); min-width: 0; }
.table-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); padding: var(--s3); border-bottom: 1px solid var(--border); }
.search-box { position: relative; flex: 0 1 260px; min-width: 150px; display: block; }
.search-box .icon { position: absolute; left: 10px; top: 11px; color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 32px; min-height: 36px; }
.filter select { min-height: 36px; padding-block: 5px; width: auto; max-width: 170px; }
.table-scroll { overflow-x: auto; }
.data-table { font-size: var(--t-sm); }
.data-table th { text-align: left; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--border); padding: 0; white-space: nowrap; }
.data-table th button { display: inline-flex; align-items: center; gap: 4px; padding: 10px 14px; font-weight: 500; }
.data-table th button:hover { color: var(--text); }
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tr.clickable { cursor: pointer; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
.data-table .num { font-variant-numeric: tabular-nums; }
.row-actions { white-space: nowrap; text-align: right; width: 1%; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: 8px 14px; border-top: 1px solid var(--border); font-size: var(--t-xs); color: var(--muted); }
.pager { display: flex; align-items: center; gap: 4px; }
.with-avatar { display: inline-flex; align-items: center; gap: 10px; }
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; font-size: 0.6875rem; font-weight: 700;
  background: color-mix(in oklab, var(--hue) 20%, var(--card)); color: color-mix(in oklab, var(--hue) 48%, var(--text));
}
.avatar[data-hue='0'] { --hue: #7c5cfc; }
.avatar[data-hue='1'] { --hue: #14b8a6; }
.avatar[data-hue='2'] { --hue: #f59e0b; }
.avatar[data-hue='3'] { --hue: #3b82f6; }
.avatar[data-hue='4'] { --hue: #ec4899; }
.avatar[data-hue='5'] { --hue: #22c55e; }
.progress-cell { display: inline-flex; align-items: center; gap: 8px; min-width: 110px; font-size: var(--t-xs); }
progress { appearance: none; width: 100%; height: 6px; border: 0; border-radius: 9px; overflow: hidden; background: color-mix(in srgb, var(--text) 10%, transparent); }
progress::-webkit-progress-bar { background: color-mix(in srgb, var(--text) 10%, transparent); }
progress::-webkit-progress-value { background: var(--accent); border-radius: 9px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 9px; }
.empty-state { display: grid; justify-items: center; gap: var(--s2); padding: var(--s7) var(--s4); color: var(--muted); text-align: center; }
.empty-state .icon { width: 28px; height: 28px; }

