/* SB-AIDESIGN Cloud admin — brand tokens from the app (black/red/white, Prompt),
   layout per ui-ux-pro-max: sidebar dashboard, KPI tiles, status colours, subtle glass depth,
   150–250ms motion, visible focus, reduced-motion safe. */

@font-face { font-family: 'Prompt'; font-weight: 400; font-display: swap; src: url('fonts/prompt-400-thai.woff2') format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-weight: 500; font-display: swap; src: url('fonts/prompt-500-thai.woff2') format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-weight: 600; font-display: swap; src: url('fonts/prompt-600-thai.woff2') format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-weight: 700; font-display: swap; src: url('fonts/prompt-700-thai.woff2') format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-weight: 400; font-display: swap; src: url('fonts/prompt-400-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Prompt'; font-weight: 500; font-display: swap; src: url('fonts/prompt-500-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Prompt'; font-weight: 600; font-display: swap; src: url('fonts/prompt-600-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Prompt'; font-weight: 700; font-display: swap; src: url('fonts/prompt-700-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #08070b;
  --shell: #0c0a10;
  --panel: #141019;
  --panel-2: #1a1520;
  --glass: rgba(26, 21, 32, 0.72);
  --border: #2c2735;
  --border-soft: #211c28;
  --hairline: rgba(255, 255, 255, 0.06);
  --white: #f5f2fa;
  --text-2: #c9c2d3;
  --muted: #948da3;
  --dim: #6f687d;
  --red: #ef1746;
  --red-2: #ff4d6d;
  --red-dim: rgba(239, 23, 70, 0.14);
  --success: #22c58b;
  --warn: #f5a524;
  --info: #4a9dff;
  --r-xl: 16px; --r-lg: 12px; --r-md: 10px; --r-sm: 8px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 12px 32px -16px rgba(0,0,0,.7);
  --font-ui: "Prompt", "Segoe UI Emoji", sans-serif;
  --side-w: 248px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
button, input, textarea, select { font-family: inherit; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(900px 500px at 100% -10%, rgba(239,23,70,.10), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, rgba(139,61,255,.06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--white); font: 400 14px/1.6 var(--font-ui); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
svg.i { width: 18px; height: 18px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2c2735; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--red); background-clip: padding-box; }
:focus-visible { outline: 2px solid var(--red-2); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ================= layout ================= */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px; background: rgba(12,10,16,.85); border-right: 1px solid var(--border-soft);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(140deg, #ff4d6d, #ef1746 55%, #9b0d2c); color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: 0 8px 20px -8px rgba(239,23,70,.8), inset 0 1px 0 rgba(255,255,255,.3);
}
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.15; letter-spacing: .3px; }
.brand-name small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; }
.nav-label { padding: 12px 10px 6px; font-size: 11px; color: var(--dim); letter-spacing: 1px; text-transform: uppercase; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 0 12px;
  border-radius: var(--r-md); color: var(--muted); text-decoration: none; font-weight: 500;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.nav-item:hover { background: var(--hairline); color: var(--white); }
.nav-item.active { background: linear-gradient(90deg, rgba(239,23,70,.18), rgba(239,23,70,.04)); color: var(--white); }
.nav-item.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--red); }
.nav-item.active svg { color: var(--red-2); }
.nav-item .count { margin-left: auto; font-size: 11.5px; color: var(--dim); }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border-soft); }
.me { display: flex; align-items: center; gap: 10px; padding: 6px 8px 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--border); font-weight: 600; color: var(--red-2); text-transform: uppercase; }
.me b { display: block; font-weight: 600; font-size: 13px; }
.me span { font-size: 11.5px; color: var(--muted); }

.main { min-width: 0; padding: 26px 32px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.2px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ================= cards / stats ================= */
.card {
  background: var(--glass); border: 1px solid var(--border-soft); border-radius: var(--r-xl);
  padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); backdrop-filter: blur(12px);
  animation: rise .35s var(--ease) both;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 9px; }
.card-head h2 svg { color: var(--red-2); }
.card-head .hint { color: var(--muted); font-size: 12.5px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  position: relative; overflow: hidden; padding: 16px 18px; border-radius: var(--r-xl);
  background: var(--glass); border: 1px solid var(--border-soft); box-shadow: var(--shadow);
  animation: rise .35s var(--ease) both;
}
.stat:nth-child(2) { animation-delay: .04s; } .stat:nth-child(3) { animation-delay: .08s; } .stat:nth-child(4) { animation-delay: .12s; }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12.5px; }
.stat-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--red-dim); color: var(--red-2); }
.stat-ico.ok { background: rgba(34,197,139,.12); color: var(--success); }
.stat-ico.info { background: rgba(74,157,255,.12); color: var(--info); }
.stat-ico.warn { background: rgba(245,165,36,.12); color: var(--warn); }
.stat-val { margin-top: 8px; font-size: 28px; font-weight: 600; line-height: 1.1; letter-spacing: -.5px; }
.stat-sub { margin-top: 2px; font-size: 12px; color: var(--dim); }

/* ================= controls ================= */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field .opt { color: var(--dim); font-weight: 400; }
input, select {
  height: 42px; padding: 0 13px; border-radius: var(--r-md); border: 1px solid var(--border);
  background: rgba(8,7,11,.6); color: var(--white); font-size: 14px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
input::placeholder { color: var(--dim); }
input:hover, select:hover { border-color: #3c3547; }
input:focus, select:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(239,23,70,.18); background: rgba(8,7,11,.85); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.75); cursor: pointer; }
select { cursor: pointer; appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23948da3' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input-ico { position: relative; }
.input-ico svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--dim); pointer-events: none; }
.input-ico input { padding-left: 38px; width: 100%; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px;
  border-radius: var(--r-md); border: 1px solid transparent; cursor: pointer; white-space: nowrap; text-decoration: none;
  background: linear-gradient(180deg, #f2284f, #e0103d); color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 18px -10px rgba(239,23,70,.9), inset 0 1px 0 rgba(255,255,255,.18);
  transition: filter .15s var(--ease), transform .1s var(--ease), background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: rgba(255,255,255,.03); border-color: var(--border); color: var(--text-2); box-shadow: none; }
.btn-ghost:hover { background: rgba(255,255,255,.07); color: var(--white); border-color: #3c3547; filter: none; }
.btn-danger:hover { border-color: rgba(255,77,109,.6); color: var(--red-2); background: var(--red-dim); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-icon { width: 34px; padding: 0; }
.btn-block { width: 100%; }

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 16px; align-items: end; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .input-ico { min-width: 240px; }
.inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ================= flash / key ================= */
.flash {
  display: flex; gap: 10px; align-items: center; padding: 12px 16px; margin-bottom: 18px; border-radius: var(--r-lg);
  background: rgba(34,197,139,.08); border: 1px solid rgba(34,197,139,.28); color: #bff0dc; animation: rise .25s var(--ease) both;
}
.flash svg { color: var(--success); }
.flash.err { background: var(--red-dim); border-color: rgba(239,23,70,.35); color: #ffd0da; }
.flash.err svg { color: var(--red-2); }
.key-card { border-color: rgba(239,23,70,.45); background: linear-gradient(160deg, rgba(239,23,70,.12), var(--glass) 55%); }
.key-row { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.key-box {
  flex: 1; min-width: 260px; padding: 13px 16px; border-radius: var(--r-md); border: 1px dashed rgba(255,77,109,.6);
  background: rgba(8,7,11,.7); font-weight: 600; font-size: 18px; letter-spacing: 1.5px; user-select: all; word-break: break-all;
}
.key-note { margin: 10px 0 0; color: var(--muted); font-size: 12.5px; display: flex; gap: 8px; align-items: center; }
.key-note svg { color: var(--warn); width: 16px; height: 16px; }

/* ================= table ================= */
.tbl-wrap { overflow-x: auto; margin: 0 -20px -20px; }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th, td { padding: 13px 20px; text-align: left; vertical-align: middle; }
thead th { position: sticky; top: 0; font-size: 12px; font-weight: 500; color: var(--dim); background: rgba(8,7,11,.5); border-bottom: 1px solid var(--border-soft); border-top: 1px solid var(--border-soft); }
tbody td { border-bottom: 1px solid var(--border-soft); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s var(--ease); }
tbody tr:hover { background: rgba(255,255,255,.025); }
.who { display: flex; align-items: center; gap: 12px; }
.who b { display: block; font-weight: 500; }
.sub { color: var(--muted); font-size: 12.5px; }
.mono { letter-spacing: 1px; color: var(--text-2); }
.meter { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.meter-bar { width: 54px; height: 6px; border-radius: 99px; background: var(--hairline); overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: inherit; background: var(--success); }
.meter-bar i.full { background: var(--warn); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
td.actions { text-align: right; }

.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.active { background: rgba(34,197,139,.12); color: var(--success); }
.pill.suspended { background: rgba(245,165,36,.12); color: var(--warn); }
.pill.revoked, .pill.expired { background: var(--red-dim); color: var(--red-2); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 6px; font-size: 11px; background: var(--hairline); color: var(--muted); margin-top: 4px; }
.tag.red { background: var(--red-dim); color: var(--red-2); }

/* details menu for per-row edits */
details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
details.menu[open] summary { background: rgba(255,255,255,.07); color: var(--white); }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 260px; padding: 12px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: 0 20px 40px -12px rgba(0,0,0,.8);
  display: grid; gap: 12px; text-align: left; animation: rise .18s var(--ease) both;
}
.menu-pop form { display: grid; gap: 8px; }
.menu-pop .lbl { font-size: 12px; color: var(--muted); }
.menu-pop hr { border: 0; border-top: 1px solid var(--border-soft); margin: 0; }

/* ================= assets ================= */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 99px; text-decoration: none;
  border: 1px solid var(--border); color: var(--muted); font-size: 13px; transition: all .15s var(--ease);
}
.chip:hover { color: var(--white); border-color: #3c3547; }
.chip.active { background: var(--red-dim); border-color: rgba(239,23,70,.5); color: var(--white); }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.asset {
  position: relative; border-radius: var(--r-lg); overflow: hidden; background: rgba(8,7,11,.6);
  border: 1px solid var(--border-soft); transition: border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
}
.asset:hover { border-color: rgba(239,23,70,.45); transform: translateY(-2px); box-shadow: 0 14px 30px -18px rgba(239,23,70,.6); }
.asset-img { position: relative; aspect-ratio: 1; background: repeating-conic-gradient(#15121b 0 25%, #100e15 0 50%) 0 0 / 18px 18px; }
.asset-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.asset-img .badge { position: absolute; left: 8px; top: 8px; padding: 2px 8px; border-radius: 6px; font-size: 11px; background: rgba(8,7,11,.75); backdrop-filter: blur(6px); color: var(--text-2); }
.asset-del { position: absolute; right: 8px; top: 8px; opacity: 0; transition: opacity .15s var(--ease); }
.asset:hover .asset-del, .asset:focus-within .asset-del { opacity: 1; }
.asset-del .btn { background: rgba(8,7,11,.8); backdrop-filter: blur(6px); }
.asset-body { padding: 10px 12px 12px; }
.asset-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--dim); font-size: 12px; margin-top: 2px; }

.empty { display: grid; place-items: center; gap: 8px; padding: 56px 16px; text-align: center; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: var(--dim); stroke-width: 1.4; }
.empty b { color: var(--text-2); font-weight: 500; }

.pager { display: flex; justify-content: center; gap: 6px; margin-top: 18px; }

/* ================= activity ================= */
.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border-soft); }
.log li:last-child { border-bottom: 0; }
.log-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--hairline); color: var(--muted); }
.log-ico svg { width: 16px; height: 16px; }
.log-ico.bad { background: var(--red-dim); color: var(--red-2); }
.log-ico.ok { background: rgba(34,197,139,.12); color: var(--success); }
.log b { font-weight: 500; }
.log time { color: var(--dim); font-size: 12px; white-space: nowrap; }

/* ================= login ================= */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 40px;
  background:
    radial-gradient(600px 400px at 20% 20%, rgba(239,23,70,.35), transparent 60%),
    radial-gradient(500px 400px at 90% 90%, rgba(139,61,255,.18), transparent 60%),
    #0b0910;
  border-right: 1px solid var(--border-soft);
}
.auth-art::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: radial-gradient(circle at 30% 40%, #000 0, transparent 75%);
}
.auth-art h2 { position: relative; z-index: 1; margin: 0; font-size: 34px; line-height: 1.25; font-weight: 600; max-width: 460px; }
.auth-art h2 span { color: var(--red-2); }
.auth-art p { position: relative; z-index: 1; color: var(--text-2); max-width: 420px; margin: 12px 0 0; }
.auth-feats { position: relative; z-index: 1; display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; color: var(--text-2); }
.auth-feats li { display: flex; gap: 10px; align-items: center; }
.auth-feats svg { color: var(--red-2); }
.auth-form { display: grid; place-items: center; padding: 32px 20px; }
.auth-box { width: 100%; max-width: 380px; animation: rise .35s var(--ease) both; }
.auth-box h1 { margin: 0 0 4px; font-size: 24px; font-weight: 600; }
.auth-box > p { margin: 0 0 24px; color: var(--muted); }
.auth-box form { display: grid; gap: 16px; }
.auth-box .btn { margin-top: 6px; height: 46px; }
.auth-foot { margin-top: 22px; display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 12.5px; }
.auth-foot svg { width: 15px; height: 15px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ================= responsive ================= */
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, 1fr); } .form-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: sticky; z-index: 30; height: auto; flex-direction: row; align-items: center; padding: 10px 14px; overflow-x: auto; }
  .brand { padding: 0 8px 0 0; } .brand-name, .nav-label, .side-foot .me, .nav-item .count { display: none; }
  .nav-item.active::before { display: none; }
  .side-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
  .main { padding: 20px 16px 40px; }
  .auth { grid-template-columns: 1fr; } .auth-art { display: none; }
}
@media (max-width: 520px) { .stats, .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: auto; } .toolbar .input-ico { min-width: 0; flex: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
