/* ==========================================================================
   ubKids components
   ========================================================================== */

/* ---------- Button ---------- */
.btn {
  --bg: var(--brand-500);
  --fg: #fff;
  --bd: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px;
  border-radius: var(--r-full);
  border: 1px solid var(--bd);
  background: var(--bg); color: var(--fg);
  font-size: 14.5px; font-weight: 600; letter-spacing: -.01em;
  cursor: pointer; white-space: nowrap; user-select: none;
  text-decoration: none;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t) var(--ease),
              background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.btn:hover { transform: translateY(-1.5px); color: var(--fg); }
.btn:active { transform: translateY(0) scale(.985); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 17px; height: 17px; flex: none; }

.btn--primary { box-shadow: var(--sh-brand); }
.btn--primary:hover { --bg: var(--brand-600); box-shadow: 0 14px 32px rgba(47,107,255,.3); }

.btn--soft { --bg: var(--brand-50); --fg: var(--brand-700); }
.btn--soft:hover { --bg: var(--brand-100); }

.btn--ghost { --bg: transparent; --fg: var(--ink-2); --bd: var(--line); }
.btn--ghost:hover { --bg: var(--surface-2); --bd: #d9dfea; }

.btn--plain { --bg: transparent; --fg: var(--muted); --bd: transparent; padding-inline: 10px; }
.btn--plain:hover { --fg: var(--ink); --bg: var(--surface-3); }

.btn--dark { --bg: var(--ink); --fg: #fff; }
.btn--dark:hover { --bg: #1d2740; }

.btn--danger { --bg: var(--rose-s); --fg: #c02338; }
.btn--danger:hover { --bg: #ffdde2; }

.btn--sm { padding: 7px 13px; font-size: 13px; }
.btn--sm svg { width: 15px; height: 15px; }
.btn--lg { padding: 14px 26px; font-size: 16px; }
.btn--block { width: 100%; }
.btn--icon { padding: 9px; border-radius: var(--r-full); }
.btn--icon.btn--sm { padding: 6px; }

.btn.is-loading { pointer-events: none; position: relative; color: transparent; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  color: var(--fg); animation: spin .6s linear infinite;
}

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card--flat { box-shadow: none; }
.card--pad-sm { padding: 15px; }
.card--pad-lg { padding: 26px; }
.card--hover {
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
}
.card--hover:hover { transform: translateY(-3px); box-shadow: var(--sh-md); border-color: #dde3ee; }

.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.card__title { font-size: 16px; font-weight: 680; letter-spacing: -.02em; }
.card__sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---------- Badge / Chip ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3.5px 10px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 600; letter-spacing: -.005em;
  background: var(--surface-3); color: var(--ink-2);
  white-space: nowrap;
}
.badge svg { width: 13px; height: 13px; }
.badge--brand { background: var(--brand-50); color: var(--brand-700); }
.badge--ok    { background: var(--mint-s); color: #0b7f5a; }
.badge--warn  { background: var(--amber-s); color: #9a6207; }
.badge--dang  { background: var(--rose-s); color: #c02338; }
.badge--coral { background: var(--coral-s); color: #c4482a; }
.badge--violet{ background: var(--violet-s); color: #6d3ddb; }
.badge--sky   { background: var(--sky-s); color: #0369a1; }
.badge--lime  { background: var(--lime-s); color: #4d7c0f; }
.badge--dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85;
}

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--r-full);
  border: 1px solid var(--line); background: var(--surface);
  font-size: 13.5px; font-weight: 550; color: var(--ink-2);
  cursor: pointer; white-space: nowrap;
  transition: all var(--t-fast) var(--ease);
}
.chip:hover { border-color: var(--brand-300); color: var(--brand-700); background: var(--brand-50); }
.chip[aria-pressed="true"], .chip.is-on {
  background: var(--ink); border-color: var(--ink); color: #fff;
}
.chip__count { font-size: 11.5px; opacity: .6; font-variant-numeric: tabular-nums; }

/* ---------- Form ---------- */
.field { display: block; }
.field + .field { margin-top: 15px; }
.label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--ink-2); margin-bottom: 6px;
}
.label .req { color: var(--dang); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.err { font-size: 12.5px; color: var(--dang); margin-top: 5px; }

.input, .select, .textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 14.5px;
  color: var(--ink);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.input:hover, .select:hover, .textarea:hover { border-color: #d5dbe7; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-400);
  box-shadow: 0 0 0 3.5px rgba(47,107,255,.13);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236b7791' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
}
.input--sm, .select--sm { padding: 8px 12px; font-size: 13.5px; }
.select--sm { padding-right: 32px; background-position: right 10px center; }

.input-group { position: relative; }
.input-group .input { padding-left: 40px; }
.input-group__icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--muted-2); pointer-events: none;
}

.checkbox, .radio {
  display: flex; align-items: flex-start; gap: 10px;
  cursor: pointer; font-size: 14px; color: var(--ink-2);
  padding: 3px 0;
}
.checkbox input, .radio input {
  appearance: none; flex: none;
  width: 18px; height: 18px; margin: 2px 0 0;
  border: 1.6px solid #ccd3e0; border-radius: 5px;
  background: var(--surface); cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  position: relative;
}
.radio input { border-radius: 50%; }
.checkbox input:checked, .radio input:checked { background: var(--brand-500); border-color: var(--brand-500); }
.checkbox input:checked::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.radio input:checked::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 6px; height: 6px; border-radius: 50%; background: #fff;
}

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; margin: 0; width: 42px; height: 24px; border-radius: 99px; background: #d7dce7; position: relative; cursor: pointer; transition: background var(--t) var(--ease); }
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: var(--sh-xs);
  transition: transform var(--t) var(--ease);
}
.switch input:checked { background: var(--brand-500); }
.switch input:checked::after { transform: translateX(18px); }

.seg {
  display: inline-flex; padding: 3.5px; gap: 3px;
  background: var(--surface-3); border-radius: var(--r-full);
}
.seg button {
  border: 0; background: transparent; cursor: pointer;
  padding: 7px 15px; border-radius: var(--r-full);
  font-size: 13.5px; font-weight: 580; color: var(--muted);
  transition: all var(--t-fast) var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"] {
  background: var(--surface); color: var(--ink); box-shadow: var(--sh-xs);
}

/* ---------- Table ---------- */
.table-wrap {
  border: 1px solid var(--line); border-radius: var(--r-md);
  overflow: auto; background: var(--surface);
}
.table { font-size: 14px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12.5px;
  color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  padding: 12px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--line); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table--compact td { padding: 9px 14px; }
.table--compact th { padding: 9px 14px; }

/* ---------- Avatar ---------- */
.avatar {
  --sz: 40px;
  width: var(--sz); height: var(--sz); flex: none;
  border-radius: 50%; display: grid; place-content: center;
  font-weight: 680; font-size: calc(var(--sz) * .38); letter-spacing: -.02em;
  background: var(--brand-50); color: var(--brand-700);
  overflow: hidden; user-select: none;
}
.avatar--sq { border-radius: calc(var(--sz) * .3); }
.avatar--sm { --sz: 32px; }
.avatar--lg { --sz: 56px; }
.avatar--xl { --sz: 80px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

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

/* ---------- Progress / meter ---------- */
.bar { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar__fill {
  height: 100%; border-radius: 99px; background: var(--brand-500);
  transition: width .8s var(--ease-out);
}
.bar--lg { height: 10px; }

.ring { transform: rotate(-90deg); }
.ring__track { stroke: var(--surface-3); }
.ring__fill { stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease-out); }

/* ---------- Stat ---------- */
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 17px 18px;
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--sh-sm); }
.stat__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.stat__label { font-size: 12.5px; color: var(--muted); font-weight: 560; }
.stat__icon {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  display: grid; place-content: center;
  background: var(--brand-50); color: var(--brand-600);
}
.stat__icon svg { width: 17px; height: 17px; }
.stat__value {
  font-size: 27px; font-weight: 740; letter-spacing: -.035em;
  font-variant-numeric: tabular-nums; line-height: 1.12;
}
.stat__foot { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 620; }
.delta--up { color: #0b7f5a; }
.delta--down { color: #c02338; }

/* ---------- Empty / skeleton ---------- */
.empty {
  text-align: center; padding: 48px 24px; color: var(--muted);
}
.empty__icon {
  width: 56px; height: 56px; border-radius: 18px; margin: 0 auto 14px;
  display: grid; place-content: center;
  background: var(--surface-3); color: var(--muted-2);
}
.empty__icon svg { width: 26px; height: 26px; }
.empty h4 { color: var(--ink-2); margin-bottom: 4px; }

.skel {
  position: relative; overflow: hidden;
  background: var(--surface-3); border-radius: var(--r-sm);
}
.skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent);
  animation: shimmer 1.4s infinite;
}

/* ---------- Toast ---------- */
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 900;
  display: flex; flex-direction: column-reverse; gap: 10px;
  max-width: min(380px, calc(100vw - 36px)); pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 13px 15px;
  box-shadow: var(--sh-lg);
  animation: slideInRight .38s var(--ease-out) both;
}
.toast.is-out { animation: fadeIn .25s var(--ease) reverse both; }
.toast__icon {
  width: 28px; height: 28px; border-radius: 9px; flex: none;
  display: grid; place-content: center;
}
.toast__icon svg { width: 15px; height: 15px; }
.toast--ok   .toast__icon { background: var(--mint-s); color: #0b7f5a; }
.toast--info .toast__icon { background: var(--brand-50); color: var(--brand-600); }
.toast--warn .toast__icon { background: var(--amber-s); color: #9a6207; }
.toast--dang .toast__icon { background: var(--rose-s); color: #c02338; }
.toast__title { font-size: 14px; font-weight: 640; }
.toast__body { font-size: 13px; color: var(--muted); margin-top: 1px; }
.toast__x {
  border: 0; background: transparent; cursor: pointer; color: var(--muted-2);
  padding: 2px; border-radius: 6px; flex: none;
}
.toast__x:hover { color: var(--ink); background: var(--surface-3); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(14, 21, 38, .42);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fadeIn .22s var(--ease) both;
  overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: var(--r-lg);
  width: min(600px, 100%); max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  box-shadow: var(--sh-lg);
  animation: popIn .3s var(--ease-out) both;
  margin: auto;
}
.modal--wide { width: min(880px, 100%); }
.modal--narrow { width: min(440px, 100%); }
.modal__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 22px 24px 14px;
}
.modal__title { font-size: 19px; font-weight: 700; letter-spacing: -.025em; }
.modal__sub { font-size: 13.5px; color: var(--muted); margin-top: 3px; }
.modal__body { padding: 0 24px 4px; overflow-y: auto; flex: 1; }
.modal__foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 18px 24px 22px; margin-top: 8px;
}
.modal__x {
  border: 0; background: var(--surface-3); cursor: pointer; color: var(--muted);
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-content: center;
  transition: all var(--t-fast) var(--ease);
}
.modal__x:hover { background: #e6e9f0; color: var(--ink); }
.modal__x svg { width: 16px; height: 16px; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: transparent; cursor: pointer;
  padding: 12px 16px; font-size: 14px; font-weight: 580;
  color: var(--muted); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all var(--t-fast) var(--ease);
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--brand-600); border-bottom-color: var(--brand-500); }

/* ---------- Tooltip ---------- */
.tip { position: relative; }
.tip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--ink); color: #fff;
  padding: 6px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: all var(--t-fast) var(--ease);
  z-index: 50;
}
.tip:hover::after { opacity: 1; transform: translateX(-50%); }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--line); margin: 20px 0; }
.dot-sep { color: var(--muted-2); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 18px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 560; text-align: right; }

.list-row {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 0; border-bottom: 1px solid var(--line-2);
}
.list-row:last-child { border-bottom: 0; }

.pill-nav { display: flex; gap: 6px; flex-wrap: wrap; }

.link-arrow { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 14px; }
.link-arrow svg { width: 15px; height: 15px; transition: transform var(--t-fast) var(--ease); }
.link-arrow:hover svg { transform: translateX(3px); }

/* Текстийн дунд орсон дүрс: өндрийг мөрөнд тааруулна */
.tiny svg, .small svg, .badge svg, .card__title svg, .hint svg {
  vertical-align: -0.14em;
  flex: none;
}
.row > svg { flex: none; }

/* Хүрэлтээр ажилладаг дэлгэц дээр зөвлөмжийн бөмбөлгийг үзүүлэхгүй */
@media (hover: none), (max-width: 760px) {
  .tip::after { content: none; }
}

/* ---------- Маягтын туслах ---------- */
.input.is-invalid, .select.is-invalid {
  border-color: var(--dang);
  box-shadow: 0 0 0 3.5px rgba(239,68,68,.12);
}
.err:empty { display: none; }
.err { display: block; }

.input.has-toggle { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted-2); cursor: pointer;
  display: grid; place-content: center;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.pw-toggle:hover, .pw-toggle.is-on { color: var(--ink); background: var(--surface-3); }
.pw-toggle svg { width: 17px; height: 17px; }

.link-btn {
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--brand-600); font-size: 13px; font-weight: 580;
}
.link-btn:hover { color: var(--brand-700); text-decoration: underline; }

.form-error {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; margin-bottom: 14px; border-radius: var(--r-sm);
  background: var(--rose-s); color: #b4213a; font-size: 13.5px; line-height: 1.5;
}
.form-error svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }

.note-box {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; margin-bottom: 16px; border-radius: var(--r-sm);
  background: var(--brand-50); color: var(--ink-2); font-size: 13.5px; line-height: 1.55;
}
.note-box > svg { width: 17px; height: 17px; flex: none; margin-top: 2px; color: var(--brand-600); }

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
.shake { animation: shake .42s var(--ease) both; }
