/* =========================================================
   UiKit — reusable components
   Requires: tokens.css
   ========================================================= */

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font), sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  transition: background 0.3s ease, color 0.3s ease;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--accent-soft);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.82rem;
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.i {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  display: block;
}

[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Logo ---------- */
.logo {
  --s: 2.5rem;
  width: var(--s);
  height: var(--s);
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 30%;
  background: var(--accent-grad);
  color: #fff;
  font-family: var(--display), sans-serif;
  font-weight: 700;
  font-size: calc(var(--s) * 0.36);
  letter-spacing: -0.02em;
  box-shadow: 0 10px 24px -8px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.logo.sm {
  --s: 2.1rem;
}

.logo.xl {
  --s: 4.2rem;
}

/* ---------- Buttons ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition:
    transform 0.18s var(--ease),
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.25s ease,
    opacity 0.18s ease;
}

.btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn:focus-visible,
.icon-btn:focus-visible,
.seg button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn.primary {
  border-color: transparent;
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 10px 22px -10px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn.primary:hover {
  box-shadow: 0 14px 28px -10px var(--accent-glow), 0 0 0 4px var(--accent-soft);
  transform: translateY(-1px);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
}

.btn.soft {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-ink);
}

.btn.danger-soft {
  background: rgba(239, 68, 68, 0.1);
  border-color: transparent;
  color: var(--danger);
}

.btn.danger-soft:hover {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
}

.btn.danger-fill {
  border-color: transparent;
  background: linear-gradient(135deg, #f87171, var(--danger));
  color: #fff;
  box-shadow: 0 10px 22px -10px rgba(239, 68, 68, 0.6);
}

.btn.danger-fill:hover {
  border-color: transparent;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.18), 0 12px 24px -10px rgba(239, 68, 68, 0.55);
}

.btn.sm {
  padding: 0.42rem 0.7rem;
  font-size: 0.82rem;
  border-radius: 10px;
}

.btn.lg {
  padding: 0.85rem 1.35rem;
  font-size: 0.98rem;
  border-radius: 14px;
}

.btn.wide {
  width: 100%;
}

.btn .spinner {
  display: none;
}

.btn.is-loading {
  pointer-events: none;
}

.btn.is-loading > :not(.spinner) {
  opacity: 0;
}

.btn.is-loading .spinner {
  display: block;
  position: absolute;
  inset: 0;
  margin: auto;
}

.spinner {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: uk-spin 0.7s linear infinite;
}

.btn-arrow {
  transition: transform 0.25s var(--ease);
}

.btn:hover .btn-arrow {
  transform: translateX(3px);
}

.icon-btn {
  width: 2.35rem;
  height: 2.35rem;
  flex: none;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s var(--ease);
}

.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.icon-btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.icon-btn:active {
  transform: scale(0.92);
}

.link {
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--accent-ink);
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.link:hover {
  text-decoration: underline;
}

/* ---------- Lang switch ---------- */
.lang-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  background: var(--surface-3);
  border: 1px solid var(--line);
}

.lang-btn {
  border: none;
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.lang-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ---------- Segmented control ---------- */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border-radius: 13px;
  background: var(--surface-3);
  border: 1px solid var(--line);
}

.seg button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  border-radius: 10px;
  padding: 0.45rem 0.8rem;
  font-size: 0.84rem;
  font-weight: 700;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.seg button:hover {
  color: var(--ink);
}

.seg button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.seg .n {
  min-width: 1.4rem;
  padding: 0 0.35rem;
  border-radius: 99px;
  font-size: 0.72rem;
  line-height: 1.25rem;
  background: var(--track);
  color: var(--muted);
}

.seg button.active .n {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* ---------- Switch ---------- */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch .track {
  position: relative;
  width: 2.3rem;
  height: 1.3rem;
  flex: none;
  border-radius: 99px;
  background: var(--line-strong);
  transition: background 0.25s ease;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(1.3rem - 6px);
  height: calc(1.3rem - 6px);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.3s var(--ease-spring);
}

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

.switch input:checked + .track::after {
  transform: translateX(1rem);
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Fields / inputs ---------- */
input,
select {
  font: inherit;
  color: var(--ink);
}

.field {
  display: grid;
  gap: 0.4rem;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink-2);
}

.field-hint {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.35;
}

.field input,
.pass-row input {
  width: 100%;
  padding: 0.72rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  font-weight: 600;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.field input:focus,
.pass-row input:focus,
select:focus,
.search:focus-within {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  background: var(--surface);
}

select {
  appearance: none;
  padding: 0.55rem 2.2rem 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2384958c' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
      no-repeat right 0.8rem center,
    var(--surface);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 11rem;
}

.search {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.85rem;
  min-width: 14rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search.grow {
  flex: 1 1 18rem;
}

.search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  padding: 0.6rem 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.pass-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.pass-row input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  letter-spacing: 0.02em;
}

/* Float field (login-style) */
.float-field {
  position: relative;
}

.float-field input {
  width: 100%;
  height: 3.6rem;
  padding: 1.35rem 3rem 0.45rem 2.9rem;
  border-radius: 14px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  font-size: 0.98rem;
  font-weight: 600;
  transition: border-color 0.2s ease, box-shadow 0.25s ease;
}

.float-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft);
}

.float-field label {
  position: absolute;
  left: 2.9rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  pointer-events: none;
  transition: all 0.22s var(--ease);
}

.float-field input:focus + label,
.float-field input:not(:placeholder-shown) + label {
  top: 0.95rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--accent-ink);
}

/* Autofill may paint a value without input events or :placeholder-shown changing.
   Kept as separate rules: an unknown pseudo-class would invalidate a shared list. */
.float-field input:-webkit-autofill + label {
  top: 0.95rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--accent-ink);
}

.float-field input:autofill + label {
  top: 0.95rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--accent-ink);
}

.ff-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  transition: color 0.2s ease;
}

.float-field:focus-within .ff-icon {
  color: var(--accent-ink);
}

.ff-action {
  position: absolute;
  right: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2.3rem;
  height: 2.3rem;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.ff-action:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* ---------- Range slider ---------- */
input[type="range"] {
  --p: 50%;
  width: 100%;
  height: 8px;
  appearance: none;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent) var(--p), var(--track) var(--p));
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 4px 12px -2px var(--accent-glow);
  transition: transform 0.2s var(--ease-spring);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
}

input[type="range"]:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.num-unit {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 0.75rem 0 0.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.num-unit:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.num-unit input[type="number"] {
  width: 3.6rem;
  padding: 0.5rem 0.25rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: right;
  font-family: var(--display), sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  appearance: textfield;
  -moz-appearance: textfield;
}

.num-unit input[type="number"]::-webkit-inner-spin-button,
.num-unit input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.num-unit input:focus {
  outline: none;
}

.num-unit input:disabled {
  cursor: not-allowed;
}

.num-unit span {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.setting-block {
  display: grid;
  gap: 0.75rem;
  padding: 1rem 1.05rem;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.setting-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.setting-label {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.3;
}

.setting-hint {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--muted);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  min-height: 3.4rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 700;
}

.setting-row:first-child {
  padding-top: 0;
}

.setting-row:last-child {
  border-bottom: none;
}

/* ---------- Alerts / badges ---------- */
.alert {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  border: 1px solid transparent;
  animation: uk-pop-in 0.35s var(--ease) both;
}

.alert.error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.25);
  color: var(--danger);
}

.alert.warn {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.28);
  color: #b45309;
}

[data-theme="dark"] .alert.warn {
  color: #fbbf24;
}

.alert.info {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.22);
  color: var(--info);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.6rem;
  border-radius: 99px;
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
  background: var(--track);
  color: var(--muted);
}

.pill::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}

.pill.online {
  background: rgba(16, 185, 129, 0.13);
  color: var(--accent-ink);
}

.pill.online::before {
  animation: uk-dot-pulse 1.8s ease-out infinite;
}

.pill.live {
  background: rgba(239, 68, 68, 0.14);
  color: var(--danger);
}

.pill.live::before {
  background: var(--danger);
  animation: uk-dot-pulse 1.8s ease-out infinite;
}

.pill.plain::before {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.5rem;
  border-radius: 7px;
  font-size: 0.74rem;
  font-weight: 700;
  background: var(--surface-3);
  color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.count-badge {
  min-width: 1.8rem;
  padding: 0.12rem 0.55rem;
  border-radius: 99px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.role-badge {
  display: inline-block;
  padding: 0.08rem 0.45rem;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.avatar {
  --h: 160;
  --s: 2.5rem;
  position: relative;
  width: var(--s);
  height: var(--s);
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 32%;
  font-size: calc(var(--s) * 0.36);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: hsl(var(--h) 70% 30%);
  background: linear-gradient(135deg, hsl(var(--h) 80% 88%), hsl(calc(var(--h) + 30) 75% 80%));
}

[data-theme="dark"] .avatar {
  color: hsl(var(--h) 80% 82%);
  background: linear-gradient(135deg, hsl(var(--h) 45% 26%), hsl(calc(var(--h) + 30) 45% 20%));
}

.avatar.sm {
  --s: 2rem;
}

.avatar.lg {
  --s: 3.1rem;
}

/* ---------- Layout bricks ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.spacer {
  flex: 1;
}

.grid-2,
.grid-2-1 {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: 1fr 1fr;
}

.grid-2-1 {
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
}

.panel {
  position: relative;
  min-width: 0;
  display: grid;
  gap: 1rem;
  align-content: start;
  padding: 1.25rem 1.3rem;
  border-radius: var(--radius-lg);
  background: var(--glass-strong);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.panel-head h3 {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.kpi-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.kpi {
  --tone: var(--accent);
  --tone-soft: var(--accent-soft);
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 0.25rem;
  padding: 1.1rem 1.2rem 1.15rem;
  border-radius: var(--radius-lg);
  background: var(--glass-strong);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  animation: uk-fade-up 0.6s var(--ease) both;
  animation-delay: calc(var(--i) * 0.06s);
}

.kpi::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--tone);
  border-radius: 0 2px 2px 0;
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-value {
  font-family: var(--display), sans-serif;
  font-weight: 600;
  font-size: 1.85rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.kpi-note {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.empty {
  display: grid;
  place-items: center;
  gap: 0.6rem;
  padding: 2.2rem 1rem;
  text-align: center;
  font-weight: 600;
  color: var(--muted);
}

.empty .ei {
  width: 3.2rem;
  height: 3.2rem;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 1.3rem;
}

.sk {
  border-radius: 12px;
  background: linear-gradient(90deg, var(--skeleton) 25%, var(--skeleton-hi) 37%, var(--skeleton) 63%);
  background-size: 400% 100%;
  animation: uk-shimmer 1.4s ease infinite;
}

.sk-kpi {
  height: 8.2rem;
  border-radius: var(--radius-lg);
}

.sk-card {
  height: 15rem;
  border-radius: var(--radius-lg);
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  inset: auto 1.2rem 1.2rem auto;
  z-index: 100;
  display: grid;
  gap: 0.6rem;
  width: min(380px, calc(100vw - 2.4rem));
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  overflow: visible;
  pointer-events: none;
}

.toast {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  background: var(--glass-strong);
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 700;
  pointer-events: auto;
  animation: uk-toast-in 0.45s var(--ease-spring) both;
}

.toast.leaving {
  animation: uk-toast-out 0.3s var(--ease) both;
}

.toast .ti {
  width: 1.8rem;
  height: 1.8rem;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.toast.error .ti {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.toast.info .ti {
  background: rgba(59, 130, 246, 0.12);
  color: var(--info);
}

.toast .tm {
  flex: 1;
  padding-top: 0.2rem;
}

.toast .tx {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0.2rem;
}

.toast::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: var(--accent);
  transform-origin: left;
  animation: uk-toast-timer var(--ttl) linear both;
  opacity: 0.6;
}

.toast.error::after {
  background: var(--danger);
}

.toast.info::after {
  background: var(--info);
}

/* ---------- Modal ---------- */
dialog.modal {
  width: min(500px, calc(100% - 1.5rem));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}

dialog.modal.small {
  width: min(420px, calc(100% - 1.5rem));
}

dialog.modal[open] {
  animation: uk-modal-in 0.4s var(--ease-spring) both;
}

dialog.modal.closing {
  animation: uk-modal-out 0.2s ease both;
}

dialog.modal::backdrop {
  background: rgba(5, 12, 9, 0.5);
  backdrop-filter: blur(6px);
  animation: uk-fade-in 0.25s ease both;
}

dialog.modal.closing::backdrop {
  animation: uk-fade-out 0.2s ease both;
}

dialog.modal form {
  display: grid;
  gap: 1rem;
  padding: 1.4rem;
}

dialog.modal header {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 0.2rem;
}

.modal-icon {
  width: 2.8rem;
  height: 2.8rem;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-size: 1.15rem;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.modal-icon.warn {
  background: rgba(245, 158, 11, 0.14);
  color: var(--warn);
}

.modal-icon.danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.modal-titles {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 0.2rem;
  padding-top: 0.15rem;
}

.modal-titles h2 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.modal-titles p {
  font-size: 0.86rem;
}

dialog.modal footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.3rem;
}

/* ---------- Charts (minimal) ---------- */
.bar-chart {
  --chart-h: 190px;
  position: relative;
  display: flex;
  align-items: stretch;
  gap: clamp(3px, 0.8vw, 8px);
  height: calc(var(--chart-h) + 1.8rem);
  padding-top: 1.4rem;
}

.bar-col {
  position: relative;
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 0.45rem;
}

.bar-track {
  position: relative;
  display: flex;
  align-items: flex-end;
  border-radius: 8px;
  background: var(--track);
}

.bar-fill {
  width: 100%;
  height: var(--v);
  min-height: 3px;
  border-radius: 8px;
  background: var(--accent-grad);
  transform-origin: bottom;
  animation: uk-bar-grow 0.9s var(--ease) both;
  animation-delay: calc(var(--i) * 0.03s);
}

.bar-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  color: var(--muted);
}

/* ---------- Keyframes ---------- */
@keyframes uk-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes uk-fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes uk-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes uk-fade-out {
  to {
    opacity: 0;
  }
}
@keyframes uk-pop-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes uk-bar-grow {
  from {
    transform: scaleY(0);
  }
  to {
    transform: scaleY(1);
  }
}
@keyframes uk-dot-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}
@keyframes uk-shimmer {
  from {
    background-position: 100% 50%;
  }
  to {
    background-position: 0 50%;
  }
}
@keyframes uk-toast-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes uk-toast-out {
  to {
    opacity: 0;
    transform: translateX(30px);
  }
}
@keyframes uk-toast-timer {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}
@keyframes uk-modal-in {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes uk-modal-out {
  to {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-2-1 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

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

  .search,
  .toolbar select {
    flex: 1 1 100%;
    min-width: 0;
  }

  .seg {
    flex: 1 1 100%;
  }

  .seg button {
    flex: 1;
    justify-content: center;
  }

  dialog.modal footer {
    flex-direction: column-reverse;
  }

  dialog.modal footer .btn {
    width: 100%;
  }

  .pass-row {
    flex-wrap: wrap;
  }

  .pass-row input {
    flex: 1 1 100%;
  }

  .pass-row .btn {
    flex: 1;
  }

  .toasts {
    right: 50%;
    transform: translateX(50%);
    bottom: 0.8rem;
  }
}

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