/* ---------- Base theme & tokens ---------- */
:root {
  color-scheme: dark;

  /* Palette */
  --bg: #0b0d10;
  --bg-2: #0f141b;
  --panel: #11151b;
  --ink: #e6edf5;
  --muted: #9fb0c8;
  --muted-2: #b9c5d8;

  --accent: #ff4d4d;
  --accent-2: #ff6666;
  --accent-ink: #0b0d10;

  --ring: #232a36;
  --ring-strong: #2f3a4c;

  /* Status (new) */
  --ok: #28c281;
  --warn: #ffb86b;
  --err: #ff6b6b;

  /* Layout */
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 36px rgba(0,0,0,.5);
  --sidebar: 260px;
  --container: 1200px;
  --gap: 14px;

  /* Type scale (new) */
  --fs-0: .875rem;
  --fs-1: 1rem;
  --fs-2: 1.125rem;
  --fs-3: 1.25rem;

  /* Motion & timing */
  --easing: cubic-bezier(.2,.8,.2,1);
  --fast: 120ms;
  --normal: 200ms;
  --slow: 320ms;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  :root { --fast: 0ms; --normal: 0ms; --slow: 0ms; }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
::selection { background: color-mix(in oklab, var(--accent) 30%, transparent); color: var(--ink); }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 700px at 85% -10%, color-mix(in oklab, var(--accent) 18%, transparent), transparent 60%),
    var(--bg);
  overflow-x: hidden;
  line-height: 1.55;
  font-size: var(--fs-1);
}

/* Links */
a { color: var(--ink); text-decoration: none; transition: color var(--fast) var(--easing); }
a:hover { color: #fff; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  background: var(--bg-2);
  border-right: 1px solid var(--ring);
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .4px; }
.badge {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7b1f1f);
  box-shadow: var(--shadow);
}

.nav { display: grid; gap: 6px; margin-top: 8px; }
.nav a {
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid transparent; color: #d8e1ef;
  transition: background-color var(--fast) var(--easing), border-color var(--fast) var(--easing), transform var(--fast) var(--easing);
  outline: none;
  font-size: var(--fs-0);
}
.nav a:hover,
.nav a.active { background: #161d28; border-color: var(--ring); }
.nav a:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--accent) 60%, #fff 0%);
  outline-offset: 2px; border-color: var(--accent);
}

.spacer { flex: 1; }
.logout {
  background: var(--accent); color: #fff; border: 0;
  border-radius: 12px; padding: 12px 14px; cursor: pointer; font-weight: 800;
  transition: transform var(--fast) var(--easing), box-shadow var(--fast) var(--easing), background-color var(--fast) var(--easing);
}
.logout:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(255,77,77,.25); }
.logout:active { transform: translateY(0); }

/* ---------- Mobile sidebar toggle ---------- */
.toggle {
  display: none; position: fixed; top: 10px; left: 10px; z-index: 50;
  background: var(--bg-2); border: 1px solid var(--ring); border-radius: 10px;
  padding: 8px 10px; color: var(--ink);
}
@media (max-width: 900px) {
  .toggle { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform var(--normal) var(--easing); }
  .sidebar.open { transform: translateX(0); }
}

/* ---------- Layout ---------- */
.main {
  margin-left: var(--sidebar);
  padding: 16px 18px 40px;
  max-width: calc(var(--container) + var(--sidebar));
}
@media (max-width: 900px) {
  .main { margin-left: 0; padding-top: 54px; }
}

/* Grid system (added) */
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
}
.span-3  { grid-column: span 3; }
.span-4  { grid-column: span 4; }
.span-6  { grid-column: span 6; }
.span-8  { grid-column: span 8; }
.span-12 { grid-column: span 12; }

@media (max-width: 1100px) {
  .span-6 { grid-column: span 12; }
  .span-4, .span-3 { grid-column: span 6; }
}
@media (max-width: 700px) {
  .span-8, .span-6, .span-4, .span-3 { grid-column: span 12; }
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  background: rgba(8,10,14,.55); backdrop-filter: blur(8px);
  border: 1px solid var(--ring); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 14px;
}
.search {
  flex: 1; display: flex; gap: 8px; align-items: center;
  background: var(--bg-2); border: 1px solid var(--ring); border-radius: 10px; padding: 8px 10px;
}
.search input {
  flex: 1; background: transparent; border: 0; color: var(--ink); outline: none;
}
.user { display: flex; gap: 10px; align-items: center; color: var(--muted); }

/* ---------- Cards ---------- */
.card {
  background: var(--panel); border: 1px solid var(--ring);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 14px;
}
#view .card {
  opacity: 0; transform: translateY(18px);
  transition: transform var(--fast) var(--easing), box-shadow var(--fast) var(--easing), border-color var(--fast) var(--easing);
}
.card:hover { border-color: var(--ring-strong); box-shadow: 0 16px 42px rgba(0,0,0,.55); }

.card h3 { margin: 0 0 8px; color: var(--accent); font-size: var(--fs-2); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--ring); padding: 10px 0; }
.list li:first-child { border-top: 0; }

/* ---------- Footer ---------- */
footer { margin-top: 16px; color: #a8b6cc; }

/* ---------- Buttons & chips ---------- */
.muted { color: var(--muted); }
.btn {
  background: var(--accent); color: #fff; border: 0;
  border-radius: var(--radius-sm); padding: 10px 14px; cursor: pointer; font-weight: 800;
  transition: transform var(--fast) var(--easing), box-shadow var(--fast) var(--easing), background-color var(--fast) var(--easing);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(255,77,77,.25); }
.btn.ghost { background: transparent; border: 1px solid var(--ring); color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-sm { padding: 8px 10px; border-radius: 8px; font-weight: 700; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px; font-size: .9rem;
  background: transparent; border: 1px solid var(--ring); color: var(--ink);
  transition: background var(--fast) var(--easing), border-color var(--fast) var(--easing);
}
.chip:hover { background: #161d28; border-color: var(--ring-strong); }

/* ---------- Card header / utilities ---------- */
.card-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.card-header .icon { width: 18px; height: 18px; color: var(--muted); }
.inline-actions { display: flex; gap: 8px; align-items: center; }

.badge-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff8, transparent 60%), var(--accent);
  box-shadow: 0 0 10px rgba(255,77,77,.45);
}

/* ---------- Key/Value list (compact stats) ---------- */
.list-kv { list-style: none; margin: 10px 0 0; padding: 0; }
.list-kv li {
  display: grid; grid-template-columns: 1fr auto; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--ring);
}
.list-kv li:first-child { border-top: 0; }
.list-kv span { color: var(--muted); }
.list-kv strong { font-weight: 800; }

/* ---------- Skeletons ---------- */
.skeleton {
  position: relative; height: 22px; border-radius: 6px; overflow: hidden;
  background: linear-gradient(90deg, #121722 0%, #1a2230 40%, #121722 80%);
  background-size: 200% 100%;
  animation: sk 1.2s linear infinite;
  margin: 8px 0;
  border: 1px solid var(--ring);
}
@keyframes sk { to { background-position-x: -200%; } }

/* ---------- Store tweaks ---------- */
.store-header {
  display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px;
}
.store-search {
  width: min(320px, 60vw);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--ring);
  background: var(--bg-2);
  color: var(--ink);
  outline: none;
}
.store-search::placeholder { color: var(--muted); }

.product-card {
  display: grid; grid-template-rows: auto 1fr; gap: 12px; height: 100%;
}
.product-media { position: relative; overflow: hidden; border-radius: 12px; background: #0f131b; border: 1px solid var(--ring); }
.product-img { width: 100%; height: auto; display: block; aspect-ratio: 16 / 10; object-fit: cover; transform: scale(1.02); }
.price-badge {
  position: absolute; top: 10px; right: 10px;
  background: var(--accent); color: #fff; font-weight: 800;
  padding: 6px 10px; border-radius: 999px; font-size: .92rem;
  box-shadow: 0 8px 22px rgba(255,77,77,.25);
}
.product-info { display: grid; align-content: start; gap: 8px; }
.product-title { margin: 0; font-size: var(--fs-2); }
.bullets li { list-style: disc; margin-left: 18px; border: 0; padding: 4px 0; }

.buy-row { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; margin-top: 6px; }
.qty { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.qty-input { width: 68px; padding: 8px; border-radius: 8px; border: 1px solid var(--ring); background: #0f141b; color: var(--ink); }

#cartItems li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; }
.item-actions { display: flex; gap: 6px; }

/* Product hover lift */
.product-card:hover { border-color: var(--ring-strong); box-shadow: 0 16px 42px rgba(0,0,0,.55); }

/* Toast */
.toast {
  position: fixed; inset: auto 16px 16px auto; z-index: 60;
  background: #111921; border: 1px solid var(--ring); border-radius: 10px;
  padding: 10px 12px; color: var(--ink); box-shadow: var(--shadow);
}

/* ---------- Responsive polish ---------- */
@media (max-width: 1100px) {
  .store-header { grid-template-columns: 1fr; gap: 6px; }
  .store-search { width: 100%; }
}
.panel { display: block; }
.chat-panel { display: grid; grid-template-rows: auto 1fr auto; gap: .75rem; height: calc(100vh - 140px); }
.panel-header { display:flex; align-items:center; justify-content: space-between; }
.messages { overflow-y:auto; padding: .5rem; border: 1px solid var(--border, #2a2f3a); border-radius: .75rem; }
.msg { padding: .5rem .6rem; margin-bottom: .35rem; background: rgba(255,255,255,0.03); border-radius: .6rem; }
.msg-head { font-size: .8rem; opacity: .8; display:flex; gap:.5rem; }
.msg-user { font-weight: 600; }
.msg-body { margin-top: .15rem; line-height: 1.35; word-wrap: break-word; }
.chat-input { display:flex; gap:.5rem; }
.chat-input input { flex:1; }
.chat-panel .btn { padding: .5rem .8rem; border-radius: .5rem; border: 1px solid #384052; background: #202636; cursor: pointer; }
.chat-panel .btn:hover { filter: brightness(1.1); }
.chat-panel .btn-danger { border-color:#5b2c2c; background:#3a1e1e; }
.chat-panel .btn-ghost { background: transparent; border:1px solid var(--ring); color: var(--ink); }
.chat-panel .btn-ghost:hover { background: var(--ring); }
.login-modal { position: fixed; inset: 0; display: none; }
.login-modal[aria-hidden="false"] { display: grid; place-items: center; z-index: 100; }
.login-modal__backdrop { position:absolute; inset:0; background: rgba(0,0,0,.55); }
.login-modal__panel {
  position: relative;
  width: min(420px, 92vw);
  background: var(--panel);
  border: 1px solid var(--ring);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.login-modal__title { margin: 0 0 10px; }
.login-modal__close { position:absolute; top:8px; right:10px; background:transparent; border:0; color:var(--ink); font-size:22px; cursor:pointer; }
.login-form__row { display:flex; flex-direction: column; gap:6px; margin:10px 0; }
.login-form__row input {
  background:#0f141b; color:var(--ink); border:1px solid var(--ring); border-radius: 10px; padding:10px 12px;
}
.login-form__check { display:flex; align-items:center; gap:8px; margin: 6px 0 12px; color: var(--muted); }
.login-form__error { color:#ff6b6b; min-height: 18px; margin-top: 8px; }


/* ===== Profile & Form components (global) ===== */
.input, select, textarea{
  background: var(--bg-2);
  border: 1.5px solid var(--ring);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
.input-sm{ padding: 9px 11px; border-radius: 8px; }
.input:focus, select:focus, textarea:focus{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.chip{
  background: #0b1220;
  border: 1px solid #3b475a;
}
.chip:hover{ background:#141b29; border-color:#4a566b; }

.btn.ghost{
  background:#0b1220;
  border:1px solid #3b475a;
  color: var(--ink);
}
.btn.ghost:hover{ filter:brightness(1.08); }



.avatar{
  width:56px; height:56px; border-radius:50%;
  display:grid; place-items:center; font-weight:800;
  background: linear-gradient(135deg, var(--accent), #7b1f1f);
  color:#fff; text-shadow:0 1px 2px rgba(0,0,0,0);
}

/* Make badges & separators pop a little more on dark */
.badge-dot{ box-shadow: 0 0 14px rgba(255,77,77,.55); }
.list li + li{ border-top: 1px dashed #2a3a4f; }

:root{
  --bg-0:#0a0c10; --bg-1:#0a0c10; --bg-2:#0b1220;
  --panel:#0f172a; --ring:#475569; --ink:#f8fafc; --muted:#cbd5e1;
  --accent:#60a5fa; --ok:#34d399; --warn:#fbbf24;
}
body{ background:#0a0c10; } /* no gradient haze */
/* Remove dim/blur from all modal backdrops */
dialog.modal {
  position: fixed;
  inset: auto;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
dialog::backdrop,
dialog.modal::backdrop,
dialog[open]::backdrop {
  background: transparent !important;
  backdrop-filter: none !important;
}
body:has(dialog[open]) { filter:none !important; opacity:1 !important; }
[inert] { filter:none !important; opacity:1 !important; }

