/* SHEKAR components */

/* ---------- glass / cards ---------- */
.card {
  position: relative;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s4);
  box-shadow: var(--shadow-1);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card.glass, .glass { background: var(--surface); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
}
.card.hi { background-image: linear-gradient(160deg, var(--surface-hi), transparent 60%); }
.card.tap { cursor: pointer; transition: transform var(--t-fast) var(--ease), border-color var(--t-fast); }
.card.tap:active { transform: scale(.985); }
.card.tap:hover { border-color: var(--border-2); }
.card-hd { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s3); }
.card-title { font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: var(--s2); }
.card-title svg { color: var(--accent); }
.card-link { font-size: 13px; color: var(--accent); background: none; border: 0; cursor: pointer; padding: 6px 4px; display: inline-flex; align-items: center; gap: 2px; min-height: 36px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-3); margin: var(--s6) 4px var(--s2); letter-spacing: .2px; }

/* ---------- header ---------- */
.hdr { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0 var(--s4); min-height: 60px; }
.hdr-title { font-size: 22px; font-weight: 800; }
.hdr-sub { font-size: 13px; color: var(--text-2); }
.hdr-actions { margin-inline-start: auto; display: flex; gap: var(--s2); }
.icon-btn {
  position: relative; width: 44px; height: 44px; border-radius: 14px; display: inline-grid; place-items: center;
  background: var(--surface-solid); border: 1px solid var(--border); cursor: pointer; color: var(--text);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast);
  flex: none;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn .dot {
  position: absolute; top: 6px; left: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; line-height: 1;
  box-shadow: 0 0 0 2px var(--bg);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 46px; padding: 0 var(--s5); border-radius: var(--r-md);
  border: 1px solid var(--border-2); background: var(--surface-solid-2); color: var(--text);
  font-weight: 700; font-size: 15px; cursor: pointer; white-space: nowrap;
  transition: transform var(--t-fast) var(--ease), filter var(--t-fast), background var(--t-fast);
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-primary { background: linear-gradient(135deg, var(--emerald-2), var(--emerald) 55%, #059669); color: var(--on-accent); border-color: transparent; box-shadow: var(--glow); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-gold { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #1d1503; border-color: transparent; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-sm { min-height: 36px; padding: 0 var(--s3); font-size: 13px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn .spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- chips & badges ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-inline: calc(var(--s4) * -1); padding-inline: var(--s4); }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: var(--r-pill);
  background: var(--surface-solid); border: 1px solid var(--border); color: var(--text-2); font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: all var(--t-fast);
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip.static { cursor: default; min-height: 28px; padding: 0 10px; font-size: 12px; }
.chip .x { opacity: .7; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 700; white-space: nowrap; background: var(--surface-solid-2); color: var(--text-2);
}
.badge.ok { background: var(--accent-soft); color: var(--emerald-2); }
.badge.lime { background: var(--lime-soft); color: var(--lime); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.badge .pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(52,211,153,.6); } 70% { box-shadow: 0 0 0 8px rgba(52,211,153,0); } 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); } }

/* ---------- stats ---------- */
.stat { padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--surface-solid); border: 1px solid var(--border); }
.stat-val { font-size: 22px; font-weight: 800; line-height: 1.3; }
.stat-lbl { font-size: 12px; color: var(--text-2); }
.stat .ic { color: var(--accent); margin-bottom: 4px; }

/* ---------- list ---------- */
.list { display: flex; flex-direction: column; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--border); background: var(--surface-solid); }
.list-item {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); min-height: 58px;
  border: 0; border-bottom: 1px solid var(--border); background: none; width: 100%; text-align: start; cursor: pointer; color: var(--text);
}
.list-item:last-child { border-bottom: 0; }
.list-item:active { background: var(--surface-hi); }
.li-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.li-icon.gold { background: var(--gold-soft); color: var(--gold); }
.li-icon.danger { background: var(--danger-soft); color: var(--danger); }
.li-icon.info { background: var(--info-soft); color: var(--info); }
.li-icon.warn { background: var(--warn-soft); color: var(--warn); }
.li-body { flex: 1 1 auto; min-width: 0; }
.li-title { font-weight: 700; font-size: 14.5px; }
.li-sub { font-size: 12.5px; color: var(--text-2); }
.li-end { color: var(--text-3); display: flex; align-items: center; gap: var(--s2); flex: none; }

/* ---------- segmented ---------- */
.seg { display: flex; padding: 4px; gap: 4px; border-radius: var(--r-md); background: var(--surface-solid); border: 1px solid var(--border); }
.seg button { flex: 1; min-height: 38px; border: 0; border-radius: 10px; background: transparent; color: var(--text-2); font-weight: 700; font-size: 13px; cursor: pointer; transition: all var(--t-fast); }
.seg button.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--border-2); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s4); }
.label { font-size: 13px; font-weight: 700; color: var(--text-2); display: flex; justify-content: space-between; align-items: center; }
.hint { font-size: 12px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--r-md);
  background: var(--surface-solid-2); border: 1px solid var(--border); transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.8; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.err { border-color: var(--danger); }
.err-msg { font-size: 12px; color: var(--danger); }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: 18px 21px, 12px 21px; background-size: 6px 6px; background-repeat: no-repeat; padding-left: 34px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to left, var(--accent) var(--fill, 50%), var(--surface-solid-2) var(--fill, 50%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--surface-solid-2); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 15px; background: var(--surface-solid-2); border: 1px solid var(--border-2); transition: background var(--t-fast); }
.switch span::after { content: ""; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--text-3); transition: transform var(--t-med) var(--ease-spring), background var(--t-fast); }
.switch input:checked + span { background: var(--accent); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(-20px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; min-height: 52px; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: 0; }

/* ---------- progress / meter ---------- */
.progress { height: 8px; border-radius: 4px; background: var(--surface-solid-2); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--lime), var(--emerald-2)); transition: width var(--t-slow) var(--ease); }
.progress.warn > i { background: var(--warn); }
.meter { display: flex; gap: 3px; height: 6px; }
.meter i { flex: 1; border-radius: 3px; background: var(--surface-solid-2); }
.meter i.on { background: var(--accent); }
.meter.l5 i.on { background: var(--lime); }

/* ---------- banners ---------- */
.sys-banner {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 7px 14px; padding-top: calc(var(--safe-t) + 7px); font-size: 12.5px; font-weight: 700; text-align: center;
}
.sys-banner.demo { background: linear-gradient(90deg, rgba(245,165,36,.16), rgba(245,165,36,.22), rgba(245,165,36,.16)); color: var(--warn); border-bottom: 1px solid rgba(245,165,36,.25); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.sys-banner.offline { background: var(--danger-soft); color: var(--danger); border-bottom: 1px solid var(--danger-soft); }
.sys-banner button { background: none; border: 0; color: inherit; text-decoration: underline; font-weight: 700; cursor: pointer; font-size: 12px; padding: 4px; }
.notice { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-md); font-size: 13px; line-height: 1.8; background: var(--info-soft); color: var(--text); border: 1px solid var(--border); }
.notice svg { flex: none; margin-top: 3px; color: var(--info); }
.notice.warn { background: var(--warn-soft); } .notice.warn svg { color: var(--warn); }
.notice.danger { background: var(--danger-soft); } .notice.danger svg { color: var(--danger); }
.notice.ok { background: var(--accent-soft); } .notice.ok svg { color: var(--accent); }
.notice.gold { background: var(--gold-soft); } .notice.gold svg { color: var(--gold); }

/* ---------- states ---------- */
.state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s2); padding: var(--s10) var(--s6); }
.state-icon { width: 72px; height: 72px; border-radius: 24px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: var(--s2); }
.state.error .state-icon { background: var(--danger-soft); color: var(--danger); }
.state.warn .state-icon { background: var(--warn-soft); color: var(--warn); }
.state-title { font-size: 17px; font-weight: 800; }
.state-text { font-size: 13.5px; color: var(--text-2); max-width: 340px; }
.state .btn { margin-top: var(--s3); }

/* ---------- skeleton ---------- */
.skel { background: var(--skeleton); background-size: 300% 100%; animation: shimmer 1.4s ease-in-out infinite; border-radius: 10px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skel-line { height: 12px; margin: 8px 0; }
.skel-card { height: 120px; border-radius: var(--r-lg); margin-bottom: var(--s3); }

/* ---------- sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.55); opacity: 0; transition: opacity var(--t-med) var(--ease); }
.sheet-backdrop.on { opacity: 1; }
.sheet {
  position: fixed; z-index: 91; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 640px; max-height: 88vh; overflow-y: auto;
  background: var(--surface-solid); border: 1px solid var(--border-2); border-bottom: 0; border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--s2) var(--s4) calc(var(--s6) + var(--safe-b)); box-shadow: var(--shadow-2);
  transform: translateY(105%); transition: transform var(--t-slow) var(--ease);
}
.sheet.on { transform: none; }
.sheet-handle { width: 42px; height: 5px; border-radius: 3px; background: var(--border-2); margin: 6px auto 12px; }
.sheet-title { font-size: 18px; font-weight: 800; margin-bottom: var(--s2); }
.sheet-text { color: var(--text-2); font-size: 14px; margin-bottom: var(--s4); }
.sheet-actions { display: flex; gap: var(--s2); margin-top: var(--s4); }
.sheet-actions .btn { flex: 1; }

/* ---------- toast ---------- */
#toast-root { position: fixed; z-index: 100; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + 84px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 520px; padding: 12px 16px; border-radius: 16px; background: var(--surface-solid-2); border: 1px solid var(--border-2); box-shadow: var(--shadow-2); font-size: 14px; font-weight: 600; animation: toastIn var(--t-med) var(--ease-spring) both; }
.toast.out { animation: toastOut var(--t-med) var(--ease) both; }
.toast.ok svg { color: var(--emerald-2); } .toast.err svg { color: var(--danger); } .toast.warn svg { color: var(--warn); }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }

/* ---------- tab bar & fab ---------- */
#tabbar {
  position: fixed; z-index: 50; left: 50%; transform: translateX(-50%); bottom: calc(10px + var(--safe-b));
  width: calc(100% - 20px); max-width: 560px; height: var(--nav-h);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; padding: 0 6px;
  background: var(--surface-solid); border: 1px solid var(--border-2); border-radius: 24px; box-shadow: var(--shadow-2);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  #tabbar { background: color-mix(in srgb, var(--surface-solid) 78%, transparent); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
}
.tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 56px; border: 0; background: none; color: var(--text-3); font-size: 11px; font-weight: 700; cursor: pointer; border-radius: 16px; transition: color var(--t-fast); }
.tab svg { transition: transform var(--t-med) var(--ease-spring); }
.tab.on { color: var(--accent); }
.tab.on svg { transform: translateY(-2px) scale(1.08); }
.tab.on::after { content: ""; position: absolute; bottom: 4px; width: 18px; height: 3px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
#fab {
  position: fixed; z-index: 51; left: calc(50% - min(280px, 50vw - 10px) + 8px); bottom: calc(var(--nav-h) + var(--safe-b) + 22px);
  height: 54px; padding: 0 20px 0 18px; border-radius: 18px; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14.5px;
  background: linear-gradient(135deg, var(--lime), var(--emerald-2) 60%); color: #03170c; box-shadow: 0 10px 30px rgba(16,185,129,.4), 0 0 0 1px rgba(255,255,255,.1) inset;
  transition: transform var(--t-med) var(--ease-spring), opacity var(--t-med);
}
#fab:active { transform: scale(.94); }
#fab.hide { transform: translateY(120px); opacity: 0; pointer-events: none; }

/* ---------- misc ---------- */
.kv { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-2); }
.kv .v { font-weight: 700; text-align: left; }
.pill-tabs { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; margin-bottom: var(--s4); }
.pill-tabs::-webkit-scrollbar { display: none; }
.chart { width: 100%; position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); fill: var(--text-3); font-size: 10px; }
.chart .tip { position: absolute; pointer-events: none; transform: translate(-50%, -110%); background: var(--surface-solid-2); border: 1px solid var(--border-2); border-radius: 10px; padding: 4px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; box-shadow: var(--shadow-1); opacity: 0; transition: opacity var(--t-fast); }
.chart .tip.on { opacity: 1; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s3); font-size: 12px; color: var(--text-2); margin-top: var(--s2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 4px; vertical-align: -1px; }
.empty-inline { padding: var(--s6) var(--s3); text-align: center; color: var(--text-3); font-size: 13px; border: 1px dashed var(--border-2); border-radius: var(--r-md); }
