/* ===================================================================
   INVETORI — Global Design System
   =================================================================== */

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

/* -------------------------------------------------------------------
   CSS Variables — Dark Mode (Default)
   ------------------------------------------------------------------- */
:root {
  /* Colors */
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-light: rgba(16, 185, 129, 0.15);
  --primary-glow: rgba(16, 185, 129, 0.3);

  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-light: rgba(239, 68, 68, 0.15);

  --warning: #f59e0b;
  --warning-hover: #d97706;
  --warning-light: rgba(245, 158, 11, 0.15);

  --info: #3b82f6;
  --info-hover: #2563eb;
  --info-light: rgba(59, 130, 246, 0.15);

  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.15);

  /* Background layers */
  --bg-body: #0f172a;
  --bg-sidebar: #0a1120;
  --bg-card: #1e293b;
  --bg-card-hover: #253347;
  --bg-input: #1e293b;
  --bg-modal: #1e293b;
  --bg-overlay: rgba(0, 0, 0, 0.7);
  --bg-table-header: #162032;
  --bg-table-row-hover: #253347;
  --bg-badge: #334155;

  /* Borders */
  --border: #334155;
  --border-light: #2d3f55;
  --border-focus: var(--primary);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --text-inverse: #0f172a;

  /* Sidebar */
  --sidebar-width: 260px;
  --sidebar-collapsed: 70px;
  --header-height: 64px;

  /* Typography */
  --font-heading: 'Poppins', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* Spacing */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-primary: 0 4px 20px rgba(16, 185, 129, 0.2);

  /* Transitions */
  --transition: all 0.2s ease;
  --transition-slow: all 0.35s ease;

  /* Scrollbar */
  --scrollbar-thumb: #334155;
  --scrollbar-track: #1e293b;
}

/* Light Mode */
[data-theme="light"] {
  --bg-body: #f1f5f9;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f8fafc;
  --bg-modal: #ffffff;
  --bg-overlay: rgba(15, 23, 42, 0.5);
  --bg-table-header: #f1f5f9;
  --bg-table-row-hover: #f8fafc;
  --bg-badge: #e2e8f0;

  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --text-inverse: #f1f5f9;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);

  --scrollbar-thumb: #cbd5e1;
  --scrollbar-track: #f1f5f9;
}

/* -------------------------------------------------------------------
   Reset & Base
   ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

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

/* -------------------------------------------------------------------
   Sidebar
   ------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  transition: var(--transition-slow);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-height);
}

.sidebar-brand .brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), #059669);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-primary);
}

.sidebar-brand .brand-icon svg { width: 20px; height: 20px; color: white; }

.sidebar-brand .brand-text { overflow: hidden; }
.sidebar-brand .brand-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  white-space: nowrap;
}
.sidebar-brand .brand-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 12px 20px 6px;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-radius: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
  white-space: nowrap;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--primary-light);
}

.nav-item.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.nav-item .nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.nav-item .nav-icon svg { width: 18px; height: 18px; }

.nav-item .nav-label { flex: 1; transition: opacity 0.2s; }
.sidebar.collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; }

.nav-item .nav-badge {
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: 600;
  min-width: 18px;
  text-align: center;
  transition: opacity 0.2s;
}
.sidebar.collapsed .nav-badge { opacity: 0; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}
.sidebar-user:hover { background: var(--bg-card-hover); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: white;
  flex-shrink: 0;
}

.user-info { overflow: hidden; flex: 1; }
.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.sidebar.collapsed .user-info { opacity: 0; width: 0; overflow: hidden; }

/* -------------------------------------------------------------------
   Main Content
   ------------------------------------------------------------------- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-slow);
}

.main-content.expanded { margin-left: var(--sidebar-collapsed); }

/* -------------------------------------------------------------------
   Header / Topbar
   ------------------------------------------------------------------- */
.topbar {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 12px; flex: 1; }

.sidebar-toggle {
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.sidebar-toggle:hover { background: var(--primary-light); color: var(--primary); }
.sidebar-toggle svg { width: 20px; height: 20px; }

.page-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-right { display: flex; align-items: center; gap: 8px; }

.topbar-btn {
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.topbar-btn:hover { border-color: var(--primary); color: var(--primary); }
.topbar-btn svg { width: 18px; height: 18px; }

.notification-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

.notif-count-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--danger);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  min-width: 16px;
  text-align: center;
  border: 2px solid var(--bg-card);
}

/* -------------------------------------------------------------------
   Page Content
   ------------------------------------------------------------------- */
.page-content {
  flex: 1;
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header-left h1 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.page-header-left p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.breadcrumb span.sep { color: var(--text-faint); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .current { color: var(--text-secondary); }

/* -------------------------------------------------------------------
   Cards
   ------------------------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: var(--transition);
}

.card:hover { border-color: var(--border-light); }

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

.card-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* Stat Cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.stat-card.primary::after { background: var(--primary); }
.stat-card.info::after { background: var(--info); }
.stat-card.warning::after { background: var(--warning); }
.stat-card.danger::after { background: var(--danger); }

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border-light);
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.info { background: var(--info-light); color: var(--info); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.danger { background: var(--danger-light); color: var(--danger); }

.stat-info { flex: 1; }
.stat-value {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}
.stat-label { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }
.stat-trend {
  font-size: 0.75rem;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-trend.up { color: var(--primary); }
.stat-trend.down { color: var(--danger); }

/* -------------------------------------------------------------------
   Grid Layouts
   ------------------------------------------------------------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

/* -------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: var(--font-body);
  line-height: 1;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: var(--shadow-primary);
}

.btn-secondary {
  background: var(--bg-badge);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }

.btn-warning {
  background: var(--warning);
  color: white;
  border-color: var(--warning);
}
.btn-warning:hover { background: var(--warning-hover); }

.btn-info {
  background: var(--info);
  color: white;
  border-color: var(--info);
}
.btn-info:hover { background: var(--info-hover); }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-badge); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }

.btn-icon {
  width: 34px; height: 34px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  background: var(--bg-badge);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.btn-icon.danger:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }
.btn-icon.warning:hover { background: var(--warning-light); color: var(--warning); border-color: var(--warning); }

/* -------------------------------------------------------------------
   Forms & Inputs
   ------------------------------------------------------------------- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-control::placeholder { color: var(--text-faint); }

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394a3b8'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}
select.form-control option { background: var(--bg-card); }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.input-group {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.input-group .form-control {
  border-radius: var(--radius) 0 0 var(--radius);
  flex: 1;
}
.input-group .btn {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: none;
}

.search-box {
  position: relative;
  flex: 1;
}
.search-box .search-icon {
  position: absolute;
  left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-faint);
  pointer-events: none;
}
.search-box .form-control { padding-left: 38px; }

.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.75rem; color: var(--danger); margin-top: 4px; display: none; }
.form-error.show { display: block; }

/* Toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle {
  position: relative;
  width: 40px; height: 22px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  left: 3px; top: 3px;
  transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* -------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------- */
.table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead { background: var(--bg-table-header); }
thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-table-row-hover); }

tbody td {
  padding: 13px 16px;
  color: var(--text-secondary);
  vertical-align: middle;
}

td .item-cell { display: flex; align-items: center; gap: 10px; }
td .item-thumb {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-badge);
  object-fit: cover;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
}
td .item-thumb svg { width: 18px; height: 18px; }
td .item-name { font-weight: 500; color: var(--text-primary); font-size: 0.875rem; }
td .item-code { font-size: 0.75rem; color: var(--text-muted); font-family: monospace; }

td .action-btns { display: flex; gap: 6px; align-items: center; }

/* -------------------------------------------------------------------
   Pagination
   ------------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-table-header);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.pagination-btns { display: flex; gap: 4px; }
.page-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 0.82rem;
  transition: var(--transition);
}
.page-btn:hover, .page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* -------------------------------------------------------------------
   Badges / Status
   ------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info    { background: var(--info-light); color: var(--info); }
.badge-muted   { background: var(--bg-badge); color: var(--text-muted); }

/* -------------------------------------------------------------------
   Filters / Toolbar
   ------------------------------------------------------------------- */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.view-toggle .vt-btn {
  width: 36px; height: 36px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.view-toggle .vt-btn svg { width: 16px; height: 16px; }
.view-toggle .vt-btn.active { background: var(--primary); color: white; }

/* -------------------------------------------------------------------
   Empty State
   ------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; margin: 0 auto 16px; opacity: 0.4; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 0.875rem; }

/* -------------------------------------------------------------------
   Charts area
   ------------------------------------------------------------------- */
.chart-wrap { position: relative; }
.chart-wrap canvas { max-height: 280px; }

/* -------------------------------------------------------------------
   Item Card (Grid view)
   ------------------------------------------------------------------- */
.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
}
.item-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-light); }
.item-card-img {
  width: 100%; height: 160px;
  background: var(--bg-badge);
  object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
}
.item-card-img svg { width: 48px; height: 48px; }
.item-card-body { padding: 14px; }
.item-card-name { font-weight: 600; color: var(--text-primary); font-size: 0.9rem; margin-bottom: 4px; }
.item-card-code { font-family: monospace; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 10px; }
.item-card-meta {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px;
}
.item-card-actions { display: flex; gap: 8px; }
.item-card-actions .btn { flex: 1; justify-content: center; }

/* -------------------------------------------------------------------
   Timeline / Activity
   ------------------------------------------------------------------- */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.activity-dot svg { width: 15px; height: 15px; }
.activity-dot.primary { background: var(--primary-light); color: var(--primary); }
.activity-dot.info { background: var(--info-light); color: var(--info); }
.activity-dot.warning { background: var(--warning-light); color: var(--warning); }
.activity-dot.danger { background: var(--danger-light); color: var(--danger); }
.activity-dot.success { background: var(--success-light); color: var(--success); }

.activity-body { flex: 1; min-width: 0; }
.activity-text { font-size: 0.84rem; color: var(--text-secondary); line-height: 1.5; }
.activity-text strong { color: var(--text-primary); font-weight: 600; }
.activity-time { font-size: 0.74rem; color: var(--text-faint); margin-top: 2px; }

/* -------------------------------------------------------------------
   Notification items
   ------------------------------------------------------------------- */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.notif-item:hover { background: var(--bg-card-hover); }
.notif-item.unread { background: var(--primary-light); }
.notif-item.unread:hover { background: rgba(16, 185, 129, 0.2); }
.notif-item:last-child { border-bottom: none; }
.notif-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.notif-icon svg { width: 17px; height: 17px; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 0.84rem; font-weight: 600; color: var(--text-primary); }
.notif-text { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.notif-time { font-size: 0.72rem; color: var(--text-faint); margin-top: 4px; }
.unread-dot {
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 8px;
}

/* -------------------------------------------------------------------
   Overdue Alert
   ------------------------------------------------------------------- */
.overdue-list { display: flex; flex-direction: column; gap: 10px; }
.overdue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--danger-light);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius);
}
.overdue-info { flex: 1; min-width: 0; }
.overdue-name { font-size: 0.84rem; font-weight: 600; color: var(--text-primary); }
.overdue-detail { font-size: 0.77rem; color: var(--text-muted); margin-top: 2px; }
.overdue-days {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--danger);
  white-space: nowrap;
}

/* -------------------------------------------------------------------
   Loan Form Steps
   ------------------------------------------------------------------- */
.steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 28px;
}
.step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  position: relative;
}
.step:not(:last-child)::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 10px;
  border-radius: 999px;
}
.step.done:not(:last-child)::after,
.step.active:not(:last-child)::after {
  background: var(--primary);
}
.step-num {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: var(--transition);
}
.step.active .step-num { border-color: var(--primary); color: var(--primary); }
.step.done .step-num { background: var(--primary); border-color: var(--primary); color: white; }
.step-label { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.step.active .step-label { color: var(--primary); font-weight: 600; }
.step.done .step-label { color: var(--text-secondary); }

/* -------------------------------------------------------------------
   QR Code display
   ------------------------------------------------------------------- */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  background: white;
  border-radius: var(--radius);
  width: fit-content;
  margin: 0 auto;
}
.qr-container p { font-size: 0.8rem; color: #475569; font-weight: 600; font-family: monospace; }

/* -------------------------------------------------------------------
   Scan area
   ------------------------------------------------------------------- */
.scan-box {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.scan-box:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.scan-box svg { width: 40px; height: 40px; margin: 0 auto 10px; }
.scan-box p { font-size: 0.875rem; }

/* -------------------------------------------------------------------
   Photo upload
   ------------------------------------------------------------------- */
.photo-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.photo-upload:hover { border-color: var(--primary); background: var(--primary-light); }
.photo-upload input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.photo-upload svg { width: 36px; height: 36px; color: var(--text-faint); margin: 0 auto 8px; }
.photo-upload p { font-size: 0.84rem; color: var(--text-muted); }
.photo-preview {
  width: 100%; height: 140px;
  object-fit: cover;
  border-radius: var(--radius);
  display: none;
}

/* -------------------------------------------------------------------
   Tabs
   ------------------------------------------------------------------- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  gap: 0;
}
.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: -2px;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-content > div { display: none; }
.tab-content > div.active { display: block; }

/* -------------------------------------------------------------------
   Responsive — Tablet
   ------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
  :root { --sidebar-width: var(--sidebar-collapsed); }
  .sidebar-brand .brand-text { display: none; }
  .nav-label { display: none; }
  .nav-badge { display: none; }
  .nav-section-label { display: none; }
  .user-info { display: none; }
  .sidebar-footer { padding: 10px 6px; }
  .sidebar-brand { justify-content: center; padding: 18px 10px; }
}

/* -------------------------------------------------------------------
   Responsive — Mobile
   ------------------------------------------------------------------- */
@media (max-width: 768px) {
  :root { --header-height: 56px; }
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
    z-index: 200;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar .brand-text { display: block; }
  .sidebar .nav-label { display: block; opacity: 1; width: auto; }
  .sidebar .nav-badge { display: inline-flex; opacity: 1; }
  .sidebar .nav-section-label { display: block; opacity: 1; }
  .sidebar .user-info { display: block; opacity: 1; width: auto; }

  .mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 199;
  }
  .mobile-overlay.show { display: block; }

  .main-content { margin-left: 0 !important; }
  .page-content { padding: 16px; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3, .grid-4, .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .table-toolbar { flex-wrap: wrap; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .steps { flex-wrap: wrap; gap: 8px; }
  .step:not(:last-child)::after { display: none; }
}

@media (max-width: 480px) {
  .stat-cards { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
}

/* -------------------------------------------------------------------
   Animations
   ------------------------------------------------------------------- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

.fade-in { animation: fadeIn 0.3s ease forwards; }
.slide-in { animation: slideIn 0.3s ease forwards; }
.pop-in { animation: popIn 0.2s ease forwards; }

/* Stagger children */
.stagger > * { animation: fadeIn 0.3s ease both; }
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-badge) 25%, var(--bg-card-hover) 50%, var(--bg-badge) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: var(--radius);
}
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* -------------------------------------------------------------------
   Dark / Light mode transition
   ------------------------------------------------------------------- */
*, body { transition-property: background-color, border-color, color; transition-duration: 0.25s; transition-timing-function: ease; }
/* Exclude transforms from slowing down */
.btn, .stat-card, .item-card, .nav-item, .sidebar { transition: var(--transition-slow); }
