/* ==========================================================================
   Healthy Ways Enterprise - Design System CSS
   Commercial Fitness & Enterprise Styling (Pure CSS, No External CDN)
   ========================================================================== */

:root {
  --primary: #0f172a;          /* Deep Slate Navy */
  --primary-light: #1e293b;
  --accent: #0ea5e9;           /* Modern Cyan / Blue */
  --accent-hover: #0284c7;
  --success: #10b981;          /* Emerald Green */
  --warning: #f59e0b;          /* Amber */
  --danger: #ef4444;           /* Rose Red */
  --bg-main: #f8fafc;          /* Clean Light Canvas */
  --bg-surface: #ffffff;       /* Pure White Card */
  --text-main: #0f172a;        /* High Contrast Dark */
  --text-muted: #64748b;       /* Slate Subdued */
  --border-color: #e2e8f0;     /* Subtle Border */
  --sidebar-w: 260px;
  --header-h: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --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);
  --shadow-xl: 0 24px 55px -28px rgb(15 23 42 / 0.45);
  --ring-accent: 0 0 0 4px rgba(14, 165, 233, 0.16);
  --brand-teal: #0f766e;
  --brand-mint: #dff7ef;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(14, 165, 233, 0.08), transparent 34rem),
    linear-gradient(180deg, #f7fbff 0%, #f8fafc 28%, #f6f8fb 100%);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* Top Tab Navigation Layout (My CMS Style) */
.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-main);
}

.top-nav-header {
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(226, 232, 240, 0.86);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 10px 28px -26px rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.top-nav-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

/* Brand Link */
.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none !important;
  flex-shrink: 0;
  min-width: 0;
}
.brand-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(16, 185, 129, 0.12));
  box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.12);
}
.brand-svg {
  width: 30px;
  height: 30px;
}
.brand-text {
  font-size: 19px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: 0;
}
.brand-text strong {
  color: var(--accent);
}

/* Nav Tabs Wrapper */
.nav-tabs-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  margin-left: 12px;
  min-width: 0;
}

/* Tab Item Pill Style */
.tab-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 9999px;
  font-size: 13.5px;
  font-weight: 750;
  color: #44546a;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.16s ease, background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  text-decoration: none !important;
  white-space: nowrap;
  min-height: 40px;
}

.tab-item:hover {
  color: #0f172a;
  background-color: #f3f8fb;
  border-color: rgba(148, 163, 184, 0.3);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -18px rgba(15, 23, 42, 0.7);
}

.tab-item.active {
  background: linear-gradient(180deg, #e8f8f5 0%, #dff4ef 100%);
  color: #0f766e;
  border-color: rgba(15, 118, 110, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.7), 0 10px 24px -20px rgba(15, 118, 110, 0.9);
}

.tab-icon {
  width: 17px;
  height: 17px;
  fill: currentColor;
  flex-shrink: 0;
}

.dropdown-chevron {
  width: 14px;
  height: 14px;
  fill: currentColor;
  margin-left: -2px;
  transition: transform 0.2s ease;
}

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

.nav-dropdown.active > .tab-item {
  background: linear-gradient(180deg, #e8f8f5 0%, #dff4ef 100%);
  color: #0f766e;
  border-color: rgba(15, 118, 110, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.7), 0 10px 24px -20px rgba(15, 118, 110, 0.9);
}

.nav-dropdown.open .dropdown-chevron,
.nav-dropdown:hover .dropdown-chevron,
.nav-dropdown:focus-within .dropdown-chevron {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  background: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  box-shadow: 0 24px 48px -28px rgba(15, 23, 42, 0.9), 0 0 0 1px rgba(255,255,255,0.04) inset;
  min-width: 260px;
  max-height: min(74vh, 560px);
  overflow-y: auto;
  padding: 8px;
  display: none;
  z-index: 1000;
  animation: dropdownFade 0.16s ease-out;
}

.nav-dropdown:nth-last-child(-n+2) .dropdown-menu,
.dropdown-menu.align-right {
  left: auto;
  right: 0;
}

.nav-dropdown.open .dropdown-menu,
.nav-dropdown:hover .dropdown-menu,
.nav-dropdown:focus-within .dropdown-menu {
  display: block;
}

@keyframes dropdownFade {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  color: #dbeafe;
  font-size: 13px;
  font-weight: 700;
  border-radius: 11px;
  text-decoration: none !important;
  transition: transform 0.14s ease, background-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
  min-height: 40px;
  position: relative;
}

.dropdown-item:hover {
  background: rgba(14, 165, 233, 0.16);
  color: #ffffff;
  transform: translateX(3px);
  box-shadow: inset 3px 0 0 #22d3ee;
}

.dropdown-item.current,
.dropdown-item[aria-current="page"] {
  background: linear-gradient(90deg, rgba(20, 184, 166, 0.24), rgba(14, 165, 233, 0.18));
  color: #ccfbf1;
  box-shadow: inset 3px 0 0 #14b8a6;
}

.dropdown-dot {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.dropdown-item:hover .dropdown-dot {
  background: linear-gradient(135deg, #0ea5e9, #14b8a6);
  box-shadow: 0 8px 18px -12px rgba(34, 211, 238, 0.9);
}

.dropdown-item.current .dropdown-dot,
.dropdown-item[aria-current="page"] .dropdown-dot {
  background: linear-gradient(135deg, #14b8a6, #99f6e4);
  box-shadow: 0 8px 18px -12px rgba(20, 184, 166, 0.9);
}

/* Right Side Controls */
.top-nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  min-width: 0;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 5px;
  border-radius: 9999px;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(203, 213, 225, 0.82);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.78);
  min-width: 0;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0f172a, #0f766e);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #0f172a;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-role {
  font-size: 10.5px;
  color: #64748b;
}

.logout-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(203, 213, 225, 0.86);
  background: rgba(255,255,255,0.92);
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none !important;
}
.logout-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}
.logout-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Page Container (Max-width centered canvas) */
.page-container {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 30px 24px 40px;
  flex: 1;
}

.page-container > div[style*="justify-content: space-between"] {
  flex-wrap: wrap;
}


/* Typography & Titles */
.page-title {
  font-size: 24px;
  font-weight: 850;
  color: var(--primary);
  margin-bottom: 6px;
}
.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Cards */
.card {
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: 18px;
  box-shadow: 0 16px 45px -36px rgba(15, 23, 42, 0.75), 0 1px 2px rgba(15, 23, 42, 0.04);
  margin-bottom: 24px;
  overflow: hidden;
}

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.92);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.72));
}

.card-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.card-body {
  padding: 22px;
}

/* Grid System */
.grid-cols-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

/* KPI Stat Cards */
.stat-card {
  background: linear-gradient(145deg, rgba(255,255,255,0.98), rgba(248,250,252,0.9));
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: 18px;
  padding: 21px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 18px 36px -34px rgba(15, 23, 42, 0.8);
  position: relative;
  overflow: hidden;
  min-height: 118px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, #0f766e, #0ea5e9);
}

.grid-cols-4 .stat-card:nth-child(2n)::before {
  background: linear-gradient(90deg, #f59e0b, #0ea5e9);
}

.grid-cols-4 .stat-card:nth-child(3n)::before {
  background: linear-gradient(90deg, #10b981, #14b8a6);
}

.grid-cols-4 .stat-card:nth-child(4n)::before {
  background: linear-gradient(90deg, #ef4444, #f59e0b);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(14, 165, 233, 0.34);
  box-shadow: 0 22px 48px -34px rgba(15, 23, 42, 0.9);
}

.stat-title {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 800;
  text-transform: uppercase;
}

.stat-value {
  font-size: 27px;
  font-weight: 850;
  color: var(--text-main);
  margin-top: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
  text-decoration: none;
  min-height: 38px;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #0f766e);
  color: #ffffff;
  box-shadow: 0 12px 24px -18px rgba(14, 165, 233, 0.9);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #0284c7, #0f766e);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 16px 28px -18px rgba(14, 165, 233, 1);
}

.btn-secondary {
  background: #f8fafc;
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background-color: #eef5f8;
  text-decoration: none;
  transform: translateY(-1px);
}

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

/* Action Icons (Eye, Pencil, Trash, Shield) */
.btn-icon {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  background: #ffffff;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.tab-item:focus-visible,
.dropdown-item:focus-visible,
.btn:focus-visible,
.btn-icon:focus-visible,
.logout-btn:focus-visible,
.form-control:focus-visible {
  outline: 3px solid rgba(14, 165, 233, 0.25);
  outline-offset: 2px;
}
.btn-icon:hover {
  background: #f1f5f9;
}
.btn-icon.view:hover { color: var(--accent); border-color: var(--accent); }
.btn-icon.edit:hover { color: var(--warning); border-color: var(--warning); }
.btn-icon.delete:hover { color: var(--danger); border-color: var(--danger); }
.btn-icon.shield:hover { color: #8b5cf6; border-color: #8b5cf6; }

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
}

.table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  text-align: left;
}

.table-compact {
  min-width: 0;
  table-layout: fixed;
}

.dashboard-summary-table th,
.dashboard-summary-table td {
  white-space: normal;
}

.dashboard-summary-table .amount-cell {
  text-align: right;
  white-space: nowrap;
  width: 42%;
}

.table th {
  background-color: #f7fafc;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-color);
}

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

.table th,
.table td {
  overflow-wrap: anywhere;
}

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

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-info    { background: #e0f2fe; color: #0369a1; }

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

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

.form-control {
  width: 100%;
  padding: 10px 13px;
  border-radius: 11px;
  border: 1px solid #dbe5ef;
  font-size: 13px;
  outline: none;
  background-color: #ffffff;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: var(--ring-accent);
}

.form-control.is-invalid {
  border-color: var(--danger);
  background-color: #fff7f7;
}

/* Modern Select & Popup Modal Dropdown System */
select.form-control,
.modal-box select,
.modal-backdrop select,
.form-group select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 100%;
  padding: 10px 38px 10px 14px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  color: #1e293b;
  background-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%230284c7' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px 16px;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

select.form-control:hover,
.modal-box select:hover,
.modal-backdrop select:hover,
.form-group select:hover {
  border-color: #0284c7;
  background-color: #f8fafc;
  box-shadow: 0 2px 5px rgba(14, 165, 233, 0.08);
}

select.form-control:focus,
.modal-box select:focus,
.modal-backdrop select:focus,
.form-group select:focus {
  border-color: #0284c7;
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18), 0 1px 3px rgba(15, 23, 42, 0.08);
  outline: none;
}

select.form-control:disabled,
.modal-box select:disabled,
.modal-backdrop select:disabled {
  background-color: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
  border-color: #e2e8f0;
  opacity: 0.75;
}

.modal-box select option,
.modal-backdrop select option,
select.form-control option {
  padding: 10px 14px;
  font-size: 13.5px;
  color: #0f172a;
  background-color: #ffffff;
}

/* Modal Form Controls Polish */
.modal-box .form-label,
.modal-backdrop .form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.modal-box input.form-control,
.modal-backdrop input.form-control,
.modal-box textarea.form-control,
.modal-backdrop textarea.form-control {
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  font-size: 13.5px;
  color: #1e293b;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-box input.form-control:focus,
.modal-backdrop input.form-control:focus,
.modal-box textarea.form-control:focus,
.modal-backdrop textarea.form-control:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18), 0 1px 3px rgba(15, 23, 42, 0.08);
  background-color: #ffffff;
}

.form-error-summary {
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  color: #991b1b;
  font-size: 13px;
  font-weight: 600;
}

.btn.is-loading,
button.is-loading {
  opacity: 0.75;
  cursor: wait;
}

/* Modal and Form Grid System */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid .full-width,
.form-grid .col-span-2 {
  grid-column: 1 / -1;
}

/* Page Header Utility */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}

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

/* Empty State Visual Component */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 38px;
  margin-bottom: 12px;
  opacity: 0.8;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size: 13px;
  max-width: 420px;
  margin: 0 auto 16px;
  line-height: 1.5;
}

/* Search Box Container */
.search-wrapper {
  position: relative;
  display: inline-block;
  max-width: 100%;
}
.search-wrapper input {
  padding-left: 32px;
}
.search-icon-pos {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  fill: var(--text-muted);
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 18px 40px -36px rgba(15, 23, 42, 0.7);
}

.filter-bar .form-group {
  margin-bottom: 0;
}

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

/* POS Terminal */
.pos-page-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 14px;
}

.pos-container-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 20px;
  height: calc(100vh - 178px);
  min-height: 640px;
  align-items: stretch;
}

.pos-catalog-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.pos-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(220px, 320px);
  gap: 12px;
  margin-bottom: 16px;
  align-items: stretch;
}

.pos-customer-select {
  width: 100%;
}

.pos-toolbar .search-wrapper {
  width: 100%;
  display: block;
}

.pos-search-control {
  position: relative;
}

.pos-search-control::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.32), rgba(15, 118, 110, 0.18));
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.pos-search-control:focus-within::before {
  opacity: 1;
}

.pos-smart-input,
.pos-smart-select {
  min-height: 48px;
  border-radius: 16px;
  border-color: rgba(203, 213, 225, 0.86);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
  box-shadow: 0 14px 30px -28px rgba(15, 23, 42, 0.9), inset 0 1px 0 rgba(255,255,255,0.9);
  font-size: 13.5px;
  font-weight: 650;
  color: #172033;
}

.pos-smart-input::placeholder {
  color: #8a97a9;
  font-weight: 500;
}

.pos-search-control .pos-smart-input {
  position: relative;
  padding-left: 48px;
}

.pos-search-control .search-icon-pos {
  left: 16px;
  width: 18px;
  height: 18px;
  fill: #6b7a90;
  z-index: 1;
}

.pos-search-control:focus-within .search-icon-pos {
  fill: var(--accent);
}

.pos-smart-input:focus,
.pos-smart-select:focus {
  border-color: rgba(14, 165, 233, 0.72);
  background: #ffffff;
  box-shadow: var(--ring-accent), 0 18px 36px -30px rgba(14, 165, 233, 0.9);
}

.pos-select-shell {
  position: relative;
}

.pos-select-shell::after {
  content: "";
  position: absolute;
  right: 17px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid #64748b;
  border-bottom: 2px solid #64748b;
  transform: translateY(-64%) rotate(45deg);
  pointer-events: none;
  transition: border-color 0.16s ease, transform 0.16s ease;
}

.pos-select-shell:focus-within::after {
  border-color: var(--accent);
  transform: translateY(-48%) rotate(225deg);
}

.pos-select-kicker {
  position: absolute;
  left: 14px;
  top: 6px;
  z-index: 1;
  font-size: 9px;
  line-height: 1;
  font-weight: 850;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #7890a8;
  pointer-events: none;
}

.pos-smart-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 20px 42px 7px 14px;
  cursor: pointer;
}

.pos-cart-select-shell .pos-smart-select {
  min-height: 52px;
  font-size: 13px;
  border-radius: 16px;
}

.pos-note-input {
  min-height: 46px;
  font-size: 12.5px;
  border-radius: 15px;
}

#discountInput {
  min-height: 31px;
  border-radius: 10px !important;
  border-color: rgba(203, 213, 225, 0.9) !important;
  background: #ffffff;
  font-weight: 700;
  color: #172033;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#discountInput:focus {
  outline: none;
  border-color: rgba(14, 165, 233, 0.72) !important;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.14);
}

.pos-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  align-content: start;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 4px;
}

.pos-item-card {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: 18px;
  padding: 10px;
  min-height: 238px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.pos-item-card:hover {
  border-color: rgba(20, 184, 166, 0.42);
  box-shadow: 0 18px 38px -30px rgba(15, 23, 42, 0.88);
  transform: translateY(-2px);
}

.pos-item-image {
  position: relative;
  height: 112px;
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #eef7fb, #f8fafc);
  border: 1px solid rgba(226, 232, 240, 0.9);
}

.pos-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pos-item-image-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 900;
  color: #0f766e;
  background: linear-gradient(135deg, rgba(204,251,241,.9), rgba(224,242,254,.9));
}

.pos-item-size-pill {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
}

.pos-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pos-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  flex-shrink: 0;
}

.pos-item-title {
  font-weight: 800;
  font-size: 13px;
  line-height: 1.35;
  margin: 5px 0;
  color: var(--primary);
}

.pos-item-sku {
  font-size: 11px;
  color: var(--accent);
  font-family: monospace;
  overflow-wrap: anywhere;
}

.pos-item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.pos-cart-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.pos-cart-line-image {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  overflow: hidden;
  background: #eef6f8;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0f766e;
  font-weight: 900;
  flex-shrink: 0;
}

.pos-cart-line-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-thumb-sm {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(204,251,241,.9), rgba(224,242,254,.9));
  color: #0f766e;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.product-thumb-sm img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pos-item-price {
  font-weight: 900;
  color: var(--success);
  font-size: 14px;
  white-space: nowrap;
}

.pos-item-stock {
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--text-muted);
  white-space: nowrap;
}

.pos-cart-panel {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  min-height: 0;
  overflow: hidden;
}

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

.pos-cart-items {
  flex: 1;
  min-height: 220px;
  overflow-y: auto;
  padding: 12px;
}

.pos-cart-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background-color: #f8fafc;
}

/* Modal Dialog */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-backdrop.show {
  display: flex;
  padding: 16px;
}
.modal-box {
  background: #ffffff;
  border-radius: 16px;
  width: 90%;
  max-width: 560px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(226, 232, 240, 0.8);
  overflow: hidden;
  animation: modalFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}
.modal-body {
  padding: 22px 24px;
  max-height: 75vh;
  overflow-y: auto;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background-color: #f8fafc;
}

/* ==========================================================================
   Responsive & Mobile Navigation Enhancements
   ========================================================================== */

@media (max-width: 992px) {
  .top-nav-container {
    padding: 0 16px;
    height: auto;
    min-height: 60px;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .nav-tabs-wrapper {
    order: 3;
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }

  .nav-tabs-wrapper > .tab-item,
  .nav-tabs-wrapper > .nav-dropdown {
    scroll-snap-align: start;
  }

  .tab-item {
    padding: 8px 12px;
    font-size: 13px;
  }

  .dropdown-menu {
    top: calc(100% + 6px);
  }

  .nav-tabs-wrapper::-webkit-scrollbar {
    height: 4px;
  }
  .nav-tabs-wrapper::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 4px;
  }

  .page-container {
    padding: 16px;
  }

  .page-title {
    font-size: 20px;
  }

  .card-header {
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
  }

  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-cols-2 {
    grid-template-columns: 1fr;
  }

  .pos-container-split {
    grid-template-columns: 1fr !important;
    height: auto !important;
    min-height: 0;
  }

  .pos-toolbar {
    grid-template-columns: 1fr;
  }

  .pos-product-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    overflow: visible;
  }

  .pos-cart-panel {
    min-height: 520px;
  }

  .pos-page-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .search-wrapper,
  .search-wrapper input {
    width: 100%;
  }

  .filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }

  .user-info {
    display: none;
  }

  .brand-text {
    font-size: 16px;
  }

  .top-nav-right {
    gap: 8px;
  }

  .user-pill {
    padding: 4px;
  }

  .logout-btn {
    width: 34px;
    height: 34px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-value {
    font-size: 22px;
  }

  .grid-cols-2 {
    grid-template-columns: 1fr;
  }

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

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header-actions {
    width: 100%;
    justify-content: stretch;
  }

  .page-header-actions > * {
    flex: 1 1 auto;
  }

  .btn {
    width: 100%;
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .pos-product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pos-item-card {
    min-height: 120px;
    padding: 10px;
  }

  .pos-item-title {
    font-size: 12px;
  }

  .pos-cart-panel {
    min-height: 480px;
  }

  .modal-footer {
    flex-wrap: wrap;
  }

  .card-body,
  .modal-body {
    padding: 16px;
  }

  .modal-box {
    width: 100%;
    margin: 10px;
  }
}

@media (max-width: 420px) {
  .top-nav-container {
    padding-left: 12px;
    padding-right: 12px;
  }

  .brand-icon {
    width: 28px;
    height: 28px;
  }

  .brand-svg {
    width: 26px;
    height: 26px;
  }

  .tab-item {
    padding: 7px 10px;
  }
}

/* ==========================================================================
   Universal Searchable Select Dropdown Component
   ========================================================================== */
.hw-ss-wrapper {
  position: relative;
  width: 100%;
  display: block;
}

.hw-ss-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-sm, 8px);
  color: #0f172a;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  user-select: none;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.hw-ss-trigger:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.hw-ss-trigger:focus,
.hw-ss-wrapper.is-open .hw-ss-trigger {
  border-color: var(--accent, #0284c7);
  background: #ffffff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.14);
}

.hw-ss-value {
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.hw-ss-value.is-placeholder {
  color: #94a3b8;
}

.hw-ss-arrow {
  flex-shrink: 0;
  color: #64748b;
  transition: transform 0.2s ease, color 0.2s ease;
}

.hw-ss-wrapper.is-open .hw-ss-arrow {
  transform: rotate(180deg);
  color: var(--accent, #0284c7);
}

/* Dropdown Panel */
.hw-ss-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1050;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  animation: hwSsFadeIn 0.15s ease;
}

.hw-ss-wrapper.is-open .hw-ss-dropdown {
  display: block;
}

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

/* Dropup */
.hw-ss-wrapper.is-dropup .hw-ss-dropdown {
  top: auto;
  bottom: calc(100% + 4px);
  animation: hwSsFadeUp 0.15s ease;
}

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

/* Search Box at the top */
.hw-ss-search-wrap {
  position: relative;
  padding: 8px 10px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hw-ss-search-icon {
  flex-shrink: 0;
  color: #64748b;
}

.hw-ss-search-input {
  width: 100%;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 26px 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: #0f172a;
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.hw-ss-search-input:focus {
  border-color: var(--accent, #0284c7);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.hw-ss-search-clear {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: #e2e8f0;
  color: #475569;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.hw-ss-search-clear:hover {
  background: #cbd5e1;
  color: #0f172a;
}

/* Options List */
.hw-ss-options-list {
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
}

.hw-ss-options-list::-webkit-scrollbar {
  width: 6px;
}
.hw-ss-options-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.hw-ss-optgroup-label {
  padding: 6px 12px 4px 12px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.04em;
  background: #f8fafc;
}

.hw-ss-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: #0f172a;
  cursor: pointer;
  transition: background 0.12s ease;
  user-select: none;
}

.hw-ss-option:hover,
.hw-ss-option.is-highlighted {
  background: #f1f5f9;
  color: var(--accent, #0284c7);
}

.hw-ss-option.is-selected {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

.hw-ss-opt-check {
  display: none;
  width: 14px;
  height: 14px;
  color: #1d4ed8;
  flex-shrink: 0;
}

.hw-ss-option.is-selected .hw-ss-opt-check {
  display: inline-block;
}

.hw-ss-option.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.hw-ss-empty {
  padding: 16px 12px;
  text-align: center;
  font-size: 12.5px;
  color: #64748b;
  background: #ffffff;
}

