/* ============================================
   SPYCO PORTAL — Floot-Style Redesign
   ============================================ */

:root {
  --bg-primary:    #0f1419;
  --bg-secondary:  #1a2332;
  --bg-card:       #1e2a3a;
  --bg-card-hover: #243447;
  --border:        #2d3f52;
  --accent:        #e94560;
  --accent-hover:  #ff5a75;
  --gold:          #f5a623;
  --success:       #22c55e;
  --warning:       #f59e0b;
  --info:          #38bdf8;
  --danger:        #ef4444;
  --text:          #e8eaed;
  --text-muted:    #8b9db5;
  --text-dim:      #5a6a7e;
  --sidebar-bg:    #141c27;
  --sidebar-w:     220px;
  --header-h:      56px;
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:          'JetBrains Mono', 'Fira Code', monospace;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 4px 24px rgba(0,0,0,0.3);
  --transition:    all 0.15s ease;
}

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

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

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 14px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ============================================
   LOGIN PAGE
   ============================================ */
#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  position: relative;
}

#login-page::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(233,69,96,0.08) 0%, transparent 70%);
  top: -150px;
  right: -150px;
  border-radius: 50%;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo img {
  height: 40px;
  object-fit: contain;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}

.login-subtitle {
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 32px;
  font-size: 0.9rem;
}

.login-btn {
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.login-btn.google-btn {
  background: #fff;
  color: #333;
}

.login-btn.google-btn:hover {
  background: #f5f5f5;
  transform: translateY(-1px);
}

.login-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: #ef4444;
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.85rem;
  display: none;
}

/* ============================================
   MAIN APP LAYOUT
   ============================================ */
#app {
  display: none;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo img {
  height: 28px;
  object-fit: contain;
}

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

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

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent);
  color: #fff;
}

.nav-item i, .nav-item svg {
  width: 18px;
  height: 18px;
  opacity: 0.8;
}

.nav-item.active i, .nav-item.active svg {
  opacity: 1;
}

/* User section at bottom */
.sidebar-user {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.sidebar-user-info {
  flex: 1;
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.sidebar-user-role {
  font-size: 0.75rem;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-logout {
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
  transition: var(--transition);
}

.sidebar-logout:hover {
  background: var(--bg-card);
  color: var(--danger);
}

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex: 1;
  width: calc(100% - var(--sidebar-w));
}

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

.header-title {
  font-size: 1.1rem;
  font-weight: 600;
  flex: 1;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

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

.page {
  display: none;
}

.page.active {
  display: block;
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.page-header p {
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================
   CARDS & STATS
   ============================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.stat-icon.blue { background: rgba(59,130,246,0.15); color: #3b82f6; }
.stat-icon.green { background: rgba(34,197,94,0.15); color: #22c55e; }
.stat-icon.gold { background: rgba(245,166,35,0.15); color: #f5a623; }
.stat-icon.red { background: rgba(239,68,68,0.15); color: #ef4444; }
.stat-icon.purple { background: rgba(168,85,247,0.15); color: #a855f7; }

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* Income Stats */
.income-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.income-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.income-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.income-value {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--success);
}

/* ============================================
   TABLES
   ============================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.data-table tr:hover td {
  background: var(--bg-card-hover);
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Code styling */
.code {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--gold);
  font-weight: 500;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-green { background: rgba(34,197,94,0.15); color: #22c55e; }
.badge-red { background: rgba(239,68,68,0.15); color: #ef4444; }
.badge-gold { background: rgba(245,166,35,0.15); color: #f5a623; }
.badge-blue { background: rgba(59,130,246,0.15); color: #3b82f6; }
.badge-grey { background: rgba(156,163,175,0.15); color: #9ca3af; }
.badge-purple { background: rgba(168,85,247,0.15); color: #a855f7; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 12px;
}

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text);
}

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

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
}

/* ============================================
   FORMS
   ============================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-full {
  grid-column: 1 / -1;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.field-group input,
.field-group select,
.field-group textarea {
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: var(--transition);
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233,69,96,0.1);
}

.field-group textarea {
  min-height: 80px;
  resize: vertical;
}

.field-group select {
  cursor: pointer;
}

/* ============================================
   SEARCH
   ============================================ */
.search-wrap {
  position: relative;
  margin-bottom: 16px;
}

.search-wrap input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

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

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

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

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ============================================
   QUICK ACTIONS
   ============================================ */
.quick-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.quick-actions .btn {
  white-space: nowrap;
}

/* ============================================
   TABS
   ============================================ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 12px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ============================================
   SPY COMMS BUILDER
   ============================================ */
.comms-builder {
  max-width: 800px;
  margin: 0 auto;
}

.comms-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.comms-output {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.comms-output-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.comms-output-value {
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--text);
  word-break: break-all;
}

.copy-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.copy-btn:hover {
  background: var(--accent-hover);
}

/* ============================================
   ACTIVITY FEED
   ============================================ */
.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-text {
  font-size: 0.9rem;
}

.activity-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================
   UTILITIES
   ============================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.hidden { display: none !important; }

/* Grid layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
  .income-stats {
    grid-template-columns: 1fr;
  }
  
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  :root {
    --sidebar-w: 0px;
  }
  
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .sidebar.open {
    transform: translateX(0);
    width: 260px;
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .comms-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   TABLE ACTIONS
   ============================================ */
.table-actions {
  display: flex;
  gap: 4px;
}

.table-actions .btn-icon {
  opacity: 0.6;
}

.table-actions .btn-icon:hover {
  opacity: 1;
}

.table-actions .btn-icon.delete:hover {
  color: var(--danger);
}

/* Checkbox in tables */
.table-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* ============================================
   PWA BANNER
   ============================================ */
#pwa-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  z-index: 9999;
  display: none;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  max-width: 400px;
}

/* Clear All button */
.clear-all-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: var(--transition);
}

.clear-all-btn:hover {
  background: var(--bg-card);
  color: var(--text);
}


/* Stats Mini */
.stats-mini {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stats-mini div {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.stats-mini div:last-child {
  border-bottom: none;
}

.stats-mini span {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.2rem;
}


/* ============================================
   RESPONSIVE DESIGN — Mobile & Tablet
   ============================================ */

/* Mobile menu toggle button */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
}

.mobile-menu-toggle:hover {
  background: var(--bg-card);
}

.mobile-menu-toggle svg {
  width: 24px;
  height: 24px;
}

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 200px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .grid-2 {
    grid-template-columns: 1fr;
  }
  
  .income-stats {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .comms-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .data-table {
    font-size: 0.85rem;
  }
  
  .data-table th,
  .data-table td {
    padding: 10px 8px;
  }
}

/* Mobile Large (481px - 767px) */
@media (max-width: 767px) {
  :root {
    --sidebar-w: 0px;
    --header-h: 56px;
  }
  
  /* Show mobile menu toggle */
  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Overlay when sidebar is open */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
  }
  
  .sidebar-overlay.show {
    display: block;
  }
  
  /* Sidebar - slide in from left */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 999;
    width: 260px;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  /* Main content - full width */
  .main-content {
    margin-left: 0;
    width: 100%;
  }
  
  /* Header adjustments */
  .header {
    padding: 12px 16px;
    gap: 12px;
  }
  
  .header-right {
    font-size: 0.75rem;
  }
  
  #current-date {
    display: none;
  }
  
  /* Page content */
  .page-content {
    padding: 16px;
  }
  
  /* Page header */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .page-header h1 {
    font-size: 1.4rem;
  }
  
  /* Stats grid - 2 columns */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .stat-card {
    padding: 16px;
  }
  
  .stat-value {
    font-size: 1.5rem;
  }
  
  /* Income stats - stack */
  .income-stats {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .income-card {
    padding: 16px;
  }
  
  /* Cards */
  .card {
    padding: 16px;
    border-radius: var(--radius);
  }
  
  .card-title {
    font-size: 0.9rem;
  }
  
  /* Tables - horizontal scroll */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }
  
  .data-table {
    min-width: 600px;
    font-size: 0.8rem;
  }
  
  .data-table th,
  .data-table td {
    padding: 10px 8px;
    white-space: nowrap;
  }
  
  /* Forms */
  .form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .comms-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  /* Buttons - larger touch targets */
  .btn {
    padding: 12px 20px;
    min-height: 44px;
  }
  
  .btn-sm {
    padding: 8px 14px;
    min-height: 36px;
  }
  
  .btn-icon {
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Quick actions - vertical */
  .quick-actions {
    flex-direction: column;
  }
  
  .quick-actions .btn {
    width: 100%;
    justify-content: center;
  }
  
  /* Modal - full screen on mobile */
  .modal {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    border-radius: 0;
    margin: 0;
  }
  
  .modal-body {
    max-height: calc(100vh - 140px);
  }
  
  /* Login page */
  .login-card {
    padding: 24px;
    margin: 16px;
    max-width: calc(100vw - 32px);
  }
  
  /* SPY COMMS output */
  .comms-output-value {
    font-size: 0.9rem;
    word-break: break-all;
  }
  
  /* Nav items */
  .nav-item {
    padding: 14px 20px;
    font-size: 0.95rem;
  }
  
  /* User profile in sidebar */
  .user-profile {
    padding: 16px;
  }
  
  /* Hide elements on mobile */
  .hide-mobile {
    display: none !important;
  }
}

/* Mobile Small (up to 480px) */
@media (max-width: 480px) {
  body {
    font-size: 13px;
  }
  
  /* Stats - single column */
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .stat-card {
    padding: 14px;
  }
  
  .stat-value {
    font-size: 1.3rem;
  }
  
  /* Page header */
  .page-header h1 {
    font-size: 1.2rem;
  }
  
  .page-header p {
    font-size: 0.8rem;
  }
  
  /* Cards compact */
  .card {
    padding: 14px;
  }
  
  /* Invoices summary cards */
  .income-card {
    padding: 14px;
  }
  
  .income-value {
    font-size: 1.3rem;
  }
  
  /* Table actions */
  .table-actions {
    display: flex;
    gap: 4px;
  }
  
  .table-actions .btn-icon {
    min-width: 36px;
    min-height: 36px;
    padding: 6px;
  }
  
  /* Inputs */
  input, select, textarea {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 12px;
  }
  
  /* Activity feed compact */
  .activity-item {
    padding: 12px 0;
  }
  
  /* Filter dropdown in tables */
  .card-title {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px;
  }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .btn {
    min-height: 44px;
  }
  
  .nav-item {
    min-height: 48px;
  }
  
  .btn-icon {
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Remove hover effects */
  .btn:hover {
    transform: none;
  }
  
  .nav-item:hover {
    background: transparent;
  }
  
  .nav-item.active,
  .nav-item:active {
    background: var(--accent);
  }
  
  .data-table tbody tr:hover {
    background: transparent;
  }
  
  .data-table tbody tr:active {
    background: var(--bg-card-hover);
  }
}

/* Landscape mode on mobile */
@media (max-width: 767px) and (orientation: landscape) {
  .modal {
    max-height: 100vh;
  }
  
  .modal-body {
    max-height: calc(100vh - 100px);
  }
  
  .login-card {
    padding: 20px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Print styles */
@media print {
  .sidebar,
  .mobile-menu-toggle,
  .btn,
  .table-actions {
    display: none !important;
  }
  
  .main-content {
    margin-left: 0;
    width: 100%;
  }
  
  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* Ensure table pages have consistent height */
.table-responsive {
  min-height: 400px;
}
