@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --nav-bg: #0f172a;
  --nav-hover: #1e293b;
  --nav-active: #3b82f6;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-focus: #93c5fd;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --emerald: #10b981;
  --emerald-light: #ecfdf5;
  --emerald-dark: #065f46;
  
  --amber: #f59e0b;
  --amber-light: #fffbeb;
  --amber-dark: #92400e;
  
  --rose: #ef4444;
  --rose-light: #fef2f2;
  --rose-dark: #991b1b;
  
  --sky: #0ea5e9;
  --sky-light: #f0f9ff;
  --sky-dark: #075985;
  
  --purple: #8b5cf6;
  --purple-light: #f5f3ff;
  --purple-dark: #5b21b6;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
}

/* App Layout */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--nav-bg);
  color: #fff;
  padding: 24px 16px;
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 50;
  box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}

.brand {
  font-size: 20px;
  font-weight: 800;
  padding: 0 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.02em;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.5);
}

.brand span {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-light);
  display: block;
}

.sidebar nav {
  flex: 1;
  overflow-y: auto;
  padding-top: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--nav-hover) transparent;
}

.nav-group {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  padding: 12px 12px 6px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  margin: 2px 0;
  color: #cbd5e1;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.sidebar nav a svg {
  width: 18px;
  height: 18px;
  opacity: 0.75;
  transition: opacity 0.15s ease;
}

.sidebar nav a:hover {
  background: var(--nav-hover);
  color: #fff;
}

.sidebar nav a:hover svg {
  opacity: 1;
}

.sidebar nav a.active {
  background: rgba(37, 99, 235, 0.2);
  color: #60a5fa;
  font-weight: 600;
}

.sidebar nav a.active svg {
  color: #60a5fa;
  opacity: 1;
}

.user-profile-bar {
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info {
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-role {
  font-size: 11px;
  color: #94a3b8;
}

.logout {
  background: transparent;
  color: #f87171;
  border: 0;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.logout:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* Main Content Area */
.main {
  margin-left: 260px;
  width: calc(100% - 260px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  height: 68px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.content {
  padding: 32px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

/* Page Headers */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
}

p {
  color: var(--text-muted);
  margin: 0;
  font-size: 14px;
}

/* Cards & Grid Layouts */
.grid {
  display: grid;
  gap: 18px;
}

.cards {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cards-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cards-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--emerald-light); color: var(--emerald); }
.stat-icon.amber { background: var(--amber-light); color: var(--amber); }
.stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-icon.rose { background: var(--rose-light); color: var(--rose); }

.card span.label {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

.card b.value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.card .trend {
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.trend.positive { color: var(--emerald); }
.trend.neutral { color: var(--text-muted); }
.trend.negative { color: var(--rose); }

.actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 20px;
}

.action {
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-main);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.action:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.badge-emerald { background: var(--emerald-light); color: var(--emerald-dark); border: 1px solid rgba(16,185,129,0.2); }
.badge-amber { background: var(--amber-light); color: var(--amber-dark); border: 1px solid rgba(245,158,11,0.2); }
.badge-rose { background: var(--rose-light); color: var(--rose-dark); border: 1px solid rgba(239,68,68,0.2); }
.badge-sky { background: var(--sky-light); color: var(--sky-dark); border: 1px solid rgba(14,165,233,0.2); }
.badge-purple { background: var(--purple-light); color: var(--purple-dark); border: 1px solid rgba(139,92,246,0.2); }
.badge-slate { background: #f1f5f9; color: #475569; border: 1px solid var(--border); }

/* Buttons */
.button, button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--surface);
  color: var(--text-main);
  border-color: var(--border);
}

.button:hover, button:hover, .btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.primary, .btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.primary:hover, .btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-success {
  background: var(--emerald);
  color: #fff;
  border-color: var(--emerald);
}

.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: var(--rose);
  color: #fff;
  border-color: var(--rose);
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
}

.btn-export {
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--text-main);
}

.btn-export:hover {
  background: #f1f5f9;
}

.full {
  width: 100%;
}

/* Tables */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: auto;
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th, .table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 13.5px;
}

.table th {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f8fafc;
}

.table tbody tr:hover {
  background: #f8fafc;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

/* Toolbars */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar input, .toolbar select {
  flex: 1;
  min-width: 220px;
}

/* Forms */
.form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-sm);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  color: var(--text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.form-actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
}

.check {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 500;
  cursor: pointer;
  margin: 12px 0;
}

.check input {
  width: auto;
  margin: 0;
  cursor: pointer;
}

/* Alerts */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert.success {
  background: var(--emerald-light);
  color: var(--emerald-dark);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert.error {
  background: var(--rose-light);
  color: var(--rose-dark);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert ul {
  margin: 0;
  padding-left: 18px;
}

/* Order Stepper Tracker */
.order-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0 28px;
  padding: 18px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: relative;
  overflow-x: auto;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  flex: 1;
  min-width: 90px;
}

.step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f1f5f9;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  z-index: 2;
  border: 2px solid var(--border);
  transition: all 0.2s ease;
}

.step.completed .step-circle {
  background: var(--emerald);
  color: #fff;
  border-color: var(--emerald);
}

.step.active .step-circle {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.step-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.step.active .step-label {
  color: var(--primary);
  font-weight: 700;
}

.step.completed .step-label {
  color: var(--text-main);
}

/* Charts Containers */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* Pagination */
.pagination {
  display: flex;
  list-style: none;
  padding: 0;
  gap: 6px;
  margin-top: 20px;
}

.pagination li a, .pagination li span {
  display: inline-flex;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-main);
  font-size: 13px;
}

.pagination li.active span {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Login Page */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, #1e293b, #0f172a);
}

.login-card {
  width: min(420px, 92vw);
  background: var(--surface);
  padding: 36px;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.2);
}

/* Print Invoice Styles */
@media print {
  .sidebar, header, .form-actions, .button, button, .toolbar, .logout, .order-stepper {
    display: none !important;
  }
  .main {
    margin-left: 0 !important;
    width: 100% !important;
  }
  .content {
    padding: 0 !important;
    max-width: 100% !important;
  }
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .card, .table-wrap, .form {
    border: none !important;
    box-shadow: none !important;
  }
}

/* Responsive */
@media(max-width: 1024px) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media(max-width: 800px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }
  .app {
    display: block;
  }
  .main {
    margin-left: 0;
    width: 100%;
  }
  .cards, .actions, .form-grid {
    grid-template-columns: 1fr;
  }
  header {
    padding: 0 16px;
  }
  .content {
    padding: 16px;
  }
  .page-head {
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }
}
