/* Gun Desk - Main Stylesheet */
/* Extracted from index.html for better maintainability */

/* ========================================
   CSS Variables
   ======================================== */
:root {
  --bg: #0b1220;
  --panel: #111827;
  --panel2: #0f172a;
  --card: #ffffff;
  --muted: #9ca3af;
  --text: #e5e7eb;
  --accent: #2563eb;
  --border: #e5e7eb;
}

/* ========================================
   Base Styles
   ======================================== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: #f3f4f6;
  color: #111827;
}

/* Skip link for keyboard navigation */
.skip-link:focus {
  position: fixed !important;
  left: 50% !important;
  top: 10px !important;
  transform: translateX(-50%);
  width: auto !important;
  height: auto !important;
  padding: 12px 24px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  overflow: visible !important;
}

/* ========================================
   Layout
   ======================================== */
.layout {
  display: flex;
  height: 100vh;
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
  width: 240px;
  min-width: 56px;
  background: var(--panel);
  color: var(--text);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  transition: width 0.2s ease;
  position: relative;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
  position: absolute;
  top: 12px;
  right: -12px;
  width: 24px;
  height: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text);
  z-index: 10;
  transition: transform 0.2s;
}

.sidebar-toggle:hover {
  background: var(--accent);
  color: #fff;
}

/* Nav Sections Container */
.nav-sections-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

/* Nav Section */
.nav-section {
  margin-bottom: 2px;
}

.nav-section.draggable {
  border-radius: 6px;
  transition: background 0.15s, transform 0.15s;
}

.nav-section.dragging {
  opacity: 0.8;
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.02);
  z-index: 100;
}

.nav-section.drag-over {
  border-top: 2px solid var(--accent);
}

/* Nav Section Header (with drag handle) */
.nav-section-header {
  display: flex;
  align-items: center;
  gap: 4px;
}

.drag-handle {
  cursor: grab;
  padding: 4px 2px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: -2px;
  opacity: 0.5;
  transition: opacity 0.15s;
  user-select: none;
}

.drag-handle:hover {
  opacity: 1;
  color: var(--text);
}

.drag-handle:active {
  cursor: grabbing;
}

/* Nav Icons */
.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  min-width: 20px;
  font-size: 14px;
  margin-right: 8px;
}

.nav-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Collapsed Sidebar */
.sidebar.collapsed {
  width: 56px;
  padding: 12px 4px;
}

.sidebar.collapsed .brand {
  display: none;
}

.sidebar.collapsed .drag-handle {
  display: none;
}

.sidebar.collapsed .nav-text {
  display: none;
}

.sidebar.collapsed .nav-icon {
  margin-right: 0;
}

.sidebar.collapsed .nav-section-toggle,
.sidebar.collapsed .nav-btn {
  justify-content: center;
  padding: 10px 8px;
}

.sidebar.collapsed .nav-section-toggle::before {
  display: none;
}

.sidebar.collapsed .nav-section-items {
  display: none !important;
}

.sidebar.collapsed .nav-section-header {
  justify-content: center;
  cursor: pointer;
}

.sidebar.collapsed .nav-section-toggle {
  cursor: pointer;
}

.sidebar.collapsed .nav-section-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.sidebar.collapsed .sidebar-footer {
  display: none;
}

.sidebar-toggle .toggle-icon {
  transition: transform 0.2s;
}

.sidebar.collapsed .sidebar-toggle .toggle-icon {
  transform: rotate(180deg);
}

/* Dashboard button special styling */
.nav-btn.dashboard-btn {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  margin-bottom: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
}

.sidebar.collapsed .nav-btn.dashboard-btn {
  padding: 10px;
}

.sidebar::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}

.brand h1 {
  font-size: 18px;
  margin: 0;
}

.brand small {
  color: var(--muted);
}

.nav-section {
  margin-bottom: 8px;
}

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 10px 0 4px;
}

.nav-section-toggle {
  flex: 1;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  font-weight: 600;
}

.nav-section-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-section-toggle.expanded::before {
  content: "▼";
  display: inline-block;
  width: 14px;
  font-size: 8px;
  margin-right: 4px;
}

.nav-section-toggle:not(.expanded)::before {
  content: "▶";
  display: inline-block;
  width: 14px;
  font-size: 8px;
  margin-right: 4px;
}

.nav-section-items {
  display: none;
  flex-direction: column;
  gap: 1px;
  margin-top: 2px;
  margin-left: 24px;
}

.nav-section-items.show {
  display: flex;
}

.nav-btn {
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-btn.active {
  background: var(--accent);
}

.nav-sub {
  padding-left: 8px;
  font-size: 12px;
  opacity: 0.9;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-size: 11px;
}

.sidebar-footer .footer-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1400;
}

/* ========================================
   Main Content Area
   ======================================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.topbar .title {
  font-weight: 700;
}

.topbar .pill {
  font-size: 12px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  padding: 3px 8px;
  border-radius: 999px;
  color: #3730a3;
}

.topbar input,
.topbar select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
}

.topbar input {
  flex: 1;
  min-width: 220px;
}

.content {
  flex: 1;
  display: flex;
  gap: 0;
  padding: 12px;
  min-height: 0;
}

/* ========================================
   Panes
   ======================================== */
.pane {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pane.left {
  flex: 1;
  min-width: 200px;
  border-radius: 10px 0 0 10px;
  border-right: none;
}

.pane.right {
  width: 380px;
  min-width: 150px;
  max-width: none;
  border-radius: 0 10px 10px 0;
}

/* Resizable Divider */
.resize-handle {
  width: 8px;
  background: #e5e7eb;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.resize-handle:hover,
.resize-handle.dragging {
  background: var(--primary, #5c6ac4);
}

.resize-handle::after {
  content: '';
  width: 3px;
  height: 40px;
  background: #a0aec0;
  border-radius: 3px;
}

.resize-handle:hover::after,
.resize-handle.dragging::after {
  background: #fff;
}

[data-theme="dark"] .resize-handle {
  background: #374151;
}

[data-theme="dark"] .resize-handle::after {
  background: #6b7280;
}

[data-theme="dark"] .resize-handle:hover,
[data-theme="dark"] .resize-handle.dragging {
  background: var(--primary, #3b82f6);
}

/* Details Panel Close Button */
.details-toggle {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 32px;
  height: 32px;
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #6b7280;
  z-index: 1002;
  transition: background 0.15s, color 0.15s;
}

.details-toggle:hover {
  background: #e5e7eb;
  color: #374151;
}

.pane.right {
  position: relative;
}

.pane.right.collapsed {
  width: 0;
  min-width: 0;
  max-width: 0;
  padding: 0;
  border: none;
  overflow: hidden;
}

.pane.right.collapsed .details-toggle {
  left: -24px;
  display: flex;
}

/* Floating toggle when panel is collapsed */
.details-toggle-floating {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 48px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px 0 0 6px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #637381;
  z-index: 5;
  box-shadow: -2px 0 4px rgba(0,0,0,0.1);
}

.details-toggle-floating:hover {
  background: #f4f5fa;
  color: #5c6ac4;
}

.details-toggle-floating.show {
  display: flex;
}

.pane-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pane-header h2 {
  margin: 0;
  font-size: 14px;
}

.pane-body {
  padding: 10px 12px;
  overflow: auto;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 600;
  cursor: pointer;
}

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

.btn.ghost {
  background: #fff;
  border: 1px solid var(--border);
}

.btn.danger {
  background: #b91c1c;
  color: #fff;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary,
.btn-secondary,
.btn-approve,
.btn-deny {
  padding: 10px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
}

.btn-secondary {
  background: #e5e7eb;
  color: #111;
}

.btn-approve {
  background: #059669;
  color: #fff;
}

.btn-deny {
  background: #dc2626;
  color: #fff;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary:hover {
  background: #d1d5db;
}

.btn-approve:hover {
  background: #047857;
}

.btn-deny:hover {
  background: #b91c1c;
}

/* ========================================
   Tables
   ======================================== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafc;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover {
  background: #f3f4f6;
}

/* ========================================
   Forms
   ======================================== */
label {
  font-size: 12px;
  color: #374151;
  display: block;
  margin-bottom: 4px;
}

input,
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
}

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

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

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* ========================================
   Cards & Utilities
   ======================================== */
.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.row .btn {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 10px 0;
}

.hint {
  font-size: 12px;
  color: #6b7280;
}

.muted {
  color: #6b7280;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f9fafb;
  font-size: 11px;
}

code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 6px;
}

.error {
  color: #b91c1c;
  background: #fee2e2;
  border: 1px solid #fecaca;
  padding: 8px;
  border-radius: 10px;
  font-size: 12px;
}

.ok {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  padding: 8px;
  border-radius: 10px;
  font-size: 12px;
}

/* ========================================
   Dashboard Styles
   ======================================== */
.dashboard-alerts {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.dashboard-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
}

.dashboard-alert.warning {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  color: #92400e;
}

.dashboard-alert.danger {
  background: #fee2e2;
  border: 1px solid #f87171;
  color: #991b1b;
}

.dashboard-alert.info {
  background: #dbeafe;
  border: 1px solid #60a5fa;
  color: #1e40af;
}

.dashboard-cards,
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.dashboard-card,
.kpi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.1s;
}

.dashboard-card:hover,
.kpi-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.dashboard-card.clickable,
.kpi-card.clickable {
  cursor: pointer;
}

.dashboard-card .card-icon,
.kpi-card .card-icon {
  font-size: 24px;
  margin-bottom: 8px;
}

.dashboard-card .card-value,
.kpi-card .card-value {
  font-size: 28px;
  font-weight: 700;
  color: #111827;
  line-height: 1.2;
}

.dashboard-card .card-label,
.kpi-card .card-label {
  font-size: 13px;
  color: #6b7280;
  margin-top: 4px;
}

.dashboard-card .card-sub,
.kpi-card .card-sub {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 8px;
}

.dashboard-section {
  margin-bottom: 24px;
}

.dashboard-section h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: #374151;
}

.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  background: #f9fafb;
  border-radius: 8px;
  font-size: 13px;
}

.activity-item .activity-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.activity-item .activity-content {
  flex: 1;
}

.activity-item .activity-time {
  font-size: 11px;
  color: #9ca3af;
  white-space: nowrap;
}

.license-expiry-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.license-expiry-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #f9fafb;
  border-radius: 8px;
  font-size: 13px;
}

.license-expiry-item.urgent {
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
}

.license-expiry-item.critical {
  background: #fee2e2;
  border-left: 3px solid #ef4444;
}

/* ========================================
   Login Modal
   ======================================== */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.login-overlay.active {
  display: flex;
}

.login-modal {
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
}

.login-modal h2 {
  margin-top: 0;
  color: #111827;
}

.login-modal .btn {
  width: 100%;
  margin-top: 16px;
}

/* ========================================
   User Info
   ======================================== */
.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: #6b7280;
  font-size: 12px;
}

.user-info button {
  background: transparent;
  border: none;
  color: #2563eb;
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  text-decoration: underline;
}

/* ========================================
   Picker Component
   ======================================== */
.picker {
  position: relative;
}

.picker-list {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  max-height: 260px;
  overflow: auto;
  z-index: 50;
  margin-top: 6px;
  display: none;
}

.picker-item {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.picker-item:last-child {
  border-bottom: none;
}

.picker-item:hover {
  background: #f3f4f6;
}

.picker-item .small {
  font-size: 11px;
  color: #6b7280;
}

/* ========================================
   Tree View
   ======================================== */
.tree-view {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tree-item {
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tree-item:hover {
  background: #f3f4f6;
}

.tree-item.expandable::before {
  content: "▶";
  display: inline-block;
  width: 16px;
}

.tree-item.expandable.expanded::before {
  content: "▼";
}

.tree-item.leaf::before {
  content: "•";
  display: inline-block;
  width: 16px;
  color: var(--accent);
}

.tree-item.level-0 {
  padding-left: 12px;
  font-weight: 600;
  color: var(--accent);
}

.tree-item.level-1 {
  padding-left: 28px;
  font-weight: 500;
}

.tree-item.level-2 {
  padding-left: 44px;
}

.tree-item.level-3 {
  padding-left: 60px;
  font-size: 13px;
}

.tree-item.grid-row {
  display: grid !important;
  padding-left: 0 !important;
}

.tree-children {
  display: none;
  flex-direction: column;
  gap: 0;
}

.tree-children.show {
  display: flex;
}

/* ========================================
   Dropdown
   ======================================== */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-btn {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dropdown-btn::after {
  content: "▼";
  font-size: 10px;
}

.dropdown.single-action .dropdown-btn::after {
  display: none;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  min-width: 200px;
  margin-top: 4px;
  display: none;
  z-index: 1000;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background: #f9fafb;
}

.dropdown-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 4px 0;
}

/* ========================================
   Notifications
   ======================================== */
.notification-bell {
  position: relative;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notification-bell:hover {
  background: #f3f4f6;
}

.notification-bell .bell-icon {
  font-size: 20px;
}

.notification-bell .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  padding: 0 4px;
}

.notification-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  width: 360px;
  max-height: 500px;
  margin-top: 8px;
  display: none;
  z-index: 1000;
}

.notification-dropdown.show {
  display: block;
}

.notification-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notification-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.notification-list {
  max-height: 400px;
  overflow-y: auto;
}

.notification-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background 0.15s;
}

.notification-item:hover {
  background: #f9fafb;
}

.notification-item.unread {
  background: #eff6ff;
}

.notification-item.unread:hover {
  background: #dbeafe;
}

.notification-item .title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}

.notification-item .message {
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
}

.notification-item .time {
  font-size: 11px;
  color: #999;
}

.notification-empty {
  padding: 24px;
  text-align: center;
  color: #999;
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: toastSlideIn 0.3s ease-out;
  pointer-events: auto;
  min-width: 280px;
}

.toast.exiting {
  animation: toastSlideOut 0.3s ease-out forwards;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
  margin-bottom: 2px;
}

.toast-message {
  font-size: 13px;
  color: #6b7280;
}

.toast-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #9ca3af;
  cursor: pointer;
  padding: 0;
  margin-left: 8px;
}

.toast-close:hover {
  color: #374151;
}

.toast.success {
  border-left: 4px solid #10b981;
}

.toast.success .toast-icon {
  color: #10b981;
}

.toast.error {
  border-left: 4px solid #ef4444;
}

.toast.error .toast-icon {
  color: #ef4444;
}

.toast.warning {
  border-left: 4px solid #f59e0b;
}

.toast.warning .toast-icon {
  color: #f59e0b;
}

.toast.info {
  border-left: 4px solid #3b82f6;
}

.toast.info .toast-icon {
  color: #3b82f6;
}

/* ========================================
   Filter Styles
   ======================================== */
.filter-pill {
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.filter-pill:hover {
  background: #0284c7;
  color: #fff;
}

.remove-filter-pill:hover {
  opacity: 0.75;
}

/* ========================================
   Shopify-style Firearm Filter Bar
   ======================================== */

.firearm-filter-bar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 14px;
}

.firearm-filter-search-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.firearm-filter-search-box {
  position: relative;
  flex: 1;
  min-width: 150px;
  max-width: 220px;
}

.firearm-filter-search-box .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: #919eab;
  pointer-events: none;
}

.firearm-filter-search-box input {
  width: 100%;
  padding: 6px 10px 6px 30px;
  border: 1px solid #c4cdd5;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.firearm-filter-search-box input::placeholder {
  color: #919eab;
}

.firearm-filter-search-box input:focus {
  outline: none;
  border-color: #5c6ac4;
  box-shadow: 0 0 0 2px rgba(92, 106, 196, 0.2);
}

.firearm-filter-dropdown-container {
  position: relative;
}

.firearm-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid #c4cdd5;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: #202223;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
}

.firearm-filter-btn:hover {
  background: #f6f6f7;
  border-color: #919eab;
}

.firearm-filter-btn.active {
  background: #f4f5fa;
  border-color: #5c6ac4;
  color: #5c6ac4;
}

.firearm-filter-btn .chevron {
  width: 12px;
  height: 12px;
  opacity: 0.6;
  transition: transform 0.2s;
}

.firearm-filter-btn.open .chevron {
  transform: rotate(180deg);
}

.firearm-filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: #5c6ac4;
  color: #fff;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
}

.firearm-filter-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: 1px solid #dfe3e8;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.05);
  min-width: 220px;
  max-height: 320px;
  z-index: 1000;
  overflow: hidden;
  flex-direction: column;
}

.firearm-filter-dropdown.show {
  display: flex;
}

.firearm-filter-dropdown-header {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f1f1;
  background: #fafbfb;
}

.firearm-filter-dropdown-search {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #c4cdd5;
  border-radius: 6px;
  font-size: 12px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.firearm-filter-dropdown-search::placeholder {
  color: #919eab;
}

.firearm-filter-dropdown-search:focus {
  outline: none;
  border-color: #5c6ac4;
  box-shadow: 0 0 0 2px rgba(92, 106, 196, 0.2);
}

.firearm-filter-dropdown-actions {
  padding: 6px 12px;
  border-bottom: 1px solid #f1f1f1;
  display: flex;
  gap: 12px;
}

.firearm-filter-dropdown-actions button {
  background: none;
  border: none;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}

.firearm-filter-dropdown-actions .select-all-btn {
  color: #5c6ac4;
}

.firearm-filter-dropdown-actions .select-all-btn:hover {
  text-decoration: underline;
}

.firearm-filter-dropdown-actions .clear-btn {
  color: #637381;
}

.firearm-filter-dropdown-actions .clear-btn:hover {
  color: #202223;
}

.firearm-filter-dropdown-options {
  flex: 1;
  overflow-y: auto;
  max-height: 200px;
  padding: 4px 0;
}

.firearm-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  color: #202223;
  transition: background 0.1s;
  justify-content: flex-start;
}

.firearm-filter-option:hover {
  background: #f9fafb;
}

.firearm-filter-checkbox {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  min-width: 14px;
  border: 1.5px solid #8c9196;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: all 0.15s ease;
  margin: 0;
}

.firearm-filter-checkbox:hover {
  border-color: #5c6ac4;
}

.firearm-filter-checkbox:checked {
  background: #5c6ac4;
  border-color: #5c6ac4;
}

.firearm-filter-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.firearm-filter-label {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.firearm-filter-dropdown-footer {
  padding: 12px 16px;
  border-top: 1px solid #f1f1f1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafbfb;
}

.firearm-filter-dropdown-footer .selection-count {
  font-size: 12px;
  color: #637381;
}

.firearm-filter-dropdown-footer .done-btn {
  padding: 8px 16px;
  background: #5c6ac4;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.firearm-filter-dropdown-footer .done-btn:hover {
  background: #4959bd;
}

.firearm-filter-selected-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 20px 0;
}

.firearm-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #e4e5e7;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  color: #202223;
  font-weight: 500;
}

.firearm-filter-tag .remove-filter-pill {
  background: transparent;
  border: none;
  color: #637381;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  font-size: 16px;
  line-height: 1;
  width: 18px;
  height: 18px;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s;
}

.firearm-filter-tag .remove-filter-pill:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #202223;
}

.filter-search-input {
  transition: all 0.15s ease;
}

.filter-search-input:hover {
  border-color: #0284c7;
}

.filter-search-input:focus {
  border-color: #0284c7;
  outline: none;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, outline-color 0.15s;
  justify-content: flex-start;
}

.filter-option:hover {
  background: #f8fafc;
}

.filter-option input[type="checkbox"] {
  margin: 0;
}

.filter-option span {
  text-align: left;
}

.filter-option:focus-within,
.filter-option:focus {
  outline: 2px solid #0284c7;
  outline-offset: 2px;
  border-radius: 8px;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

.filter-quick:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.filter-quick:focus {
  outline: 2px solid #0284c7;
  outline-offset: 2px;
}

#clear-filters-btn {
  transition: all 0.2s ease;
}

#clear-filters-btn:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

/* Shopify-style filter bar */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  flex-wrap: wrap;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: #fff;
  border: 1px solid #c4cdd5;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #202223;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
}

.filter-btn:hover {
  background: #f6f6f7;
  border-color: #919eab;
}

.filter-btn.active {
  background: #f4f5fa;
  border-color: #5c6ac4;
  color: #5c6ac4;
}

.filter-btn svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  transition: transform 0.2s;
}

.filter-btn.open svg {
  transform: rotate(180deg);
}

.filter-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid #dfe3e8;
  border-radius: 12px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.05);
  min-width: 280px;
  max-height: 400px;
  z-index: 1000;
  display: none;
  overflow: hidden;
}

.filter-dropdown.show {
  display: flex;
  flex-direction: column;
}

.filter-dropdown-header {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f1f1;
  background: #fafbfb;
}

.filter-dropdown-search {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #c4cdd5;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-dropdown-search::placeholder {
  color: #919eab;
}

.filter-dropdown-search:focus {
  outline: none;
  border-color: #5c6ac4;
  box-shadow: 0 0 0 2px rgba(92, 106, 196, 0.2);
}

.filter-dropdown-options {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  max-height: 260px;
}

.filter-dropdown-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  color: #202223;
  transition: background 0.1s;
}

.filter-dropdown-option:hover {
  background: #f9fafb;
}

.filter-dropdown-option input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid #c4cdd5;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.filter-dropdown-option input[type="checkbox"]:hover {
  border-color: #919eab;
}

.filter-dropdown-option input[type="checkbox"]:checked {
  background: #5c6ac4;
  border-color: #5c6ac4;
}

.filter-dropdown-option input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.filter-dropdown-option span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-dropdown-footer {
  padding: 12px 16px;
  border-top: 1px solid #f1f1f1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafbfb;
}

.filter-dropdown-footer button {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-dropdown-footer .apply-btn {
  background: #5c6ac4;
  color: #fff;
  border: none;
}

.filter-dropdown-footer .apply-btn:hover {
  background: #4959bd;
}

.filter-dropdown-footer .clear-btn {
  background: transparent;
  border: 1px solid #c4cdd5;
  color: #637381;
}

.filter-dropdown-footer .clear-btn:hover {
  background: #f1f2f3;
  border-color: #919eab;
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: #5c6ac4;
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
}

.filters-bar .search-box {
  flex: 1;
  min-width: 240px;
  max-width: 380px;
  position: relative;
}

.filters-bar .search-box::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23919eab'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
  background-size: contain;
  pointer-events: none;
}

.filters-bar .search-box input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid #c4cdd5;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.filters-bar .search-box input::placeholder {
  color: #919eab;
}

.filters-bar .search-box input:focus {
  outline: none;
  border-color: #5c6ac4;
  box-shadow: 0 0 0 2px rgba(92, 106, 196, 0.2);
}

.active-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: 8px;
}

.active-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #e4e5e7;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  color: #202223;
  font-weight: 500;
}

.active-filter-tag button {
  background: transparent;
  border: none;
  color: #637381;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  font-size: 16px;
  line-height: 1;
  width: 18px;
  height: 18px;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s;
}

.active-filter-tag button:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #202223;
}

.clear-all-filters {
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: #5c6ac4;
  font-weight: 500;
  transition: all 0.15s;
}

.clear-all-filters:hover {
  background: #f4f5fa;
  color: #4959bd;
}

/* Add filter button */
.add-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: transparent;
  border: 1px dashed #c4cdd5;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #637381;
  cursor: pointer;
  transition: all 0.15s ease;
}

.add-filter-btn:hover {
  background: #f6f6f7;
  border-color: #919eab;
  color: #202223;
}

/* Filter divider */
.filter-divider {
  width: 1px;
  height: 24px;
  background: #dfe3e8;
  margin: 0 4px;
}

/* ========================================
   Photo Gallery
   ======================================== */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #f3f4f6;
  cursor: move;
  transition: transform 0.2s, box-shadow 0.2s;
}

.photo-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.photo-item.dragging {
  opacity: 0.5;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-item .actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px;
}

.photo-item .actions button {
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

.photo-item .actions button:hover {
  background: rgba(0, 0, 0, 0.9);
}

.photo-upload-area {
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin: 16px 0;
}

.photo-upload-area:hover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.photo-upload-area input {
  display: none;
}

.photo-qr-modal {
  padding: 24px;
  text-align: center;
}

.photo-qr-modal img {
  max-width: 280px;
  margin: 20px auto;
}

/* ========================================
   Modal Styles
   ======================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
}

.modal-content h2 {
  margin-top: 0;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 3000;
}

/* ========================================
   Admin Panel
   ======================================== */
.admin-dealer-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.admin-dealer-card h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
}

.admin-dealer-card p {
  margin: 4px 0;
  font-size: 13px;
  color: #6b7280;
}

.admin-dealer-actions,
.request-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.admin-dealer-actions button,
.request-actions button {
  padding: 6px 12px;
  font-size: 12px;
}

.access-request-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.access-request-card p {
  margin: 4px 0;
  font-size: 13px;
}

.admin-add-dealer {
  margin-bottom: 20px;
}

/* ========================================
   Mobile Responsive
   ======================================== */
.mobile-only {
  display: none;
}

body.mobile .mobile-only {
  display: inline-flex;
}

body.mobile .layout {
  flex-direction: column;
  height: auto;
  min-height: 100vh;
}

body.mobile .topbar {
  flex-wrap: wrap;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 1200;
}

body.mobile .content {
  flex-direction: column;
}

body.mobile .pane.left,
body.mobile .pane.right {
  width: 100%;
  min-width: 0;
}

body.mobile .pane.right {
  margin-top: 10px;
}

body.mobile .sidebar {
  position: fixed;
  top: 0;
  left: -300px;
  bottom: 0;
  width: 260px;
  transition: left 0.2s ease;
  z-index: 1500;
}

body.mobile .sidebar.open {
  left: 0;
}

/* Removed: body.mobile .sidebar-backdrop display:block rule
   The JS controls backdrop visibility via inline style */

body.mobile .pane-body {
  max-height: none;
}

body.mobile #global-search {
  min-width: 0;
  flex: 1;
}

body.mobile .topbar .title {
  display: none;
}

/* ========================================
   CSS Media Query Responsive Enhancements
   ======================================== */

/* Tablet breakpoint (768px - 1024px) */
@media screen and (max-width: 1024px) {
  .sidebar {
    width: 220px;
  }

  .pane.left {
    width: 45%;
    min-width: 280px;
  }

  .content {
    padding: 10px;
    gap: 10px;
  }

  .two-col {
    gap: 8px;
  }

  th, td {
    padding: 6px;
    font-size: 11px;
  }
}

/* Mobile breakpoint (max 768px) */
@media screen and (max-width: 768px) {
  /* Force mobile layout */
  .layout {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    bottom: 0;
    width: 280px;
    transition: left 0.25s ease;
    z-index: 1500;
  }

  .sidebar.open {
    left: 0;
  }

  /* Only show backdrop when sidebar is open - JS toggles display via inline style */
  /* Remove the !important that was overriding JS display:none */

  .mobile-only {
    display: inline-flex !important;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
    position: sticky;
    top: 0;
    z-index: 1200;
  }

  .topbar .title {
    display: none;
  }

  .topbar input,
  .topbar select {
    font-size: 14px; /* Larger for touch */
    padding: 10px 12px;
  }

  #global-search {
    min-width: 0 !important;
    flex: 1;
    order: 10;
    width: 100%;
  }

  .content {
    flex-direction: column;
    padding: 8px;
    gap: 8px;
  }

  .pane.left,
  .pane.right {
    width: 100%;
    min-width: 0;
  }

  .pane.right {
    margin-top: 8px;
  }

  /* Two-column forms become single column on mobile */
  .two-col {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Table horizontal scroll wrapper */
  .pane-body {
    overflow-x: auto;
    max-height: none;
  }

  table {
    min-width: 600px; /* Force horizontal scroll for wide tables */
  }

  th, td {
    padding: 8px 6px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* Larger touch targets for buttons */
  .btn, button {
    min-height: 44px;
    padding: 10px 14px;
  }

  .nav-btn {
    padding: 12px 10px;
    min-height: 44px;
  }

  /* Modal improvements for mobile */
  .modal-content {
    width: 95%;
    max-width: 95%;
    max-height: 90vh;
    margin: 5vh auto;
  }

  /* Dashboard cards stack vertically */
  .dashboard-cards,
  .kpi-grid {
    grid-template-columns: 1fr !important;
  }

  /* Action buttons stack */
  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  /* Dropdown menus full width */
  .dropdown-menu {
    width: 100%;
    left: 0;
    right: 0;
  }

  /* User info hidden on small screens */
  .user-info {
    display: none;
  }

  /* Filter bar improvements */
  .filter-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .filter-bar select,
  .filter-bar input {
    flex: 1 1 calc(50% - 4px);
    min-width: 120px;
  }
}

/* Small mobile breakpoint (max 480px) */
@media screen and (max-width: 480px) {
  .topbar {
    padding: 6px 8px;
  }

  .content {
    padding: 6px;
  }

  .pane-header {
    padding: 8px 10px;
    flex-wrap: wrap;
  }

  .pane-body {
    padding: 8px 10px;
  }

  /* Very small screens: minimal padding */
  .modal-content {
    padding: 12px;
  }

  /* Notification bell adjustments */
  .notification-dropdown {
    width: calc(100vw - 20px);
    right: -10px;
  }

  /* Smaller font for dense data */
  th, td {
    font-size: 11px;
    padding: 6px 4px;
  }
}

/* Keyboard shortcut keys */
kbd {
  display: inline-block;
  padding: 3px 6px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.2;
  color: #374151;
  background-color: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  box-shadow: inset 0 -1px 0 #d1d5db;
}

/* Print responsive: hide navigation */
@media print {
  .sidebar,
  .topbar,
  .mobile-only,
  .notification-bell,
  .dropdown {
    display: none !important;
  }

  .layout {
    display: block;
  }

  .main {
    display: block;
  }

  .content {
    display: block;
    padding: 0;
  }

  .pane {
    border: none;
    box-shadow: none;
    page-break-inside: avoid;
  }

  .pane.left,
  .pane.right {
    width: 100%;
  }
}

/* Touch device enhancements */
@media (hover: none) and (pointer: coarse) {
  /* Larger clickable areas for touch */
  .btn, button {
    min-height: 44px;
  }

  .nav-btn {
    min-height: 48px;
  }

  tr.clickable td {
    padding: 12px 8px;
  }

  /* Remove hover states that don't work well on touch */
  tr.clickable:hover {
    background: transparent;
  }

  tr.clickable:active {
    background: #e5e7eb;
  }

  .nav-btn:hover {
    background: transparent;
  }

  .nav-btn:active {
    background: rgba(255, 255, 255, 0.1);
  }
}

/* High contrast / accessibility improvements */
@media (prefers-contrast: high) {
  :root {
    --border: #1f2937;
  }

  .btn.primary {
    background: #1d4ed8;
  }

  th {
    background: #e5e7eb;
  }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }

  .modal-content {
    animation: none;
  }

  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ========================================
   Dark Mode Theme
   ======================================== */
[data-theme="dark"] {
  --bg: #0b1220;
  --panel: #111827;
  --panel2: #0f172a;
  --card: #1f2937;
  --muted: #9ca3af;
  --text: #e5e7eb;
  --accent: #3b82f6;
  --border: #374151;
}

[data-theme="dark"] body {
  background: #0f172a;
  color: #e5e7eb;
}

[data-theme="dark"] .main {
  background: #1e293b;
}

[data-theme="dark"] .list-pane,
[data-theme="dark"] .detail-pane {
  background: #1e293b;
}

[data-theme="dark"] .card {
  background: #1f2937;
  border-color: #374151;
  color: #e5e7eb;
}

[data-theme="dark"] .topbar {
  background: #111827;
  border-color: #374151;
}

[data-theme="dark"] .topbar .pill {
  background: #1e3a5f;
  border-color: #3b82f6;
  color: #93c5fd;
}

[data-theme="dark"] #current-dealer-display {
  background: #1e3a5f !important;
  color: #93c5fd !important;
}

[data-theme="dark"] .search-container input {
  background: #374151;
  border-color: #4b5563;
  color: #e5e7eb;
}

[data-theme="dark"] .search-container input::placeholder {
  color: #9ca3af;
}

[data-theme="dark"] table thead th {
  background: #374151;
  color: #e5e7eb;
}

[data-theme="dark"] table tbody tr {
  border-color: #374151;
}

[data-theme="dark"] table tbody tr:hover {
  background: #374151;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #374151;
  border-color: #4b5563;
  color: #e5e7eb;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: #9ca3af;
}

[data-theme="dark"] label {
  color: #9ca3af;
}

[data-theme="dark"] .divider {
  background: #374151;
}

[data-theme="dark"] .hint {
  color: #9ca3af;
}

[data-theme="dark"] .tag {
  background: #374151;
  color: #e5e7eb;
}

[data-theme="dark"] .btn {
  background: #374151;
  color: #e5e7eb;
  border-color: #4b5563;
}

[data-theme="dark"] .btn.ghost {
  background: transparent;
  color: #9ca3af;
}

[data-theme="dark"] .btn.ghost:hover {
  background: #374151;
  color: #e5e7eb;
}

[data-theme="dark"] pre {
  background: #374151 !important;
  border-color: #4b5563 !important;
  color: #e5e7eb;
}

[data-theme="dark"] .alert {
  background: #374151;
  border-color: #4b5563;
}

[data-theme="dark"] .picker-list {
  background: #1f2937;
  border-color: #374151;
}

[data-theme="dark"] .picker-list div:hover {
  background: #374151;
}

/* Dark mode - pane backgrounds */
[data-theme="dark"] .pane {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .pane-header {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .pane-header h2 {
  color: #f1f5f9;
}

/* Dark mode - table improvements */
[data-theme="dark"] table {
  background: transparent;
}

[data-theme="dark"] table tbody td {
  color: #e2e8f0;
  border-color: #334155;
}

[data-theme="dark"] table tbody tr {
  background: transparent;
}

[data-theme="dark"] table tbody tr:nth-child(even) {
  background: rgba(51, 65, 85, 0.3);
}

[data-theme="dark"] table tbody tr:hover {
  background: rgba(59, 130, 246, 0.15);
}

/* Dark mode - sidebar */
[data-theme="dark"] .sidebar {
  background: #0f172a;
  border-color: #1e293b;
}

[data-theme="dark"] .sidebar .nav-section-header {
  color: #94a3b8;
}

[data-theme="dark"] .sidebar a {
  color: #cbd5e1;
}

[data-theme="dark"] .sidebar a:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #e2e8f0;
}

[data-theme="dark"] .sidebar a.active {
  background: var(--primary, #3b82f6);
  color: #fff;
}

/* Dark mode - dropdown menus */
[data-theme="dark"] .dropdown-menu {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .dropdown-menu a,
[data-theme="dark"] .dropdown-menu button {
  color: #e2e8f0;
}

[data-theme="dark"] .dropdown-menu a:hover,
[data-theme="dark"] .dropdown-menu button:hover {
  background: #334155;
}

/* Dark mode - status badges */
[data-theme="dark"] .status-badge {
  opacity: 0.9;
}

/* Dark mode - modals */
[data-theme="dark"] .modal-overlay {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .modal-overlay h2,
[data-theme="dark"] .modal-overlay h3 {
  color: #f1f5f9;
}

/* Dark mode - scrollbars */
[data-theme="dark"] ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
  background: #1e293b;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Dark mode - details toggle */
[data-theme="dark"] .details-toggle {
  background: #334155;
  color: #e2e8f0;
  border-color: #475569;
}

[data-theme="dark"] .details-toggle:hover {
  background: #475569;
}

/* Dark mode - pane body (details panel content) */
[data-theme="dark"] .pane-body {
  background: #1e293b;
  color: #e2e8f0;
}

[data-theme="dark"] #detail-pane {
  background: #1e293b;
}

/* Dark mode - section headers in details */
[data-theme="dark"] .section-header,
[data-theme="dark"] h3,
[data-theme="dark"] h4 {
  color: #94a3b8 !important;
}

/* Dark mode - field labels */
[data-theme="dark"] .field-label,
[data-theme="dark"] .detail-label,
[data-theme="dark"] small,
[data-theme="dark"] .hint {
  color: #64748b !important;
}

/* Dark mode - override inline styles for labels */
[data-theme="dark"] label {
  color: #94a3b8 !important;
}

[data-theme="dark"] .two-col label,
[data-theme="dark"] .pane-body label {
  color: #94a3b8 !important;
}

/* Dark mode - override inline h4 colors */
[data-theme="dark"] .pane-body h4,
[data-theme="dark"] #detail-pane h4 {
  color: #cbd5e1 !important;
}

/* Dark mode - two-col values */
[data-theme="dark"] .two-col div,
[data-theme="dark"] .pane-body div {
  color: #e2e8f0;
}

[data-theme="dark"] .two-col b,
[data-theme="dark"] .pane-body b,
[data-theme="dark"] .two-col strong,
[data-theme="dark"] .pane-body strong {
  color: #f1f5f9;
}

/* Dark mode - dividers in detail pane */
[data-theme="dark"] .pane-body .divider,
[data-theme="dark"] #detail-pane .divider {
  background: #334155;
}

/* Dark mode - field values */
[data-theme="dark"] .field-value,
[data-theme="dark"] .detail-value,
[data-theme="dark"] strong,
[data-theme="dark"] b {
  color: #f1f5f9;
}

/* Dark mode - row styling in details */
[data-theme="dark"] .row {
  color: #e2e8f0;
}

/* Dark mode - card inside details */
[data-theme="dark"] .card,
[data-theme="dark"] .info-card,
[data-theme="dark"] .detail-card {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

/* Dark mode - success/warning/error alerts */
[data-theme="dark"] .alert.success,
[data-theme="dark"] .success-alert {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
  color: #4ade80;
}

[data-theme="dark"] .alert.warning,
[data-theme="dark"] .warning-alert {
  background: rgba(234, 179, 8, 0.15);
  border-color: rgba(234, 179, 8, 0.3);
  color: #facc15;
}

[data-theme="dark"] .alert.error,
[data-theme="dark"] .error-alert {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* Dark mode - dividers and borders */
[data-theme="dark"] hr,
[data-theme="dark"] .divider {
  background: #334155;
  border-color: #334155;
}

/* Dark mode - buttons */
[data-theme="dark"] .btn {
  background: #334155;
  color: #e2e8f0;
  border-color: #475569;
}

[data-theme="dark"] .btn:hover {
  background: #475569;
}

[data-theme="dark"] .btn.primary {
  background: var(--primary, #3b82f6);
  color: #fff;
  border-color: var(--primary, #3b82f6);
}

[data-theme="dark"] .btn.primary:hover {
  background: #2563eb;
}

[data-theme="dark"] .btn.ghost {
  background: transparent;
  color: #94a3b8;
  border-color: #475569;
}

[data-theme="dark"] .btn.ghost:hover {
  background: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] .btn.danger {
  background: #dc2626;
  color: #fff;
}

/* Dark mode - tags/badges */
[data-theme="dark"] .tag,
[data-theme="dark"] .badge,
[data-theme="dark"] .status-badge {
  background: #334155;
  color: #e2e8f0;
  border-color: #475569;
}

/* Dark mode - filters bar */
[data-theme="dark"] .filters-bar {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .filters-bar .search-box input {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
}

[data-theme="dark"] .filters-bar .search-box input::placeholder {
  color: #94a3b8;
}

[data-theme="dark"] .filters-bar .search-box input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

[data-theme="dark"] .filters-bar .search-box::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
}

[data-theme="dark"] .filter-btn {
  background: #334155;
  color: #e2e8f0;
  border-color: #475569;
}

[data-theme="dark"] .filter-btn:hover,
[data-theme="dark"] .filter-btn.active {
  background: #475569;
}

/* Dark mode - active filter tags */
[data-theme="dark"] .active-filter-tag {
  background: #334155;
  color: #e2e8f0;
  border-color: #475569;
}

[data-theme="dark"] .active-filter-tag:hover {
  background: #475569;
}

/* Dark mode - Export button */
[data-theme="dark"] #export-list-btn {
  color: #e2e8f0;
  border-color: #475569;
}

/* Dark mode - link colors */
[data-theme="dark"] a {
  color: #60a5fa;
}

[data-theme="dark"] a:hover {
  color: #93c5fd;
}

/* Dark mode - dropdown results/autocomplete */
[data-theme="dark"] .search-results,
[data-theme="dark"] .autocomplete-results,
[data-theme="dark"] [id$="-results"] {
  background: #1e293b !important;
  border-color: #334155 !important;
}

/* Dark mode - inline styled elements override */
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:white"] {
  background: #1e293b !important;
}

[data-theme="dark"] [style*="color:#6b7280"],
[data-theme="dark"] [style*="color: #6b7280"],
[data-theme="dark"] [style*="color:#637381"],
[data-theme="dark"] [style*="color:#64748b"] {
  color: #94a3b8 !important;
}

/* Dark mode - PRN check status boxes */
[data-theme="dark"] [style*="background:#dcfce7"],
[data-theme="dark"] [style*="background:#d1fae5"] {
  background: rgba(34, 197, 94, 0.15) !important;
  border-color: rgba(34, 197, 94, 0.3) !important;
}

[data-theme="dark"] [style*="background:#fef3c7"],
[data-theme="dark"] [style*="background:#fef9c3"] {
  background: rgba(234, 179, 8, 0.15) !important;
  border-color: rgba(234, 179, 8, 0.3) !important;
}

[data-theme="dark"] [style*="background:#fee2e2"],
[data-theme="dark"] [style*="background:#fecaca"] {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
}

/* Theme toggle button */
.theme-toggle,
.layout-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: inherit;
  transition: background 0.2s, border-color 0.2s;
}

.theme-toggle:hover,
.layout-toggle:hover {
  background: rgba(255,255,255,0.1);
}

[data-theme="dark"] .theme-toggle,
[data-theme="dark"] .layout-toggle {
  border-color: #4b5563;
}

.layout-toggle {
  font-size: 12px;
  letter-spacing: 1px;
}

.layout-toggle.two-pane {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Two-pane mode - full width list, slide-over details */
body.two-pane-mode .pane.left {
  flex: 1;
  max-width: 100%;
  border-radius: 10px;
}

body.two-pane-mode .resize-handle {
  display: none;
}

body.two-pane-mode .details-toggle-floating {
  display: none !important;
}

/* Slide-over resize handle (left edge) */
.slide-resize-handle {
  display: none;
  position: absolute;
  left: 0;
  top: 0;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  background: transparent;
  z-index: 1001;
  transition: background 0.2s;
}

.slide-resize-handle:hover,
.slide-resize-handle.dragging {
  background: var(--primary);
}

[data-theme="dark"] .slide-resize-handle:hover,
[data-theme="dark"] .slide-resize-handle.dragging {
  background: var(--primary, #3b82f6);
}

body.two-pane-mode .pane.right.slide-open .slide-resize-handle {
  display: none;
}

/* Single-pane mode: list and detail are mutually exclusive */
body.two-pane-mode .pane.left {
  flex: 1;
  display: flex;
  border-radius: 10px;
}

body.two-pane-mode .pane.right {
  display: none !important;
  flex: 1;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  border-radius: 10px;
}

/* When detail is open, hide list and show detail */
body.two-pane-mode.detail-open .pane.left {
  display: none !important;
}

body.two-pane-mode.detail-open .pane.right {
  display: flex !important;
}

/* Full width detail content */
body.two-pane-mode .pane.right .pane-body {
  width: 100%;
  max-width: 100%;
  padding: 20px 24px;
  flex: 1;
}

body.two-pane-mode .pane.right .pane-header {
  border-bottom: 1px solid var(--border);
}

/* Hide the slide backdrop - not needed */
.slide-backdrop {
  display: none !important;
}

/* Full width mode for dashboard - hide right pane, expand left */
body.full-width-mode .pane.left {
  width: 100%;
  max-width: 100%;
}

body.full-width-mode .pane.right {
  display: none;
}

/* ========================================
   Vertical Mode - Stacked Layout
   ======================================== */
body.vertical-mode .content {
  flex-direction: column;
}

body.vertical-mode .pane.left {
  flex: 1;
  min-height: 200px;
  max-height: none;
  border-radius: 10px 10px 0 0;
  border-right: 1px solid var(--border);
  border-bottom: none;
  min-width: 100%;
}

body.vertical-mode .pane.right {
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  height: 50%;
  min-height: 150px;
  border-radius: 0 0 10px 10px;
  flex-shrink: 0;
}

body.vertical-mode .resize-handle {
  width: 100%;
  height: 8px;
  cursor: ns-resize;
  flex-direction: row;
}

body.vertical-mode .resize-handle::after {
  width: 40px;
  height: 3px;
}

body.vertical-mode .details-toggle {
  left: 50%;
  top: -12px;
  transform: translateX(-50%);
  width: 48px;
  height: 24px;
  border-radius: 6px 6px 0 0;
}

body.vertical-mode .details-toggle-floating {
  top: auto;
  bottom: 20px;
  right: 50%;
  transform: translateX(50%);
}

body.vertical-mode .pane.right.collapsed {
  height: 0;
  min-height: 0;
  padding: 0;
  border: none;
  overflow: hidden;
}

/* Dark mode - vertical mode */
[data-theme="dark"] body.vertical-mode .resize-handle {
  background: #374151;
}

/* Layout toggle - vertical state */
.layout-toggle.vertical {
  background: rgba(59, 130, 246, 0.2);
  border-color: #3b82f6;
}

/* ========================================
   Single-Pane Detail Mode (Focus Mode)
   ======================================== */
/* When viewing a detail form, hide nav and list to focus on the form */
body.single-pane-mode .sidebar {
  display: none;
}

body.single-pane-mode main .pane.left {
  display: none;
}

body.single-pane-mode main .pane.right {
  flex: 1;
  max-width: 100%;
  border-left: none;
}

body.single-pane-mode .resize-handle,
body.single-pane-mode .details-toggle,
body.single-pane-mode .details-toggle-floating {
  display: none;
}

/* Back button for single-pane mode */
.detail-back-button {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 16px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  color: #374151;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.detail-back-button:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
}

body.single-pane-mode .detail-back-button {
  display: flex;
}

/* Dark mode support */
[data-theme="dark"] .detail-back-button {
  background: #1f2937;
  border-color: #374151;
  color: #e5e7eb;
}

[data-theme="dark"] .detail-back-button:hover {
  background: #374151;
  border-color: #4b5563;
}

/* ========================================
   Form State Module
   ======================================== */
.unsaved-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  font-size: 13px;
  color: #92400e;
  animation: fadeSlideIn 0.2s ease-out;
}

.unsaved-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: #f59e0b;
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: bold;
}

.form-dirty {
  position: relative;
}

[data-theme="dark"] .unsaved-indicator {
  background: #422006;
  border-color: #d97706;
  color: #fcd34d;
}

[data-theme="dark"] .unsaved-icon {
  background: #d97706;
}

/* ========================================
   Loading States Module
   ======================================== */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.15s ease-out;
}

.loading-spinner {
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--accent, #2563eb);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-small {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #e5e7eb;
  border-top-color: var(--accent, #2563eb);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.loading-message {
  color: #6b7280;
  font-size: 14px;
  font-weight: 500;
}

.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #6b7280;
  font-size: 14px;
}

.btn-loading {
  pointer-events: none;
  opacity: 0.7;
}

/* Skeleton Loaders */
.skeleton-table,
.skeleton-form,
.skeleton-card,
.skeleton-list {
  animation: fadeIn 0.2s ease-out;
}

.skeleton-row,
.skeleton-header,
.skeleton-field,
.skeleton-title,
.skeleton-text,
.skeleton-label,
.skeleton-input,
.skeleton-avatar,
.skeleton-list-item {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-table .skeleton-row {
  height: 44px;
  margin-bottom: 8px;
}

.skeleton-table .skeleton-header {
  height: 40px;
  margin-bottom: 12px;
  background: linear-gradient(90deg, #e5e7eb 25%, #d1d5db 50%, #e5e7eb 75%);
  background-size: 200% 100%;
}

.skeleton-field {
  margin-bottom: 16px;
}

.skeleton-label {
  height: 14px;
  width: 100px;
  margin-bottom: 6px;
}

.skeleton-input {
  height: 38px;
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: 12px;
}

.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
}

.skeleton-text.short {
  width: 40%;
}

.skeleton-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  background: transparent;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-list-content {
  flex: 1;
}

.skeleton-list-content .skeleton-text {
  margin-bottom: 6px;
}

.skeleton-list-content .skeleton-text.short {
  width: 60%;
  margin-bottom: 0;
}

[data-theme="dark"] .loading-overlay {
  background: rgba(17, 24, 39, 0.9);
}

[data-theme="dark"] .loading-message,
[data-theme="dark"] .loading-inline {
  color: #9ca3af;
}

[data-theme="dark"] .spinner {
  border-color: #374151;
  border-top-color: var(--accent, #3b82f6);
}

[data-theme="dark"] .spinner-small {
  border-color: #374151;
  border-top-color: var(--accent, #3b82f6);
}

[data-theme="dark"] .skeleton-row,
[data-theme="dark"] .skeleton-field,
[data-theme="dark"] .skeleton-title,
[data-theme="dark"] .skeleton-text,
[data-theme="dark"] .skeleton-label,
[data-theme="dark"] .skeleton-input,
[data-theme="dark"] .skeleton-avatar {
  background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
  background-size: 200% 100%;
}

[data-theme="dark"] .skeleton-header {
  background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
  background-size: 200% 100%;
}

/* ========================================
   Validation Module
   ======================================== */
input.invalid,
select.invalid,
textarea.invalid {
  border-color: #ef4444 !important;
  background-color: #fef2f2;
}

input.invalid:focus,
select.invalid:focus,
textarea.invalid:focus {
  outline: 2px solid #ef4444;
  outline-offset: 1px;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

input.valid,
select.valid,
textarea.valid {
  border-color: #22c55e;
}

input.valid:focus,
select.valid:focus,
textarea.valid:focus {
  outline: 2px solid #22c55e;
  outline-offset: 1px;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.field-error {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #dc2626;
  font-size: 12px;
  margin-top: 4px;
  animation: fadeSlideIn 0.2s ease-out;
}

.field-error::before {
  content: '!';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  font-size: 10px;
  font-weight: bold;
  flex-shrink: 0;
}

[data-theme="dark"] input.invalid,
[data-theme="dark"] select.invalid,
[data-theme="dark"] textarea.invalid {
  background-color: #450a0a;
  border-color: #f87171 !important;
}

[data-theme="dark"] input.valid,
[data-theme="dark"] select.valid,
[data-theme="dark"] textarea.valid {
  border-color: #4ade80;
}

[data-theme="dark"] .field-error {
  color: #fca5a5;
}

[data-theme="dark"] .field-error::before {
  background: #f87171;
}

/* ========================================
   Focus Trap Module (no special styles needed)
   ======================================== */

/* ========================================
   Screen Reader Announcer Module
   ======================================== */
.sr-only,
.announcer-region {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
