/* assets/css/style.css - myBillBook Design System */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-hover: #1e293b;
  --sidebar-active: #2563eb;
  --bg-main: #f8fafc;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --success: #10b981;
  --success-bg: #d1fae5;
  --success-text: #065f46;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  --info: #0284c7;
  --info-bg: #e0f2fe;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  --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);
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Layout Structure */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: 250px;
  background-color: var(--sidebar-bg);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: all 0.2s ease;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.25rem;
  color: #fff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.4);
}

.brand-details h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-size: 0.68rem;
  font-weight: 600;
  background: rgba(37, 99, 235, 0.25);
  color: #60a5fa;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 2px;
}

.brand-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 4px 0;
}

.brand-logo-img {
  max-width: 180px;
  max-height: 48px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
}

.sidebar-nav {
  padding: 16px 10px;
  flex: 1;
}

.nav-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: #64748b;
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  color: var(--sidebar-text);
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  margin-bottom: 3px;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background-color: var(--sidebar-hover);
  color: #ffffff;
}

.nav-item.active {
  background-color: var(--sidebar-active);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
}

.nav-pill {
  margin-left: auto;
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  font-weight: 700;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.business-quick-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.business-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: #3b82f6;
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.business-info-meta {
  overflow: hidden;
}

.business-name-short {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.business-gst-pill {
  font-size: 0.68rem;
  color: #94a3b8;
}

/* Main Area */
.app-main {
  margin-left: 250px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Header */
.app-header {
  height: 64px;
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.header-search {
  position: relative;
  max-width: 340px;
  width: 100%;
}

.header-search input {
  width: 100%;
  height: 38px;
  background-color: #f1f5f9;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 0 16px 0 38px;
  font-size: 0.85rem;
  color: var(--text-main);
  transition: all 0.2s;
  outline: none;
}

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

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-light);
  pointer-events: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-quick-create {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
  transition: all 0.15s;
}

.btn-quick-create:hover {
  background-color: var(--primary-hover);
}

.btn-pos-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: #10b981;
  color: #ffffff;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
  transition: all 0.15s;
}

.btn-pos-shortcut:hover {
  background-color: #059669;
}

/* User Profile Header Dropdown */
.user-header-menu {
  position: relative;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-full);
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.user-profile-btn:hover,
.user-profile-btn.active {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
}

.user-header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.user-header-meta {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.15;
}

.user-header-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #0f172a;
}

.user-header-role {
  font-size: 0.68rem;
  font-weight: 600;
  color: #64748b;
}

.user-caret {
  color: #94a3b8;
  transition: transform 0.2s ease;
}

.user-profile-btn.active .user-caret {
  transform: rotate(180deg);
}

.user-dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: none;
  overflow: hidden;
  animation: slideUp 0.15s ease;
}

.user-dropdown-panel.open {
  display: block;
}

.user-dropdown-header {
  padding: 14px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.user-dropdown-title {
  font-weight: 700;
  font-size: 0.88rem;
  color: #0f172a;
}

.user-dropdown-sub {
  font-size: 0.74rem;
  color: #64748b;
  margin-top: 2px;
}

.user-dropdown-body {
  padding: 6px 0;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #334155;
  transition: all 0.15s ease;
  text-decoration: none;
}

.user-dropdown-item:hover {
  background: #f1f5f9;
  color: #2563eb;
}

.user-dropdown-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 6px 0;
}

.user-dropdown-logout {
  color: #ef4444 !important;
}

.user-dropdown-logout:hover {
  background: #fee2e2 !important;
  color: #b91c1c !important;
}

/* Page Content */
.content-body {
  padding: 24px;
  flex: 1;
}

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

.page-title-group h1 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.page-title-group p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-accent, var(--primary));
}

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

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-icon-wrap {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background-color: var(--kpi-bg, var(--primary-light));
  color: var(--kpi-color, var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-value {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
}

.kpi-subtext {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Cards & Tables */
.card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

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

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

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

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

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

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}

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

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

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

.badge-paid {
  background-color: var(--success-bg);
  color: var(--success-text);
}

.badge-unpaid {
  background-color: var(--danger-bg);
  color: var(--danger-text);
}

.badge-partial {
  background-color: var(--warning-bg);
  color: var(--warning-text);
}

.badge-low-stock {
  background-color: #ffedd5;
  color: #9a3412;
}

.badge-in-stock {
  background-color: #e0e7ff;
  color: #3730a3;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

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

.btn-secondary {
  background-color: #ffffff;
  border-color: var(--border-color);
  color: #334155;
}

.btn-secondary:hover {
  background-color: #f1f5f9;
}

.btn-success {
  background-color: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background-color: #059669;
}

.btn-danger {
  background-color: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}

.btn-danger:hover {
  background-color: #ef4444;
  color: #ffffff;
}

.btn-sm {
  padding: 5px 9px;
  font-size: 0.78rem;
}

.btn-icon-only {
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.btn-icon-only:hover {
  color: var(--primary);
  background-color: var(--primary-light);
}

/* Form Controls */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  height: 38px;
  padding: 8px 12px;
  font-size: 0.86rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: all 0.15s ease;
}

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

textarea.form-control {
  height: auto;
  min-height: 80px;
}

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

/* Invoice Editor Specifics */
.invoice-editor-box {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
}

.invoice-meta-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 1px dashed var(--border-color);
  margin-bottom: 20px;
}

.items-calc-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.items-calc-table th {
  background: #f1f5f9;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
  text-align: left;
}

.items-calc-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
}

.items-calc-table input,
.items-calc-table select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  outline: none;
}

.items-calc-table input:focus,
.items-calc-table select:focus {
  border-color: var(--primary);
}

.invoice-totals-section {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.totals-card {
  width: 360px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.86rem;
  color: #475569;
}

.totals-row.grand-total {
  border-top: 2px solid #cbd5e1;
  padding-top: 10px;
  margin-top: 6px;
  font-size: 1.1rem;
  font-weight: 800;
  color: #0f172a;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 99;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
  animation: fadeIn 0.15s ease-out;
}

.modal-container {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease-out;
}

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

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--text-muted);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background-color: #f8fafc;
}

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

.toast {
  background: #1e293b;
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  animation: slideInRight 0.2s ease;
  min-width: 280px;
}

.toast.toast-success {
  border-left: 4px solid var(--success);
}

.toast.toast-danger {
  border-left: 4px solid var(--danger);
}

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

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

@keyframes slideInRight {
  from { transform: translateX(50px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* =========================================================
   COMPREHENSIVE MOBILE RESPONSIVE SYSTEM
   ========================================================= */

/* Desktop defaults for mobile toggle elements */
.btn-sidebar-toggle {
  display: none;
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 6px;
  color: var(--text-main);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 0;
}

.btn-sidebar-toggle:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.sidebar-close-btn {
  display: none;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.4rem;
  line-height: 1;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: 8px;
}

.sidebar-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 70;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

/* Tablet & Mobile Screens (<= 992px) */
@media (max-width: 992px) {
  .kpi-grid,
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr !important;
    gap: 20px;
  }

  .pos-wrapper {
    grid-template-columns: 1fr !important;
  }

  .header-search {
    max-width: 240px;
  }
}

/* Main Mobile Navigation Breakpoint (<= 900px) */
@media (max-width: 900px) {
  .btn-sidebar-toggle {
    display: inline-flex;
    margin-right: 4px;
  }

  .sidebar-close-btn {
    display: inline-flex;
  }

  .app-sidebar {
    width: 270px;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: none;
  }

  .app-sidebar.show {
    transform: translateX(0);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
  }

  .app-main {
    margin-left: 0 !important;
    width: 100%;
    min-width: 0;
  }

  .app-header {
    padding: 0 16px;
    height: 58px;
  }

  .content-body {
    padding: 16px;
  }

  .invoice-meta-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
  }

  .page-header .page-actions,
  .page-header .header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .page-header .page-actions .btn,
  .page-header .header-actions .btn {
    flex: 1;
    min-width: 130px;
    justify-content: center;
  }
}

/* Small Tablets & Large Phones (<= 768px) */
@media (max-width: 768px) {
  .header-fy-pill {
    display: none;
  }

  .header-search {
    max-width: 180px;
  }

  .header-search input {
    font-size: 0.8rem;
    padding-left: 32px;
  }

  .header-search .search-icon {
    left: 9px;
    width: 14px;
    height: 14px;
  }

  .btn-pos-shortcut,
  .btn-quick-create {
    padding: 7px 10px;
    font-size: 0.8rem;
  }

  /* Form Rows stack vertically */
  .form-row {
    flex-direction: column;
    gap: 12px;
  }

  /* Modals on mobile */
  .modal-container {
    width: 94% !important;
    max-width: 94% !important;
    margin: 16px auto;
    max-height: 90vh;
    border-radius: var(--radius-md);
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-body {
    padding: 14px 16px;
  }

  .modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .modal-footer .btn {
    flex: 1;
    justify-content: center;
  }

  /* Tables horizontal scrolling */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    margin-bottom: 12px;
  }

  .data-table th,
  .data-table td {
    padding: 9px 12px;
    font-size: 0.82rem;
  }

  /* Invoice totals card */
  .totals-card {
    width: 100% !important;
  }

  .invoice-totals-section {
    justify-content: stretch;
  }

  /* Dual column cards stack */
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  [style*="grid-template-columns: repeat(auto-fill, minmax(360px, 1fr))"] {
    grid-template-columns: 1fr !important;
  }
}

/* Phones & Compact Mobile Screens (<= 560px) */
@media (max-width: 560px) {
  .app-header {
    padding: 0 12px;
    height: 54px;
  }

  .content-body {
    padding: 12px 10px;
  }

  /* Header compact buttons (show icon only or compact text) */
  .btn-action-text {
    display: none;
  }

  .btn-pos-shortcut,
  .btn-quick-create {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
  }

  .btn-pos-shortcut svg,
  .btn-quick-create svg {
    margin: 0;
  }

  /* User profile in header: hide text name/role, show avatar */
  .user-header-meta,
  .user-caret {
    display: none;
  }

  .user-profile-btn {
    padding: 2px;
    border: none;
    background: transparent;
  }

  .user-header-avatar {
    width: 32px;
    height: 32px;
  }

  .user-dropdown-panel {
    right: 0;
    max-width: calc(100vw - 20px);
    width: 250px;
  }

  /* KPI cards stack into 1 column on small phones */
  .kpi-grid,
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  .kpi-card {
    padding: 14px;
  }

  .kpi-value {
    font-size: 1.35rem;
  }

  .card {
    border-radius: 10px;
    margin-bottom: 16px;
  }

  .card-header {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .card-body {
    padding: 14px;
  }

  .card-title {
    font-size: 0.95rem;
  }

  .page-title-group h1 {
    font-size: 1.25rem;
  }

  .page-title-group p {
    font-size: 0.78rem;
  }

  /* POS item cards */
  #posItemGrid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .pos-item-card {
    padding: 8px !important;
  }

  /* Login card on mobile */
  .login-card {
    padding: 28px 20px;
    border-radius: 16px;
  }

  .login-brand h1 {
    font-size: 1.2rem;
  }

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

  /* Input fields touch ergonomics */
  .form-control,
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px !important; /* Prevents auto-zoom on iOS */
    min-height: 40px;
  }

  /* Toast notification on mobile */
  .toast-container {
    left: 14px;
    right: 14px;
    bottom: 16px;
  }

  .toast {
    min-width: 0;
    width: 100%;
  }
}

