/* Dashboard (sidebar layout), store and shared app components. Loaded after style.css. */

.icon { display: inline-flex; width: 18px; height: 18px; flex: none; }
.icon svg { width: 100%; height: 100%; }
code { font: 12.5px var(--font-mono); padding: 1px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); }
.nowrap { white-space: nowrap; }
.center-text { text-align: center; }

.shell { position: relative; z-index: 1; display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 20px;
  padding: 20px 14px; overflow-y: auto;
  background: rgb(10 10 10 / .85); border-right: 1px solid var(--border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.sidebar > .logo { padding: 4px 10px 8px; }
.side-nav { flex: 1; display: flex; flex-direction: column; gap: 18px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-title { padding: 0 10px 6px; font: 500 11px var(--font-mono); text-transform: uppercase; letter-spacing: .18em; color: #6b6b76; }
.side-nav a {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: 9px;
  font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none;
  transition: color .15s, background-color .15s;
}
.side-nav a:hover { color: var(--text); background: var(--surface-2); }
.side-nav a.active { color: var(--text); background: rgb(var(--primary-rgb) / .1); }
.side-nav a.active .icon { color: var(--primary); }
.side-nav a.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }

.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 8px 0; border-top: 1px solid var(--border); }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me-text { display: flex; flex-direction: column; min-width: 0; font-size: 13px; line-height: 1.3; }
.me-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text span { font-size: 12px; }
.avatar {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px;
  font: 700 15px var(--font-display); color: var(--on-primary);
  background: linear-gradient(135deg, var(--primary-muted), var(--primary));
}
.avatar.big { width: 56px; height: 56px; border-radius: 16px; font-size: 24px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 56px;
  display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: rgb(0 0 0 / .7); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.crumb { font: 12px var(--font-mono); color: var(--muted); letter-spacing: .04em; }
.icon-btn { display: none; width: 36px; padding: 0; }
.announcement {
  display: flex; align-items: center; gap: 10px; margin: 20px 28px 0; padding: 12px 16px;
  border: 1px solid rgb(var(--primary-rgb) / .3); border-radius: 12px;
  background: rgb(var(--primary-rgb) / .08); color: var(--primary-muted); font-size: 14px;
}
.announcement .icon { color: var(--primary); }
.view { padding: 28px 28px 80px; outline: none; }
.side-backdrop { display: none; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; width: 272px; transform: translateX(-100%); transition: transform .25s ease; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .side-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgb(0 0 0 / .6); }
  .icon-btn { display: inline-flex; }
  .topbar, .view { padding-left: 16px; padding-right: 16px; }
  .announcement { margin: 16px 16px 0; }
}

.loading { display: grid; place-items: center; min-height: 40vh; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.stack { display: grid; gap: 20px; align-content: start; min-width: 0; }
.narrow-page { max-width: 760px; }
.view .page-head, .store-page .page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 0 0 4px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.store-page .center-head { justify-content: center; text-align: center; margin-bottom: 20px; }
.page-head p { margin: 10px 0 0; }

/* stats */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; min-width: 0; }
.stat-label { font: 500 11px var(--font-mono); text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.stat-value { font: 700 28px/1.1 var(--font-display); letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-value.small { font-size: 17px; font-weight: 600; }
.stat-value .mono { font-size: 20px; font-weight: 500; }
.stat-sub { font-size: 12px; color: var(--muted); }

/* cards & links */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.link, .strong-link { color: var(--primary); text-decoration: none; font-weight: 500; }
.strong-link { color: var(--text); }
.link:hover, .strong-link:hover { color: var(--primary-hover); text-decoration: underline; }
.back-link { display: inline-flex; align-items: center; gap: 6px; width: fit-content; font-size: 14px; color: var(--muted); text-decoration: none; }
.back-link:hover { color: var(--text); }
.user-title { display: flex; align-items: center; gap: 16px; }
.user-title h1 { margin: 0 0 8px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.callout { padding: 12px 16px; border-radius: 12px; border: 1px solid var(--border-strong); font-size: 14px; }
.callout.warn { border-color: rgb(var(--primary-rgb) / .35); background: rgb(var(--primary-rgb) / .07); color: var(--primary-muted); }
.small-note { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 0; }
.card > p.muted { margin-top: 0; }

/* toolbars, tables, pager */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.toolbar > label { margin: 0; min-width: 160px; }
.grow { flex: 1; }
.row > label.small-field { flex: 0 0 110px; min-width: 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.table-foot .pager { margin: 0; flex: 1; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 13px; }
.pager-btns { display: flex; align-items: center; gap: 10px; }
tr.clickable { cursor: pointer; }
th.check-col, td.check-col { width: 36px; padding-right: 0; }
td input[type="checkbox"], th input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
td { vertical-align: middle; }

button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { border-color: var(--border-strong); background: var(--surface-2); }
.key-code { height: 28px; padding: 0 8px; font: 13px var(--font-mono); color: var(--text); }
.small-text { height: 24px; padding: 0 6px; font-size: 12px; color: var(--muted); }
.btn-danger, button.btn-danger { background: var(--danger); border-color: var(--danger); color: #1a0405; }
.btn-danger:hover { box-shadow: 0 0 30px -6px var(--danger); border-color: var(--danger); }
.inline-select { width: auto; margin: 0; padding: 4px 8px; font-size: 13px; }
.status-cell { display: flex; align-items: center; gap: 10px; }

.badge.warn { color: var(--primary); border-color: rgb(var(--primary-rgb) / .35); background: rgb(var(--primary-rgb) / .08); }
.badge.dot::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; vertical-align: 1px; }

/* toasts */
.toasts { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 40px)); }
.toast {
  padding: 12px 16px; border-radius: 12px; font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: 0 12px 40px rgb(0 0 0 / .5);
  animation: rise-in .25s ease both; transition: opacity .3s, transform .3s;
}
.toast.ok { border-left: 3px solid var(--ok); }
.toast.bad { border-left: 3px solid var(--danger); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px;
  background: rgb(0 0 0 / .65); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: fade-in .15s ease both; transition: opacity .15s;
}
.modal-backdrop.out { opacity: 0; }
@keyframes fade-in { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 26px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 18px;
  box-shadow: 0 30px 80px rgb(0 0 0 / .6); animation: rise-in .2s ease both;
}
.modal h3 { margin: 0 0 8px; font: 600 19px var(--font-display); }
.modal > p { margin: 0 0 18px; font-size: 14px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.modal-actions button { height: 40px; min-width: 96px; }
.hint { display: block; margin-top: 6px; font-size: 12px; font-weight: 400; color: #6b6b76; }
label.check { display: flex; align-items: center; gap: 10px; color: var(--text); }
label.check input { width: 16px; height: 16px; }

/* charts */
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.chart-head h2 { margin: 0 0 6px; }
.chart { display: grid; grid-template-columns: auto 1fr; grid-template-rows: 150px auto; column-gap: 10px; }
.chart-grid { display: flex; flex-direction: column; justify-content: space-between; font: 11px var(--font-mono); color: var(--muted); text-align: right; }
.chart-bars {
  position: relative; display: flex; align-items: flex-end; gap: 2px;
  border-bottom: 1px solid var(--border-strong);
  background: linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 100% 50%;
}
.bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; outline: none; }
.bar { width: 100%; height: var(--h); border-radius: 4px 4px 0 0; background: #d9742a; transition: background-color .15s; }
.bar-col:hover .bar, .bar-col:focus-visible .bar { background: var(--primary); }
.chart-tip {
  position: absolute; bottom: calc(100% + 6px); left: var(--x); transform: translateX(-50%);
  display: flex; gap: 8px; padding: 5px 10px; border-radius: 8px; white-space: nowrap; pointer-events: none;
  font-size: 12px; background: var(--surface-2); border: 1px solid var(--border-strong);
}
.chart-x { grid-column: 2; display: flex; justify-content: space-between; margin-top: 8px; font: 11px var(--font-mono); color: var(--muted); }

/* activity feed */
.feed { list-style: none; margin: 0; padding: 0; display: grid; }
.feed li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.feed li:last-child { border-bottom: 0; }
.feed-time { font-size: 12px; white-space: nowrap; }

/* user pages */
.empty-state { display: grid; justify-items: start; gap: 14px; }
.empty-state p { margin: 0; color: var(--muted); }
.license-dl { width: 100%; margin-top: 16px; }
.meta.big { gap: 12px; font-size: 14px; margin: 0; }
.redeem-card .row { margin-top: 18px; }
.key-input { font-size: 16px; letter-spacing: .06em; }
.keys-output { margin-top: 16px; display: grid; gap: 10px; }
.keys-output textarea { margin: 0; }

/* store */
.store-page { max-width: 960px; }
.product-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.product-head h2 { margin: 0 0 6px; font-size: 20px; }
.product-head p { margin: 0; max-width: 560px; font-size: 14px; line-height: 1.6; }
.product-meta { display: flex; align-items: center; gap: 10px; }
.plans { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.plan {
  display: flex; flex-direction: column; gap: 4px; padding: 18px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; transition: border-color .2s;
}
.plan:hover { border-color: rgb(var(--primary-rgb) / .4); }
.plan-name { font: 600 15px var(--font-display); }
.plan-price { font: 700 28px/1.2 var(--font-display); letter-spacing: -.02em; color: var(--primary); }
.plan .btn, .plan button { margin-top: 12px; width: 100%; }

/* switches */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; margin: 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.switch-row:last-child { border-bottom: 0; }
.switch-row > span:first-child { display: flex; flex-direction: column; gap: 3px; color: var(--text); font-weight: 400; }
.switch-row small { font-size: 13px; }
.switch { position: relative; flex: none; width: 42px; height: 24px; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--border-strong); transition: background-color .2s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text); transition: transform .2s; }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(18px); background: var(--on-primary); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px rgb(var(--primary-rgb) / .3); }

/* loader */
.loader-card { border-color: rgb(var(--primary-rgb) / .3); background: linear-gradient(135deg, rgb(var(--primary-rgb) / .08), var(--surface) 60%); }
.loader-main { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; }
.loader-main h2 { margin: 0 0 4px; }
.loader-main p { margin: 0; font-size: 14px; }
.loader-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; color: var(--primary); background: rgb(var(--primary-rgb) / .12); border: 1px solid rgb(var(--primary-rgb) / .25); }
.loader-icon .icon { width: 22px; height: 22px; }
.loader-meta { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 24px; }
.loader-meta div { flex-direction: column; gap: 2px; justify-content: flex-start; }
.loader-meta .small-text { padding: 0; height: auto; }
.row > label.small-field.wide { flex-basis: 160px; }
@media (max-width: 700px) { .loader-main { grid-template-columns: 1fr; } .loader-icon { display: none; } }
input[type="file"] { padding: 6px; cursor: pointer; }
input[type="file"]::file-selector-button {
  margin-right: 12px; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 600 13px var(--font-sans);
}
input[type="file"]::file-selector-button:hover { border-color: rgb(var(--primary-rgb) / .45); }
