*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2a2f45;
  --accent: #3d7fff;
  --accent-hover: #5a94ff;
  --danger: #e53e3e;
  --success: #38a169;
  --warning: #d69e2e;
  --text: #e2e8f0;
  --text-muted: #718096;
  --radius: 10px;
  --sidebar-w: 220px;
}

body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

/* ─── LOGIN ──────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 40px; width: 380px; }
.login-logo { font-size: 22px; font-weight: 700; margin-bottom: 24px; color: var(--text); }
.login-logo span { color: var(--accent); }
.login-logo em { font-style: normal; color: var(--text-muted); font-size: 14px; font-weight: 400; margin-left: 8px; }
.login-card h2 { font-size: 20px; margin-bottom: 24px; }

/* ─── APP LAYOUT ─────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ─── SIDEBAR ────────────────────────────────────────── */
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; }
.sidebar-logo { padding: 20px; font-size: 18px; font-weight: 700; border-bottom: 1px solid var(--border); }
.sidebar-logo span { color: var(--accent); }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--text-muted); text-decoration: none; font-size: 13.5px; font-weight: 500; transition: all .15s; position: relative; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(61,127,255,.15); color: var(--accent); }
.badge { background: var(--danger); color: #fff; border-radius: 20px; font-size: 10px; font-weight: 700; padding: 1px 6px; margin-left: auto; display: none; }
.badge.show { display: inline-block; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.admin-info { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.admin-info strong { display: block; color: var(--text); font-size: 13px; }

/* ─── MAIN ───────────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 28px; overflow-y: auto; }
.page { display: none; }
.page.active { display: block; }

/* ─── COMPONENTS ─────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; }

.btn-primary { background: var(--accent); color: #fff; border: none; padding: 9px 18px; border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 600; transition: background .15s; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); padding: 9px 18px; border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 500; transition: all .15s; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; border: none; padding: 7px 14px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 600; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.full { width: 100%; }
.btn-logout { background: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: 7px 14px; border-radius: 7px; cursor: pointer; font-size: 12.5px; width: 100%; transition: all .15s; }
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ─── CARDS / SURFACES ───────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 14px; }

/* ─── KPI GRID ───────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.kpi-value { font-family: 'DM Mono', monospace; font-size: 26px; font-weight: 500; color: var(--text); }
.kpi-growth { font-size: 12px; margin-top: 4px; }
.kpi-growth.up { color: var(--success); }
.kpi-growth.down { color: var(--danger); }

/* ─── GRID 2 COL ─────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }

/* ─── TABLE ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 14px; border-bottom: 1px solid var(--border); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.mono { font-family: 'DM Mono', monospace; font-size: 13px; }

/* ─── STATUT BADGES ──────────────────────────────────── */
.status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-PENDING { background: rgba(214,158,46,.15); color: var(--warning); }
.status-CONFIRMED { background: rgba(56,161,105,.15); color: var(--success); }
.status-PROCESSING { background: rgba(61,127,255,.15); color: var(--accent); }
.status-SHIPPED { background: rgba(159,122,234,.15); color: #9f7aea; }
.status-DELIVERED { background: rgba(56,161,105,.2); color: #48bb78; }
.status-CANCELLED { background: rgba(229,62,62,.15); color: var(--danger); }
.status-UNREAD { background: rgba(214,158,46,.15); color: var(--warning); }
.status-READ { background: rgba(113,128,150,.15); color: var(--text-muted); }
.status-REPLIED { background: rgba(56,161,105,.15); color: var(--success); }
.status-ARCHIVED { background: rgba(113,128,150,.1); color: var(--text-muted); }

/* ─── SEARCH / FILTERS ───────────────────────────────── */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; }
.search-input { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; color: var(--text); font-size: 13.5px; flex: 1; outline: none; transition: border .15s; }
.search-input:focus { border-color: var(--accent); }
select.filter-select { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; color: var(--text); font-size: 13px; outline: none; cursor: pointer; }

/* ─── STOCK INDICATOR ────────────────────────────────── */
.stock-ok { color: var(--success); }
.stock-low { color: var(--warning); }
.stock-critical { color: var(--danger); font-weight: 600; }

/* ─── FORM ───────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], textarea, select.form-select {
  width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 14px; color: var(--text); font-size: 13.5px; outline: none; transition: border .15s; font-family: inherit;
}
input:focus, textarea:focus, select.form-select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 100px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; }

/* ─── PAGINATION ─────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 16px; justify-content: flex-end; }
.pagination button { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.pagination button:disabled { opacity: .4; cursor: default; }
.pagination .page-info { font-size: 12.5px; color: var(--text-muted); }

/* ─── LOW STOCK LIST ─────────────────────────────────── */
.low-stock-list { display: flex; flex-direction: column; gap: 8px; }
.low-stock-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--surface2); border-radius: 8px; }
.low-stock-item .name { font-size: 13px; font-weight: 500; }
.low-stock-item .cat { font-size: 11.5px; color: var(--text-muted); }

/* ─── TOP PRODUCTS ───────────────────────────────────── */
.top-product-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.top-product-item:last-child { border-bottom: none; }
.top-product-rank { font-family: 'DM Mono', monospace; font-size: 18px; color: var(--text-muted); width: 30px; }
.top-product-info { flex: 1; }
.top-product-info .pname { font-size: 13.5px; font-weight: 600; }
.top-product-info .pcount { font-size: 12px; color: var(--text-muted); }

/* ─── CHART (SVG simple) ─────────────────────────────── */
.chart-wrap { position: relative; height: 180px; }
.chart-wrap svg { width: 100%; height: 100%; }

/* ─── ORDER STATUS DONUT ─────────────────────────────── */
.status-list { display: flex; flex-direction: column; gap: 8px; }
.status-row { display: flex; align-items: center; justify-content: space-between; }
.status-row .count { font-family: 'DM Mono', monospace; font-size: 15px; }

/* ─── MESSAGE CARD ───────────────────────────────────── */
.msg-card { background: var(--surface2); border-radius: var(--radius); padding: 16px; margin-bottom: 10px; border-left: 3px solid var(--border); }
.msg-card.unread { border-left-color: var(--accent); }
.msg-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.msg-name { font-weight: 600; font-size: 14px; }
.msg-email { color: var(--text-muted); font-size: 12.5px; }
.msg-text { font-size: 13.5px; color: var(--text-muted); line-height: 1.6; margin-bottom: 10px; }
.msg-actions { display: flex; gap: 8px; }
.msg-date { font-size: 11.5px; color: var(--text-muted); margin-left: auto; }

/* ─── PRODUCT CARD IN ADMIN ──────────────────────────── */
.product-row-img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--surface2); }

/* ─── MODAL ──────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; width: 560px; max-width: 95vw; max-height: 90vh; overflow-y: auto; position: relative; }
.modal-close { position: absolute; top: 14px; right: 16px; background: none; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; line-height: 1; }
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 20px; }

/* ─── TOAST ──────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--surface); border: 1px solid var(--border); padding: 12px 20px; border-radius: 10px; font-size: 13.5px; opacity: 0; transform: translateY(10px); transition: all .25s; z-index: 2000; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }

/* ─── SCROLLBAR ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── EMPTY STATE ────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 16px; opacity: .3; }

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
