/* ==========================================================================
   PATUNGAN - PREMIUM DESIGN SYSTEM (VANILLA CSS)
   Focus: Mobile-first, Clean slate, High-readability, Proportional layouts
   ========================================================================== */

/* 1. Global Reset & Core Styling */
:root {
  --primary: #4f46e5;         /* Indigo 600 */
  --primary-hover: #4338ca;   /* Indigo 700 */
  --primary-light: #e0e7ff;   /* Indigo 100 */
  --background: #f8fafc;      /* Slate 50 */
  --surface: #ffffff;
  --text-main: #0f172a;       /* Slate 900 */
  --text-muted: #64748b;      /* Slate 500 */
  --border: #e2e8f0;          /* Slate 200 */
  --border-focus: #cbd5e1;    /* Slate 300 */
  
  --success: #10b981;         /* Emerald 500 */
  --success-text: #047857;    /* Emerald 700 */
  --success-light: #d1fae5;   /* Emerald 100 */
  
  --danger: #f43f5e;          /* Rose 500 */
  --danger-text: #be123c;      /* Rose 700 */
  --danger-light: #ffe4e6;     /* Rose 100 */
  
  --warning: #f59e0b;         /* Amber 500 */
  --warning-text: #b45309;    /* Amber 700 */
  --warning-light: #fef3c7;   /* Amber 100 */
  
  --info: #0284c7;            /* Sky 600 */
  --info-light: #e0f2fe;      /* Sky 100 */
  
  --whatsapp: #25d366;        /* WA Brand Color */
  --whatsapp-hover: #20ba5a;
  
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  --card-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --sheet-shadow: 0 -10px 25px -5px rgba(15, 23, 42, 0.1), 0 -8px 10px -6px rgba(15, 23, 42, 0.1);
  --modal-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.15);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-round: 9999px;
  
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--background);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 15px;
  overflow: hidden;
  height: 100%;
  height: -webkit-fill-available;
  width: 100%;
  overscroll-behavior: none;
}

/* 2. Layout Structure */
#app-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: -webkit-fill-available;
  width: 100%;
  max-width: 480px; /* Mobile focused container centering on large screens */
  margin: 0 auto;
  background-color: var(--background);
  position: relative;
  box-shadow: 0 0 40px rgba(15, 23, 42, 0.08);
  overscroll-behavior: none;
  /* Force fixed-position children (like FAB) to be relative to app-container on desktop */
  transform: translate(0);
}

/* Screen Navigation */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 16px;
  background-color: var(--background);
  -webkit-overflow-scrolling: touch; /* Butter-smooth momentum scrolling for iOS */
  overscroll-behavior-y: contain;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* Welcome Screen Styling */
#welcome-screen {
  justify-content: center;
  align-items: center;
  overflow-y: auto;
  padding: 24px;
}

#workspace-screen {
  overflow: hidden;
  padding: 0;
  position: relative;
}

.welcome-card {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
}

.logo-area {
  text-align: center;
  margin-bottom: 28px;
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  background-color: var(--primary-light);
  color: var(--primary);
  margin-bottom: 16px;
}

.logo-icon i {
  width: 32px;
  height: 32px;
}

.logo-area h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.logo-area p {
  color: var(--text-muted);
  font-size: 14px;
}

/* Workspace Screen Sticky Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: calc(14px + var(--safe-top));
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.header-title-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header-title-area h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-round);
  background-color: var(--border);
  color: var(--text-muted);
  width: max-content;
}

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

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

.badge-info {
  background-color: var(--info-light);
  color: var(--info);
}

/* Sticky App Content Pane */
.app-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
  padding: 0 16px 80px 16px; /* Padding for bottom navbar & horizontal spacing */
  -webkit-overflow-scrolling: touch; /* Butter-smooth momentum scrolling for iOS */
  overscroll-behavior-y: contain;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

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

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

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

.panel-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

/* Bottom Navigation Bar */
.app-navbar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: calc(64px + var(--safe-bottom));
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 20;
  padding-bottom: var(--safe-bottom);
}

.nav-item {
  flex: 1;
  height: 100%;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  gap: 4px;
  transition: color 0.15s ease, transform 0.1s ease;
}

.nav-item i {
  width: 20px;
  height: 20px;
  stroke-width: 2.2;
}

.nav-item:active {
  transform: scale(0.95);
}

.nav-item.active {
  color: var(--primary);
}

/* 3. Cards & Lists UI */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  padding: 16px;
  margin-bottom: 16px;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card:active {
  transform: translateY(1px);
}

/* Buttons System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}
.btn-primary:active {
  transform: scale(0.98);
}

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

.btn-block {
  display: flex;
  width: 100%;
}

.btn-sm {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.btn-xs {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.btn-square {
  padding: 12px;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-round);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-icon:hover {
  background-color: var(--background);
  color: var(--text-main);
}

/* Ensure button taps inside scrollable areas don't block iOS scroll */
.member-chip .btn-icon,
.member-chip-actions .btn-icon {
  touch-action: manipulation;
}

.btn-icon-badge {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background-color: var(--background);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-icon-badge.locked {
  background-color: var(--warning-light);
  color: var(--warning-text);
  border-color: var(--warning);
}

.btn-icon-badge.unlocked {
  background-color: var(--success-light);
  color: var(--success-text);
  border-color: var(--success);
}

/* Floating Action Button (FAB) */
.btn-fab {
  position: fixed;
  bottom: 80px;
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-round);
  box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3), 0 4px 6px -4px rgba(79, 70, 229, 0.3);
  z-index: 15;
  padding: 0;
}

.btn-fab i {
  width: 24px;
  height: 24px;
}

/* Forms Styling */
.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
}

.label-info {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}

.form-group input,
.form-group select,
.form-group textarea {
  font-family: var(--font-family);
  font-size: 16px; /* Prevents annoying iOS Safari auto-zoom on input focus */
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  outline: none;
  background-color: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.form-row .col {
  flex: 1;
}

.form-row .col-4 {
  width: 33.33%;
}

.form-row .col-6 {
  width: 50%;
}

.input-group {
  display: flex;
  gap: 8px;
  width: 100%;
}

.input-group input {
  flex: 1;
}

.input-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* Custom Checkbox */
.checkbox-container {
  display: flex;
  align-items: center;
  position: relative;
  padding-left: 28px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  user-select: none;
}

.checkbox-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: absolute;
  top: 1px;
  left: 0;
  height: 18px;
  width: 18px;
  background-color: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 4px;
  transition: all 0.15s ease;
}

.checkbox-container:hover input ~ .checkmark {
  border-color: var(--text-muted);
}

.checkbox-container input:checked ~ .checkmark {
  background-color: var(--primary);
  border-color: var(--primary);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
  display: block;
}

.checkbox-container .checkmark:after {
  left: 6px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* 4. Tab Panels Layout Details */

/* Group Tab */
.add-member-card {
  padding: 12px;
  border-style: dashed;
  border-width: 1.5px;
}

.members-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  /* Prevent iOS from stealing scroll gestures on this container */
  touch-action: pan-y;
}

.member-chip {
  background-color: var(--surface);
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--card-shadow);
  /* Prevent transform on :active causing iOS scroll issues */
  touch-action: pan-y;
  -webkit-transform: translateZ(0);
}

.member-name-area {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.member-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-round);
  background-color: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.btn-remove-member {
  color: var(--text-muted);
}
.btn-remove-member:hover {
  color: var(--danger);
  background-color: var(--danger-light);
}

/* Bills Tab */
.bills-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bill-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bill-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.bill-card-info h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.bill-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.bill-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bill-meta-item i {
  width: 13px;
  height: 13px;
}

.bill-card-amount {
  text-align: right;
  flex-shrink: 0;
}

.bill-total-tag {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
}

.bill-sub-tag {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}

/* Item Chips in Card */
.bill-items-list-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}

.preview-item-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.preview-item-left {
  display: flex;
  gap: 6px;
  color: var(--text-main);
}

.preview-item-qty {
  color: var(--text-muted);
  font-weight: 600;
}

.preview-item-names {
  color: var(--text-muted);
  font-size: 11px;
  font-style: italic;
  margin-left: 4px;
}

.bill-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Settlement Tab */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.summary-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0;
}

.summary-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.summary-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.card-total .summary-val {
  color: var(--primary);
}

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

.section-container h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.section-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.section-title-bar h4 {
  margin-bottom: 0;
}

.section-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Balances Grid Stack */
.balances-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.balance-item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--card-shadow);
}

.balance-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.balance-user-info {
  display: flex;
  flex-direction: column;
}

.balance-user-name {
  font-weight: 700;
  font-size: 14px;
}

.balance-user-details {
  font-size: 11px;
  color: var(--text-muted);
}

.balance-item-right {
  text-align: right;
  display: flex;
  flex-direction: column;
}

.balance-amount {
  font-size: 14px;
  font-weight: 800;
}

.balance-amount.positive {
  color: var(--success-text);
}

.balance-amount.negative {
  color: var(--danger-text);
}

.balance-amount-desc {
  font-size: 10px;
  color: var(--text-muted);
}

/* Settlements/Transfers Stack */
.settlements-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settlement-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--card-shadow);
}

.settlement-flow {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.settlement-party {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 80px;
  text-align: center;
}

.settlement-party .party-name {
  font-size: 12px;
  font-weight: 700;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.settlement-arrow-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.settlement-amount {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 2px;
  background-color: var(--primary-light);
  padding: 2px 8px;
  border-radius: var(--radius-round);
}

.settlement-line-arrow {
  width: 100%;
  height: 2px;
  background-color: var(--primary);
  position: relative;
}

.settlement-line-arrow::after {
  content: "";
  position: absolute;
  right: 0;
  top: -4px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid var(--primary);
}

.share-buttons-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

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

/* Empty / No Items States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-icon {
  width: 56px;
  height: 56px;
  background-color: var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-round);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.empty-icon i {
  width: 28px;
  height: 28px;
}

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

.empty-state p {
  font-size: 12px;
  margin-bottom: 16px;
  max-width: 260px;
}

/* 5. Modals, Sheets & Backdrops */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.modal-backdrop.active {
  display: block;
  opacity: 1;
}

/* Bottom Sheet */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: 480px;
  background-color: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--sheet-shadow);
  z-index: 101;
  display: flex;
  flex-direction: column;
  max-height: 92dvh;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.3, 1);
  padding-bottom: var(--safe-bottom);
}

.bottom-sheet.active {
  transform: translate(-50%, 0);
}

.sheet-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.sheet-drag-handle {
  width: 36px;
  height: 4px;
  background-color: var(--border);
  border-radius: var(--radius-round);
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
}

.sheet-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 4px;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.sheet-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.sheet-actions .btn {
  flex: 1;
}

/* Disabled inputs in view-only bill sheet */
.bottom-sheet input:disabled,
.bottom-sheet select:disabled,
.bottom-sheet textarea:disabled {
  background-color: var(--background);
  color: var(--text-main);
  opacity: 0.8;
  cursor: default;
  -webkit-text-fill-color: var(--text-main);
}

/* Edit/View Only Display Control */
.view-only-hidden {
  display: inherit;
}

body.view-only .edit-only {
  display: none !important;
}

body.edit-only .view-only {
  display: none !important;
}

/* Interactive Split Selector Matrix */
.split-info-header {
  background-color: var(--background);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.split-info-header h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.split-price-details {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.split-help-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.4;
}

.split-quick-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.split-members-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.split-member-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--surface);
  transition: all 0.15s ease;
}

.split-member-row.selected {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.split-member-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.split-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.split-member-name {
  font-size: 13px;
  font-weight: 600;
}

.split-amount-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 8px;
}

/* Numeric Counter for splitting (3 meatballs, 1 for A, 2 for B) */
.split-counter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-counter {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-round);
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  transition: all 0.1s ease;
}

.btn-counter:active {
  transform: scale(0.9);
  background-color: var(--background);
}

.counter-value {
  font-size: 13px;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
}

.split-summary-footer {
  margin-top: 16px;
  background-color: var(--background);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background-color: var(--border);
  border-radius: var(--radius-round);
  overflow: hidden;
  margin-top: 6px;
}

.progress-bar {
  height: 100%;
  background-color: var(--primary);
  border-radius: var(--radius-round);
  transition: width 0.2s ease;
}

.progress-bar.success {
  background-color: var(--success);
}

.progress-bar.danger {
  background-color: var(--danger);
}

.split-warning {
  margin-top: 8px;
  color: var(--danger-text);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}

.split-warning i {
  width: 14px;
  height: 14px;
}

/* ==================== BILL FORM ITEMS SCROLL ==================== */
.bill-items-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 12px;
}

.bill-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background-color: var(--background);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.item-field-name {
  flex: 3;
}

.item-field-qty {
  flex: 1.2;
}

.item-field-price {
  flex: 2;
}

.bill-item-row input {
  font-size: 12px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  width: 100%;
}

.btn-item-split-assign {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.btn-item-split-assign.assigned {
  background-color: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-item-split-assign i {
  width: 16px;
  height: 16px;
}

.btn-delete-item-row {
  color: var(--text-muted);
}
.btn-delete-item-row:hover {
  color: var(--danger);
}

/* Tax / Discount / Summary Totals block */
.bill-summary-totals {
  background-color: var(--background);
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.discount-line {
  color: var(--success-text);
}

.grand-total {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 2px;
}

.grand-total span:last-child {
  color: var(--primary);
}

/* Down Payment View Adjustments */
.dp-checkbox-area {
  margin-top: 4px;
  margin-bottom: 12px;
}

.dp-details {
  background-color: var(--warning-light);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--warning);
  margin-bottom: 12px;
  animation: slideDown 0.2s ease-out;
}

.hidden {
  display: none !important;
}

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

/* OCR Receipt Scanner Modal Details */
.ocr-banner {
  background-color: var(--primary-light);
  border: 1.5px dashed var(--primary);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.ocr-banner-content {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.ocr-banner-content i {
  color: var(--primary);
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.ocr-banner-content h5 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.ocr-banner-content p {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

.ocr-upload-zone {
  border: 2px dashed var(--border);
  background-color: var(--background);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: all 0.15s ease;
  margin-bottom: 20px;
}

.ocr-upload-zone:hover {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.upload-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
}

.file-input-hidden {
  display: none;
}

.ocr-tips-card {
  background-color: var(--info-light);
  border: 1px solid var(--info);
  border-radius: var(--radius-md);
  padding: 14px;
  color: var(--info);
}

.ocr-tips-card h5 {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.ocr-tips-card ul {
  font-size: 11px;
  padding-left: 16px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Spinner and OCR loader */
.ocr-loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  min-height: 220px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: var(--radius-round);
  animation: spin 1s infinite linear;
  margin-bottom: 16px;
}

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

.spin {
  animation: spin 1s infinite linear;
}

.ocr-loader-container h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.ocr-loader-container p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.ocr-loader-container .progress-bar-container {
  max-width: 200px;
}

/* OCR Results Layout */
.ocr-result-split-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.text-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.text-panel textarea {
  font-family: monospace;
  font-size: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  resize: vertical;
  background-color: var(--background);
}

.parsed-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.parsed-items-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  background-color: var(--background);
}

.ocr-parsed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background-color: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.ocr-parsed-row-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.ocr-parsed-item-name {
  font-size: 12px;
  font-weight: 600;
}

.ocr-parsed-item-price {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.ocr-step {
  display: none;
}

.ocr-step.active {
  display: block;
}

/* ==================== MODAL PASSWORD DIALOG ==================== */
.modal-dialog {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 90%;
  max-width: 380px;
  background-color: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--modal-shadow);
  z-index: 110;
  display: none;
  opacity: 0;
  transition: all 0.2s ease;
}

.modal-dialog.active {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.modal-content {
  padding: 24px;
}

.modal-header {
  margin-bottom: 12px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-header h3 i {
  color: var(--warning);
}

.modal-body p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.4;
}

.text-danger {
  color: var(--danger);
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
  display: block;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.modal-actions .btn {
  flex: 1;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.6);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  gap: 12px;
}

.loading-overlay p {
  font-size: 14px;
  font-weight: 600;
}

/* ==================== WELCOME LANDING SCREEN HISTORY CARDS ==================== */
.history-item-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--card-shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.history-item-card:hover {
  transform: translateY(-1px);
  border-color: var(--primary-light);
}

.history-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  overflow: hidden;
}

.history-item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background-color: var(--background);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.history-item-icon i {
  width: 18px;
  height: 18px;
}

.history-item-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
}

.history-item-info h5 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-info span {
  font-size: 10px;
  color: var(--text-muted);
}

/* Member chip details stack additions */
.member-details-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.member-name-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.member-pay-info {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}

.member-chip-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Settlement cards styling additions */
.settlement-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--card-shadow);
}

.settlement-card-header {
  width: 100%;
}

.settlement-instruction-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: center;
}

.settlement-pay-details {
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.settlement-pay-details.empty {
  color: var(--text-muted);
  font-style: italic;
}

.pay-details-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.pay-details-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}

.pay-details-val {
  font-size: 12px;
  font-weight: 700;
  font-family: monospace;
  color: var(--text);
}

/* Settlement explanation block additions */
.settlement-explanation {
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.explanation-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.explanation-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.explanation-list li {
  line-height: 1.4;
  margin-bottom: 6px;
}

.explanation-list li:last-child {
  margin-bottom: 0;
}

.explanation-row-main {
  font-size: 11px;
}

.btn-toggle-details {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 6px;
  margin-top: 4px;
  margin-left: 14px; /* Align with text after 👉 */
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-sm);
  background-color: var(--primary-light);
  transition: all 0.2s ease;
}

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

.btn-toggle-details .chevron-icon {
  width: 10px;
  height: 10px;
  transition: transform 0.2s ease;
}

.explanation-details-collapsed {
  display: none;
  margin-top: 6px;
  margin-left: 14px; /* Align with text after 👉 */
  padding: 8px 10px;
  background-color: var(--background);
  border-left: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  flex-direction: column;
  gap: 6px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.explanation-details-collapsed.active {
  display: flex;
}

.detail-activity-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.detail-activity-card:not(:last-child) {
  margin-bottom: 8px;
}

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

.detail-activity-name {
  font-weight: 700;
  color: var(--text-main);
  font-size: 10.5px;
}

.detail-activity-net-total {
  font-size: 10px;
  color: var(--primary);
}

.detail-activity-items-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 4px;
}

.detail-activity-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9.5px;
  color: var(--text);
}

.activity-item-name {
  color: var(--text);
  font-weight: 500;
}

.activity-item-portion {
  font-size: 8px;
  color: var(--text-muted);
  font-weight: normal;
}

.activity-item-price {
  font-family: monospace;
  font-weight: 600;
  color: var(--text-main);
}

.detail-activity-summary-section {
  border-top: 1px dashed var(--border);
  padding-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.activity-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9px;
  color: var(--text-muted);
}

.activity-summary-row.adjustment {
  font-style: italic;
  color: var(--text-muted);
}

.detail-activity-payment-row {
  border-top: 1px solid var(--border);
  padding-top: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9.5px;
  font-weight: 600;
}

.text-success-muted {
  color: var(--success-text);
  font-weight: 700;
}

.detail-activity-routing-explanation {
  background-color: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 8.5px;
  line-height: 1.35;
  color: var(--text);
  border-left: 2px solid var(--primary);
  margin-top: 4px;
}

/* Universal iOS Auto-Zoom Mitigation Rule */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="email"],
select,
textarea {
  font-size: 16px !important;
}


