/*
 * Chai & Coffee Tracker - Design System
 * Theme: Indian Chai (Clay Kulhad Terracotta) & Roasted Coffee
 * Mobile-First, Fullport Viewport (100dvh)
 */

:root {
  /* Brand Colors - Indian Chai & Coffee */
  --chai-terracotta: #B5481B;
  --chai-terracotta-hover: #9E3C12;
  --chai-amber: #D97706;
  --chai-saffron: #F59E0B;
  --coffee-dark: #331E14;
  --coffee-espresso: #24140D;
  --coffee-roast: #4A2E20;
  
  /* Semantic Tokens */
  --status-approved: #1E6B45;
  --status-approved-bg: #EAF5EF;
  --status-pending: #B45309;
  --status-pending-bg: #FEF3C7;
  --status-rejected: #B91C1C;
  --status-rejected-bg: #FEE2E2;

  /* Surfaces & Canvas */
  --bg-canvas: #FAF7F2;
  --bg-surface: #FFFFFF;
  --bg-surface-secondary: #F4EFEA;
  --bg-surface-tertiary: #EFE8E0;
  --border-subtle: #E8DDD2;
  --border-strong: #D5C5B5;

  /* Text & Ink */
  --ink-primary: #2B1B15;
  --ink-secondary: #6E5A4E;
  --ink-muted: #948175;
  --ink-on-dark: #FFFFFF;
  --ink-on-primary: #FFFFFF;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(51, 30, 20, 0.06);
  --shadow-md: 0 4px 12px rgba(51, 30, 20, 0.08);
  --shadow-lg: 0 10px 24px rgba(51, 30, 20, 0.12);
  --shadow-drawer: 0 -4px 20px rgba(51, 30, 20, 0.15);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  /* Touch Targets (Apple HIG & Material 3 minimum 44px) */
  --touch-min: 44px;
  --header-height: 60px;
  --bottom-nav-height: 68px;
  --sidebar-width: 260px;
}

/* Reset & Fullport Foundation */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  height: 100dvh;
  width: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-canvas);
  color: var(--ink-primary);
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Fullport Shell Layout */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* Header */
.app-header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 30;
  flex-shrink: 0;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-logo-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--chai-terracotta), var(--coffee-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFF;
  font-size: 20px;
  box-shadow: 0 2px 6px rgba(194, 94, 46, 0.3);
}

.brand-meta {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--coffee-dark);
  line-height: 1.2;
}

.brand-tagline {
  font-size: 11px;
  color: var(--ink-muted);
  font-weight: 500;
}

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

.user-profile-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 6px;
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--chai-terracotta);
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  min-width: 36px;
  min-height: 36px;
}

.btn-logout:hover {
  background: var(--bg-surface-tertiary);
  color: var(--status-rejected);
}

/* App Body (Sidebar + Content) */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Desktop Sidebar Nav */
.desktop-sidebar {
  display: none;
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  padding: 20px 12px;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex-shrink: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  color: var(--ink-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  min-height: var(--touch-min);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-link:hover {
  background: var(--bg-surface-secondary);
  color: var(--coffee-dark);
}

.nav-link.active {
  background: var(--chai-terracotta);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(194, 94, 46, 0.25);
}

.nav-link .badge-count {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  background: var(--chai-amber);
  color: #FFF;
}

.nav-link.active .badge-count {
  background: #FFF;
  color: var(--chai-terracotta);
}

/* Main Content Container (Fullport Scroll) */
.app-main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: calc(var(--bottom-nav-height) + 20px);
}

/* Strict Mobile vs Desktop Panes Isolation */
.desktop-sidebar {
  display: none !important;
}

.bottom-nav {
  display: none !important;
  height: 72px;
  min-height: 72px;
  width: 100%;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 8px 12px max(12px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(51, 30, 20, 0.05);
  z-index: 40;
  box-sizing: border-box;
}

@media (max-width: 767.98px) {
  .desktop-sidebar {
    display: none !important;
  }
  body.authenticated .bottom-nav {
    display: flex !important;
    align-items: center;
    justify-content: space-around;
  }
}

@media (min-width: 768px) {
  body.authenticated .desktop-sidebar {
    display: flex !important;
  }
  .app-main {
    padding: 24px 32px;
    padding-bottom: 40px;
  }
  .bottom-nav {
    display: none !important;
  }
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  height: 100%;
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  min-width: 0;
  padding: 4px 2px;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item.active {
  color: var(--chai-terracotta);
}

.bottom-nav-item .nav-icon {
  font-size: 20px;
}

.bottom-nav-item .nav-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 16px);
  background: var(--chai-terracotta);
  color: #FFF;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  padding: 1px 5px;
  line-height: 1.2;
}

/* SPA View Panels */
.view-panel {
  display: none;
  animation: fadeIn 0.25s ease-out;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Allow data tables and ledger to use full desktop width */
.view-panel.view-fullwidth,
#view-ledger,
#view-approvals,
#view-catalog,
#view-settings {
  max-width: 100%;
}

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

/* Auth & Login View Screen */
#view-login.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - var(--header-height) - 48px);
}

.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
  margin: 0 auto;
  box-sizing: border-box;
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 12px;
  display: inline-block;
  filter: drop-shadow(0 2px 4px rgba(181, 72, 27, 0.2));
}

.login-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--coffee-dark);
  letter-spacing: -0.4px;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--ink-secondary);
  line-height: 1.4;
}

@media (max-width: 767.98px) {
  .login-card {
    padding: 28px 20px;
    border-radius: var(--radius-md);
  }
}

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

/* Typography & Headings */
.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--coffee-dark);
}

.page-subtitle {
  font-size: 13px;
  color: var(--ink-secondary);
  margin-top: 2px;
}

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

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

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

.kpi-card.today::before { background: var(--chai-terracotta); }
.kpi-card.mtd::before { background: var(--coffee-dark); }
.kpi-card.pending::before { background: var(--chai-amber); }
.kpi-card.paid::before { background: var(--status-approved); }
.kpi-card.ratio::before { background: #6366F1; }

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.kpi-icon {
  font-size: 18px;
}

.kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.kpi-main-val {
  font-size: 26px;
  font-weight: 800;
  color: var(--coffee-dark);
  line-height: 1;
}

.kpi-sub-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.kpi-footer {
  font-size: 12px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Tea vs Coffee Meter */
.ratio-meter-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ratio-bar {
  height: 8px;
  border-radius: var(--radius-pill);
  background: #E5D5C5;
  display: flex;
  overflow: hidden;
}

.ratio-tea-fill {
  background: var(--chai-terracotta);
  transition: width 0.3s ease;
}

.ratio-coffee-fill {
  background: var(--coffee-dark);
  transition: width 0.3s ease;
}

.ratio-legend {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
}

.ratio-tea-legend { color: var(--chai-terracotta); }
.ratio-coffee-legend { color: var(--coffee-dark); }

/* Interactive Calendar Section */
.calendar-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.calendar-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.calendar-current-month {
  font-size: 18px;
  font-weight: 800;
  color: var(--coffee-dark);
}

.calendar-nav-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-cal-nav {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-secondary);
  color: var(--ink-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.15s;
}

.btn-cal-nav:hover {
  background: var(--border-subtle);
}

.btn-cal-today {
  padding: 0 12px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-secondary);
  color: var(--ink-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-cal-today:hover {
  background: var(--chai-terracotta);
  color: #FFF;
  border-color: var(--chai-terracotta);
}

/* Calendar Grid */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 8px;
  text-align: center;
}

.calendar-weekday-cell {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  padding: 8px 0;
  letter-spacing: 0.5px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

/* Calendar Date Cards (Borders, Surfaces & Hierarchy) */
.calendar-day-cell,
.cal-day-cell {
  background: var(--bg-surface, #FFFFFF);
  border: 1px solid var(--border-subtle, #E8DDD2);
  border-radius: var(--radius-md, 10px);
  min-height: 105px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  box-shadow: 0 1px 3px rgba(51, 30, 20, 0.04);
}

.calendar-day-cell:hover,
.cal-day-cell:hover {
  border-color: var(--chai-terracotta);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: #FFFFFF;
}

/* Weekend Subtle Shading */
.calendar-day-cell.weekend,
.cal-day-cell.weekend {
  background: #FAF7F2;
  border-color: #ECE3DA;
}

.calendar-day-cell.empty,
.cal-day-cell.empty,
.cal-day-cell.empty-day {
  background: transparent;
  border: 1px dashed rgba(213, 197, 181, 0.45);
  box-shadow: none;
  cursor: default;
  pointer-events: none;
  min-height: 80px;
}

/* Today Active Highlight */
.calendar-day-cell.today,
.cal-day-cell.today {
  border: 2px solid var(--chai-terracotta);
  background: #FFF9F5;
  box-shadow: 0 0 0 1px var(--chai-terracotta), var(--shadow-sm);
}

.calendar-day-cell.today .cal-day-number,
.cal-day-cell.today .cal-day-number {
  background: var(--chai-terracotta);
  color: #FFFFFF;
  border-radius: 50%;
}

/* Status Borders */
.calendar-day-cell.status-approved,
.cal-day-cell.status-approved {
  border-top: 3px solid var(--status-approved);
}

.calendar-day-cell.status-pending,
.cal-day-cell.status-pending {
  border-top: 3px solid var(--chai-amber);
}

/* Day Number Badge */
.cal-day-number,
.cal-date-number {
  font-size: 13px;
  font-weight: 700;
  color: var(--coffee-dark);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.cal-day-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  justify-content: flex-end;
}

/* Slot Badges */
.cal-slot-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 4px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-slot-badge.morning {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FDE68A;
}

.cal-slot-badge.afternoon {
  background: #F4EFEA;
  color: #4A2E20;
  border: 1px solid #D5C5B5;
}

.cal-slot-badge.adhoc {
  background: #EDE9FE;
  color: #5B21B6;
  border: 1px solid #DDD6FE;
}

/* Day Total Row */
.cal-day-total {
  font-size: 12px;
  font-weight: 800;
  color: var(--chai-terracotta);
  text-align: right;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}

/* Mobile adjustments for calendar cells */
@media (max-width: 768px) {
  .calendar-weekdays {
    gap: 4px;
  }
  .calendar-weekday-cell {
    font-size: 10px;
    padding: 4px 0;
  }
  .calendar-grid {
    gap: 4px;
  }
  .calendar-day-cell,
  .cal-day-cell {
    min-height: 72px;
    padding: 4px;
    border-radius: 6px;
  }
  .cal-day-number {
    font-size: 11px;
    width: 18px;
    height: 18px;
    margin-bottom: 2px;
  }
  .cal-slot-badge {
    font-size: 9px;
    padding: 1px 3px;
  }
  .cal-day-total {
    font-size: 10px;
    padding-top: 2px;
  }
}

/* Delivery Logger Form Layout (Responsive POS Workstation) */
.delivery-grid-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

@media (min-width: 1024px) {
  .delivery-grid-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
  }
}

.delivery-config-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  width: 100%;
}

.delivery-items-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  width: 100%;
}

.logger-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  max-width: 650px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--coffee-dark);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink-primary);
  background: var(--bg-surface-secondary);
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--chai-terracotta);
  background: #FFF;
}

/* Segmented Slot Control */
.slot-selector,
.slot-segmented-control {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  background: var(--bg-surface-secondary);
  padding: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.slot-option-btn {
  height: 42px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.slot-option-btn:hover {
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink-primary);
}

.slot-option-btn.active {
  background: var(--bg-surface);
  color: var(--chai-terracotta);
  border-color: var(--border-subtle);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

/* Stepper Cards Grid */
.stepper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.stepper-item-card {
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stepper-item-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.stepper-item-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--coffee-dark);
}

.stepper-item-price {
  font-size: 13px;
  font-weight: 600;
  color: var(--chai-terracotta);
}

.stepper-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.btn-stepper {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: #FFF;
  color: var(--coffee-dark);
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-stepper:active {
  transform: scale(0.92);
  background: var(--bg-surface-tertiary);
}

.stepper-count-input {
  flex: 1;
  height: 44px;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: #FFF;
  color: var(--coffee-dark);
}

.stepper-quick-add {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.btn-quick-tag {
  font-size: 11px;
  font-weight: 700;
  background: #FFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  cursor: pointer;
  color: var(--ink-secondary);
}

.btn-quick-tag:hover {
  background: var(--chai-terracotta);
  color: #FFF;
  border-color: var(--chai-terracotta);
}

/* Live Amount Summary Banner */
.live-summary-banner {
  background: linear-gradient(135deg, var(--coffee-dark), var(--coffee-roast));
  color: #FFF;
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}

.live-summary-cups {
  font-size: 13px;
  opacity: 0.9;
}

.live-summary-amount {
  font-size: 24px;
  font-weight: 800;
  color: #FCD34D;
}

/* Primary Action Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--chai-terracotta);
  color: #FFFFFF;
  border: 1px solid var(--chai-terracotta);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 2px 6px rgba(181, 72, 27, 0.25);
}

.btn-primary:hover {
  background: var(--chai-terracotta-hover);
  border-color: var(--chai-terracotta-hover);
  box-shadow: 0 4px 12px rgba(181, 72, 27, 0.35);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(181, 72, 27, 0.2);
}

/* Alert Boxes */
.alert-box {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.alert-error {
  background: var(--status-rejected-bg);
  color: var(--status-rejected);
  border: 1px solid rgba(185, 28, 28, 0.2);
}

/* Primary Pill Button */
.btn-primary-pill {
  width: 100%;
  height: 48px;
  background: var(--chai-terracotta);
  color: #FFF;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(194, 94, 46, 0.35);
  transition: all 0.2s;
}

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

.btn-primary-pill:active {
  transform: scale(0.98);
}

/* Approvals & Verification Cards */
.approvals-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.approval-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.approval-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}

.approval-badge-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge.pending { background: var(--status-pending-bg); color: var(--status-pending); }
.badge.approved { background: var(--status-approved-bg); color: var(--status-approved); }
.badge.rejected { background: var(--status-rejected-bg); color: var(--status-rejected); }
.badge.slot { background: var(--bg-surface-secondary); color: var(--ink-secondary); border: 1px solid var(--border-subtle); }
.badge.badge-paid, .badge-paid { background: #DCFCE7; color: #15803D; border: 1px solid #BBF7D0; }
.badge.badge-unpaid, .badge-unpaid { background: #FEF3C7; color: #B45309; border: 1px solid #FDE68A; }

.approval-breakdown-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--bg-surface-secondary);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
}

.breakdown-item {
  display: flex;
  flex-direction: column;
}

.breakdown-label {
  font-size: 11px;
  color: var(--ink-muted);
}

.breakdown-val {
  font-weight: 700;
  color: var(--coffee-dark);
}

.approval-actions-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.btn-action {
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.btn-approve {
  background: var(--status-approved);
  color: #FFF;
}
.btn-approve:hover { background: #175436; }

.btn-edit-approve {
  background: var(--bg-surface-secondary);
  border-color: var(--border-strong);
  color: var(--ink-primary);
}
.btn-edit-approve:hover { background: var(--bg-surface-tertiary); }

.btn-reject {
  background: #FFF;
  border-color: var(--status-rejected);
  color: var(--status-rejected);
}
.btn-reject:hover { background: var(--status-rejected-bg); }

/* Modal & Slide Drawer */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(36, 20, 13, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

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

/* Delivery Slip Inspection modal stacks above payment selection and other base modals */
#modal-delivery-details {
  z-index: 120 !important;
}

/* Standard Centered Modal Dialog */
.modal-dialog {
  background: var(--bg-surface, #FFFFFF);
  color: var(--ink-primary, #2B1B15);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 550px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalPop 0.2s ease-out;
  border: 1px solid var(--border-subtle);
}

/* Date Inspector Drawer Modal */
.date-drawer {
  background: var(--bg-surface, #FFFFFF);
  color: var(--ink-primary, #2B1B15);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: modalPop 0.2s ease-out;
  border: 1px solid var(--border-subtle);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--coffee-dark);
  margin: 0;
}

.drawer-subtitle {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 3px;
  display: block;
}

/* Mobile More Dossier Bottom Sheet */
.bottom-sheet,
.modal-dossier {
  background: var(--bg-surface, #FFFFFF);
  color: var(--ink-primary, #2B1B15);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-subtle);
  padding: 20px;
  animation: modalPop 0.2s ease-out;
}

.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong, #D5C5B5);
  margin: 0 auto 16px auto;
  display: block;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.sheet-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--coffee-dark);
  margin: 0;
}

.sheet-subtitle {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Dossier User Profile Card */
.dossier-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

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

.dossier-user-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--coffee-dark);
}

.dossier-user-role {
  font-size: 12px;
  color: var(--chai-terracotta);
  font-weight: 600;
}

.dossier-user-office {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* Dossier Action Navigation Grid */
.dossier-nav-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.dossier-nav-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 12px 14px;
  background: #FFFFFF;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 74px;
}

.dossier-nav-item:hover,
.dossier-nav-item:active {
  background: #FFF9F5;
  border-color: var(--chai-terracotta);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.dossier-icon {
  font-size: 20px;
  margin-bottom: 4px;
}

.dossier-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--coffee-dark);
}

.dossier-hint {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.dossier-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

/* Mobile Bottom Sheet Specific Layout (< 768px) */
@media (max-width: 767.98px) {
  #modal-more-dossier,
  .modal-overlay:has(.bottom-sheet) {
    align-items: flex-end;
    padding: 0;
  }

  #modal-more-dossier .bottom-sheet,
  .bottom-sheet {
    max-width: 100%;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 16px 20px calc(env(safe-area-inset-bottom, 0px) + 24px) 20px;
    animation: slideUpSheet 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -8px 32px rgba(36, 20, 13, 0.3);
  }
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes modalPop {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--coffee-dark);
}

.btn-close-modal {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 4px;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-secondary);
}

/* Master Data / Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

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

.data-table th {
  background: var(--bg-surface-secondary);
  color: var(--ink-secondary);
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--ink-primary);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: #FFFDF9;
}

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

.empty-state-icon {
  font-size: 40px;
  opacity: 0.6;
}

.empty-state-text {
  font-size: 14px;
  font-weight: 500;
}

/* Compact Mobile Header (Prevents Brand Name Clipping) */
@media (max-width: 600px) {
  .app-header {
    padding: 0 12px;
    gap: 8px;
    height: 56px;
  }
  .brand-logo-badge {
    width: 32px;
    height: 32px;
    font-size: 16px;
    flex-shrink: 0;
  }
  .brand-name {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }
  .brand-tagline {
    display: none;
  }
  .user-profile-pill #header-user-name,
  .user-profile-pill #header-role-badge {
    display: none !important;
  }
  .user-profile-pill {
    padding: 2px;
    border: none;
    background: transparent;
  }
  .header-actions {
    gap: 6px;
  }
}

/* Calendar Weekend (Sat/Sun) Subtle Shading */
.calendar-day.weekend {
  background: rgba(51, 30, 20, 0.022);
}
.calendar-day.weekend .day-number {
  color: var(--ink-muted);
  font-weight: 500;
}

/* Master Settings Item Action Buttons */
.item-action-btns {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}
.btn-icon-action {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}
.btn-icon-action:hover {
  border-color: var(--chai-terracotta);
  color: var(--chai-terracotta);
  background: var(--bg-surface-secondary);
}
.btn-icon-action.danger:hover {
  border-color: var(--status-rejected);
  color: var(--status-rejected);
  background: rgba(197, 48, 48, 0.08);
}
.btn-icon-action.warning:hover {
  border-color: var(--chai-amber);
  color: var(--chai-amber);
  background: rgba(217, 119, 6, 0.08);
}

/* Sub-Tab Navigation for Ledger */
.subtab-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: var(--bg-surface-secondary);
  padding: 4px;
  border-radius: var(--radius-pill);
  width: fit-content;
}
.subtab-btn {
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.subtab-btn.active {
  background: var(--bg-surface);
  color: var(--chai-terracotta);
  box-shadow: 0 1px 4px rgba(51, 30, 20, 0.08);
}
.settlement-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(51, 30, 20, 0.04);
}

/* Category Filter Tabs */
.category-filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px 12px 2px;
  margin-bottom: 14px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.category-filter-bar::-webkit-scrollbar {
  display: none;
}
.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
  min-height: 40px;
}
.category-pill:hover {
  background: var(--bg-surface-secondary);
  border-color: var(--chai-terracotta);
}
.category-pill.active {
  background: var(--chai-terracotta);
  color: #FFF;
  border-color: var(--chai-terracotta);
  box-shadow: 0 2px 8px rgba(181, 72, 27, 0.25);
}

/* Product Cards Grid */
.products-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.product-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(51, 30, 20, 0.04);
  transition: all 0.18s ease;
}
.product-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.product-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}
.product-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--coffee-dark);
  line-height: 1.3;
}
.product-card-code {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.product-card-desc {
  font-size: 12px;
  color: var(--ink-secondary);
  margin-bottom: 8px;
  line-height: 1.4;
}
.product-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}
.badge-meta {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-secondary);
  color: var(--ink-secondary);
  text-transform: capitalize;
}
.badge-veg {
  background: #EAF5EF;
  color: #1E6B45;
  border-color: #C6E7D2;
}
.badge-vegan {
  background: #E0F2FE;
  color: #0369A1;
  border-color: #BAE6FD;
}
.badge-hot {
  background: #FFF7ED;
  color: #C2410C;
  border-color: #FFEDD5;
}
.badge-cold {
  background: #F0FDFA;
  color: #0F766E;
  border-color: #CCFBF1;
}
.badge-custom-rate {
  background: #FEF3C7;
  color: #B45309;
  border-color: #FDE68A;
  font-weight: 700;
}
.product-pricing-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-subtle);
}
.product-price-val {
  font-size: 17px;
  font-weight: 800;
  color: var(--chai-terracotta);
}
.product-price-unit {
  font-size: 11px;
  color: var(--ink-muted);
  font-weight: 500;
}
.item-chip-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--coffee-dark);
  margin: 2px 4px 2px 0;
}
.cart-summary-pill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-surface-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  font-size: 13px;
}

.slip-select-row {
  transition: background 0.15s ease;
}
.slip-select-row:hover {
  background: var(--bg-surface-secondary, #FAF7F2);
}
.slip-select-row.row-selected {
  background: #F0FDF4 !important;
}
.slip-select-row.row-selected:hover {
  background: #DCFCE7 !important;
}

/* Thermal Slip Print Styles (80mm standard POS roll) */
@media print {
  @page {
    size: 80mm auto;
    margin: 3mm;
  }
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace !important;
  }
  .desktop-sidebar, .bottom-nav, .app-header, .view-container, .modal-footer, .btn-close-modal, #btn-toggle-audit {
    display: none !important;
  }
  .modal-overlay {
    position: static !important;
    background: none !important;
    display: block !important;
    padding: 0 !important;
  }
  .modal-dialog {
    max-width: 100% !important;
    width: 100% !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
}

/* Provider Statistics Table Card */
.provider-stats-card {
  margin-top: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.provider-stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-wrap: wrap;
  gap: 8px;
}

.provider-stats-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--coffee-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.provider-stats-subtitle {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.provider-stats-period-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--chai-terracotta);
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
}

.provider-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.provider-stats-table th {
  background: var(--bg-surface-secondary);
  color: var(--ink-secondary);
  font-weight: 600;
  font-size: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.provider-stats-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.provider-stat-row:hover {
  background: #FAF8F5;
}

.provider-items-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 340px;
}

.provider-item-chip {
  font-size: 11px;
  padding: 2px 7px;
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: inline-block;
  white-space: nowrap;
  color: var(--ink-secondary);
}

.cal-slot-badge.paid {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--status-approved-bg);
  color: var(--status-approved);
  border: 1px solid rgba(30, 107, 69, 0.2);
}
