/* =====================================================================
   AVALON ADMIN — control panel styling (independent of site skins)
   ===================================================================== */
:root {
  --a-bg: #f4f6fb;
  --a-panel: #ffffff;
  --a-panel-2: #f9fafd;
  --a-ink: #131629;
  --a-soft: #545a76;
  --a-faint: #8b91ab;
  --a-line: #e3e7f1;
  --a-line-2: #cfd5e5;
  --a-accent: #3d5afe;
  --a-accent-wash: #eef1ff;
  --a-side: #101426;
  --a-side-ink: #c5cbe0;
  --ok: #12996a; --ok-wash: #e6f7f0;
  --warn: #c47b06; --warn-wash: #fdf4e3;
  --bad: #d92b4b; --bad-wash: #fdedf0;
  --r: 11px; --r-sm: 8px;
  --shadow: 0 2px 4px rgba(19,22,41,.04), 0 12px 32px -12px rgba(19,22,41,.14);
}
@media (prefers-color-scheme: dark) {
  :root[data-admin-theme="auto"] {
    --a-bg: #0d1018; --a-panel: #151a26; --a-panel-2: #1b2130;
    --a-ink: #e8ecf7; --a-soft: #9aa3bd; --a-faint: #6d7691;
    --a-line: #232a3a; --a-line-2: #303950; --a-accent-wash: #1a2140;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--a-bg); color: var(--a-ink);
  font: 15px/1.6 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.22; letter-spacing: -.018em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
:focus-visible { outline: 2px solid var(--a-accent); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
@media (max-width: 980px) { .shell { grid-template-columns: 1fr; } }

.side {
  background: var(--a-side); color: var(--a-side-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
@media (max-width: 980px) {
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 300;
          transform: translateX(-100%); transition: transform .3s cubic-bezier(.2,.8,.2,1); }
  body.side-open .side { transform: none; }
  body.side-open::after { content: ""; position: fixed; inset: 0; background: rgba(6,8,18,.55); z-index: 250; }
}
.side__brand { padding: 1.3rem 1.3rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.07); display: flex; align-items: center; gap: .7rem; }
.side__brand b { color: #fff; font-size: .95rem; letter-spacing: .06em; }
.side__brand span { display: block; font-size: .62rem; letter-spacing: .2em; text-transform: uppercase; opacity: .5; }
.side nav { padding: .9rem .7rem; flex: 1; }
.side__label { font-size: .62rem; letter-spacing: .2em; text-transform: uppercase; opacity: .38; padding: 1rem .7rem .45rem; }
.side a.nav-i {
  display: flex; align-items: center; gap: .72rem; padding: .62rem .75rem; border-radius: 9px;
  font-size: .9rem; margin-bottom: 1px; transition: background .18s, color .18s;
}
.side a.nav-i:hover { background: rgba(255,255,255,.06); color: #fff; }
.side a.nav-i.is-on { background: var(--a-accent); color: #fff; }
.side a.nav-i .ico { flex: none; opacity: .85; }
.side a.nav-i .pill { margin-left: auto; background: rgba(255,255,255,.14); font-size: .68rem; padding: .1rem .42rem; border-radius: 20px; }
.side a.nav-i.is-on .pill { background: rgba(255,255,255,.25); }
.side__foot { padding: 1rem; border-top: 1px solid rgba(255,255,255,.07); font-size: .8rem; }
.side__foot a { display: flex; align-items: center; gap: .5rem; opacity: .7; padding: .35rem 0; }
.side__foot a:hover { opacity: 1; color: #fff; }

/* -------------------------------------------------------------- main */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar2 {
  background: var(--a-panel); border-bottom: 1px solid var(--a-line);
  padding: 0 1.4rem; height: 62px; display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 100;
}
.topbar2 h1 { margin: 0; font-size: 1.06rem; }
.topbar2 .spacer { margin-left: auto; }
.hamb { display: none; width: 38px; height: 38px; border: 1px solid var(--a-line-2); border-radius: 9px; align-items: center; justify-content: center; }
@media (max-width: 980px) { .hamb { display: inline-flex; } }
.whoami { display: flex; align-items: center; gap: .6rem; font-size: .86rem; }
.whoami i { width: 32px; height: 32px; border-radius: 50%; background: var(--a-accent); color: #fff; display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: .8rem; }
.content { padding: 1.5rem 1.4rem 4rem; flex: 1; }
@media (max-width: 640px) { .content { padding: 1.1rem .9rem 3rem; } }

/* ------------------------------------------------------------ panels */
.panel { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 1.3rem; }
.panel__head { padding: 1.05rem 1.25rem; border-bottom: 1px solid var(--a-line); display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.panel__head h2 { margin: 0; font-size: 1rem; }
.panel__head .spacer { margin-left: auto; }
.panel__body { padding: 1.25rem; }
.panel__foot { padding: 1rem 1.25rem; border-top: 1px solid var(--a-line); background: var(--a-panel-2); border-radius: 0 0 var(--r) var(--r); display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

.grid { display: grid; gap: 1.3rem; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%,320px), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%,240px), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(100%,190px), 1fr)); }
.split-form { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 1.3rem; align-items: start; }
@media (max-width: 1100px) { .split-form { grid-template-columns: 1fr; } }
.sticky { position: sticky; top: 78px; }

/* ------------------------------------------------------------- stats */
.kpi { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--r); padding: 1.15rem 1.25rem; box-shadow: var(--shadow); }
.kpi span { font-size: .74rem; letter-spacing: .13em; text-transform: uppercase; color: var(--a-faint); display: block; }
.kpi b { font-size: 2rem; letter-spacing: -.03em; display: block; margin: .3rem 0 .1rem; }
.kpi small { font-size: .8rem; color: var(--a-soft); }
.kpi--accent { background: linear-gradient(140deg, var(--a-accent), #2438c9); border-color: transparent; color: #fff; }
.kpi--accent span, .kpi--accent small { color: rgba(255,255,255,.72); }

/* ------------------------------------------------------------- table */
.tablewrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tbl th, table.tbl td { padding: .78rem .9rem; text-align: left; border-bottom: 1px solid var(--a-line); vertical-align: middle; }
table.tbl th { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--a-faint); font-weight: 600; background: var(--a-panel-2); white-space: nowrap; }
table.tbl tbody tr:hover { background: var(--a-panel-2); }
table.tbl td.actions { text-align: right; white-space: nowrap; }
table.tbl img.thumb { width: 54px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--a-line); }
.drag-handle { cursor: grab; color: var(--a-faint); }

/* ------------------------------------------------------------ badges */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 600; padding: .22rem .58rem; border-radius: 20px; }
.badge--ok { background: var(--ok-wash); color: var(--ok); }
.badge--warn { background: var(--warn-wash); color: var(--warn); }
.badge--bad { background: var(--bad-wash); color: var(--bad); }
.badge--mute { background: var(--a-panel-2); color: var(--a-faint); border: 1px solid var(--a-line); }
.badge--accent { background: var(--a-accent-wash); color: var(--a-accent); }

/* ------------------------------------------------------------ button */
.b { display: inline-flex; align-items: center; gap: .45rem; padding: .58rem 1rem; border-radius: var(--r-sm);
     font-size: .875rem; font-weight: 600; border: 1px solid transparent; transition: all .18s; white-space: nowrap; }
.b--pri { background: var(--a-accent); color: #fff; }
.b--pri:hover { background: #2f49e0; }
.b--out { border-color: var(--a-line-2); color: var(--a-ink); background: var(--a-panel); }
.b--out:hover { border-color: var(--a-accent); color: var(--a-accent); }
.b--bad { background: var(--bad-wash); color: var(--bad); border-color: transparent; }
.b--bad:hover { background: var(--bad); color: #fff; }
.b--sm { padding: .38rem .7rem; font-size: .8rem; }
.b--icon { padding: .42rem; }
.b--block { width: 100%; justify-content: center; }
.b[disabled] { opacity: .5; pointer-events: none; }

/* ------------------------------------------------------------- forms */
.f { margin-bottom: 1.05rem; }
.f > label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .35rem; }
.f > label .req { color: var(--bad); }
.f small { display: block; font-size: .78rem; color: var(--a-faint); margin-top: .3rem; }
.i, .s, .t {
  width: 100%; padding: .62rem .8rem; border: 1px solid var(--a-line-2); border-radius: var(--r-sm);
  background: var(--a-panel); color: var(--a-ink); transition: border-color .18s, box-shadow .18s;
}
.i:focus, .s:focus, .t:focus { outline: none; border-color: var(--a-accent); box-shadow: 0 0 0 3px var(--a-accent-wash); }
.t { min-height: 130px; resize: vertical; line-height: 1.6; font-family: inherit; }
.t--code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: .85rem; }
.s { appearance: none; padding-right: 2.2rem;
     background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%23545a76' stroke-width='1.8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
     background-repeat: no-repeat; background-position: right .8rem center; background-size: 11px; }
.r2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.r3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 0 1rem; }
@media (max-width: 700px) { .r2, .r3 { grid-template-columns: 1fr; } }
.ck { display: flex; gap: .55rem; align-items: flex-start; font-size: .88rem; margin-bottom: .7rem; }
.ck input { margin-top: .25rem; width: 16px; height: 16px; accent-color: var(--a-accent); }
.hint { background: var(--a-accent-wash); border: 1px solid color-mix(in srgb, var(--a-accent) 25%, transparent); border-radius: var(--r-sm); padding: .8rem 1rem; font-size: .85rem; color: var(--a-soft); margin-bottom: 1rem; }

/* ------------------------------------------------------------ alerts */
.al { display: flex; gap: .7rem; padding: .85rem 1rem; border-radius: var(--r-sm); font-size: .9rem; margin-bottom: 1.1rem; border: 1px solid; align-items: flex-start; }
.al--ok { background: var(--ok-wash); border-color: var(--ok); color: #0b6a48; }
.al--bad { background: var(--bad-wash); border-color: var(--bad); color: #97142d; }
.al--warn { background: var(--warn-wash); border-color: var(--warn); color: #7d5104; }
.al--info { background: var(--a-accent-wash); border-color: var(--a-accent); color: #2438c9; }

/* -------------------------------------------------------- media grid */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px,1fr)); gap: .8rem; }
.mtile { position: relative; border: 1px solid var(--a-line); border-radius: var(--r-sm); overflow: hidden; background: var(--a-panel-2); aspect-ratio: 4/3; }
.mtile img, .mtile video { width: 100%; height: 100%; object-fit: cover; }
.mtile__bar { position: absolute; inset: auto 0 0 0; padding: .4rem .5rem; background: linear-gradient(to top, rgba(8,10,20,.88), transparent); color: #fff; font-size: .7rem; display: flex; gap: .3rem; align-items: center; justify-content: space-between; }
.mtile__pick { position: absolute; inset: 0; }
.mtile.is-picked { outline: 3px solid var(--a-accent); outline-offset: -3px; }
.mtile__x { position: absolute; top: .35rem; right: .35rem; width: 26px; height: 26px; border-radius: 6px; background: rgba(8,10,20,.6); color: #fff; display: grid; place-items: center; }
.mtile__x:hover { background: var(--bad); }

/* -------------------------------------------------------- media pick */
.pickfield { display: flex; gap: .6rem; align-items: flex-start; }
.pickfield__prev { width: 92px; height: 68px; border: 1px dashed var(--a-line-2); border-radius: var(--r-sm); overflow: hidden; flex: none; display: grid; place-items: center; background: var(--a-panel-2); color: var(--a-faint); }
.pickfield__prev img { width: 100%; height: 100%; object-fit: cover; }
.pickfield__ctl { flex: 1; display: grid; gap: .4rem; }

/* --------------------------------------------------------- skin card */
.skincard { border: 2px solid var(--a-line); border-radius: var(--r); overflow: hidden; background: var(--a-panel); transition: border-color .2s, transform .25s; }
.skincard:hover { transform: translateY(-3px); }
.skincard.is-on { border-color: var(--a-accent); }
.skincard__prev { height: 130px; display: flex; }
.skincard__prev i { flex: 1; }
.skincard__body { padding: 1rem 1.1rem 1.2rem; }
.skincard__body h3 { margin: 0 0 .3rem; font-size: 1rem; }
.skincard__body p { margin: 0 0 .9rem; font-size: .84rem; color: var(--a-soft); }

/* ------------------------------------------------------ template pick */
.tplgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%,205px),1fr)); gap: .8rem; }
.tpl { border: 2px solid var(--a-line); border-radius: var(--r-sm); padding: .9rem; cursor: pointer; transition: border-color .18s, background .18s; }
.tpl:hover { border-color: var(--a-line-2); }
.tpl input { position: absolute; opacity: 0; }
.tpl.is-on { border-color: var(--a-accent); background: var(--a-accent-wash); }
.tpl b { display: block; font-size: .88rem; margin-bottom: .2rem; }
.tpl span { font-size: .78rem; color: var(--a-soft); line-height: 1.45; display: block; }
.tpl__wire { height: 58px; border-radius: 5px; background: var(--a-panel-2); border: 1px solid var(--a-line); margin-bottom: .6rem; padding: 5px; display: grid; gap: 3px; }
.tpl__wire i { background: var(--a-line-2); border-radius: 2px; display: block; }

/* ------------------------------------------------------------- login */
.loginwrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: radial-gradient(900px 520px at 82% -8%, rgba(61,90,254,.16), transparent 60%), var(--a-side); }
.loginbox { width: 100%; max-width: 405px; background: var(--a-panel); border-radius: 18px; padding: 2.1rem; box-shadow: 0 30px 80px -24px rgba(0,0,0,.55); }
.loginbox h1 { font-size: 1.35rem; margin-bottom: .2rem; }
.loginbox p.sub { color: var(--a-soft); font-size: .9rem; margin: 0 0 1.5rem; }

/* -------------------------------------------------------------- misc */
.muted { color: var(--a-faint); }
.small { font-size: .84rem; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: .84rem; }
.right { text-align: right; } .center { text-align: center; }
.mt0{margin-top:0}.mb0{margin-bottom:0}.mt1{margin-top:1rem}.mt2{margin-top:1.6rem}
.flexrow { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.empty2 { padding: 3rem 1rem; text-align: center; color: var(--a-faint); }
.pager2 { display: flex; gap: .35rem; justify-content: center; padding: 1rem; flex-wrap: wrap; }
.pager2 a, .pager2 span { min-width: 36px; height: 36px; display: grid; place-items: center; padding: 0 .7rem; border: 1px solid var(--a-line); border-radius: var(--r-sm); font-size: .85rem; }
.pager2 .is-on { background: var(--a-accent); color: #fff; border-color: var(--a-accent); }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--a-line); margin-bottom: 1.3rem; overflow-x: auto; }
.tabs a { padding: .7rem 1rem; font-size: .9rem; font-weight: 500; color: var(--a-soft); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.is-on { color: var(--a-accent); border-bottom-color: var(--a-accent); }
.chip2 { display: inline-block; font-size: .74rem; padding: .18rem .5rem; border-radius: 5px; background: var(--a-panel-2); border: 1px solid var(--a-line); color: var(--a-soft); }
