/* ===== PURITY LABS ADMIN ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #2E7D32;
  --primary-dark: #256828;
  --primary-soft: #E8F3E9;
  --ink: #181818;
  --text: #4a5560;
  --muted: #8a94a0;
  --line: #E7EBE9;
  --bg: #F4F6F5;
  --card: #ffffff;
  --danger: #D64545;
  --warn: #E8A33D;
  --ok: #2E7D32;
  --sidebar: #10241a;
  --sidebar-soft: #173325;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,36,26,.06), 0 4px 16px rgba(16,36,26,.05);
}
html { font-size: 14px; }
body { font-family: 'Outfit', system-ui, sans-serif; color: var(--text); background: var(--bg); }
img { max-width: 100%; display: block; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }

input, select, textarea {
  font-family: inherit; font-size: .95rem; color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
  background: #fff; width: 100%; outline: none; transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(46,125,50,.12); }
label { display: block; font-size: .8rem; font-weight: 600; color: var(--text); margin-bottom: 6px; letter-spacing: .2px; }
::placeholder { color: #b6bec7; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 16px; border-radius: 9px; border: none; font-weight: 600; font-size: .9rem;
  transition: all .2s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #bd3a3a; }
.btn-sm { padding: 6px 11px; font-size: .82rem; border-radius: 7px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--text); display: inline-flex; align-items: center; justify-content: center; transition: all .2s; }
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.notif-dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.lb-text { font-weight: 800; color: #fff; letter-spacing: -.5px; }
.lb-text span { color: #66bb6a; }

/* ===== LOGIN ===== */
.login-gate { position: fixed; inset: 0; z-index: 1000; background: radial-gradient(1200px 600px at 20% -10%, #1b4130, #0d1f16 60%); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-gate.hidden { display: none; }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .lb-text { color: var(--ink); font-size: 1.6rem; }
.login-brand .lb-text span { color: var(--primary); }
.login-brand small { display: block; color: var(--muted); font-size: .78rem; letter-spacing: 3px; text-transform: uppercase; margin-top: 4px; }
.login-title { font-size: 1.35rem; color: var(--ink); margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: .9rem; margin-bottom: 24px; }
.login-error { color: var(--danger); font-size: .85rem; min-height: 18px; margin-bottom: 8px; }
.login-hint { margin-top: 18px; text-align: center; font-size: .8rem; color: var(--muted); }
.login-hint code { background: var(--primary-soft); color: var(--primary-dark); padding: 2px 8px; border-radius: 6px; font-size: .8rem; }
.hidden { display: none !important; }
.login-hint { text-align: center; font-size: .8rem; color: var(--muted); margin-top: 14px; }

/* ===== LAYOUT ===== */
.admin-wrap { display: none; min-height: 100vh; }
.admin-wrap.ready { display: flex; }
.sidebar { width: 258px; min-width: 258px; background: var(--sidebar); color: #cfd8d2; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-brand { padding: 24px 22px 16px; }
.side-brand .lb-text { font-size: 1.4rem; }
.side-brand-sub { font-size: .72rem; color: #7fa08d; letter-spacing: 2.5px; text-transform: uppercase; }
.side-profile { display: flex; align-items: center; gap: 12px; padding: 14px 20px; margin: 0 12px 14px; background: var(--sidebar-soft); border-radius: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1rem; }
.side-profile-meta { display: flex; flex-direction: column; }
.side-profile-meta b { color: #fff; font-size: .92rem; }
.side-profile-meta span { font-size: .74rem; color: #7fa08d; }
.side-nav { flex: 1; padding: 0 12px; }
.side-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; border-radius: 10px; color: #b9cbbf; background: none; border: none; font-size: .92rem; font-weight: 500; margin-bottom: 2px; transition: all .18s; text-align: left; }
.side-item i { width: 20px; text-align: center; font-size: .95rem; }
.side-item:hover { background: var(--sidebar-soft); color: #fff; }
.side-item.active { background: var(--primary); color: #fff; box-shadow: 0 6px 18px rgba(46,125,50,.35); }
.side-item .side-badge { margin-left: auto; font-size: .72rem; background: rgba(255,255,255,.14); padding: 1px 8px; border-radius: 20px; }
.side-item.active .side-badge { background: rgba(255,255,255,.22); }
.side-footer { padding: 14px 12px; border-top: 1px solid rgba(255,255,255,.07); display: flex; flex-direction: column; gap: 2px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #8fb09b; font-size: .85rem; background: none; border: none; width: 100%; text-align: left; }
.side-link:hover { color: #fff; background: var(--sidebar-soft); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 26px; display: flex; align-items: center; gap: 18px; position: sticky; top: 0; z-index: 50; }
.hamburger { display: none; width: 40px; height: 40px; background: #fff; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); }
.topbar-title h1 { font-size: 1.15rem; color: var(--ink); font-weight: 700; }
.topbar-title span { font-size: .78rem; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.global-search { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; width: 300px; }
.global-search i { color: var(--muted); }
.global-search input { border: none; background: none; padding: 9px 0; }
.content { padding: 26px; flex: 1; }
.panel { display: none; animation: fadeUp .25s ease; }
.panel.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== CARDS & GRID ===== */
.grid { display: grid; gap: 18px; }
.grid.stat-grid { grid-template-columns: repeat(4, 1fr); }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.four { grid-template-columns: repeat(4, 1fr); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-head h3 { font-size: 1rem; color: var(--ink); font-weight: 700; }
.card-head p { font-size: .82rem; color: var(--muted); }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: flex; align-items: center; gap: 16px; }
.stat-icon { width: 52px; height: 52px; border-radius: 13px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.stat-icon.green { background: var(--primary-soft); color: var(--primary); }
.stat-icon.blue { background: #E7F0FB; color: #2C6CB2; }
.stat-icon.amber { background: #FCF0DE; color: #C07E1F; }
.stat-icon.red { background: #FBE7E7; color: var(--danger); }
.stat-info b { font-size: 1.45rem; color: var(--ink); font-weight: 800; display: block; line-height: 1.2; }
.stat-info span { font-size: .8rem; color: var(--muted); }
.stat-info .trend { font-size: .74rem; font-weight: 600; }
.trend.up { color: var(--ok); }
.trend.down { color: var(--danger); }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 640px; }
.data th { text-align: left; padding: 12px 14px; background: #FBFCFC; color: var(--muted); font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data td { padding: 12px 14px; border-bottom: 1px solid #F1F4F2; vertical-align: middle; }
.data tr:last-child td { border-bottom: none; }
.data tbody tr:hover { background: #FAFCFA; }
.td-prod { display: flex; align-items: center; gap: 12px; }
.td-prod img { width: 42px; height: 42px; object-fit: cover; border-radius: 9px; background: #F2F5F3; }
.td-prod b { color: var(--ink); display: block; font-size: .9rem; }
.td-prod small { color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: .74rem; font-weight: 700; }
.badge.ok { background: var(--primary-soft); color: var(--primary-dark); }
.badge.warn { background: #FCF0DE; color: #C07E1F; }
.badge.red { background: #FBE7E7; color: var(--danger); }
.badge.muted { background: #EEF1F0; color: var(--muted); }
.badge.blue { background: #E7F0FB; color: #2C6CB2; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-action { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; font-size: .78rem; transition: all .15s; }
.icon-action:hover { color: var(--primary); border-color: var(--primary); }
.icon-action.danger:hover { color: var(--danger); border-color: var(--danger); }
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty i { font-size: 2rem; margin-bottom: 10px; color: #c9d3cd; }
.empty p { font-size: .9rem; }

/* ===== TOOLBAR ===== */
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { padding: 8px 14px; font-size: .83rem; font-weight: 600; color: var(--muted); background: #fff; border: none; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--primary-soft); color: var(--primary-dark); }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(13,31,22,.5); z-index: 200; display: none; align-items: flex-start; justify-content: center; padding: 40px 20px; overflow-y: auto; backdrop-filter: blur(2px); }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 14px; max-width: 620px; width: 100%; box-shadow: 0 24px 60px rgba(0,0,0,.25); animation: fadeUp .2s ease; }
.modal.modal-sm { max-width: 400px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 1.02rem; color: var(--ink); }
.modal-close { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--muted); }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.modal-foot.right { justify-content: flex-end; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: flex; flex-direction: column; }
.form-field.full { grid-column: 1 / -1; }
.form-field .hint { font-size: .74rem; color: var(--muted); margin-top: 4px; }
textarea { min-height: 90px; resize: vertical; }

/* ===== TOASTS ===== */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 400; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #fff; border-left: 4px solid var(--ok); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.15); padding: 12px 16px; min-width: 240px; display: flex; gap: 10px; align-items: center; font-size: .88rem; color: var(--ink); animation: slideIn .25s ease; }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast i { color: var(--ok); }
.toast.error i { color: var(--danger); }
.toast.warn i { color: var(--warn); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== CONFIRM ===== */
.confirm-icon { width: 54px; height: 54px; border-radius: 50%; background: #FBE7E7; color: var(--danger); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; margin: 0 auto 14px; }
#confirmTitle { text-align: center; color: var(--ink); margin-bottom: 6px; }
#confirmText { text-align: center; color: var(--muted); font-size: .88rem; }

/* ===== CHART (pure CSS) ===== */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding: 8px 4px 0; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart-bar { width: 100%; max-width: 34px; background: linear-gradient(180deg, #43a047, #2E7D32); border-radius: 5px 5px 0 0; min-height: 3px; transition: height .4s ease; position: relative; }
.chart-bar:hover { filter: brightness(1.08); }
.chart-bar .tip { position: absolute; top: -24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: .68rem; padding: 2px 7px; border-radius: 5px; opacity: 0; white-space: nowrap; }
.chart-bar:hover .tip { opacity: 1; }
.chart-lab { font-size: .68rem; color: var(--muted); }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: .8rem; color: var(--muted); }
.chart-legend i { width: 10px; height: 10px; display: inline-block; border-radius: 3px; margin-right: 5px; }

/* ===== WIDGETS ===== */
.mini-progress { height: 8px; border-radius: 20px; background: #EEF1F0; overflow: hidden; margin-top: 8px; }
.mini-progress span { display: block; height: 100%; border-radius: 20px; background: var(--primary); }
.recent-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #F1F4F2; }
.recent-item:last-child { border-bottom: none; }
.avatar-sm { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: .8rem; flex-shrink: 0; }
.recent-meta { flex: 1; min-width: 0; }
.recent-meta b { color: var(--ink); font-size: .86rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-meta span { font-size: .76rem; color: var(--muted); }
.recent-val { font-weight: 700; color: var(--ink); font-size: .88rem; }

/* ===== CONTENT FORMS ===== */
.page-tree { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.page-tree-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #fff; }
.page-tree-item:last-child { border-bottom: none; }
.page-tree-item .drag { color: #c9d3cd; cursor: grab; }
.page-tree-item .link { flex: 1; color: var(--ink); font-weight: 500; }
.page-tree-item .chip { font-size: .7rem; color: var(--muted); background: #F1F4F2; padding: 2px 8px; border-radius: 10px; }

/* ===== MEDIA ===== */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.media-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.media-thumb { height: 110px; background: #F2F5F3; display: flex; align-items: center; justify-content: center; padding: 6px; }
.media-thumb img { max-height: 100%; max-width: 100%; object-fit: contain; }
.media-meta { padding: 10px 12px; }
.media-meta b { font-size: .78rem; color: var(--ink); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-meta span { font-size: .72rem; color: var(--muted); }
.media-actions { padding: 0 12px 10px; display: flex; gap: 6px; }

/* ===== REVIEWS ===== */
.stars { color: #e7a93d; letter-spacing: 2px; }
.review-head { display: flex; align-items: center; gap: 8px; }

/* ===== ANALYTICS ===== */
.kpi-row { display: flex; gap: 10px; flex-wrap: wrap; }
.kpi-chip { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }

/* ===== TAB BAR ===== */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; border-bottom: 1px solid var(--line); padding-bottom: 0; flex-wrap: wrap; }
.tab-btn { padding: 10px 16px; font-size: .85rem; font-weight: 600; color: var(--muted); background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-btn.active { color: var(--primary); border-color: var(--primary); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .grid.stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid.four { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 120; transform: translateX(-100%); transition: transform .25s ease; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .sidebar.open { transform: none; }
  .hamburger { display: flex; align-items: center; justify-content: center; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .global-search { width: 100%; order: 3; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .grid.stat-grid { grid-template-columns: 1fr; }
  .topbar-title span { display: none; }
}