:root {
    color-scheme: dark;
    --bg-body: #050508;
    --bg-admin: #090a0f;
    --bg-admin-inner: #06070a;
    --mk-accent: #0055ff;
    --mk-accent-rgb: 0, 85, 255;
    --mk-accent-hi: #4580f7;
    --mk-accent-hi-rgb: 69, 128, 247;
    --mk-accent-soft: #88aefc;
    --mk-accent-pale: #c5d7fc;
    --mk-accent-lo: #0546c7;
    --mk-accent-deep: #002299;
    --mk-on-accent: #ffffff;
    --stroke: rgba(255, 255, 255, 0.08);
    --muted: #cbd5e1;
    --font-main: 'Kanit', 'Prompt', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-family: var(--font-main);
    font-synthesis: none;
    color: #fff;
    background: var(--bg-body);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; padding-top: env(safe-area-inset-top, 0px); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(var(--mk-accent-rgb), .085) 1px, transparent 1px),
        linear-gradient(90deg, rgba(var(--mk-accent-rgb), .085) 1px, transparent 1px);
    background-size: 64px 64px;
    -webkit-mask-image: radial-gradient(ellipse 130% 100% at 50% 30%, black 35%, transparent 90%);
    mask-image: radial-gradient(ellipse 130% 100% at 50% 30%, black 35%, transparent 90%);
    pointer-events: none;
}
.ambient-glow-1 {
    position: fixed;
    top: 0;
    left: 50%;
    width: min(800px, 100%);
    height: 400px;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at center, rgba(var(--mk-accent-rgb), .09) 0%, transparent 70%);
    pointer-events: none;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 2px solid var(--mk-accent-soft); outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 3vw, 2.12rem); font-weight: 800; line-height: 1.25; }
h2 { font-size: 1.12rem; font-weight: 700; line-height: 1.4; }
.wrap { width: min(1320px, 100% - 2rem); margin-inline: auto; }
main { position: relative; }
.top { position: relative; z-index: 1; margin: 12px auto 24px; }
.top-content, .brand, .account { display: flex; align-items: center; }
.top-content {
    min-height: 58px;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 18px;
    border: 1px solid var(--stroke);
    border-radius: 999px;
    background: rgba(8, 9, 14, .94);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .8), 0 0 20px rgba(var(--mk-accent-rgb), .08);
}
.brand { min-width: 0; gap: 10px; font-size: 1.05rem; font-weight: 800; line-height: 1.15; }
.brand span { overflow-wrap: anywhere; }
.brand-logo-img { flex: 0 0 auto; width: 32px; height: 32px; object-fit: contain; border-radius: 50%; filter: drop-shadow(0 0 8px rgba(var(--mk-accent-rgb), .5)); }
.account { flex: 0 1 auto; min-width: max-content; gap: 12px; justify-content: end; }
.username { display: inline-flex; align-items: center; gap: 7px; max-width: min(22vw, 180px); color: var(--muted); }
.account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: #10b981; }

.login-area { width: min(900px, 100% - 2rem); padding: 6px 0 40px; }
.auth-split-card {
    margin: 20px auto 40px;
    border: 1px solid rgba(106, 128, 160, .28);
    border-radius: 24px;
    overflow: hidden;
    background: linear-gradient(165deg, rgba(12, 14, 20, .98), rgba(6, 8, 12, .99));
    box-shadow: 0 40px 100px rgba(0, 0, 0, .8), 0 0 40px rgba(106, 128, 160, .15);
    display: grid;
    grid-template-columns: 1.05fr .95fr;
}
.auth-aside-celestial {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 36px 24px;
    border-right: 1px solid var(--stroke);
    background: radial-gradient(circle at center, rgba(var(--mk-accent-rgb), .094) 0%, #06070b 72%);
    overflow: hidden;
}
.auth-celestial-wrap { width: 260px; height: 260px; display: flex; align-items: center; justify-content: center; margin: 10px auto 28px; }
.auth-panel { min-width: 0; padding: 40px 36px; display: flex; flex-direction: column; justify-content: center; }
.auth-header-title { font-size: 1.45rem; font-weight: 800; margin-bottom: 4px; }
.auth-header-sub { font-size: .84rem; color: var(--muted); margin-bottom: 20px; }
.auth-input-group { margin-bottom: 16px; }
.auth-label-title { font-size: .72rem; font-weight: 800; line-height: 1.35; margin-bottom: 6px; }
.auth-panel .auth-custom-input { background: #090a0f; border-radius: 12px; padding: 12px 16px; font-size: .88rem; }
.auth-custom-input::placeholder { color: #8794a8; }
.auth-submit-btn {
    width: 100%;
    min-height: 44px;
    margin: 10px 0 16px;
    padding: 12px;
    border: 0;
    border-radius: 12px;
    background: #fff;
    color: #050508;
    font-size: .9rem;
    font-weight: 800;
    line-height: 1.25;
    box-shadow: 0 0 20px rgba(255, 255, 255, .25);
}
.auth-submit-btn:hover { background: #edf3ff; }

.dashboard { padding: 7px 0 65px; }
.panel { background: var(--bg-admin); border: 1px solid var(--stroke); border-radius: 18px; }
.headline { margin-bottom: 20px; }
.intro { margin-top: 6px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { display: grid; gap: 7px; padding: 16px; background: var(--bg-admin-inner); border-radius: 16px; }
.stat span { display: inline-flex; align-items: center; gap: 7px; font-size: .86rem; }
.admin-stat-num { font-size: 1.8rem; font-weight: 900; line-height: 1.2; }
.active { --state: #6ee7b7; --state-bg: #152c25; }
.unused { --state: var(--mk-accent-soft); --state-bg: #152342; }
.suspended { --state: #fcd58a; --state-bg: #32261b; }
.expired { --state: #fda4af; --state-bg: #361d26; }
.stat i, .badge i { display: inline-block; flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--state); }

label { display: block; color: #fff; font-size: .74rem; font-weight: 800; line-height: 1.35; }
input, select {
    width: 100%;
    min-height: 43px;
    padding: 10px 14px;
    color: #fff;
    background: #07080c;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 10px;
    font-size: .86rem;
}
input::placeholder { color: #94a3b8; }
input:focus, select:focus { border-color: rgba(106, 128, 160, .8); box-shadow: 0 0 12px rgba(106, 128, 160, .25); }
input:-webkit-autofill { -webkit-text-fill-color: #fff; box-shadow: 0 0 0 100px #090a0f inset; }
.primary, .plain {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    min-height: 39px;
    border: 1px solid rgba(var(--mk-accent-rgb), .28);
    border-radius: 10px;
    background: rgba(var(--mk-accent-rgb), .12);
    color: var(--mk-accent-pale);
    font-size: .84rem;
    font-weight: 800;
    text-align: center;
    white-space: nowrap;
}
.primary { min-height: 43px; border-color: transparent; padding-inline: 18px; color: var(--mk-on-accent); background: linear-gradient(135deg, var(--mk-accent-lo), var(--mk-accent) 40%, var(--mk-accent-deep)); }
.primary:hover { background: linear-gradient(135deg, var(--mk-accent-lo), var(--mk-accent-deep)); }
.plain:hover { background: rgba(var(--mk-accent-rgb), .2); }
.top .plain { min-height: 34px; border-radius: 999px; }

.issue { display: grid; grid-template-columns: minmax(140px, .42fr) minmax(0, 1fr); align-items: center; gap: 16px; padding: 20px; margin-bottom: 20px; border-color: rgba(var(--mk-accent-rgb), .28); }
.issue p, .listing-head p, .empty p { margin-top: 4px; color: var(--muted); font-size: .86rem; }
.issue-form { display: grid; align-items: start; grid-template-columns: minmax(95px, .43fr) minmax(0, 1fr); gap: 12px; }
.issue-form .custom-key, .issue-form .issue-note, .issue-form button { grid-column: 1 / -1; }
.custom-key small { display: block; color: var(--muted); margin-top: 5px; }
.issue-form label, .product-form label { margin-bottom: 6px; }
.product-settings { grid-column: 1 / -1; padding: 12px 0 0; border-top: 1px solid var(--stroke); min-width: 0; }
.product-settings summary { cursor: pointer; font-weight: 650; color: var(--mk-accent-pale); width: fit-content; }
.product-form { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; align-items: end; margin-top: 12px; }
.product-form .plain { min-height: 43px; }
.listing { overflow: hidden; }
.listing-head { display: grid; padding: 18px 20px; gap: 12px; }
.filters { display: grid; gap: 8px; }
.filter-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto; gap: 8px; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.filters input, .filters select { min-width: 0; width: 100%; }
.filters .plain { min-height: 43px; }
.empty { color: var(--muted); text-align: center; padding: 38px 12px 43px; border-top: 1px solid var(--stroke); }
.empty strong { color: #fff; }
.scroll-table { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.admin-table th, .admin-table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.admin-table th:first-child, .admin-table td:first-child { padding-left: 20px; }
.admin-table th:last-child, .admin-table td:last-child { padding-right: 20px; }
.admin-table th { background: rgba(255, 255, 255, .02); font-size: .72rem; font-weight: 800; white-space: nowrap; }
.admin-table td { overflow-wrap: anywhere; font-size: .84rem; }
.admin-table tr:hover td { background: rgba(255, 255, 255, .02); }
td small { display: block; color: var(--muted); margin-top: 4px; }
td time, td code { white-space: nowrap; }
td code { color: var(--mk-accent-pale); }
.badge { background: var(--state-bg); color: var(--state); padding: 4px 8px; border-radius: 999px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.danger { background: rgba(225, 38, 69, .12); color: #ffc0ca; border-color: rgba(225, 38, 69, .35); }
.danger:hover { background: rgba(225, 38, 69, .2); }
.pager { display: flex; justify-content: end; align-items: center; gap: 12px; color: var(--muted); padding: 14px 20px; }
.notice { padding: 13px 14px; border-radius: 10px; border: 1px solid; margin-bottom: 16px; }
.error { color: #ffb9c3; background: #291219; border-color: #6b2637; }
.success { color: #b7f7db; background: #122621; border-color: #2e624f; }
.success p { margin: 4px 0 8px; }

@media (max-width: 768px) {
    .auth-split-card { grid-template-columns: 1fr; }
    .auth-aside-celestial { border-right: 0; border-bottom: 1px solid var(--stroke); padding: 30px 20px; }
    .auth-celestial-wrap { width: min(260px, 100%); height: auto; aspect-ratio: 1; margin: 0; }
    .auth-panel { padding: 30px 24px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .issue { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .admin-table { min-width: 750px; }
}
@media (max-width: 480px) {
    .top { margin: 8px auto 16px; }
    .top-content { min-height: 62px; padding: 7px 11px; }
    .brand { font-size: .81rem; gap: 7px; }
    .brand-logo-img { width: 28px; height: 28px; }
    .account .username { display: none; }
    .headline .intro { font-size: .84rem; }
    .issue, .listing-head { padding: 15px 13px; }
    .filters select, .filters .plain { padding-inline: 7px; font-size: .79rem; }
    .filter-row { gap: 5px; }
    .filter-row select { padding-inline: 4px; text-overflow: ellipsis; }
    .filter-row .plain { padding-inline: 5px; font-size: clamp(.63rem, 2.9vw, .8rem); }
    .issue-form { grid-template-columns: minmax(85px, .5fr) minmax(0, 1fr); }
    .product-form { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    .mk-a3-scene, .mk-a3-orbit, .mk-a3-e, .mk-atom-logo { animation: none !important; }
}

/* ── 2. Shop logo + 3D atom ──
   Real 3D: each orbit is a ring tilted in depth; the electron travels round it and
   passes behind / in front of the logo (the logo sits in the middle plane).
   The atom only sways gently in 3D; it never spins flat. */
.mk-atom {
    position: relative;
    flex: 0 0 auto;
    width: 100%;
    aspect-ratio: 1 / 1;
    perspective: 560px;
    perspective-origin: 50% 50%;
}
.mk-a3-scene {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    animation: mkA3Sway 7.5s ease-in-out infinite;
}
@keyframes mkA3Sway {
    0%, 100% { transform: rotateX(10deg) rotateY(-14deg); }
    50%      { transform: rotateX(-8deg) rotateY(14deg); }
}
.mk-a3-ring {
    position: absolute;
    inset: 4%;
    transform-style: preserve-3d;
    transform: rotateZ(var(--mk-a3-r, 0deg)) rotateX(70deg);
}
.mk-a3-ring:nth-child(2) { --mk-a3-r: 60deg; }
.mk-a3-ring:nth-child(3) { --mk-a3-r: 120deg; }
.mk-a3-orbit {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(var(--mk-accent-rgb), 0.95);
    box-shadow: 0 0 9px rgba(var(--mk-accent-rgb), 0.75), inset 0 0 9px rgba(var(--mk-accent-rgb), 0.55);
    transform-style: preserve-3d;
    animation: mkA3Orbit var(--mk-atom-speed, 2.6s) linear infinite;
}
.mk-a3-ring:nth-child(2) .mk-a3-orbit,
.mk-a3-ring:nth-child(2) .mk-a3-e { animation-duration: calc(var(--mk-atom-speed, 2.6s) * 1.18); animation-delay: calc(var(--mk-atom-speed, 2.6s) * -0.4); }
.mk-a3-ring:nth-child(3) .mk-a3-orbit,
.mk-a3-ring:nth-child(3) .mk-a3-e { animation-duration: calc(var(--mk-atom-speed, 2.6s) * 0.86); animation-delay: calc(var(--mk-atom-speed, 2.6s) * -0.75); }
@keyframes mkA3Orbit {
    to { transform: rotateZ(360deg); }
}
/* electron: undoes the orbit turn and the tilt so it always faces the viewer (round, not squashed) */
.mk-a3-e {
    position: absolute;
    left: 50%;
    top: 0;
    width: 9%;
    height: 9%;
    margin: -4.5% 0 0 -4.5%;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #ffffff 0 34%, var(--mk-accent-soft) 58%, rgba(var(--mk-accent-hi-rgb), 0) 72%);
    box-shadow: 0 0 10px 3px rgba(var(--mk-accent-hi-rgb), 0.9), 0 0 3px 1px #ffffff;
    animation: mkA3Face var(--mk-atom-speed, 2.6s) linear infinite;
}
@keyframes mkA3Face {
    from { transform: rotateZ(0deg) rotateX(-70deg); }
    to   { transform: rotateZ(-360deg) rotateX(-70deg); }
}
.mk-atom-logo {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 46%;
    height: 46%;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(var(--mk-accent-rgb), 0.8)) drop-shadow(0 0 2px rgba(255, 255, 255, 0.35));
    transform: translateZ(0);
    animation: mkAtomFloat 3.4s ease-in-out infinite;
}
@keyframes mkAtomFloat {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50%      { transform: translate3d(0, -3%, 0) scale(1.035); }
}

.auth-celestial-wrap.mk-atom-host {
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-celestial-wrap.mk-atom-host .mk-atom {
    width: min(300px, 82%);
}
.auth-celestial-wrap.mk-atom-host .mk-atom-logo {
    width: 44%;
    height: 44%;
    border-radius: 50%;
}

#license-list { scroll-margin-top: 8px; }
html.dialog-active, html.dialog-active body { overflow: hidden; overscroll-behavior: none; }
.panel-dialog {
    box-sizing: border-box;
    position: fixed;
    inset: 0;
    max-width: none;
    width: min(600px, calc(100% - 22px));
    max-height: min(86vh, calc(100% - 24px));
    max-height: min(86dvh, calc(100% - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    overflow: auto;
    overscroll-behavior: contain;
    margin: auto;
    padding: clamp(12px, 3vw, 22px);
    color: #fff;
    background: var(--bg-admin);
    border: 1px solid rgba(var(--mk-accent-rgb), .36);
    border-radius: 16px;
    box-shadow: 0 18px 62px #000b;
}
.panel-dialog::backdrop { background: rgba(2, 4, 9, .82); }
.confirmation-dialog, .feedback-dialog { width: min(440px, calc(100% - 22px)); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-close { min-height: 34px; width: 34px; flex: 0 0 34px; padding: 0; font-size: 1.25rem; line-height: 1; }
.dialog-message { margin: 12px 0; overflow-wrap: anywhere; color: var(--muted); }
.dialog-footer { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 8px; margin-top: 12px; }
.dialog-footer > * { min-height: 43px; }
.issued-code {
    display: block;
    padding: 12px;
    font: .94rem/1.6 ui-monospace, monospace;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    white-space: pre;
    user-select: text;
    -webkit-user-select: text;
    background: var(--bg-admin-inner);
    border: 1px solid var(--stroke);
    border-radius: 10px;
}
.copy-status:not(:empty) { font-size: .84rem; color: var(--muted); margin-top: 8px; }
.key-details { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 14px 0; gap: 8px; }
.key-details > div { min-width: 0; padding: 9px; background: var(--bg-admin-inner); border: 1px solid var(--stroke); border-radius: 10px; }
.key-details dt { color: var(--muted); font-size: .8rem; }
.key-details dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.key-details small { color: var(--muted); }
.adjust-form { display: grid; gap: 8px; align-items: end; margin-bottom: 10px; }
.adjust-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.adjust-form label, .compensation-duration label { margin-bottom: 6px; }
.manage-buttons > button { height: 44px; }
.manage-buttons { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.manage-buttons > button { width: 100%; padding: 4px 2px; font-size: clamp(.68rem, 2.8vw, .84rem); }
.manage-buttons > button:disabled { opacity: .45; cursor: default; }
.reset-button { margin-top: 10px; }
@media (max-width: 680px) {
    .key-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.compensation-duration { margin: 12px 0; }
#comp-custom[hidden] { display: none; }
.key-details .key-note dd { white-space: pre-wrap; }
