/* ============================================
   VARIABLES & RESET
   ============================================ */
:root {
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #eff6ff;
  --color-morning: #2563eb;
  --color-morning-bg: #dbeafe;
  --color-afternoon: #ea580c;
  --color-afternoon-bg: #ffedd5;
  --color-free: #6b7280;
  --color-free-bg: #f3f4f6;
  --color-danger: #dc2626;
  --color-danger-bg: #fef2f2;
  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --color-success: #16a34a;
  --color-success-bg: #f0fdf4;
  --color-text: #111827;
  --color-text-secondary: #6b7280;
  --color-border: #e5e7eb;
  --color-bg: #f9fafb;
  --color-surface: #ffffff;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  --transition: 150ms ease;
}

[data-theme="dark"] {
  color-scheme: dark;
  --color-primary: #3b82f6;
  --color-primary-hover: #60a5fa;
  --color-primary-light: #1e293b;
  --color-morning: #93c5fd;
  --color-morning-bg: #1e3a8a;
  --color-afternoon: #fdba74;
  --color-afternoon-bg: #431407;
  --color-free: #e2e8f0;
  --color-free-bg: #334155;
  --color-danger: #f87171;
  --color-danger-bg: #450a0a;
  --color-warning: #fbbf24;
  --color-warning-bg: #451a03;
  --color-success: #4ade80;
  --color-success-bg: #052e16;
  --color-text: #f9fafb;
  --color-text-secondary: #cbd5e1;
  --color-border: #475569;
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color var(--transition), color var(--transition);
}

input, select, textarea {
  color: var(--color-text);
  background-color: var(--color-surface);
  font-family: inherit;
}

input::placeholder, textarea::placeholder {
  color: var(--color-text-secondary);
  opacity: 0.85;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

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

.btn-outline {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-outline:hover:not(:disabled) {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.375rem;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="number"] {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.2);
  cursor: pointer;
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ============================================
   SECTION PANELS
   ============================================ */
.panel-section {
  padding: 2rem 1.5rem;
}

.section-container {
  max-width: 1200px;
  margin: 0 auto;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.config-row {
  margin-bottom: 1.5rem;
}

.config-row .form-group {
  max-width: 300px;
}

.config-row--main {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: flex-end;
  margin-bottom: 2rem;
}

.config-row--main .form-group {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  margin-bottom: 0;
}

.form-select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  background-color: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition);
}

.form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

.generated-weeks-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.week-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.week-pill:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.week-pill.active {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
}

.emp-shifts-badge {
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  margin-top: 0.25rem;
}

.config-block {
  margin-bottom: 2rem;
}

.config-block h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.config-hint {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-bottom: 1rem;
}

/* ============================================
   EMPLOYEE GRID
   ============================================ */
.employee-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.85rem;
}

.employee-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.employee-card:hover {
  border-color: var(--color-primary);
}

.emp-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.875rem;
}

.emp-key-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-primary);
  background-color: var(--color-primary-light);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.emp-name-input {
  font-size: 0.875rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background-color: var(--color-surface);
  color: var(--color-text);
  width: 100%;
}

.emp-pattern-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.emp-pattern-label {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  font-weight: 600;
}

.emp-pattern-select {
  font-size: 0.8125rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background-color: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  width: 100%;
}

.emp-pattern-select:focus,
.emp-name-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

/* Pattern Reference Banner */
.pattern-banner {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(14, 165, 233, 0.05));
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
}

[data-theme="dark"] .pattern-banner {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(14, 165, 233, 0.08));
  border-color: rgba(59, 130, 246, 0.3);
}

.pattern-banner-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.35rem;
}

.pattern-banner-icon {
  font-size: 1.15rem;
}

.pattern-banner-text {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.45;
}

.pattern-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pattern-chip {
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  white-space: nowrap;
}

.pattern-chip strong {
  color: var(--color-primary);
}

/* ============================================
   DEMAND TABLE & MULTI-WEEK NAVIGATION
   ============================================ */
.demand-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.demand-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.demand-weeks-nav {
  margin-top: 0.25rem;
  margin-bottom: 0.65rem;
}

.demand-week-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
  position: relative;
  border-radius: var(--radius);
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.demand-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.demand-table th,
.demand-table td {
  padding: 0.625rem 0.75rem;
  text-align: center;
  border: 1px solid var(--color-border);
}

.demand-table th:first-child,
.demand-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.08);
}

.demand-table thead th:first-child {
  z-index: 4;
  background: var(--color-surface);
}

.demand-table th {
  background: var(--color-surface);
  font-weight: 700;
  font-size: 0.8125rem;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.row-label {
  font-weight: 600;
  text-align: left !important;
  white-space: nowrap;
}

.row-label--morning {
  background: var(--color-morning-bg);
  color: var(--color-morning);
}

.row-label--afternoon {
  background: var(--color-afternoon-bg);
  color: var(--color-afternoon);
}

.demand-input {
  width: 60px;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-surface);
}

.demand-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* ============================================
   SCHEDULE TABLE
   ============================================ */
.schedule-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.schedule-actions {
  display: flex;
  gap: 0.75rem;
}

.schedule-table {
  width: 100%;
  min-width: 950px;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.schedule-table th,
.schedule-table td {
  border: 1px solid var(--color-border);
}

.schedule-table th:first-child,
.schedule-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.08);
}

.schedule-table thead th:first-child {
  z-index: 4;
  background: var(--color-surface);
}

.schedule-table thead th {
  background: var(--color-surface);
  padding: 0.75rem 0.5rem;
  text-align: center;
  vertical-align: middle;
}

.col-shift {
  width: 120px;
  min-width: 120px;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text);
  letter-spacing: 0.03em;
  background: var(--color-surface);
}

.day-col-header {
  min-width: 120px;
}

.day-header-name {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--color-text);
}

.day-header-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-top: 2px;
}

.row-label {
  font-weight: 700;
  text-align: center;
  vertical-align: middle;
  padding: 1rem 0.75rem;
  font-size: 0.9375rem;
}

.row-label--morning {
  background: var(--color-morning-bg);
  color: var(--color-morning);
}

.row-label--afternoon {
  background: var(--color-afternoon-bg);
  color: var(--color-afternoon);
}

.row-label--free {
  background: var(--color-free-bg);
  color: var(--color-free);
}

.shift-cell {
  vertical-align: top;
  padding: 0.5rem;
  background: var(--color-surface);
}

.shift-cell--morning {
  background-color: #fafcff;
}

.shift-cell--afternoon {
  background-color: #fffbf7;
}

.shift-cell--free {
  background-color: #fbfbfb;
}

[data-theme="dark"] .shift-cell {
  background-color: #0f172a;
}

[data-theme="dark"] .shift-cell--morning {
  background-color: rgba(30, 58, 138, 0.25);
}

[data-theme="dark"] .shift-cell--afternoon {
  background-color: rgba(67, 20, 7, 0.35);
}

[data-theme="dark"] .shift-cell--free {
  background-color: rgba(15, 23, 42, 0.8);
}

.employee-pill-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.employee-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  color: var(--color-text);
}

.employee-pill--morning {
  border-left: 3px solid var(--color-morning);
}

.employee-pill--afternoon {
  border-left: 3px solid var(--color-afternoon);
}

.employee-pill--free {
  border-left: 3px solid var(--color-free);
  color: var(--color-text);
  opacity: 0.9;
}

.employee-pill-name {
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text);
}

.employee-shift-select {
  padding: 0.15rem 0.3rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--color-surface);
  cursor: pointer;
  color: var(--color-text);
  line-height: 1;
}

.employee-shift-select:focus {
  outline: none;
  border-color: var(--color-primary);
}

.empty-shift-notice {
  display: block;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  padding: 0.5rem 0;
  opacity: 0.7;
}

/* ============================================
   PDF CONTAINER (hidden offscreen wrapper, used for export)
   ============================================ */
.pdf-export-wrapper {
  position: absolute;
  left: 0;
  top: 0;
  width: 1060px;
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.pdf-container {
  position: static;
  width: 100%;
  max-width: 1060px;
  padding: 24px 30px;
  background: #ffffff;
  color: #111827;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  box-sizing: border-box;
}

.pdf-header {
  text-align: center;
  margin-bottom: 20px;
}

.pdf-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 4px;
}

.pdf-header p {
  font-size: 13px;
  color: #6b7280;
}

.pdf-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
}

.pdf-table th,
.pdf-table td {
  border: 1px solid #d1d5db;
  padding: 6px 8px;
}

.pdf-col-shift {
  width: 95px;
  text-align: center;
  font-weight: 700;
  font-size: 11px;
  background: #f3f4f6;
  text-transform: uppercase;
}

.pdf-header-name {
  font-weight: 700;
  font-size: 11px;
  color: #111827;
}

.pdf-header-date {
  font-size: 10px;
  color: #2563eb;
  font-weight: 600;
  margin-top: 1px;
}

.pdf-row-label {
  font-weight: 700;
  text-align: center;
  vertical-align: middle;
  font-size: 12px;
}

.pdf-row-label--morning {
  background: #dbeafe;
  color: #1e40af;
}

.pdf-row-label--afternoon {
  background: #ffedd5;
  color: #c2410c;
}

.pdf-row-label--free {
  background: #f3f4f6;
  color: #4b5563;
}

.pdf-shift-cell {
  vertical-align: top;
  padding: 6px;
  text-align: left;
}

.pdf-cell-morning {
  background: #f8fafc;
}

.pdf-cell-afternoon {
  background: #fffaf5;
}

.pdf-cell-free {
  background: #fbfbfb;
}

.pdf-emp-name {
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 6px;
  margin-bottom: 3px;
  border-radius: 3px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #1f2937;
}

.pdf-emp-name:last-child {
  margin-bottom: 0;
}

.pdf-empty {
  display: block;
  text-align: center;
  color: #9ca3af;
  font-size: 11px;
}

/* ============================================
   APP HEADER
   ============================================ */
.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition), border-color var(--transition);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

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

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius);
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--color-text);
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

.btn-help {
  font-weight: 700;
  color: var(--color-primary);
}

.help-btn-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1;
  transition: all var(--transition);
}

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

/* ============================================
   WEEK NAVIGATION CONTROLS
   ============================================ */
.week-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.week-nav input[type="date"] {
  flex: 1;
}

.week-nav-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.week-badge {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  border: 1px solid var(--color-border);
  white-space: nowrap;
}

.btn-sm {
  padding: 0.25rem 0.55rem;
  font-size: 0.8125rem;
}

/* ============================================
   LIVE AUDIT & BALANCE PANEL
   ============================================ */
.audit-panel {
  margin-top: 2rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition), border-color var(--transition);
}

.audit-header {
  margin-bottom: 1.25rem;
}

.audit-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.audit-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text);
}

.audit-subtitle {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin-top: 0.25rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  letter-spacing: 0.02em;
}

.badge--success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success);
}

.badge--warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning);
}

.badge--danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

.audit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.audit-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
}

.audit-card h4 {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.audit-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.audit-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid transparent;
}

.audit-tag--ok {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-color: rgba(34, 197, 94, 0.25);
}

.audit-tag--warn {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-color: rgba(245, 158, 11, 0.25);
}

.audit-tag--err {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-color: rgba(239, 68, 68, 0.25);
}

[data-theme="dark"] .badge--success {
  background: #064e3b;
  color: #86efac;
  border-color: #10b981;
}

[data-theme="dark"] .badge--warning {
  background: #451a03;
  color: #fcd34d;
  border-color: #f59e0b;
}

[data-theme="dark"] .badge--danger {
  background: #450a0a;
  color: #fca5a5;
  border-color: #ef4444;
}

[data-theme="dark"] .audit-tag--ok {
  background: #064e3b;
  color: #86efac;
  border-color: rgba(134, 239, 172, 0.35);
}

[data-theme="dark"] .audit-tag--warn {
  background: #451a03;
  color: #fcd34d;
  border-color: rgba(252, 211, 77, 0.35);
}

[data-theme="dark"] .audit-tag--err {
  background: #450a0a;
  color: #fca5a5;
  border-color: rgba(252, 165, 165, 0.35);
}

.equity-details {
  margin-top: 1rem;
  border-top: 1px solid var(--color-border);
  padding-top: 0.875rem;
}

.equity-summary-toggle {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-primary);
  user-select: none;
}

.equity-table-container {
  margin-top: 0.75rem;
}

.equity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.equity-table th, .equity-table td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  text-align: center;
}

.equity-table th:first-child,
.equity-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background-color: var(--color-surface);
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.08);
}

.equity-table thead th:first-child {
  z-index: 4;
}

.equity-table th {
  background: var(--color-surface);
  font-weight: 700;
  color: var(--color-text);
}

/* ============================================
   INDIVIDUAL EMPLOYEE MODAL
   ============================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
  animation: modalIn 200ms ease;
}

.modal-card--large {
  max-width: 820px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.modal-body--scrollable {
  overflow-y: auto;
  flex: 1 1 auto;
  max-height: calc(88vh - 135px);
  padding: 1.5rem;
}

.modal-title-with-icon {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-header-icon {
  font-size: 1.25rem;
}

.help-modal-content {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.help-section {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.help-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary);
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-border);
  margin: 0;
}

.help-intro-text {
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
  margin: 0;
  line-height: 1.5;
}

.help-steps-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.help-step-item {
  display: flex;
  gap: 1rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  transition: border-color var(--transition);
}

.help-step-item:hover {
  border-color: var(--color-primary);
}

.help-step-number {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

.help-step-details {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.help-step-details strong {
  font-size: 0.95rem;
  color: var(--color-text);
}

.help-step-details p {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin: 0;
}

.help-note {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-primary-light);
  border-left: 3px solid var(--color-primary);
  border-radius: 4px;
  font-size: 0.8125rem;
  color: var(--color-text);
}

.help-bullet-list {
  margin: 0.5rem 0 0 1.25rem;
  padding: 0;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.help-features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.help-feature-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: transform var(--transition), border-color var(--transition);
}

.help-feature-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
}

.help-feature-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  color: var(--color-text);
}

.help-feature-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.help-feature-card p {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  line-height: 1.45;
  margin: 0;
}

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

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

.modal-header h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text);
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.modal-close-btn:hover {
  color: var(--color-text);
}

.modal-body {
  padding: 1.25rem;
}

.form-select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  background: var(--color-surface);
  color: var(--color-text);
  margin-top: 0.35rem;
}

.individual-schedule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.5rem;
  margin-top: 1rem;
}

.indiv-day-card {
  padding: 0.625rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  text-align: center;
  background: var(--color-bg);
}

.indiv-day-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text);
  text-transform: uppercase;
}

.indiv-day-date {
  font-size: 0.75rem;
  color: var(--color-primary);
  margin-bottom: 0.35rem;
}

.indiv-shift-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.indiv-shift-badge--morning {
  background: var(--color-morning-bg);
  color: var(--color-morning);
}

.indiv-shift-badge--afternoon {
  background: var(--color-afternoon-bg);
  color: var(--color-afternoon);
}

.indiv-shift-badge--free {
  background: var(--color-free-bg);
  color: var(--color-free);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 10000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  animation: toastSlideIn 250ms ease forwards;
  max-width: 380px;
}

.toast--success { border-left: 4px solid var(--color-success); }
.toast--warning { border-left: 4px solid var(--color-warning); }
.toast--error { border-left: 4px solid var(--color-danger); }
.toast--info { border-left: 4px solid var(--color-primary); }

.toast-icon { font-size: 1.15rem; line-height: 1; }
.toast-message { flex: 1; }

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

.toast-fadeout {
  opacity: 0;
  transform: translateY(12px);
  transition: all 250ms ease;
}

/* ============================================
   RESPONSIVE DESIGN (DESKTOP, TABLET, MOBILE)
   ============================================ */

/* Large Tablets & Small Desktops (<= 1024px) */
@media (max-width: 1024px) {
  .section-container {
    max-width: 100%;
  }

  .config-row--main {
    gap: 1rem;
  }

  .config-row--main .form-group {
    flex: 1 1 calc(33.333% - 1rem);
    min-width: 190px;
  }

  .employee-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .audit-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
}

/* Tablets & Mobile Landscape (<= 768px) */
@media (max-width: 768px) {
  /* Layout & Spacing */
  .panel-section {
    padding: 1.25rem 0.85rem;
  }

  .section-title {
    font-size: 1.3rem;
    margin-bottom: 1.25rem;
  }

  .app-header {
    padding: 0.6rem 1rem;
  }

  .brand-title {
    font-size: 1.15rem;
  }

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

  /* Main Form Controls */
  .config-row--main {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    margin-bottom: 1.5rem;
  }

  .config-row--main .form-group {
    max-width: 100%;
    min-width: 100%;
    width: 100%;
  }

  /* Prevent automatic zoom-in on touch focus in iOS Safari */
  input[type="text"],
  input[type="date"],
  input[type="number"],
  select,
  .form-select,
  .demand-input,
  .emp-name-input,
  .emp-pattern-select {
    font-size: 16px !important;
  }

  /* Touch-friendly input heights */
  .form-select,
  .form-group input {
    min-height: 44px;
  }

  /* Horizontal swipeable navigation pills */
  .generated-weeks-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding: 0.25rem 0.1rem 0.65rem;
    scrollbar-width: thin;
  }

  .week-pill {
    flex-shrink: 0;
    scroll-snap-align: start;
    font-size: 0.8rem;
    padding: 0.45rem 0.85rem;
    white-space: nowrap;
  }

  /* Demand Header & Actions */
  .demand-header-flex {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .demand-actions {
    width: 100%;
  }

  .demand-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 42px;
  }

  .demand-input {
    width: 52px;
    height: 42px;
  }

  /* Primary Action Button */
  #btn-generate {
    width: 100%;
    min-height: 48px;
    font-size: 1.05rem;
    justify-content: center;
  }

  /* Employee Cards Grid */
  .employee-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  /* Schedule Header & Action Buttons */
  .schedule-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 1.25rem;
  }

  .schedule-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    width: 100%;
  }

  .schedule-actions .btn {
    width: 100%;
    justify-content: center;
    font-size: 0.8125rem;
    padding: 0.6rem 0.65rem;
    min-height: 42px;
  }

  /* Audit Grid */
  .audit-panel {
    padding: 1rem 0.85rem;
  }

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

  /* Modals */
  .modal-backdrop {
    padding: 0.5rem;
  }

  .modal-card {
    max-width: 100%;
    width: 100%;
    max-height: 94vh;
    border-radius: var(--radius);
  }

  .modal-body--scrollable {
    padding: 1rem;
    max-height: calc(94vh - 120px);
  }

  .help-features-grid {
    grid-template-columns: 1fr;
  }

  .help-step-item {
    flex-direction: column;
    gap: 0.5rem;
  }

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

  /* Toasts */
  .toast-container {
    bottom: 0.85rem;
    right: 0.85rem;
    left: 0.85rem;
  }

  .toast {
    max-width: 100%;
    font-size: 0.85rem;
  }
}

/* Smartphone Portrait (<= 480px) */
@media (max-width: 480px) {
  .app-header {
    padding: 0.5rem 0.75rem;
  }

  .brand-title {
    font-size: 1.05rem;
  }

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

  .schedule-actions {
    grid-template-columns: 1fr;
  }

  .schedule-actions .btn {
    font-size: 0.875rem;
    min-height: 44px;
  }

  .individual-schedule-grid {
    grid-template-columns: 1fr;
  }

  .schedule-table {
    font-size: 0.8125rem;
  }

  .col-shift {
    width: 95px;
    min-width: 95px;
    font-size: 0.75rem;
  }

  .row-label {
    padding: 0.75rem 0.5rem;
    font-size: 0.8125rem;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  #config-panel,
  .schedule-actions {
    display: none !important;
  }

  .panel-section {
    padding: 0;
  }

  .schedule-table {
    font-size: 11px;
  }

  .employee-shift-select {
    display: none;
  }
}

/* ============================================
   NEW UI IMPROVEMENTS
   ============================================ */

/* Auth Modal Styles */
.auth-dialog {
  margin: auto;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  width: 100%;
  max-width: 400px;
}
.auth-dialog::backdrop {
  background: rgba(0, 0, 0, 0.8);
}
.auth-content {
  background: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius);
  color: var(--color-text);
  display: flex;
  flex-direction: column;
}
.auth-content input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-sizing: border-box;
}

/* Screen Reader Only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Enhanced Table Headers */
.demand-table th, .schedule-table th {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
}

[data-theme="dark"] .demand-table th, 
[data-theme="dark"] .schedule-table th {
  background: var(--color-primary-light);
  border-bottom: 2px solid var(--color-primary);
}
