/* ── Reset & Base ─────────────────────────────────────── */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0;}
html,body{height:100%;}
body{font-family:'Inter',sans-serif;font-size:14px;color:#1e293b;background:#f1f5f9;display:flex;}
a{text-decoration:none;color:inherit;}
img{max-width:100%;display:block;}
button{cursor:pointer;border:none;background:none;font-family:inherit;}

/* ── CSS Variables ────────────────────────────────────── */
:root{
  --primary:#4f46e5;
  --primary-light:#eef2ff;
  --sidebar-bg:#1a1f36;
  --sidebar-width:240px;
  --topbar-h:60px;
  --radius:10px;
  --shadow:0 1px 3px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.04);
  --border:#e2e8f0;
  --text-muted:#64748b;
  --text-light:#94a3b8;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar{
  width:var(--sidebar-width);
  background:var(--sidebar-bg);
  height:100vh;
  position:fixed;
  top:0;left:0;
  display:flex;flex-direction:column;
  overflow-y:auto;
  z-index:100;
  transition:transform .25s ease,width .25s ease;
}
.sidebar::-webkit-scrollbar{width:4px;}
.sidebar::-webkit-scrollbar-thumb{background:rgba(255,255,255,.1);border-radius:2px;}

/* Brand */
.sidebar-brand{
  padding:22px 20px 16px;
  display:flex;flex-direction:column;align-items:center;
  border-bottom:1px solid rgba(255,255,255,.06);
  text-align:center;
}
.brand-crown{margin-bottom:6px;}
.brand-name{
  display:block;
  color:#fff;
  font-size:18px;font-weight:700;
  letter-spacing:2px;
}
.brand-sep{
  display:block;
  color:#f59e0b;
  font-size:9px;
  letter-spacing:3px;
  margin-top:2px;
}

/* Sidebar User */
.sidebar-user{
  padding:14px 20px;
  display:flex;align-items:center;gap:12px;
  border-bottom:1px solid rgba(255,255,255,.06);
}
.user-avatar{
  width:40px;height:40px;
  border-radius:50%;
  background:rgba(255,255,255,.1);
  display:flex;align-items:center;justify-content:center;
  flex-shrink:0;
  color:#94a3b8;
}
.user-welcome{display:block;color:#94a3b8;font-size:11px;}
.user-name{display:block;color:#fff;font-size:13px;font-weight:600;}
.user-status{display:block;color:#22c55e;font-size:10px;margin-top:1px;}

/* Nav */
.sidebar-nav{flex:1;padding:10px 0;}
.nav-section{
  padding:14px 20px 5px;
  color:#4b5ea8;
  font-size:10px;font-weight:700;letter-spacing:1.2px;
  text-transform:uppercase;
}
.nav-item{
  display:flex;align-items:center;gap:10px;
  padding:9px 20px;
  color:#94a3b8;
  font-size:13px;
  transition:background .15s,color .15s;
  position:relative;
}
.nav-item:hover{background:rgba(255,255,255,.05);color:#e2e8f0;}
.nav-item.active{
  background:rgba(79,70,229,.25);
  color:#fff;
}
.nav-item.active::before{
  content:'';
  position:absolute;left:0;top:0;bottom:0;
  width:3px;
  background:#4f46e5;
  border-radius:0 2px 2px 0;
}
.nav-icon{width:18px;height:18px;flex-shrink:0;stroke:currentColor;}
.nav-label{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.nav-chevron{width:14px;height:14px;flex-shrink:0;opacity:.5;stroke:currentColor;}
.nav-badge{
  background:#ef4444;color:#fff;
  font-size:10px;font-weight:700;
  padding:1px 6px;border-radius:99px;
  margin-left:2px;
}
.nav-divider{height:1px;background:rgba(255,255,255,.06);margin:8px 20px;}
.nav-logout{color:#f87171;}
.nav-logout:hover{background:rgba(239,68,68,.1);color:#f87171;}

/* ── Main Wrapper ─────────────────────────────────────── */
.main-wrapper{
  margin-left:var(--sidebar-width);
  flex:1;min-width:0;
  display:flex;flex-direction:column;
  min-height:100vh;
  transition:margin-left .25s ease;
}

/* ── Topbar ───────────────────────────────────────────── */
.topbar{
  height:var(--topbar-h);
  background:#fff;
  border-bottom:1px solid var(--border);
  display:flex;align-items:center;justify-content:space-between;
  padding:0 24px;
  position:sticky;top:0;z-index:90;
  box-shadow:var(--shadow);
}
.topbar-left{display:flex;align-items:center;gap:14px;}
.sidebar-toggle{
  width:36px;height:36px;
  border-radius:8px;
  background:#f8fafc;border:1px solid var(--border);
  display:flex;align-items:center;justify-content:center;
  color:#64748b;transition:background .15s;
}
.sidebar-toggle:hover{background:#f1f5f9;}
.topbar-page-name{font-size:15px;font-weight:600;color:#1e293b;}
.topbar-right{display:flex;align-items:center;gap:10px;}
.topbar-notif{
  width:36px;height:36px;
  border-radius:8px;
  background:#f8fafc;border:1px solid var(--border);
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;position:relative;color:#64748b;
}
.topbar-notif:hover{background:#f1f5f9;}
.notif-dot{
  position:absolute;top:6px;right:6px;
  width:8px;height:8px;
  background:#ef4444;border-radius:50%;
  border:2px solid #fff;
}
.topbar-user{
  display:flex;align-items:center;gap:8px;
  padding:6px 12px;
  border-radius:8px;
  background:#f8fafc;border:1px solid var(--border);
  cursor:pointer;color:#374151;
  font-size:13px;font-weight:500;
}
.topbar-user:hover{background:#f1f5f9;}
.topbar-avatar{
  width:24px;height:24px;border-radius:50%;
  background:#e0e7ff;
  display:flex;align-items:center;justify-content:center;
  color:#4f46e5;
}

/* ── Page Content ─────────────────────────────────────── */
.page-main{flex:1;padding:24px;}
.page-header{margin-bottom:20px;}
.page-title{font-size:22px;font-weight:700;color:#1e293b;margin-bottom:4px;}
.page-breadcrumb{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--text-muted);}
.page-breadcrumb a{color:var(--text-muted);}
.page-breadcrumb a:hover{color:var(--primary);}
.page-breadcrumb span:last-child{color:#1e293b;}

/* ── Alerts ───────────────────────────────────────────── */
.alert{
  padding:12px 16px;border-radius:8px;
  font-size:13px;font-weight:500;
  margin-bottom:18px;
}
.alert-success{background:#f0fdf4;color:#166534;border:1px solid #bbf7d0;}
.alert-danger{background:#fef2f2;color:#991b1b;border:1px solid #fecaca;}

/* ── Stats Row (horizontal, 5 cards) ─────────────────── */
.stats-row{
  display:grid;
  grid-template-columns:repeat(5,1fr);
  gap:16px;
  margin-bottom:24px;
}
.stat-card{
  background:#fff;
  border-radius:var(--radius);
  border:1px solid var(--border);
  padding:20px 18px;
  display:flex;align-items:flex-start;gap:14px;
  box-shadow:var(--shadow);
}
.stat-icon-wrap{
  width:56px;height:56px;flex-shrink:0;
  border-radius:12px;
  display:flex;align-items:center;justify-content:center;
}
.stat-icon-wrap.blue{background:#dbeafe;color:#2563eb;}
.stat-icon-wrap.green{background:#dcfce7;color:#16a34a;}
.stat-icon-wrap.orange{background:#ffedd5;color:#ea580c;}
.stat-icon-wrap.pink{background:#fce7f3;color:#db2777;}
.stat-icon-wrap.teal{background:#ccfbf1;color:#0d9488;}
.stat-icon-wrap.purple{background:#ede9fe;color:#7c3aed;}
.stat-icon-wrap.indigo{background:#e0e7ff;color:#4338ca;}
.stat-body{display:flex;flex-direction:column;min-width:0;}
.stat-label{font-size:11.5px;color:var(--text-muted);margin-bottom:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.stat-value{font-size:26px;font-weight:700;color:#1e293b;line-height:1.1;margin-bottom:6px;}
.stat-link{font-size:11px;color:var(--primary);white-space:nowrap;}
.stat-link:hover{text-decoration:underline;}

/* ── Dashboard Grid ───────────────────────────────────── */
.dash-grid{
  display:grid;
  grid-template-columns:1fr 400px;
  gap:20px;
}
.dash-chart-card{}
.dash-orders-card{}

/* ── Card ─────────────────────────────────────────────── */
.card{
  background:#fff;
  border-radius:var(--radius);
  border:1px solid var(--border);
  box-shadow:var(--shadow);
  overflow:hidden;
}
.card-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:16px 20px;
  border-bottom:1px solid var(--border);
}
.card-title{font-size:14px;font-weight:600;color:#1e293b;}
.card-body{padding:20px;}

/* Chart */
.chart-container{height:240px;position:relative;}

/* Chart summary */
.chart-summary{
  display:grid;grid-template-columns:repeat(4,1fr);
  gap:16px;
  padding-top:16px;
  border-top:1px solid var(--border);
  margin-top:16px;
  text-align:center;
}
.cs-item{}
.cs-value{display:block;font-size:20px;font-weight:700;color:#1e293b;}
.cs-value.cs-green{color:#16a34a;}
.cs-label{display:block;font-size:11px;color:var(--text-muted);margin-top:2px;}

/* View all button */
.btn-view-all{
  font-size:12px;color:var(--primary);font-weight:500;
  padding:5px 12px;border-radius:6px;border:1px solid var(--border);
  background:#f8fafc;white-space:nowrap;
}
.btn-view-all:hover{background:#eef2ff;}

/* Recent Orders Table */
.dash-orders-table{width:100%;border-collapse:collapse;font-size:12.5px;}
.dash-orders-table th{
  padding:10px 14px;
  text-align:left;font-weight:600;font-size:11px;
  color:var(--text-muted);
  border-bottom:1px solid var(--border);
  background:#f8fafc;
}
.dash-orders-table td{
  padding:11px 14px;
  border-bottom:1px solid #f1f5f9;
  color:#374151;
}
.dash-orders-table tr:last-child td{border-bottom:none;}
.dash-orders-table tr:hover td{background:#fafafa;}
.order-id{font-weight:600;color:#1e293b;}
.order-date{color:var(--text-muted);font-size:11.5px;}

/* ── Badges ───────────────────────────────────────────── */
.badge{display:inline-block;padding:3px 10px;border-radius:99px;font-size:11px;font-weight:600;}
.badge-success{background:#dcfce7;color:#166534;}
.badge-danger{background:#fee2e2;color:#991b1b;}
.badge-warning{background:#fef9c3;color:#854d0e;}
.badge-info{background:#dbeafe;color:#1e40af;}
.badge-processing{background:#fef3c7;color:#92400e;}
.badge-shipped{background:#cffafe;color:#164e63;}
.badge-purple{background:#ede9fe;color:#5b21b6;}
.badge-orange{background:#ffedd5;color:#9a3412;}
.badge-secondary{background:#f1f5f9;color:#475569;}
.badge-gray{background:#f1f5f9;color:#475569;}

/* ── Quick Actions Row ────────────────────────────────── */
.quick-actions-row{
  display:grid;
  grid-template-columns:repeat(6,1fr);
  gap:14px;
}
.qa-card{
  display:flex;flex-direction:column;align-items:flex-start;
  gap:10px;
  padding:16px;
  border-radius:10px;
  border:1px solid var(--border);
  background:#fff;
  transition:box-shadow .15s,transform .15s;
  text-decoration:none;color:inherit;
}
.qa-card:hover{box-shadow:0 4px 12px rgba(0,0,0,.08);transform:translateY(-2px);}
.qa-icon-wrap{
  width:44px;height:44px;
  border-radius:10px;
  display:flex;align-items:center;justify-content:center;
}
.qa-icon-wrap.blue{background:#dbeafe;color:#2563eb;}
.qa-icon-wrap.green{background:#dcfce7;color:#16a34a;}
.qa-icon-wrap.orange{background:#ffedd5;color:#ea580c;}
.qa-icon-wrap.pink{background:#fce7f3;color:#db2777;}
.qa-icon-wrap.indigo{background:#e0e7ff;color:#4338ca;}
.qa-icon-wrap.purple{background:#ede9fe;color:#7c3aed;}
.qa-icon-wrap.teal{background:#ccfbf1;color:#0d9488;}
.qa-title{font-size:12.5px;font-weight:600;color:#1e293b;}
.qa-sub{font-size:11px;color:var(--text-muted);}

/* ── Page Footer ──────────────────────────────────────── */
.page-footer{
  display:flex;justify-content:space-between;align-items:center;
  padding:16px 0 8px;
  margin-top:24px;
  border-top:1px solid var(--border);
  font-size:12px;color:var(--text-muted);
}

/* ── Other pages: Generic table ───────────────────────── */
.table-wrap{overflow-x:auto;}
table{width:100%;border-collapse:collapse;font-size:13px;}
thead tr{background:#f8fafc;}
th{padding:11px 14px;text-align:left;font-size:11.5px;font-weight:600;color:var(--text-muted);border-bottom:1px solid var(--border);}
td{padding:11px 14px;border-bottom:1px solid #f8fafc;color:#374151;}
tbody tr:last-child td{border-bottom:none;}
tbody tr:hover td{background:#fafafa;}

/* ── Buttons ──────────────────────────────────────────── */
.btn{display:inline-flex;align-items:center;gap:6px;padding:8px 16px;border-radius:8px;font-size:13px;font-weight:500;cursor:pointer;transition:all .15s;border:1px solid transparent;}
.btn-primary{background:var(--primary);color:#fff;border-color:var(--primary);}
.btn-primary:hover{background:#4338ca;}
.btn-secondary{background:#f1f5f9;color:#374151;border-color:var(--border);}
.btn-secondary:hover{background:#e2e8f0;}
.btn-danger{background:#fef2f2;color:#dc2626;border-color:#fecaca;}
.btn-danger:hover{background:#fee2e2;}
.btn-outline{background:#fff;color:var(--primary);border-color:var(--border);}
.btn-outline:hover{background:var(--primary-light);}
.btn-sm{padding:5px 11px;font-size:12px;border-radius:6px;}
.btn-success{background:#f0fdf4;color:#16a34a;border-color:#bbf7d0;}

/* ── Forms ────────────────────────────────────────────── */
.form-card{background:#fff;border-radius:var(--radius);border:1px solid var(--border);padding:24px;box-shadow:var(--shadow);}
.form-group{margin-bottom:16px;}
.form-label{display:block;font-size:12.5px;font-weight:500;color:#374151;margin-bottom:6px;}
.form-control{
  width:100%;padding:9px 12px;
  border:1px solid var(--border);border-radius:8px;
  font-size:13px;font-family:inherit;color:#1e293b;
  background:#fff;outline:none;
  transition:border-color .15s,box-shadow .15s;
}
.form-control:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(79,70,229,.1);}
select.form-control{cursor:pointer;}
textarea.form-control{resize:vertical;min-height:80px;}
.form-grid{display:grid;gap:16px;}
.form-grid-2{grid-template-columns:1fr 1fr;}
.form-grid-3{grid-template-columns:1fr 1fr 1fr;}
.form-hint{font-size:11px;color:var(--text-muted);margin-top:4px;}

/* ── Toggle Switch ────────────────────────────────────── */
.toggle{display:inline-flex;align-items:center;cursor:pointer;}
.toggle input{display:none;}
.toggle-slider{
  width:40px;height:22px;
  background:#cbd5e1;border-radius:99px;
  position:relative;transition:background .2s;
}
.toggle-slider::after{
  content:'';position:absolute;
  top:3px;left:3px;
  width:16px;height:16px;
  border-radius:50%;background:#fff;
  transition:transform .2s;
  box-shadow:0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider{background:#4f46e5;}
.toggle input:checked + .toggle-slider::after{transform:translateX(18px);}

/* ── Upload Area ──────────────────────────────────────── */
.upload-area{
  border:2px dashed var(--border);border-radius:8px;
  padding:24px;text-align:center;
  cursor:pointer;transition:border-color .15s;
  position:relative;
}
.upload-area:hover{border-color:var(--primary);background:var(--primary-light);}
.upload-area input[type=file]{
  position:absolute;inset:0;opacity:0;cursor:pointer;width:100%;height:100%;
}
.upload-area svg{color:#94a3b8;margin:0 auto 8px;}
.upload-area p{font-size:13px;font-weight:500;color:#374151;}
.upload-area small{font-size:11px;color:var(--text-muted);}
.img-preview{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px;}
.img-preview-item img{width:80px;height:60px;object-fit:cover;border-radius:6px;border:1px solid var(--border);}

/* ── Pagination ───────────────────────────────────────── */
.pagination{display:flex;align-items:center;gap:6px;margin-top:16px;}
.pagination a,.pagination span{
  display:inline-flex;align-items:center;justify-content:center;
  width:32px;height:32px;border-radius:6px;font-size:13px;
  border:1px solid var(--border);color:#374151;
}
.pagination a:hover{background:#f1f5f9;}
.pagination .current{background:var(--primary);color:#fff;border-color:var(--primary);}

/* ── Split Layout ─────────────────────────────────────── */
.page-layout-split{display:flex;gap:24px;align-items:flex-start;}

/* ── Login Page ───────────────────────────────────────── */
.login-page{
  min-height:100vh;width:100%;
  background:linear-gradient(135deg,#1e1b4b 0%,#312e81 50%,#4338ca 100%);
  display:flex;align-items:center;justify-content:center;
  padding:24px;
}
.login-card{
  background:#fff;border-radius:16px;
  padding:40px 36px;width:100%;max-width:400px;
  box-shadow:0 20px 60px rgba(0,0,0,.25);
}
.login-brand{text-align:center;margin-bottom:28px;}
.login-brand-name{font-size:22px;font-weight:800;color:#1e1b4b;letter-spacing:2px;}
.login-brand-sub{font-size:10px;color:#f59e0b;letter-spacing:3px;margin-top:2px;}
.login-title{font-size:18px;font-weight:700;color:#1e293b;margin-bottom:4px;}
.login-sub{font-size:13px;color:var(--text-muted);margin-bottom:24px;}
.login-btn{
  width:100%;padding:11px;
  background:var(--primary);color:#fff;
  border-radius:8px;font-size:14px;font-weight:600;
  border:none;cursor:pointer;margin-top:8px;
  transition:background .15s;
}
.login-btn:hover{background:#4338ca;}
.login-error{
  background:#fef2f2;color:#dc2626;
  border:1px solid #fecaca;border-radius:8px;
  padding:10px 14px;font-size:13px;margin-bottom:16px;
}

/* ── Sidebar Collapsed ────────────────────────────────── */
.sidebar-collapsed .sidebar{width:64px;}
.sidebar-collapsed .sidebar .brand-crown{margin:0;}
.sidebar-collapsed .sidebar .brand-text,
.sidebar-collapsed .sidebar .sidebar-user .user-info,
.sidebar-collapsed .sidebar .nav-label,
.sidebar-collapsed .sidebar .nav-chevron,
.sidebar-collapsed .sidebar .nav-badge,
.sidebar-collapsed .sidebar .nav-section,
.sidebar-collapsed .sidebar .nav-divider,
.sidebar-collapsed .sidebar .sidebar-brand .brand-name,
.sidebar-collapsed .sidebar .sidebar-brand .brand-sep{display:none;}
.sidebar-collapsed .sidebar .sidebar-brand{padding:14px 0;align-items:center;}
.sidebar-collapsed .sidebar .nav-item{justify-content:center;padding:10px 0;}
.sidebar-collapsed .sidebar .nav-item.active::before{display:none;}
.sidebar-collapsed .main-wrapper{margin-left:64px;}

/* ── Responsive ───────────────────────────────────────── */
@media(max-width:1280px){
  .stats-row{grid-template-columns:repeat(3,1fr);}
  .quick-actions-row{grid-template-columns:repeat(3,1fr);}
}
@media(max-width:1024px){
  .dash-grid{grid-template-columns:1fr;}
  .chart-summary{grid-template-columns:repeat(2,1fr);}
}
@media(max-width:768px){
  .sidebar{transform:translateX(-100%);}
  .sidebar.open{transform:translateX(0);}
  .main-wrapper{margin-left:0!important;}
  .stats-row{grid-template-columns:repeat(2,1fr);}
  .quick-actions-row{grid-template-columns:repeat(2,1fr);}
  .page-main{padding:16px;}
}
@media(max-width:480px){
  .stats-row{grid-template-columns:1fr;}
  .quick-actions-row{grid-template-columns:1fr;}
}

/* ── Print ────────────────────────────────────────────── */
@media print{
  .sidebar,.topbar,.page-header,.btn,.pagination{display:none!important;}
  .main-wrapper{margin:0!important;}
  .page-main{padding:0!important;}
}
