/* Battery Inventory - Professional Mobile-Friendly Design System */
:root {
  --primary: #0d47a1;
  --primary-light: #1565c0;
  --primary-dark: #002171;
  --accent: #ff8f00;
  --accent-light: #ffb74d;
  --success: #2e7d32;
  --warning: #ed6c02;
  --danger: #c62828;
  --surface: #f8fafc;
  --surface-card: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #f1f5f9;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --radius: 8px;
  --radius-lg: 12px;
  --nav-height: 56px;
  --sidebar-width: 260px;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--surface); color: var(--text-primary); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app-wrap { display: flex; min-height: 100vh; flex-direction: column; }
@media (min-width: 768px) { .app-wrap { flex-direction: row; } }

/* Top bar - mobile first */
.topbar {
  height: var(--nav-height);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}
.topbar h1 { font-size: 1.1rem; font-weight: 600; margin: 0; }
.topbar .menu-toggle {
  background: none;
  border: none;
  color: white;
  padding: 0.5rem;
  cursor: pointer;
  font-size: 1.25rem;
}
@media (min-width: 768px) { .topbar .menu-toggle { display: none; } }

/* Sidebar */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  width: 100%;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.sidebar.open { max-height: 80vh; }
@media (min-width: 768px) {
  .sidebar {
    width: var(--sidebar-width);
    max-height: none;
    min-height: calc(100vh - var(--nav-height));
    flex-shrink: 0;
  }
}
.sidebar nav { padding: 1rem 0; }
.sidebar a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.2s, color 0.2s;
}
.sidebar a:hover { background: rgba(255,255,255,0.06); color: white; }
.sidebar a.active { background: rgba(255,255,255,0.08); color: var(--sidebar-active); border-left-color: var(--accent); }
.sidebar .nav-icon { font-size: 1.2rem; opacity: 0.9; }

/* Main content */
.main { flex: 1; padding: 1rem; overflow-x: auto; }
@media (min-width: 768px) { .main { padding: 1.5rem 2rem; } }

.page-title { font-size: 1.5rem; font-weight: 700; margin: 0 0 1rem; color: var(--text-primary); }
.page-subtitle { color: var(--text-secondary); margin: -0.5rem 0 1rem; font-size: 0.95rem; }

/* Cards */
.card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.card-title { font-size: 1.1rem; font-weight: 600; margin: 0; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.05s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-light); color: #1e293b; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { background: var(--surface); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* Filters bar */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.filter-group { display: flex; flex-direction: column; gap: 0.25rem; min-width: 120px; }
.filter-group label { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); }
.filter-group input,
.filter-group select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: white;
}
.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(13, 71, 161, 0.2);
}

/* Tables - responsive */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--surface); font-weight: 600; color: var(--text-secondary); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; white-space: nowrap; }
tr:hover { background: rgba(13, 71, 161, 0.04); }
@media (max-width: 640px) {
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.75rem; padding: 0.75rem; background: white; }
  td { padding: 0.35rem 0; border: none; display: flex; justify-content: space-between; gap: 1rem; }
  td::before { content: attr(data-label); font-weight: 600; color: var(--text-secondary); flex-shrink: 0; }
}

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.stat-card.accent { border-left-color: var(--accent); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card .value { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }
.stat-card .label { font-size: 0.85rem; color: var(--text-secondary); margin-top: 0.25rem; }

/* Forms */
.form-grid { display: grid; gap: 1rem; }
@media (min-width: 640px) { .form-grid { grid-template-columns: repeat(2, 1fr); } }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group label { font-size: 0.9rem; font-weight: 500; color: var(--text-primary); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
}
.badge-success { background: #dcfce7; color: var(--success); }
.badge-warning { background: #fff4e6; color: var(--warning); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-info { background: #e0f2fe; color: var(--primary); }

/* Mobile spacing */
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Utility */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
