/* ==========================================================================
   FM BROKER - Design System & Stylesheet (Updated with Auth & Role Segregation)
   ========================================================================== */

:root {
  /* Color Palette */
  --fm-primary: #0A192F;
  --fm-primary-light: #172A45;
  --fm-primary-dark: #020C1B;
  
  --fm-accent: #0284C7;
  --fm-accent-hover: #0369A1;
  --fm-accent-light: #E0F2FE;
  
  --fm-success: #059669;
  --fm-success-light: #ECFDF5;
  --fm-warning: #D97706;
  --fm-warning-light: #FFFBEB;
  --fm-danger: #DC2626;
  --fm-danger-light: #FEF2F2;
  
  --fm-bg: #F8FAFC;
  --fm-surface: #FFFFFF;
  --fm-surface-subtle: #F1F5F9;
  --fm-border: #E2E8F0;
  --fm-border-hover: #CBD5E1;
  
  --fm-text: #0F172A;
  --fm-text-muted: #64748B;
  --fm-text-subtle: #94A3B8;
  --fm-text-inverse: #FFFFFF;

  /* Typography */
  --font-heading: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  /* Elevation & Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--fm-bg);
  color: var(--fm-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--fm-text);
  font-weight: 700;
  letter-spacing: -0.02em;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ==========================================================================
   LOGIN / AUTH SCREEN
   ========================================================================== */

.login-page-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #0A192F 0%, #172A45 50%, #0F172A 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.login-card {
  background: #FFFFFF;
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
  width: 100%;
  max-width: 480px;
  padding: 2.25rem 2rem;
  position: relative;
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-brand-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-logo-box {
  width: 58px;
  height: 58px;
  background: linear-gradient(135deg, #0284C7 0%, #0369A1 100%);
  color: white;
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 800;
  font-family: var(--font-heading);
  box-shadow: 0 8px 16px rgba(2, 132, 199, 0.35);
  margin-bottom: 0.75rem;
}

.login-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: #0F172A;
  margin-bottom: 0.2rem;
}

.login-subtitle {
  font-size: 0.85rem;
  color: #64748B;
}

/* Login Role Switcher Tabs */
.login-role-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #F1F5F9;
  padding: 0.3rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  gap: 0.25rem;
}

.login-role-btn {
  padding: 0.65rem 0.5rem;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 700;
  color: #64748B;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: var(--transition);
}

.login-role-btn.active {
  background: #FFFFFF;
  color: #0F172A;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Quick Access Chips */
.quick-login-box {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: var(--radius-md);
  padding: 0.85rem;
  margin-bottom: 1.25rem;
}

.quick-login-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.quick-chips-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.quick-chip-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  transition: var(--transition);
}

.quick-chip-item:hover {
  border-color: var(--fm-accent);
  background: var(--fm-accent-light);
}

.quick-chip-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1E293B;
}

.quick-chip-user img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

.quick-chip-tag {
  font-size: 0.7rem;
  color: #0284C7;
  font-weight: 600;
}

.btn-login-submit {
  width: 100%;
  background: var(--fm-accent);
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
  transition: var(--transition);
  margin-top: 0.5rem;
}

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

/* ==========================================================================
   APP HEADER & NAVIGATION (AUTHENTICATED)
   ========================================================================== */

.app-header {
  background: var(--fm-primary);
  color: var(--fm-text-inverse);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.brand-logo-badge {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #0284C7 0%, #0369A1 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.25rem;
  color: white;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.brand-text-group {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #FFFFFF;
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: #94A3B8;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
}

/* User Session Badge & Switcher in Header */
.session-user-box {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.15);
  gap: 0.65rem;
}

.session-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.session-user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.session-user-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #FFFFFF;
}

.session-user-role {
  font-size: 0.68rem;
  color: #38BDF8;
  font-weight: 600;
}

.btn-logout {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #FCA5A5;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn-logout:hover {
  background: #EF4444;
  color: white;
}

/* Header Right Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.notif-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: white;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
}

.notif-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--fm-danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--fm-primary);
}

.btn-primary-action {
  background: var(--fm-accent);
  color: white;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
  transition: var(--transition);
}

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

/* Navigation Sub-Bar */
.sub-nav {
  background: #FFFFFF;
  border-bottom: 1px solid var(--fm-border);
  box-shadow: var(--shadow-xs);
}

.sub-nav-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
}

.nav-item {
  padding: 0.85rem 1rem;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--fm-text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 3px solid transparent;
  transition: var(--transition);
}

.nav-item:hover {
  color: var(--fm-text);
  background: var(--fm-surface-subtle);
}

.nav-item.active {
  color: var(--fm-accent);
  border-bottom-color: var(--fm-accent);
  background: transparent;
}

.nav-badge {
  background: var(--fm-danger-light);
  color: var(--fm-danger);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 99px;
}

/* Main Container Layout */
.main-content {
  max-width: 1400px;
  margin: 1.5rem auto 3rem;
  padding: 0 1.5rem;
}

/* Page Header Title Section */
.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title-group h2 {
  font-size: 1.5rem;
  color: var(--fm-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-title-group p {
  color: var(--fm-text-muted);
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Metric Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--fm-border-hover);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
  background: var(--fm-accent);
}

.metric-card.success::before { background: var(--fm-success); }
.metric-card.warning::before { background: var(--fm-warning); }
.metric-card.danger::before { background: var(--fm-danger); }

.metric-info {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--fm-text-muted);
}

.metric-value {
  font-size: 1.65rem;
  font-weight: 800;
  font-family: var(--font-heading);
  color: var(--fm-text);
  margin-top: 0.35rem;
  line-height: 1.1;
}

.metric-sub {
  font-size: 0.78rem;
  color: var(--fm-text-muted);
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.metric-sub.positive { color: var(--fm-success); font-weight: 600; }
.metric-sub.alert { color: var(--fm-danger); font-weight: 600; }

.metric-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--fm-accent-light);
  color: var(--fm-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.metric-card.success .metric-icon-box { background: var(--fm-success-light); color: var(--fm-success); }
.metric-card.warning .metric-icon-box { background: var(--fm-warning-light); color: var(--fm-warning); }
.metric-card.danger .metric-icon-box { background: var(--fm-danger-light); color: var(--fm-danger); }

/* Banner Alert Section */
.alert-banner {
  background: linear-gradient(90deg, #FEF2F2 0%, #FFFBEB 100%);
  border: 1px solid #FECACA;
  border-left: 5px solid var(--fm-danger);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow-xs);
}

.alert-banner-content {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.alert-banner-icon {
  font-size: 1.5rem;
}

.alert-banner-text h4 {
  font-size: 0.95rem;
  color: #991B1B;
}

.alert-banner-text p {
  font-size: 0.85rem;
  color: #7F1D1D;
  margin-top: 0.15rem;
}

.btn-alert-action {
  background: var(--fm-danger);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.btn-alert-action:hover {
  background: #B91C1C;
}

/* Dashboard Two-Column Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Content Cards & Containers */
.card {
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--fm-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FFFFFF;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--fm-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-body {
  padding: 1.25rem;
}

/* Search & Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.search-input-wrapper {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fm-text-subtle);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.6rem 0.75rem 0.6rem 2.4rem;
  border: 1px solid var(--fm-border);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  outline: none;
  background: var(--fm-surface);
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--fm-accent);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.filter-select {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--fm-border);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  background: var(--fm-surface);
  color: var(--fm-text);
  outline: none;
  cursor: pointer;
}

.filter-select:focus {
  border-color: var(--fm-accent);
}

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

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

.data-table th {
  background: var(--fm-surface-subtle);
  padding: 0.75rem 1rem;
  color: var(--fm-text-muted);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--fm-border);
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--fm-border);
  vertical-align: middle;
}

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

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

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

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

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

.badge-neutral {
  background: var(--fm-surface-subtle);
  color: var(--fm-text-muted);
}

.badge-branch {
  background: #EFF6FF;
  color: #1D4ED8;
  font-weight: 600;
}

/* Producer Leaderboard List */
.producer-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.producer-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.producer-card-row:hover {
  border-color: var(--fm-accent);
  background: #F8FAFC;
}

.producer-info-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.producer-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--fm-border);
}

.producer-details h4 {
  font-size: 0.92rem;
  font-weight: 700;
}

.producer-details p {
  font-size: 0.78rem;
  color: var(--fm-text-muted);
}

.producer-stats {
  text-align: right;
}

.producer-stat-num {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--fm-text);
}

.producer-stat-lbl {
  font-size: 0.72rem;
  color: var(--fm-text-muted);
}

/* Action Buttons inside tables */
.table-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--fm-border);
  background: white;
  color: var(--fm-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  border-color: var(--fm-accent);
  color: var(--fm-accent);
  background: var(--fm-accent-light);
}

.btn-icon.whatsapp {
  color: #10B981;
}
.btn-icon.whatsapp:hover {
  background: #ECFDF5;
  border-color: #10B981;
}

.btn-sm-action {
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--fm-border);
  background: white;
  color: var(--fm-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: var(--transition);
}

.btn-sm-action:hover {
  background: var(--fm-surface-subtle);
  border-color: var(--fm-border-hover);
}

.btn-sm-primary {
  background: var(--fm-accent);
  color: white;
  border-color: var(--fm-accent);
}

.btn-sm-primary:hover {
  background: var(--fm-accent-hover);
}

/* Expiration Center Tabs */
.tab-pills {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.tab-pill {
  padding: 0.5rem 1rem;
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fm-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition);
}

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

.tab-pill.active {
  background: var(--fm-primary);
  color: white;
  border-color: var(--fm-primary);
}

/* ==========================================================================
   MODALS & OVERLAYS
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: white;
  width: 100%;
  max-width: 560px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-backdrop.open .modal-dialog {
  transform: scale(1);
}

.modal-dialog.large {
  max-width: 720px;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  background: #F8FAFC;
  border-bottom: 1px solid var(--fm-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--fm-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--fm-text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close-btn:hover {
  background: var(--fm-surface-subtle);
  color: var(--fm-text);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: #F8FAFC;
  border-top: 1px solid var(--fm-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Form Controls */
.form-group {
  margin-bottom: 1.15rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--fm-text);
  margin-bottom: 0.4rem;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--fm-border);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  outline: none;
  background: white;
  transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--fm-accent);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.form-textarea {
  min-height: 90px;
  resize: vertical;
}

/* WhatsApp Preview */
.whatsapp-preview-card {
  background: #E5DDD5;
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.25rem;
  background-image: radial-gradient(#D1C7B7 1px, transparent 1px);
  background-size: 16px 16px;
}

.whatsapp-bubble {
  background: #FFFFFF;
  border-radius: 12px 12px 12px 2px;
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  font-size: 0.88rem;
  color: #111827;
  line-height: 1.45;
  white-space: pre-wrap;
}

.whatsapp-bubble-time {
  font-size: 0.7rem;
  color: #9CA3AF;
  text-align: right;
  margin-top: 0.35rem;
}

.btn-whatsapp-send {
  background: #25D366;
  color: white;
  border: none;
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.4);
  transition: var(--transition);
  text-decoration: none;
}

.btn-whatsapp-send:hover {
  background: #20BA5C;
  transform: translateY(-1px);
}

/* Digital QR Verification Modal */
.qr-modal-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1rem;
}

.qr-box {
  width: 180px;
  height: 180px;
  background: white;
  border: 4px solid var(--fm-primary);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  margin: 1rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.qr-placeholder-svg {
  width: 100%;
  height: 100%;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--fm-primary);
  color: white;
  padding: 0.75rem 1.2rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 4px solid var(--fm-accent);
}

.toast.success { border-left-color: var(--fm-success); }
.toast.danger { border-left-color: var(--fm-danger); }

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

@media (max-width: 860px) {
  .header-container {
    flex-direction: column;
    align-items: stretch;
  }
  .sub-nav-container {
    overflow-x: auto;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}
