/* ============================================================
   Precious CMS — admin panel
   ============================================================ */
:root{
  --primary:#4A2C6F; --accent:#C9A227;
  --ink:#1c1a22; --paper:#f4f2f8; --card:#fff;
  --line:#e5e1ee; --muted:#6d6880;
  --primary-deep:color-mix(in srgb,var(--primary) 78%,#000);
  --ok:#1a6b39; --ok-bg:#e7f6ec; --err:#a62828; --err-bg:#fdeaea;
  --radius:14px; --radius-sm:9px;
  --body:"Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
  --shadow:0 8px 26px -14px rgba(40,20,70,.4);
}
*,*::before,*::after{box-sizing:border-box}
body.admin,body.admin-login{margin:0;font-family:var(--body);background:var(--paper);color:var(--ink);line-height:1.55}
a{color:var(--primary)}
h1,h2,h3{margin:0 0 .4em;font-weight:600;line-height:1.2}
small{color:var(--muted);font-weight:400;font-size:.8rem}
code{background:#f0edf7;padding:.1rem .35rem;border-radius:5px;font-size:.85em}

/* ---------- Shell ---------- */
.a-shell{display:flex;min-height:100vh}
.a-sidebar{width:250px;flex-shrink:0;background:var(--primary-deep);color:#fff;display:flex;flex-direction:column;position:sticky;top:0;height:100vh}
.a-brand{display:flex;align-items:center;gap:.7rem;padding:1.3rem 1.2rem;border-bottom:1px solid rgba(255,255,255,.12)}
.a-brand span{display:flex;flex-direction:column;font-weight:600;line-height:1.1}
.a-brand small{color:rgba(255,255,255,.6);font-weight:400;font-size:.72rem}
.a-logo{width:38px;height:38px;border-radius:10px;background:var(--accent);color:#2a2000;
  display:grid;place-items:center;font-weight:700;font-size:1.2rem;flex-shrink:0}
.a-menu{display:flex;flex-direction:column;padding:.8rem .6rem;gap:2px;flex:1}
.a-menu a{display:flex;align-items:center;gap:.7rem;color:rgba(255,255,255,.82);padding:.7rem .8rem;
  border-radius:9px;font-weight:500;font-size:.95rem;text-decoration:none}
.a-menu a:hover{background:rgba(255,255,255,.08);color:#fff}
.a-menu a.is-active{background:var(--accent);color:#2a2000}
.a-ico{width:20px;text-align:center;opacity:.9}
.a-side-foot{padding:.8rem .6rem 1.2rem;display:flex;flex-direction:column;gap:2px;border-top:1px solid rgba(255,255,255,.12)}
.a-side-foot a{color:rgba(255,255,255,.75);padding:.55rem .8rem;border-radius:8px;font-size:.9rem;text-decoration:none}
.a-side-foot a:hover{background:rgba(255,255,255,.08);color:#fff}

.a-main{flex:1;min-width:0;display:flex;flex-direction:column}
.a-topbar{display:flex;justify-content:space-between;align-items:center;gap:1rem;
  padding:1.3rem clamp(1rem,3vw,2.2rem);background:var(--card);border-bottom:1px solid var(--line)}
.a-topbar h1{font-size:1.4rem;margin:0}
.a-topbar p{margin:.2rem 0 0;color:var(--muted);font-size:.9rem}
.a-user{display:flex;align-items:center;gap:.6rem;font-weight:500;font-size:.9rem}
.a-avatar{width:36px;height:36px;border-radius:50%;background:var(--primary);color:#fff;display:grid;place-items:center;font-weight:600}
.a-content{padding:clamp(1rem,3vw,2.2rem);max-width:1100px;width:100%}

/* ---------- Alerts ---------- */
.a-alert{padding:.85rem 1.1rem;border-radius:var(--radius-sm);margin-bottom:1.2rem;font-weight:500}
.a-ok{background:var(--ok-bg);color:var(--ok);border:1px solid #b6e0c4}
.a-err{background:var(--err-bg);color:var(--err);border:1px solid #f3c2c2}

/* ---------- Cards / stats ---------- */
.stat-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:1rem;margin-bottom:1.4rem}
.stat-card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:1.4rem;
  display:flex;flex-direction:column;gap:.2rem;color:var(--ink);transition:transform .15s,box-shadow .2s}
.stat-card:hover{transform:translateY(-3px);box-shadow:var(--shadow)}
.stat-num{font-size:2.2rem;font-weight:700;color:var(--primary)}
.stat-label{color:var(--muted);font-size:.9rem}

.panel{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);
  padding:clamp(1.1rem,2.5vw,1.7rem);margin-bottom:1.3rem}
.panel h2{font-size:1.15rem;margin-bottom:.9rem}
.quick-actions{display:flex;flex-wrap:wrap;gap:.6rem;margin-bottom:.8rem}
.muted{color:var(--muted)}

/* ---------- Forms ---------- */
.a-form label{display:flex;flex-direction:column;gap:.35rem;font-weight:600;font-size:.9rem;margin-bottom:1rem}
.a-form input[type=text],.a-form input[type=email],.a-form input[type=password],
.a-form input[type=number],.a-form textarea,.a-form select{
  font:inherit;font-weight:400;padding:.65rem .75rem;border:1px solid var(--line);
  border-radius:var(--radius-sm);background:#fdfcff;color:var(--ink);width:100%}
.a-form textarea{resize:vertical}
.a-form textarea.mono{font-family:ui-monospace,"SFMono-Regular",Menlo,Consolas,monospace;font-size:.9rem;line-height:1.5}
.a-form input:focus,.a-form textarea:focus,.a-form select:focus{outline:2px solid var(--primary);border-color:var(--primary)}
.a-form input[type=file]{font-size:.85rem}
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:0 1.1rem}
.grid-3{display:grid;grid-template-columns:repeat(3,1fr);gap:0 1.1rem}
.grid-4{display:grid;grid-template-columns:repeat(4,1fr);gap:1rem}
.check{flex-direction:row!important;align-items:center;gap:.6rem!important;font-weight:500}
.check input{width:auto}
.form-actions{display:flex;gap:.7rem;flex-wrap:wrap;margin-top:.4rem}
.color-field .color-row{display:flex;gap:.4rem;align-items:center}
.color-row input[type=color]{width:44px;height:40px;padding:0;border:1px solid var(--line);border-radius:8px;background:none;cursor:pointer}
.color-hex{max-width:120px}
.img-preview{display:inline-block;padding:.4rem;background:#f0edf7;border:1px solid var(--line);border-radius:9px;margin-bottom:.3rem}
.img-preview img{max-height:60px;width:auto;border-radius:4px}
.img-preview.small img{max-height:36px}
.img-preview.wide img{max-height:120px}

/* ---------- Buttons ---------- */
.a-btn{display:inline-flex;align-items:center;gap:.4rem;font:inherit;font-weight:600;font-size:.9rem;
  padding:.6rem 1.1rem;border-radius:9px;border:1px solid transparent;cursor:pointer;transition:.15s;text-decoration:none;line-height:1}
.a-btn-sm{padding:.4rem .7rem;font-size:.82rem}
.a-btn-primary{background:var(--primary);color:#fff}
.a-btn-primary:hover{background:var(--primary-deep)}
.a-btn-ghost{background:#fff;border-color:var(--line);color:var(--ink)}
.a-btn-ghost:hover{border-color:var(--primary);color:var(--primary)}
.a-btn-danger{background:#fff;border-color:#f0cccc;color:var(--err)}
.a-btn-danger:hover{background:var(--err);color:#fff;border-color:var(--err)}

/* ---------- Tables ---------- */
.toolbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:1rem;gap:1rem}
.a-table-wrap{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);overflow:auto}
.a-table{width:100%;border-collapse:collapse;font-size:.92rem}
.a-table th,.a-table td{padding:.8rem 1rem;text-align:left;border-bottom:1px solid var(--line);vertical-align:middle}
.a-table th{background:#faf9fd;font-size:.75rem;text-transform:uppercase;letter-spacing:.08em;color:var(--muted)}
.a-table tr:last-child td{border-bottom:0}
.ta-r{text-align:right}
.thumb-cell{width:70px}
.thumb{display:block;width:54px;height:36px;border-radius:6px;background-size:cover;background-position:center;background-color:#eee}
.pill{display:inline-block;padding:.2rem .6rem;border-radius:999px;font-size:.75rem;font-weight:600}
.pill-on{background:var(--ok-bg);color:var(--ok)}
.pill-off{background:#eee;color:#777}
.empty{background:var(--card);border:1px dashed var(--line);border-radius:var(--radius);padding:2.4rem;text-align:center;color:var(--muted)}

/* ---------- Mobile nav toggle ---------- */
.a-nav-toggle{display:none;position:fixed;top:.8rem;left:.8rem;z-index:60;width:44px;height:44px;
  border:0;border-radius:10px;background:var(--primary);color:#fff;font-size:1.2rem;cursor:pointer}

/* ---------- Login ---------- */
.admin-login{display:grid;place-items:center;min-height:100vh;
  background:linear-gradient(135deg,var(--primary),var(--primary-deep));padding:1.2rem}
.login-card{background:#fff;border-radius:18px;padding:2.2rem;width:min(410px,100%);box-shadow:0 30px 60px -20px rgba(0,0,0,.5)}
.login-brand{text-align:center;margin-bottom:1.4rem}
.login-brand .a-logo{margin:0 auto .8rem}
.login-brand h1{font-size:1.4rem;margin:0}
.login-brand p{color:var(--muted);margin:.2rem 0 0;font-size:.9rem}
.login-card .a-btn-primary{width:100%;justify-content:center;padding:.75rem;margin-top:.3rem}
.login-hint{text-align:center;font-size:.8rem;color:var(--muted);margin:1.1rem 0 0}

/* ---------- Responsive ---------- */
@media (max-width:860px){
  .grid-2,.grid-3{grid-template-columns:1fr}
  .grid-4{grid-template-columns:1fr 1fr}
  .a-sidebar{position:fixed;left:0;top:0;transform:translateX(-100%);transition:transform .25s ease;z-index:55}
  .a-sidebar.open{transform:none}
  .a-nav-toggle{display:block}
  .a-topbar{padding-left:4rem}
}
@media (max-width:480px){
  .grid-4{grid-template-columns:1fr}
  .a-user span:last-child{display:none}
}
.a-brand-img{width:42px;height:42px;object-fit:contain;background:#fff;border-radius:10px;padding:3px}
.rich-editor-wrap{border:1px solid var(--line);border-radius:10px;overflow:hidden;background:#fff;margin-top:.35rem}.rich-toolbar{display:flex;flex-wrap:wrap;gap:4px;padding:7px;background:#f8f8fb;border-bottom:1px solid var(--line)}.rich-toolbar button{border:1px solid var(--line);background:#fff;border-radius:6px;padding:.35rem .55rem;cursor:pointer;font-weight:600}.rich-editor{min-height:260px;padding:1rem;outline:none;line-height:1.65}.rich-editor:focus{box-shadow:inset 0 0 0 2px color-mix(in srgb,var(--primary) 20%,transparent)}
.copy-link{width:min(420px,100%);font-size:.78rem;padding:.4rem .5rem;border:1px solid var(--line);border-radius:7px;background:#fafafa}

/* Team patch */
.team-avatar-placeholder{width:54px;height:54px;border-radius:50%;background:var(--primary);color:#fff;display:inline-grid;place-items:center;font-weight:700;font-size:1.15rem}

/* V2.2 Typography Manager */
.typography-panel>.panel-note{margin-top:-.35rem;color:#746d82}.type-card{border:1px solid #e7e2eb;background:#fbfafc;border-radius:14px;padding:1.1rem 1.15rem;margin:1rem 0}.type-card h3{margin:0 0 .9rem;font-size:1rem;color:#39204f}.type-card label small{display:inline-block;margin-left:.4rem;color:#8a8292;font-weight:600}.type-card input[type=number]{max-width:130px}

/* ============================================================
   V2.3 Advanced Rich Text Editor
   ============================================================ */
.rich-editor-v23{border:1px solid #d8dce5;border-radius:12px;overflow:hidden;background:#fff;margin-top:.45rem;box-shadow:0 1px 2px rgba(20,31,50,.03)}
.rich-editor-v23 .rich-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:6px;padding:12px;background:#f5f8fb;border-bottom:1px solid #dfe4eb;position:sticky;top:0;z-index:2}
.rich-editor-v23 .rich-select{height:42px;min-width:112px;padding:0 34px 0 12px!important;border:1px solid #cfd7e2!important;border-radius:8px!important;background:#fff;color:#16263a;font:600 14px/1 var(--body)!important;cursor:pointer;width:auto!important}
.rich-editor-v23 .rich-format{min-width:150px}.rich-editor-v23 .rich-font{min-width:220px}.rich-editor-v23 .rich-size{min-width:120px}
.rich-editor-v23 .rich-tool{width:42px;height:42px;display:inline-grid;place-items:center;border:0;background:transparent;color:#17324d;border-radius:7px;padding:0;font:600 20px/1 var(--body);cursor:pointer;transition:.15s}
.rich-editor-v23 .rich-tool:hover,.rich-editor-v23 .rich-tool:focus{background:#e8eef5;color:var(--primary);outline:none}
.rich-editor-v23 .rich-tool.rich-align,.rich-editor-v23 .rich-tool.rich-list{font-size:21px}.rich-editor-v23 .rich-right{transform:scaleX(-1)}
.rich-editor-v23 .rich-source-toggle{width:48px;font-size:14px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.rich-editor-v23 .rich-divider{width:1px;height:34px;background:#d8dfe7;margin:0 2px}
.rich-editor-v23 .rich-color-tool{position:relative;width:42px;height:42px;display:grid!important;place-items:center;margin:0!important;cursor:pointer;border-radius:7px;font-size:18px}
.rich-editor-v23 .rich-color-tool:hover{background:#e8eef5}.rich-editor-v23 .rich-color-tool input[type=color]{position:absolute;inset:auto 6px 3px;width:30px;height:5px;border:0;padding:0;background:transparent;cursor:pointer}
.rich-editor-v23 .rich-editor{min-height:300px;padding:26px 28px;background:#fff;color:#10243b;font-size:17px;line-height:1.7;outline:none;overflow:auto}
.rich-editor-v23 .rich-editor:focus{box-shadow:inset 0 0 0 2px color-mix(in srgb,var(--primary) 15%,transparent)}
.rich-editor-v23 .rich-editor p:first-child{margin-top:0}.rich-editor-v23 .rich-editor img{max-width:100%;height:auto}.rich-editor-v23 .rich-editor blockquote{border-left:4px solid var(--primary);margin:1rem 0;padding:.5rem 1rem;background:#f8f6fb;color:#514a5c}
.rich-editor-v23 .rich-editor table,.rich-editor-v23 .rich-editor .content-table{width:100%;border-collapse:collapse;margin:1rem 0}.rich-editor-v23 .rich-editor td,.rich-editor-v23 .rich-editor th{border:1px solid #cfd7e2;padding:.65rem;min-width:70px}
.rich-editor-v23 .rich-source{display:block;width:100%;min-height:300px;border:0!important;border-radius:0!important;padding:20px 22px!important;background:#101823!important;color:#eaf1f8!important;font:14px/1.65 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace!important;resize:vertical;outline:none!important}
@media(max-width:760px){.rich-editor-v23 .rich-toolbar{gap:4px;padding:8px}.rich-editor-v23 .rich-select{min-width:calc(33.333% - 4px);max-width:100%;flex:1}.rich-editor-v23 .rich-font{min-width:46%}.rich-editor-v23 .rich-editor{padding:18px 16px;min-height:250px}.rich-editor-v23 .rich-divider{display:none}}
