/* ===========================
   Global Styles
   =========================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #1e1e2e 0%, #2a2a3e 100%);
  color: #e0e0e0;
  line-height: 1.6;
  min-height: 100vh;
  padding: 0;
  margin: 0;
}

/* ===========================
   Navigation Bar
   =========================== */
.navbar {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
}

.nav-brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: #4a9eff;
  padding: 15px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 70px;
}

.nav-logo {
  height: 40px;
  width: 40px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.nav-menu {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 5px;
}

.nav-item {
  position: relative;
}

.nav-item .nav-link {
  display: block;
  padding: 15px 20px;
  color: #a0a0a0;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  border-bottom: 3px solid transparent;
}

.nav-item .nav-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active .nav-link {
  color: #4a9eff;
  border-bottom-color: #4a9eff;
}

/* User Dropdown Menu */
.nav-item.dropdown {
  position: relative;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: rgba(30, 30, 46, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  min-width: 200px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  display: none;
  z-index: 1100;
  margin-top: 5px;
}

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

.dropdown-item {
  display: block;
  padding: 12px 20px;
  color: #e0e0e0;
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

.dropdown-item:hover {
  background: rgba(74, 158, 255, 0.2);
  color: #ffffff;
}

.dropdown-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
  margin: 5px 0;
}

.container {
  max-width: 1800px;
  margin: 0 auto;
  padding: 20px;
}

/* ===========================
   Header
   =========================== */
header {
  text-align: center;
  margin-bottom: 30px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

h1 {
  color: #ffffff;
  font-size: 2.5rem;
  margin-bottom: 10px;
}

h2 {
  color: #ffffff;
  font-size: 1.5rem;
  margin-bottom: 15px;
}

#statusBar {
  margin-top: 10px;
  font-size: 0.9rem;
  color: #a0a0a0;
}

/* ===========================
   Card Sections
   =========================== */
.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 25px;
  margin-bottom: 25px;
}

@media (max-width: 1200px) {
  .upload-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 25px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.instructions {
  color: #b0b0b0;
  margin-bottom: 15px;
  font-size: 0.95rem;
}

.instructions code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  color: #ffa500;
  font-family: 'Courier New', monospace;
}

/* ===========================
   Form Elements
   =========================== */
textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 12px;
  color: #e0e0e0;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  resize: vertical;
  margin-bottom: 15px;
}

textarea::placeholder {
  color: #666;
}

textarea:focus {
  outline: none;
  border-color: #4a9eff;
}

input[type="text"],
input[type="number"] {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 8px 10px;
  color: #e0e0e0;
  font-size: 0.9rem;
  width: 100%;
}

input[type="text"]:focus,
input[type="number"]:focus {
  outline: none;
  border-color: #4a9eff;
}

input[type="text"]:read-only {
  background: rgba(0, 0, 0, 0.5);
  color: #a0a0a0;
}

select {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 8px 10px;
  color: #e0e0e0;
  font-size: 0.9rem;
  cursor: pointer;
  width: 100%;
}

select option {
  background: #ffffff;
  color: #000000;
}

select:focus {
  outline: none;
  border-color: #4a9eff;
}

/* ===========================
   Buttons
   =========================== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, #4a9eff 0%, #357abd 100%);
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #5fadff 0%, #4a8ecf 100%);
}

.btn-success {
  background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
  color: white;
}

.btn-success:hover {
  background: linear-gradient(135deg, #32bc51 0%, #248f3d 100%);
}

.btn-danger {
  background: linear-gradient(135deg, #dc3545 0%, #a71d2a 100%);
  color: white;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #e74c5c 0%, #bd2130 100%);
}

.btn-secondary {
  background: linear-gradient(135deg, #6c757d 0%, #545b62 100%);
  color: white;
  padding: 10px 20px;
  font-size: 0.9rem;
}

.btn-secondary:hover {
  background: linear-gradient(135deg, #7d868f 0%, #5f666d 100%);
}

.btn-warning {
  background: linear-gradient(135deg, #ff8c00 0%, #cc7000 100%);
  color: white;
  padding: 6px 12px;
  font-size: 0.85rem;
  margin-right: 5px;
}

.btn-warning:hover {
  background: linear-gradient(135deg, #ffa31a 0%, #e68600 100%);
}

.btn-large {
  padding: 15px 40px;
  font-size: 1.1rem;
}

/* ===========================
   Order Controls
   =========================== */
.order-controls-with-notes {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 20px;
  margin-bottom: 20px;
  align-items: stretch;
}

@media (max-width: 1200px) {
  .order-controls-with-notes {
    grid-template-columns: 1fr;
  }
}

.order-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: stretch;
  height: 100%;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
}

.control-group label {
  font-size: 0.9rem;
  color: #b0b0b0;
  font-weight: 500;
}

.control-group input[type="number"],
.control-group select {
  width: 100%;
}

.order-controls .btn {
  width: 100%;
}

/* Quick Notes Compact */
.quick-notes-compact {
  background: transparent;
  border: none;
  padding: 0;
}

.notes-header-compact {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  font-size: 0.9rem;
  color: #b0b0b0;
  font-weight: 500;
  height: 21px;
}

.notes-header-compact label {
  font-size: 0.9rem;
  color: #b0b0b0;
  font-weight: 500;
  margin: 0;
}

.quick-notes-compact #notesSpreadsheet {
  /* Minimal styling - let Handsontable handle everything */
  width: 100%;
  max-width: 100%;
  min-height: 300px;
  overflow-x: auto;
}

.quick-notes-compact #notesSpreadsheet .handsontable {
  /* Minimal styling */
}

/* ===========================
   Status Messages
   =========================== */
.status-message {
  margin-top: 10px;
  padding: 10px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  display: none;
}

.status-message.show {
  display: block;
}

.status-message.success {
  background: rgba(40, 167, 69, 0.2);
  border: 1px solid rgba(40, 167, 69, 0.4);
  color: #5fdc7f;
}

.status-message.error {
  background: rgba(220, 53, 69, 0.2);
  border: 1px solid rgba(220, 53, 69, 0.4);
  color: #ff6b7a;
}

.status-message.info {
  background: rgba(74, 158, 255, 0.2);
  border: 1px solid rgba(74, 158, 255, 0.4);
  color: #7fb8ff;
}

/* ===========================
   Table
   =========================== */
.table-container {
  overflow-x: auto;
  margin: 20px 0;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(0, 0, 0, 0.2);
}

thead {
  background: rgba(255, 255, 255, 0.1);
}

th {
  padding: 12px 10px;
  text-align: left;
  font-weight: 600;
  color: #ffffff;
  font-size: 0.85rem;
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
  white-space: nowrap;
}

td {
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.85rem;
}

tbody tr {
  transition: background 0.2s ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

td input,
td select,
td textarea {
  font-size: 0.85rem;
  padding: 6px 8px;
}

td textarea.formatted-string {
  font-family: 'Courier New', monospace;
  resize: vertical;
  min-width: 250px;
  background: rgba(0, 0, 0, 0.5);
  color: #a0a0a0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

/* ===========================
   Submit Section
   =========================== */
.submit-section {
  text-align: center;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

/* ===========================
   Collapsible Sections
   =========================== */
.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  padding: 0.5rem 0;
}

.collapsible-header:hover h2 {
  color: #4a9eff;
}

.collapse-toggle {
  background: rgba(74, 158, 255, 0.2);
  border: 1px solid rgba(74, 158, 255, 0.4);
  color: #4a9eff;
  font-size: 1rem;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: bold;
}

.collapse-toggle:hover {
  background: rgba(74, 158, 255, 0.3);
  transform: scale(1.05);
}

.collapsible-content {
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.upload-section {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  padding: 1.5rem;
}

.upload-section h3 {
  color: #ffffff;
  font-size: 1.2rem;
  margin: 0 0 1rem 0;
}

/* ===========================
   Notes Spreadsheet
   =========================== */
.notes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.notes-header h3 {
  color: #ffffff;
  font-size: 1.2rem;
  margin: 0;
}

/* Handsontable Dark Theme Overrides */
#notesSpreadsheet .handsontable {
  color: #e0e0e0;
  font-family: inherit;
  font-size: 0.85rem;
  pointer-events: auto;
  max-width: 100%;
  width: 100%;
}

#notesSpreadsheet .handsontable td {
  background: rgba(30, 35, 50, 0.6);
  border-color: rgba(100, 110, 140, 0.3);
  color: #000000;
  cursor: cell;
  pointer-events: auto;
}

/* Alternating row colors - light red and light purple */
#notesSpreadsheet .handsontable tbody tr:nth-child(odd) td {
  background: rgba(220, 100, 100, 0.15);
}

#notesSpreadsheet .handsontable tbody tr:nth-child(even) td {
  background: rgba(180, 100, 220, 0.15);
}

#notesSpreadsheet .handsontable th {
  background: rgba(20, 25, 40, 0.8);
  color: #9ca3af;
  border-color: rgba(100, 110, 140, 0.3);
  font-size: 0.75rem;
  font-weight: 600;
  pointer-events: auto;
}

#notesSpreadsheet .handsontable td.current {
  background: rgba(74, 158, 255, 0.25);
  color: #000000;
}

#notesSpreadsheet .handsontable td.area {
  background: rgba(74, 158, 255, 0.12);
}

/* Style the input editor when editing a cell */
#notesSpreadsheet .handsontable .handsontableInput {
  color: #000000;
}

#notesSpreadsheet .handsontable textarea.handsontableInput {
  color: #000000;
}

/* Disable row hover highlight */
#notesSpreadsheet .handsontable tbody tr:hover td {
  background: inherit !important;
}

#notesSpreadsheet .handsontable tbody tr:nth-child(odd):hover td {
  background: rgba(220, 100, 100, 0.15) !important;
}

#notesSpreadsheet .handsontable tbody tr:nth-child(even):hover td {
  background: rgba(180, 100, 220, 0.15) !important;
}

#notesSpreadsheet .handsontable .wtBorder {
  border-color: #4a9eff;
}

#notesSpreadsheet .handsontable .htDimmed {
  color: #b0b0b0;
}

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

/* ===========================
   Orders Page Specific
   =========================== */
.orders-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.orders-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.date-filter-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.date-filter-buttons .btn {
  padding: 8px 16px;
  font-size: 0.9rem;
}

.date-filter-buttons .btn.active {
  background: linear-gradient(135deg, #5fadff 0%, #4a8ecf 100%);
  box-shadow: 0 2px 8px rgba(74, 158, 255, 0.4);
}

.custom-date-range {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}

.custom-date-range span {
  color: #a0a0a0;
  font-size: 0.9rem;
}

.date-input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 6px 10px;
  color: #e0e0e0;
  font-size: 0.9rem;
}

.date-input:focus {
  outline: none;
  border-color: #4a9eff;
}

.stats-container {
  margin: 20px 0;
  padding: 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stat-label {
  color: #a0a0a0;
  font-size: 0.85rem;
  font-weight: 500;
}

.stat-value {
  color: #ffffff;
  font-size: 1.5rem;
  font-weight: 700;
}

.profit-positive {
  color: #5fdc7f;
}

.profit-negative {
  color: #ff6b7a;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #a0a0a0;
  font-size: 1.1rem;
}

/* Order edit inputs in table */
.order-edit-input,
.order-edit-select {
  width: 100%;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.order-edit-input:focus,
.order-edit-select:focus {
  outline: none;
  border-color: #4a9eff;
  background: rgba(0, 0, 0, 0.5);
}

.order-edit-input[type="number"] {
  text-align: right;
}

.order-edit-select {
  cursor: pointer;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

.badge-empty {
  background: rgba(160, 160, 160, 0.2);
  color: #a0a0a0;
}

.badge-success {
  background: rgba(40, 167, 69, 0.2);
  border: 1px solid rgba(40, 167, 69, 0.4);
  color: #5fdc7f;
}

.badge-danger {
  background: rgba(220, 53, 69, 0.2);
  border: 1px solid rgba(220, 53, 69, 0.4);
  color: #ff6b7a;
}

.badge-info {
  background: rgba(74, 158, 255, 0.2);
  border: 1px solid rgba(74, 158, 255, 0.4);
  color: #7fb8ff;
}

/* Owes Me Row Highlighting */
tr.owes-me-row {
  background-color: rgba(220, 53, 69, 0.15) !important;
  border-left: 3px solid #dc3545;
}

tr.owes-me-row:hover {
  background-color: rgba(220, 53, 69, 0.25) !important;
}

.url-cell {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.url-link {
  color: #4a9eff;
  text-decoration: none;
}

.url-link:hover {
  text-decoration: underline;
}

/* ===========================
   Admin Section
   =========================== */
.bulk-actions {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.bulk-actions .btn {
  margin: 0;
}

.row-changed {
  background: rgba(74, 158, 255, 0.15) !important;
  border-left: 3px solid #4a9eff;
}

.admin-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.15);
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 12px 24px;
  color: #a0a0a0;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.3s ease;
  margin-bottom: -2px;
}

.tab-btn:hover {
  color: #e0e0e0;
}

.tab-btn.active {
  color: #4a9eff;
  border-bottom-color: #4a9eff;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.admin-email-input,
.admin-card-input {
  min-width: 250px;
}

.admin-uses-input {
  width: 80px;
  text-align: center;
}

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

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

.tool-checkbox {
  cursor: pointer;
  width: 18px;
  height: 18px;
}

/* ===========================
   Order Form Layout
   =========================== */
.order-form-container {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 0.5rem 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.order-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  gap: 1rem;
}

.order-form-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-main-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.form-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group-spacer {
  height: 2.5rem;
}

.button-group {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.3rem;
}

.button-group .btn {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  align-items: flex-end;
}

.form-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.form-group-full {
  grid-column: span 4;
}

.form-group label {
  font-size: 0.8rem;
  color: #b0b0b0;
  margin-bottom: 0.2rem;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.3);
  color: #e0e0e0;
  font-size: 0.9rem;
}

.email-meta,
.card-meta {
  font-size: 0.7rem !important;
  color: var(--text-secondary) !important;
  margin-top: 0.2rem !important;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  margin: 0;
  padding: 0.3rem 0.5rem;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.checkbox-label span {
  color: #e0e0e0;
  font-size: 0.95rem;
}

.btn-submit-row {
  width: 100%;
  padding: 0.75rem;
}

.owes-me-checkbox {
  cursor: pointer;
  width: 20px;
  height: 20px;
}

.server-add-section {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.server-input {
  flex: 1;
  max-width: 300px;
}

.admin-server-input {
  min-width: 200px;
}

/* ===========================
   Autocomplete
   =========================== */
.autocomplete-container {
  position: relative;
  width: 100%;
}

.admin-category-input {
  min-width: 200px;
  width: 100%;
}

.autocomplete-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(30, 30, 46, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.card-autocomplete-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(30, 30, 46, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.autocomplete-item {
  padding: 10px;
  cursor: pointer;
  color: #e0e0e0;
  transition: background 0.2s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

.autocomplete-item:hover {
  background: rgba(74, 158, 255, 0.2);
}

.admin-category-name-input {
  min-width: 200px;
}

/* ===========================
   Modal Dialog
   =========================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  animation: fadeIn 0.2s ease;
}

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

.modal-content {
  background: #1e1e1e;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  animation: slideIn 0.2s ease;
}

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

.modal-content h3 {
  margin: 0 0 1.5rem 0;
  color: #ffffff;
  font-size: 1.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  padding-bottom: 0.75rem;
}

.modal-content .form-group {
  margin-bottom: 1.25rem;
}

.modal-content label {
  display: block;
  font-size: 0.9rem;
  color: #b0b0b0;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.modal-content input[type="text"],
.modal-content textarea {
  width: 100%;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 1rem;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.modal-content input[type="text"]:focus,
.modal-content textarea:focus {
  outline: none;
  border-color: #4a9eff;
  background: rgba(74, 158, 255, 0.1);
}

.modal-content textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.modal-field-with-button {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.modal-field-with-button input {
  flex: 1;
}

.modal-field-with-button .btn {
  margin-top: 0;
  white-space: nowrap;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-actions .btn {
  min-width: 100px;
}

/* ===========================
   Card Formatter
   =========================== */
.formatter-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 15px;
  margin-bottom: 15px;
}

.formatter-field {
  display: flex;
  flex-direction: column;
}

.formatter-field label {
  font-size: 0.9rem;
  color: #b0b0b0;
  margin-bottom: 8px;
  font-weight: 500;
}

.formatter-field input {
  padding: 10px;
}

.formatter-textarea {
  grid-column: span 2;
}

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

/* ===========================
   Responsive Design
   =========================== */

/* Loading Spinner */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-overlay.show {
  display: flex;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(74, 158, 255, 0.3);
  border-top-color: #4a9eff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-text {
  color: #fff;
  margin-top: 15px;
  font-size: 1.1rem;
}

/* Pagination Controls Enhanced */
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 15px;
  margin: 15px 0;
}

.pagination-controls input[type="number"] {
  width: 60px;
  text-align: center;
  padding: 6px;
}

.pagination-controls select {
  padding: 6px 10px;
}

.page-jump-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-jump-container label {
  color: #a0a0a0;
  font-size: 0.9rem;
}

/* Mobile menu toggle button */
.nav-toggle {
  display: none;
  background: rgba(74, 158, 255, 0.2);
  border: 1px solid rgba(74, 158, 255, 0.4);
  color: #4a9eff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 10px 15px;
  border-radius: 6px;
  transition: all 0.3s ease;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-toggle:hover {
  background: rgba(74, 158, 255, 0.3);
}

.nav-toggle:active {
  background: rgba(74, 158, 255, 0.4);
}

@media (max-width: 768px) {
  /* Hide spreadsheet on mobile */
  .quick-notes-compact {
    display: none !important;
  }

  .order-controls-with-notes {
    grid-template-columns: 1fr !important;
  }

  /* Enable horizontal scrolling for tables */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* For orders table on mobile - keep it scrollable */
  #submittedOrdersTable {
    min-width: 800px;
  }

  #activityTable {
    min-width: 600px;
  }

  /* Mobile navbar */
  .nav-container {
    flex-wrap: wrap;
    padding: 0 15px;
  }

  .nav-brand {
    font-size: 1.2rem;
    min-height: 60px;
  }

  .nav-logo {
    height: 32px;
    width: 32px;
  }

  .nav-toggle {
    display: flex !important;
  }

  .nav-menu {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 0;
    padding: 10px 0;
  }

  .nav-menu.show {
    display: flex;
  }

  .nav-item .nav-link {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .nav-item.active .nav-link {
    border-bottom: 1px solid #4a9eff;
  }

  .dropdown-menu {
    position: static;
    display: none;
    width: 100%;
    margin-top: 0;
    border-radius: 0;
  }

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

  .dropdown-item {
    padding: 10px 25px;
  }

  /* Adjust content for mobile */
  .container {
    padding: 10px;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.2rem;
  }

  .card {
    padding: 15px;
  }

  /* Form controls */
  .order-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .control-group input[type="number"],
  .control-group select {
    width: 100%;
    min-width: auto;
  }

  /* Make inputs full width */
  input[type="text"],
  input[type="number"],
  input[type="password"],
  select,
  textarea {
    width: 100%;
    font-size: 16px; /* Prevent zoom on iOS */
  }

  /* Tables - Mobile Card Layout */
  .table-container {
    overflow-x: visible;
    font-size: 0.75rem;
  }

  /* Admin tables - enable horizontal scroll instead of card layout */
  #adminEmailsTable,
  #adminCardsTable {
    min-width: 600px; /* Force horizontal scroll */
  }

  /* Simplify table display for better mobile UX */
  #adminEmailsTable th,
  #adminCardsTable th {
    font-size: 0.75rem;
    padding: 8px 6px;
    white-space: nowrap;
  }

  #adminEmailsTable td,
  #adminCardsTable td {
    font-size: 0.8rem;
    padding: 6px 4px;
  }

  /* Remove old card layout labels */

  /* Admin inputs - make them full width on mobile */
  .admin-email-input,
  .admin-card-input,
  .admin-category-input {
    width: 100%;
    min-width: auto;
    font-size: 14px;
    box-sizing: border-box;
  }

  .admin-uses-input {
    width: 100%;
  }

  /* Buttons - Larger touch targets on mobile */
  .btn {
    padding: 12px 16px;
    font-size: 0.9rem;
    min-height: 44px; /* iOS recommended touch target */
  }

  .btn-sm {
    padding: 8px 12px;
    font-size: 0.8rem;
    min-height: 36px;
  }

  /* Better checkbox sizing for mobile */
  input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    cursor: pointer;
  }

  .email-checkbox,
  .card-checkbox,
  .owes-me-checkbox {
    width: 24px !important;
    height: 24px !important;
  }

  /* Upload grid */
  .upload-grid {
    grid-template-columns: 1fr;
  }

  /* Center pagination controls on mobile */
  .bulk-actions {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px;
  }

  .pagination-controls {
    justify-content: center !important;
    margin: 10px 0 !important;
    flex-wrap: wrap;
  }

  .page-jump-container {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
  }

  /* Bottom pagination wrapper */
  .table-container > div[style*="justify-content: flex-end"] {
    justify-content: center !important;
  }

  /* Stats grid */

  .table-container {
    font-size: 0.8rem;
  }

  th, td {
    padding: 8px 6px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .orders-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .order-form-grid {
    grid-template-columns: 1fr;
  }

  .form-group.full-width,
  .form-group.submit-section-inline {
    grid-column: span 1;
  }

  /* Mobile filter grid */
  .filters-grid {
    grid-template-columns: 1fr !important;
  }

  /* Orders controls stacking */
  .orders-controls {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .orders-controls .btn {
    flex: 1;
    min-width: 120px;
  }

  /* Header actions wrapping */
  .header-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  .header-actions .btn {
    font-size: 0.75rem;
    padding: 6px 10px;
    white-space: nowrap;
  }

  /* Improve modal on mobile */
  .modal-content {
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
  }

  /* Better spacing for bulk actions */
  .bulk-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .bulk-actions > div {
    width: 100%;
  }

  .bulk-actions input[type="text"] {
    width: 100% !important;
  }

  /* Admin tabs - make scrollable on mobile */
  .admin-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }

  .tab-btn {
    white-space: nowrap;
    font-size: 0.9rem;
    padding: 10px 16px;
  }

  /* Improve form grid spacing */
  .formatter-grid {
    grid-template-columns: 1fr;
  }

  .formatter-field.formatter-textarea {
    grid-column: span 1;
  }

  .formatter-actions {
    flex-direction: column;
  }

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

  .formatter-actions .checkbox-label {
    justify-content: center;
    padding: 12px;
  }

  /* Server add section improvements */
  .server-add-section {
    flex-direction: column;
    align-items: stretch;
  }

  .server-add-section .server-input {
    max-width: 100%;
  }

  .server-add-section input[type="text"],
  .server-add-section input[type="number"] {
    width: 100%;
  }
}
