/* ==========================================================================
   Uniform Stock Management System - CSS
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;

  --secondary: #475569;
  --secondary-light: #f1f5f9;

  --success: #059669;
  --success-light: #ecfdf5;
  --success-border: #a7f3d0;

  --warning: #d97706;
  --warning-light: #fffbeb;
  --warning-border: #fde68a;

  --danger: #dc2626;
  --danger-light: #fef2f2;
  --danger-border: #fecaca;

  --info: #0284c7;
  --info-light: #f0f9ff;
  --info-border: #bae6fd;

  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
  overflow-y: auto;
}

.sync-status-bar {
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sync-status-inner {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: #94a3b8;
}

.sync-dot.online { background: var(--success); box-shadow: 0 0 0 3px var(--success-light); }
.sync-dot.syncing { background: var(--warning); animation: syncPulse 1s infinite alternate; }
.sync-dot.offline { background: #94a3b8; }

@keyframes syncPulse { to { opacity: 0.35; } }

.sync-now-btn {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0 6px 12px;
}

.cloud-settings-card {
  border: 1px solid var(--primary-border);
  background: var(--primary-light);
  padding: 14px;
  border-radius: var(--radius-md);
}

.cloud-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.cloud-settings-status {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-search { max-width: 320px; }

/* Container */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header & Nav */
header.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 22px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.brand-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

/* Navigation Tabs */
.nav-tabs-wrapper {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}

.nav-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 6px 0;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.925rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.tab-btn:hover {
  background: var(--secondary-light);
  color: var(--text-main);
}

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

.tab-badge {
  background: #e2e8f0;
  color: #475569;
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.tab-btn.active .tab-badge {
  background: var(--primary);
  color: white;
}

.inventory-category-summary {
  display: flex;
  gap: 10px;
  margin: 0 0 16px;
  padding: 2px 0 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.inventory-category-card {
  display: flex;
  min-width: 165px;
  padding: 13px 15px;
  flex: 1 0 165px;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.inventory-category-card:hover,
.inventory-category-card.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.inventory-category-name { color: var(--text-muted); font-size: .82rem; }
.inventory-category-card strong { color: var(--primary); font-size: 1.15rem; }
.inventory-category-card small { color: var(--text-muted); }

/* Main Content */
main.main-content {
  padding: 1.5rem 0 3rem 0;
}

.movement-shortcuts {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 1rem;
  padding: 16px 18px;
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #eff6ff, #ecfdf5);
  box-shadow: var(--shadow-sm);
}

.movement-shortcuts strong { font-size: 1rem; }
.movement-shortcuts p { margin-top: 2px; color: var(--text-muted); font-size: 0.82rem; }
.movement-shortcut-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Summary Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

#dashboard-stats .stat-card {
  cursor: pointer;
}

#dashboard-stats .stat-card:hover,
#dashboard-stats .stat-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

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

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.stat-card.stat-blue::before { background: var(--primary); }
.stat-card.stat-green::before { background: var(--success); }
.stat-card.stat-orange::before { background: var(--warning); }
.stat-card.stat-red::before { background: var(--danger); }

.stat-info .stat-label {
  font-size: 0.825rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-info .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.stat-info .stat-sub {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-blue .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-green .stat-icon { background: var(--success-light); color: var(--success); }
.stat-orange .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-red .stat-icon { background: var(--danger-light); color: var(--danger); }

/* Progress Card */
.progress-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

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

.progress-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.progress-pct {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
}

.progress-bar-bg {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb 0%, #10b981 100%);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.progress-details {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Toolbar & Filter Bar */
.toolbar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

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

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

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.filter-select {
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--bg-card);
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

.filter-select:focus {
  border-color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
  background: var(--secondary-light);
  color: var(--secondary);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover {
  background: #047857;
}

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

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

.btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.btn-icon-only {
  padding: 8px;
  border-radius: var(--radius-md);
}

/* Uniform Inventory Table */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

table.data-table th {
  background: #f8fafc;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--secondary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

table.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

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

/* Item Cell formatting */
.item-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: #e0e7ff;
  color: #4338ca;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 600;
  flex-shrink: 0;
}

.item-title {
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 2px;
}

.item-sku {
  font-size: 0.775rem;
  color: var(--text-muted);
  font-family: monospace;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-size {
  background: #e2e8f0;
  color: #334155;
  font-family: monospace;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 9px;
}

.badge-cat {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.badge-location {
  background: #f1f5f9;
  color: #64748b;
}

/* Counting status badges */
.badge-match {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-deficit {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.badge-surplus {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.badge-uncounted {
  background: #f1f5f9;
  color: #64748b;
  border: 1px dashed #cbd5e1;
}

/* Quick Counter Controls */
.quick-counter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.counter-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: white;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

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

.counter-btn-step {
  font-size: 0.725rem;
  padding: 0 4px;
  width: auto;
  min-width: 32px;
}

.counter-input {
  width: 54px;
  height: 28px;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  outline: none;
}

.counter-input:focus {
  border-color: var(--primary);
  background: white;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(0.98);
  transition: transform 0.2s ease;
}

.modal-backdrop.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  background: var(--secondary-light);
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

/* Forms */
.form-group {
  margin-bottom: 1.15rem;
}

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

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--danger);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  background: white;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Checkbox pill selector for bulk sizes */
.size-checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.size-pill-label {
  cursor: pointer;
}

.size-pill-label input[type="checkbox"] {
  display: none;
}

.size-pill-box {
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #f8fafc;
  font-weight: 600;
  font-size: 0.85rem;
  transition: var(--transition);
}

.size-pill-label input[type="checkbox"]:checked + .size-pill-box {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.3);
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0f172a;
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease-out;
}

.toast.success { background: #065f46; border-left: 4px solid #10b981; }
.toast.danger { background: #991b1b; border-left: 4px solid #ef4444; }
.toast.warning { background: #92400e; border-left: 4px solid #f59e0b; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Scanner Video Area */
.scanner-viewport {
  position: relative;
  width: 100%;
  height: 280px;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-reader {
  width: 100%;
  height: 100%;
}

.scanner-reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

.scanner-reader img {
  display: none !important;
}

.scanner-overlay {
  position: absolute;
  width: 200px;
  height: 140px;
  border: 2px dashed #38bdf8;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

/* Print Specific Styles */
@media print {
  body {
    background: white;
    color: black;
    font-size: 11pt;
  }

  header.app-header,
  .nav-tabs-wrapper,
  .toolbar-card,
  .header-actions,
  .quick-counter,
  .btn,
  #toast-container,
  .no-print {
    display: none !important;
  }

  main.main-content {
    padding: 0;
  }

  .print-only {
    display: block !important;
  }

  .table-card {
    border: none;
    box-shadow: none;
  }

  table.data-table th, table.data-table td {
    border: 1px solid #94a3b8;
    padding: 8px 10px;
    font-size: 10pt;
  }

  .print-header {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #334155;
    padding-bottom: 12px;
  }

  .print-signatures {
    margin-top: 40px;
    display: flex;
    justify-content: space-between;
    page-break-inside: avoid;
  }

  .sign-box {
    text-align: center;
    width: 200px;
  }

  .sign-line {
    border-bottom: 1px dotted #000;
    margin-top: 45px;
    margin-bottom: 6px;
  }
}

.print-only {
  display: none;
}

.movement-search-results {
  display: none;
  max-height: 280px;
  margin: -2px 0 6px;
  overflow-y: auto;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.movement-search-results.is-visible { display: block; }

.movement-search-result {
  display: flex;
  width: 100%;
  padding: 11px 12px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
  color: #0f172a;
  text-align: left;
  cursor: pointer;
}

.movement-search-result:last-child { border-bottom: 0; }
.movement-search-result:hover, .movement-search-result:focus { background: #eff6ff; outline: 2px solid #2563eb; outline-offset: -2px; }
.movement-result-main { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.movement-result-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.movement-result-meta { flex: 0 0 auto; color: #475569; font-size: .82rem; }
.movement-search-empty { padding: 14px; color: #b91c1c; text-align: center; }
.movement-search-count { min-height: 20px; margin: 0 2px 7px; color: #64748b; font-size: .82rem; }

body.auth-locked > :not(#auth-screen):not(script) { visibility: hidden; }
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: safe center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  background: linear-gradient(145deg,#eff6ff,#ecfdf5);
}
.auth-screen[hidden] { display: none; }
.auth-card { width: min(430px,100%); margin: auto; padding: 30px; border: 1px solid #dbeafe; border-radius: 22px; background: #fff; box-shadow: 0 24px 70px rgba(15,23,42,.16); }
.auth-mark { width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 18px; background: #2563eb; font-size: 30px; }
.auth-card h2,.auth-card > p { text-align: center; }
.auth-card > p { margin: 5px 0 20px; color: #64748b; }
.auth-form { display: grid; gap: 10px; }
.auth-form .btn { margin-top: 8px; }
.auth-notice,.user-help { color: #475569; font-size: .86rem; }
.auth-notice { padding: 10px; border-radius: 10px; background: #eff6ff; color: #1d4ed8; }
.auth-error { margin-top: 14px; padding: 10px; border-radius: 10px; color: #b91c1c; background: #fef2f2; }
.auth-loading { margin-top: 14px; text-align: center; color: #64748b; font-size: .86rem; }
.auth-optional { color: #64748b; font-size: .78rem; font-weight: 400; }
.login-mode-badge { width: fit-content; margin: -10px auto 16px; padding: 6px 14px; border-radius: 999px; background: #eff6ff; color: #1d4ed8; font-size: .78rem; font-weight: 700; letter-spacing: .08em; }
.login-mode-badge.is-admin { background: #fef3c7; color: #92400e; }
.user-chip { padding: 7px 10px; border: 1px solid #dbeafe; border-radius: 12px; background: #eff6ff; color: #1e40af; font-size: .78rem; white-space: nowrap; }
.user-create-grid { display: grid; grid-template-columns: 1fr 1.3fr 1.4fr auto; gap: 8px; align-items: center; }
.modal-users-content { max-width: 1050px; }
.users-table { min-width: 850px; }
.user-action-row { display: flex; gap: 5px; flex-wrap: wrap; }
.admin-hidden { display: none !important; }
.role-user [data-action="edit-item"], .role-user [data-action="delete-item"], .role-user [data-action="reconcile"] { display: none !important; }

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .container { padding-left: 12px; padding-right: 12px; }

  header.app-header { position: static; }

  .header-inner {
    height: auto;
    padding: 12px 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }

  .header-actions .btn { min-height: 44px; flex: 0 0 auto; }

  .brand-text h1 { font-size: 1rem; }
  .brand-text p { display: none; }

  .nav-tabs-wrapper {
    position: sticky;
    top: 0;
    z-index: 35;
    box-shadow: var(--shadow-sm);
  }

  .tab-btn { min-height: 46px; padding: 9px 13px; }

  main.main-content { padding-top: 1rem; }

  .movement-shortcuts { align-items: stretch; flex-direction: column; }
  .movement-shortcut-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .movement-shortcut-actions .btn { min-height: 48px; }

  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 1rem; }
  .stat-info .stat-value { font-size: 1.35rem; }
  .stat-icon { width: 36px; height: 36px; }

  .table-responsive { -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 900px; }
  .data-table th, .data-table td { padding: 10px 9px; }

  .quick-counter { flex-wrap: nowrap; }
  .counter-btn { min-width: 42px; min-height: 42px; }
  .counter-input { min-height: 42px; font-size: 16px; }

  .btn, .form-control, .filter-select { min-height: 44px; }
  input, select, textarea { font-size: 16px !important; }
  .movement-search-result { min-height: 54px; align-items: flex-start; flex-direction: column; gap: 4px; }
  .movement-result-meta { font-size: .8rem; }

  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-content {
    width: 100%;
    max-height: 92dvh;
    border-radius: 18px 18px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .modal-footer { position: sticky; bottom: 0; background: white; }

  .history-search { width: 100%; max-width: none; }

  #toast-container { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .toast { width: 100%; }

  .form-row {
    grid-template-columns: 1fr;
  }
  .auth-screen { display: block; }
  .auth-card { margin: 0 auto; padding: 22px 18px; }
  .user-create-grid { grid-template-columns: 1fr; }

  .toolbar-row {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    width: 100%;
  }

  .filter-select {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr; }
  .sync-status-text { max-width: 70%; }
}
