:root {
  --admin-bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #182230;
  --muted: #667085;
  --line: #d9e0ea;
  --dark: #111827;
  --accent: #0f766e;
  --accent-soft: #e6f5f2;
  --warn: #b45309;
  --radius: 8px;
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--admin-bg); }
a { color: inherit; }
.admin-body { min-height: 100vh; }
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.admin-sidebar { background: #111827; color: #fff; padding: 22px 16px; display: flex; flex-direction: column; gap: 26px; }
.admin-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.admin-brand-mark { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; background: #0f766e; color: #fff; font-weight: 800; }
.admin-brand strong { display: block; font-size: 18px; }
.admin-brand small { display: block; margin-top: 2px; color: rgba(255,255,255,.62); font-size: 12px; }
.admin-nav { display: grid; gap: 6px; }
.admin-nav a { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: rgba(255,255,255,.76); }
.admin-nav a:hover, .admin-nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.admin-nav small { color: rgba(255,255,255,.46); }
.admin-main { min-width: 0; padding: 26px; }
.admin-topbar { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 20px; }
.admin-eyebrow { color: var(--accent); font-weight: 800; font-size: 12px; letter-spacing: 0; text-transform: uppercase; }
.admin-topbar h1, .auth-card h2 { margin: 4px 0 0; font-size: 28px; line-height: 1.2; }
.admin-topbar p, .auth-desc { margin: 8px 0 0; color: var(--muted); max-width: 720px; line-height: 1.55; }
.admin-top-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.logout-form { margin: 0; }
.admin-content { display: grid; gap: 18px; }
.admin-alert { margin-bottom: 16px; border: 1px solid #a7dccf; background: var(--accent-soft); color: #0f4d47; padding: 12px 14px; border-radius: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 14px; border-radius: 8px; border: 1px solid transparent; text-decoration: none; font: inherit; cursor: pointer; white-space: nowrap; }
.btn-dark { background: var(--dark); color: #fff; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-muted { background: #fff; border-color: var(--line); color: var(--text); }
.btn-danger { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 20px; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-header h2, .panel-header h3 { margin: 0; font-size: 18px; }
.panel-header p { margin: 6px 0 0; color: var(--muted); line-height: 1.5; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin-top: 8px; font-size: 28px; }
.analytics-filter { display: grid; grid-template-columns: repeat(2, minmax(0, 180px)) auto; gap: 12px; align-items: end; }
.analytics-total-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.quick-card { display: block; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 18px; text-decoration: none; }
.quick-card strong { display: block; margin-bottom: 6px; }
.quick-card span { color: var(--muted); font-size: 14px; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > span { font-size: 13px; font-weight: 700; color: #344054; }
.upload-dropzone { display: block; width: fit-content; max-width: 100%; cursor: pointer; border-radius: 8px; }
.upload-dropzone:hover .image-preview, .upload-dropzone:hover .image-placeholder { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, .12); }
.upload-input:focus-visible + .upload-dropzone .image-preview, .upload-input:focus-visible + .upload-dropzone .image-placeholder { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, .18); }
.field small { color: var(--muted); line-height: 1.45; }
input, textarea, select { width: 100%; min-height: 42px; border: 1px solid #cfd8e3; border-radius: 8px; padding: 10px 12px; font: inherit; color: var(--text); background: #fff; }
.upload-input { position: absolute; width: 1px; min-width: 1px; min-height: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; padding: 0; }
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { outline: 3px solid rgba(15, 118, 110, .15); border-color: var(--accent); }
.rich-editor { border: 1px solid #cfd8e3; border-radius: 8px; background: #fff; overflow: hidden; }
.rich-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); background: var(--panel-soft); }
.rich-toolbar button { min-height: 32px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: #344054; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; }
.rich-toolbar button:hover, .rich-toolbar button:focus-visible { border-color: var(--accent); color: #0f4d47; outline: 2px solid rgba(15, 118, 110, .12); }
.rich-surface { min-height: 340px; padding: 16px; line-height: 1.7; outline: none; overflow-wrap: anywhere; }
.rich-surface:focus { box-shadow: inset 0 0 0 3px rgba(15, 118, 110, .14); }
.rich-surface > *:first-child { margin-top: 0; }
.rich-surface > *:last-child { margin-bottom: 0; }
.rich-surface h2, .rich-surface h3 { line-height: 1.3; }
.rich-surface blockquote { margin: 14px 0; padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--panel-soft); color: #344054; }
.rich-surface pre { overflow-x: auto; padding: 12px; border-radius: 8px; background: #111827; color: #f8fafc; }
.rich-source { display: none; }
.section-stack { display: grid; gap: 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 4px 0 0; }
.nav-row, .banner-row, .product-admin-row { display: grid; gap: 12px; align-items: end; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); margin-bottom: 12px; }
.nav-row { grid-template-columns: 80px 1fr 1.4fr 100px; }
.banner-row { grid-template-columns: 80px 1.2fr 1fr 1fr 120px 100px; }
.product-admin-row { align-items: start; }
.check-field { display: flex; align-items: center; gap: 8px; min-height: 42px; font-weight: 700; color: #344054; }
.check-field input { width: 18px; min-height: 18px; }
.image-preview { width: 100%; max-width: 220px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.image-placeholder { display: grid; place-items: center; width: 100%; max-width: 220px; aspect-ratio: 16 / 9; border: 1px dashed #b8c3d1; border-radius: 8px; color: var(--muted); background: #fff; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.admin-table th, .admin-table td { text-align: left; border-bottom: 1px solid var(--line); padding: 13px 10px; vertical-align: middle; }
.admin-table th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0; }
.admin-main, .panel, .stat-card, .quick-card, .field, .nav-row, .banner-row, .product-admin-row, .admin-topbar > *, .panel-header > * { min-width: 0; }
.title-cell span, .field input, .field textarea, .field small { overflow-wrap: anywhere; }
.title-cell strong { display: block; }
.title-cell span { display: block; color: var(--muted); margin-top: 4px; font-size: 13px; }
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-neutral { background: #e5e7eb; color: #374151; }
.empty-state { border: 1px dashed #b8c3d1; border-radius: 8px; padding: 24px; text-align: center; background: var(--panel-soft); }
.empty-state p { color: var(--muted); margin-bottom: 0; }
.auth-panel { min-height: 100vh; display: grid; grid-template-columns: minmax(280px, 1fr) minmax(320px, 480px); }
.admin-auth-body { background: #0f172a; }
.auth-visual { color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; background: radial-gradient(circle at 20% 20%, rgba(20,184,166,.28), transparent 32%), #111827; }
.auth-visual h1 { max-width: 560px; font-size: 42px; line-height: 1.12; margin: 0; }
.auth-visual p { max-width: 520px; color: rgba(255,255,255,.72); line-height: 1.7; font-size: 17px; }
.auth-card { background: #fff; padding: 52px 42px; display: flex; flex-direction: column; justify-content: center; }
.auth-card form { display: grid; gap: 16px; margin-top: 22px; }

@media (max-width: 980px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; padding: 14px; }
  .admin-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .admin-nav a { display: grid; min-height: 54px; }
  .admin-main { padding: 18px; }
  .stat-grid, .analytics-total-grid, .quick-grid, .form-grid, .form-grid.three { grid-template-columns: 1fr 1fr; }
  .analytics-filter { grid-template-columns: 1fr 1fr; }
  .banner-row { grid-template-columns: 80px 1fr 1fr; }
}

@media (max-width: 640px) {
  .admin-topbar, .panel-header { display: grid; }
  .admin-top-actions, .form-actions { justify-content: stretch; }
  .admin-top-actions .btn, .form-actions .btn { flex: 1 1 140px; min-width: 0; white-space: normal; text-align: center; }
  .admin-nav { grid-template-columns: 1fr 1fr; }
  .stat-grid, .analytics-total-grid, .analytics-filter, .quick-grid, .form-grid, .form-grid.three, .nav-row, .banner-row, .product-admin-row { grid-template-columns: 1fr; }
  .admin-topbar h1, .auth-card h2 { font-size: 24px; }
  .auth-panel { grid-template-columns: 1fr; }
  .auth-visual { min-height: 260px; padding: 30px; }
  .auth-visual h1 { font-size: 30px; }
  .auth-card { padding: 30px 22px; }
}
