/* HeadOS Flux UI - Mobile-First Design + Recipe Cards + Micro-UX */

/* ========== ROOT THEME ========== */
:root {
  --bg: #0a0a0f;
  --panel: #12121a;
  --text: #e8e8f0;
  --text-dim: #9090a8;
  --line: #2a2a38;
  --pink: #ff69b4;
  --pink-dim: rgba(255, 105, 180, 0.15);
  --radius: 8px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  --spacing-xs: 0.5rem;
  --spacing-sm: 0.75rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --touch-target: 44px;
}

/* Smooth scroll for all in-page navigation */
html {
  scroll-behavior: smooth;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ========== TOPBAR ========== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--touch-target);
}

.app-header-left h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--pink);
  margin-bottom: 0.1rem;
}

.app-header-left small {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.app-header-right input {
  width: 60px;
  padding: 0.4rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  min-height: 36px;
}

/* ========== TABS ========== */
.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 var(--spacing-md);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: var(--spacing-sm) var(--spacing-md);
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  min-height: var(--touch-target);
  display: flex;
  align-items: center;

  /* Instant visual feedback */
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.08s ease,
    box-shadow 0.15s ease;
}

.tab:hover {
  color: var(--text);
  background: var(--pink-dim);
}

.tab:active {
  transform: scale(0.97);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.tab.active {
  color: var(--pink);
  border-bottom-color: var(--pink);
}

/* ========== MAIN CONTENT ========== */
.app-main {
  flex: 1;
  padding: var(--spacing-md);
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

/* ========== SECTION ========== */
.section {
  margin-bottom: var(--spacing-lg);
}

.section h2 {
  font-size: 1.5rem;
  margin-bottom: var(--spacing-md);
  color: var(--text);
}

.section-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.section-tabs::-webkit-scrollbar {
  display: none;
}

/* ========== CARDS ========== */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: var(--spacing-md);

  /* Card hover feedback */
  transition:
    transform 0.15s ease,
    box-shadow 0.2s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  border-color: var(--pink-dim);
}

.card:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  gap: var(--spacing-sm);
}

.card-head-left h3 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 0.1rem;
}

.card-head-left small {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.card-head-actions {
  display: flex;
  gap: var(--spacing-xs);
  flex-wrap: wrap;
  align-items: center;
}

.card-body {
  padding: var(--spacing-md);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

/* ========== BUTTONS ========== */
.btn {
  position: relative;
  overflow: hidden; /* for ripple */
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  user-select: none;

  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    transform 0.08s ease,
    box-shadow 0.15s ease;
}

.btn:hover {
  background: var(--pink-dim);
  border-color: var(--pink);
}

.btn:active {
  transform: scale(0.97);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* Button ripple effect */
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.45) 0, transparent 60%);
  opacity: 0;
  transform: scale(0.2);
  transition:
    opacity 0.35s ease,
    transform 0.35s ease;
  pointer-events: none;
}

.btn:active::after {
  opacity: 1;
  transform: scale(1.4);
}

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

.btn.primary:hover {
  background: #ff4da6;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
}

.btn.ghost:hover {
  background: var(--pink-dim);
}

.btn.danger {
  background: #dc2626;
  border-color: #dc2626;
  color: white;
}

.btn.danger:hover {
  background: #b91c1c;
}

/* ========== TABLE ========== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 calc(-1 * var(--spacing-md));
  padding: 0 var(--spacing-md);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.table thead {
  background: var(--bg);
  border-bottom: 2px solid var(--line);

  /* Sticky header */
  position: sticky;
  top: 64px; /* below topbar/tabs */
  z-index: 5;
}

.table th {
  padding: var(--spacing-sm) var(--spacing-md);
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  background: var(--bg);
}

.table td {
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 0.9rem;
}

.table tbody tr {
  transition: background 0.15s ease;
}

.table tbody tr:hover {
  background: var(--pink-dim);
}

.table tbody tr.clickable {
  cursor: pointer;
}

.table tbody tr:active {
  background: rgba(255, 105, 180, 0.25);
}

/* ========== FORMS ========== */
.inline-form {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.form-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-field label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-dim);
}

.form-field input,
.form-field textarea,
.form-field select {
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
  min-height: var(--touch-target);
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 3px var(--pink-dim);
  background: #181821;
}

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

.field-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 0.2rem;
}

.form-actions {
  display: flex;
  gap: var(--spacing-sm);
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ========== EMPTY STATE ========== */
.empty {
  text-align: center;
  padding: var(--spacing-xl) var(--spacing-md);
  color: var(--text-dim);
  font-style: italic;
}

/* ========== SCHEDULE ========== */
.schedule-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--spacing-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.schedule-controls {
  display: flex;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
  flex-wrap: wrap;
}

.schedule-controls input[type="date"] {
  flex: 1;
  min-width: 150px;
}

.schedule-grid {
  display: flex;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 800px;
}

.schedule-time-col,
.schedule-emp-col {
  flex: 0 0 80px;
  background: var(--panel);
}

.schedule-emp-col {
  flex: 1;
  min-width: 120px;
}

.schedule-emp-head {
  padding: var(--spacing-sm);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  text-align: center;
  background: var(--bg);
  font-size: 0.85rem;
}

.schedule-time-slot {
  padding: var(--spacing-xs);
  border-bottom: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
}

.schedule-emp-body {
  position: relative;
  height: 600px;
}

.schedule-hour-slot {
  height: 60px;
  border-bottom: 1px solid var(--line);
}

.schedule-block {
  position: absolute;
  left: 4px;
  right: 4px;
  background: var(--pink);
  border-radius: 4px;
  padding: 0.4rem;
  cursor: pointer;
  overflow: hidden;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.schedule-block:hover {
  transform: scale(1.02);
  box-shadow: 0 2px 8px rgba(255, 105, 180, 0.4);
}

.schedule-block:active {
  transform: scale(0.98);
}

.schedule-block-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
  margin-bottom: 0.2rem;
}

.schedule-block-time,
.schedule-block-pnl {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.9);
}

/* ========== RELATION AUTOCOMPLETE ========== */
.relation-autocomplete {
  position: relative;
  width: 100%;
}

.relation-input {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
  min-height: var(--touch-target);
}

.relation-input:focus {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 3px var(--pink-dim);
  background: #181821;
}

.relation-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--pink);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(255, 105, 180, 0.2);
  max-height: 300px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 1000;
}

.relation-suggestion-item {
  padding: var(--spacing-sm) var(--spacing-md);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--text);
  min-height: var(--touch-target);
  display: flex;
  align-items: center;
}

.relation-suggestion-item:last-child {
  border-bottom: none;
}

.relation-suggestion-item:hover {
  background: var(--pink-dim);
  color: var(--pink);
}

.relation-suggestion-item:active {
  background: rgba(255, 105, 180, 0.25);
}

.relation-suggestion-item mark {
  background: var(--pink);
  color: white;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

.relation-no-result {
  color: var(--text-dim);
  cursor: default;
  font-style: italic;
}

.relation-no-result:hover {
  background: transparent;
  color: var(--text-dim);
}

.relation-suggestions::-webkit-scrollbar {
  width: 8px;
}

.relation-suggestions::-webkit-scrollbar-track {
  background: var(--bg);
  border-radius: var(--radius);
}

.relation-suggestions::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: var(--radius);
}

.relation-suggestions::-webkit-scrollbar-thumb:hover {
  background: var(--pink);
}

/* ========== RECIPE CARD SYSTEM ========== */
.recipe-view-toggle {
  display: flex;
  gap: 0.5rem;
}

.recipe-view-btn {
  padding: var(--spacing-xs) var(--spacing-md);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    transform 0.08s ease;
  min-height: 36px;
}

.recipe-view-btn:hover {
  background: var(--pink-dim);
  color: var(--pink);
}

.recipe-view-btn:active {
  transform: scale(0.97);
}

.recipe-view-btn.active {
  background: var(--pink);
  border-color: var(--pink);
  color: white;
}

/* Animated view switch for recipe cards */
.recipe-card-view,
.table-wrap {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.recipe-card-view.entering,
.table-wrap.entering {
  opacity: 0;
  transform: translateY(4px);
}

.recipe-card-view.entered,
.table-wrap.entered {
  opacity: 1;
  transform: translateY(0);
}

.recipe-card-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

.recipe-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.25s ease,
    border-color 0.2s ease,
    background 0.15s ease;
}

.recipe-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(255, 105, 180, 0.3);
  border-color: var(--pink);
}

.recipe-card:active {
  transform: translateY(-2px);
}

.recipe-card-header {
  padding: var(--spacing-md);
  background: var(--bg);
  border-bottom: 2px solid var(--pink);
}

.recipe-card-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--pink);
  margin-bottom: 0.3rem;
}

.recipe-card-meta {
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.recipe-card-meta-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.recipe-card-meta-item strong {
  color: var(--text);
}

.recipe-card-body {
  padding: var(--spacing-md);
}

.recipe-card-section {
  margin-bottom: var(--spacing-md);
}

.recipe-card-section:last-child {
  margin-bottom: 0;
}

.recipe-card-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: var(--spacing-sm);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.recipe-card-section-title::before {
  content: "";
  width: 3px;
  height: 12px;
  background: var(--pink);
  border-radius: 2px;
}

.recipe-ingredients-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.recipe-ingredient-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.recipe-ingredient-item:last-child {
  border-bottom: none;
}

.recipe-ingredient-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}

.recipe-ingredient-name::before {
  content: "✓";
  color: var(--pink);
  font-weight: bold;
  font-size: 1rem;
}

.recipe-ingredient-qty {
  font-weight: 600;
  color: var(--pink);
  white-space: nowrap;
}

.recipe-steps-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: step-counter;
}

.recipe-step-item {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-xs) 0;
  font-size: 0.9rem;
  color: var(--text);
  counter-increment: step-counter;
}

.recipe-step-item::before {
  content: counter(step-counter) ".";
  font-weight: 600;
  color: var(--pink);
  min-width: 1.5rem;
}

.recipe-notes {
  background: var(--bg);
  padding: var(--spacing-sm);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
  line-height: 1.5;
}

.recipe-card-footer {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-sm);
}

.recipe-card-badge {
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.recipe-card-badge.active {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.recipe-card-badge.inactive {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.recipe-card-actions {
  display: flex;
  gap: 0.25rem;
}

.recipe-card-action-btn {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    transform 0.08s ease;
  min-height: 36px;
}

.recipe-card-action-btn:hover {
  background: var(--pink-dim);
  border-color: var(--pink);
  color: var(--pink);
}

.recipe-card-action-btn:active {
  transform: scale(0.95);
}

.recipe-cards-empty {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--text-dim);
}

.recipe-cards-empty-icon {
  font-size: 3rem;
  margin-bottom: var(--spacing-md);
  opacity: 0.5;
}

/* ========== FLOATING ACTION BUTTON (FAB) & GLOBAL SEARCH ========== */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--pink);
  color: white;
  border: none;
  box-shadow:
    0 4px 12px rgba(255, 105, 180, 0.4),
    0 8px 24px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  z-index: 9999;
  user-select: none;
  overflow: hidden;
}

.fab:hover {
  transform: scale(1.1);
  box-shadow:
    0 6px 16px rgba(255, 105, 180, 0.5),
    0 12px 32px rgba(0, 0, 0, 0.4);
}

.fab:active {
  transform: scale(0.95);
}

/* FAB pulse */
.fab::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  opacity: 0;
  animation: fab-pulse 2s infinite;
}

@keyframes fab-pulse {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.3);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

/* Global search modal (your newer style kept) */
.global-search-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

.global-search-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.global-search-box {
  position: relative;
  width: 90%;
  max-width: 600px;
  background: var(--panel, #1e1e1e);
  border-radius: var(--radius, 8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: slideDown 0.2s ease-out;
}

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

.global-search-input {
  width: 100%;
  padding: 16px 20px;
  font-size: 16px;
  border: none;
  background: transparent;
  color: var(--text, #fff);
  outline: none;
  border-bottom: 1px solid var(--line, #333);
}

.global-search-input::placeholder {
  color: var(--text-muted, #888);
}

.global-search-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px 0;
}

.global-search-empty,
.global-search-loading {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted, #888);
  font-size: 14px;
}

.global-search-group {
  margin-bottom: 12px;
}

.global-search-group-title {
  padding: 8px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.global-search-item {
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.15s ease;
  font-size: 14px;
  color: var(--text, #fff);
}

.global-search-item:hover {
  background: var(--line, #333);
}

.global-search-item mark {
  background: var(--pink, #e91e63);
  color: white;
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 600;
}

.global-search-secondary {
  color: var(--text-muted, #888);
  font-size: 13px;
  margin-left: 8px;
}

/* ========== UNIVERSAL CARD VIEW ========== */
.universal-view-toggle {
  display: flex;
  gap: 4px;
  background: var(--line, #333);
  border-radius: var(--radius, 6px);
  padding: 4px;
  margin-right: 8px;
}

.view-btn {
  padding: 6px 12px;
  font-size: 13px;
  background: transparent;
  color: var(--text, #fff);
  border: none;
  border-radius: calc(var(--radius, 6px) - 2px);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.view-btn:hover {
  background: var(--bg, #000);
}

.view-btn.active {
  background: var(--pink, #e91e63);
  color: white;
}

.universal-card-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 8px 0;
}

.universal-card {
  background: var(--panel, #1e1e1e);
  border: 1px solid var(--line, #333);
  border-radius: var(--radius, 8px);
  padding: 16px;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    border-color 0.15s ease;
}

.universal-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border-color: var(--pink, #e91e63);
}

.universal-card-header {
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line, #333);
  padding-bottom: 8px;
}

.universal-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text, #fff);
  margin-bottom: 6px;
}

.universal-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.universal-card-meta-item {
  font-size: 12px;
  color: var(--text-muted, #888);
  background: var(--line, #333);
  padding: 4px 8px;
  border-radius: 4px;
}

.universal-card-body {
  margin-bottom: 12px;
}

.universal-card-field {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--line, #333);
}

.universal-card-field:last-child {
  border-bottom: none;
}

.universal-card-field-label {
  font-weight: 500;
  color: var(--text-muted, #888);
  margin-right: 8px;
}

.universal-card-field-value {
  color: var(--text, #fff);
  text-align: right;
  word-break: break-word;
}

.universal-card-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--line, #333);
}

.universal-card-action-btn {
  padding: 6px 12px;
  font-size: 13px;
  background: var(--pink, #e91e63);
  color: white;
  border: none;
  border-radius: var(--radius, 6px);
  cursor: pointer;
  transition: background 0.15s ease;
}

.universal-card-action-btn:hover {
  background: #c2185b;
}

/* ========== RESPONSIVE BREAKPOINTS ========== */
@media (max-width: 375px) {
  :root {
    --spacing-md: 0.75rem;
    --spacing-lg: 1rem;
  }

  .app-header-left h1 {
    font-size: 1.1rem;
  }

  .section h2 {
    font-size: 1.3rem;
  }

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

  .recipe-card-view {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .recipe-card-view {
    grid-template-columns: 1fr;
  }

  .recipe-card-meta {
    flex-direction: column;
    gap: 0.3rem;
  }

  .recipe-card-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .recipe-card-actions {
    justify-content: space-between;
  }

  .fab {
    width: 56px;
    height: 56px;
    bottom: 16px;
    right: 16px;
    font-size: 1.3rem;
  }
}

@media (min-width: 640px) {
  .form-fields {
    grid-template-columns: repeat(2, 1fr);
  }

  .app-main {
    padding: var(--spacing-lg);
  }

  .topbar {
    padding: var(--spacing-md) var(--spacing-lg);
  }
}

@media (min-width: 1024px) {
  .form-fields {
    grid-template-columns: repeat(3, 1fr);
  }

  .app-main {
    padding: var(--spacing-xl) var(--spacing-lg);
  }

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

@media (min-width: 1440px) {
  .app-main {
    max-width: 1800px;
  }
}

/* ========== ACCESSIBILITY ========== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: high) {
  :root {
    --line: #444;
    --text-dim: #aaa;
  }
}
/* ========== TOAST NOTIFICATIONS ========== */
.toast {
  position: fixed;
  bottom: 80px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 9998;
  transform: translateX(400px);
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.toast-success {
  border-left: 4px solid #22c55e;
}

.toast.toast-error {
  border-left: 4px solid #ef4444;
}

.toast.toast-warning {
  border-left: 4px solid #f59e0b;
}

.toast.toast-info {
  border-left: 4px solid var(--pink);
}

.toast::before {
  font-size: 1.2rem;
}

.toast.toast-success::before {
  content: '✓';
  color: #22c55e;
}

.toast.toast-error::before {
  content: '✗';
  color: #ef4444;
}

.toast.toast-warning::before {
  content: '⚠';
  color: #f59e0b;
}

.toast.toast-info::before {
  content: 'ℹ';
  color: var(--pink);
}

@media (max-width: 640px) {
  .toast {
    right: 16px;
    left: 16px;
    bottom: 70px;
    max-width: none;
  }
}

/* ========== FORM VALIDATION STYLES ========== */
.form-field.required label::after {
  content: ' *';
  color: var(--pink);
  font-weight: 600;
}

.form-field input:invalid,
.form-field textarea:invalid,
.form-field select:invalid {
  border-color: #ef4444;
}

.form-field input:valid,
.form-field textarea:valid,
.form-field select:valid {
  border-color: var(--line);
}

.field-error {
  font-size: 0.8rem;
  color: #ef4444;
  margin-top: 0.3rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.field-error::before {
  content: '⚠';
}

.field-success {
  font-size: 0.8rem;
  color: #22c55e;
  margin-top: 0.3rem;
  display: none;
}

.form-field.validated input:valid ~ .field-success {
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-field.validated input:valid ~ .field-success::before {
  content: '✓';
}

/* ========== RECENT ITEMS SECTION ========== */
.global-search-recent {
  padding: 8px 0;
  border-bottom: 2px solid var(--line);
}

.global-search-recent-title {
  padding: 8px 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.global-search-recent-title::before {
  content: '🕒';
  font-size: 14px;
}

.global-search-recent-item {
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s ease;
  font-size: 14px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.global-search-recent-item:hover {
  background: var(--line);
}

.global-search-recent-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.global-search-recent-clear {
  padding: 6px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--pink);
  cursor: pointer;
  transition: background 0.15s ease;
}

.global-search-recent-clear:hover {
  background: var(--pink-dim);
}

/* ========== SUCCESS CHECKMARK ANIMATION ========== */
.success-checkmark {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 120px;
  height: 120px;
  background: rgba(34, 197, 94, 0.95);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 60px;
  color: white;
  z-index: 10001;
  animation: successPop 1.2s ease-out forwards;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(34, 197, 94, 0.4);
}

@keyframes successPop {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(0deg);
    opacity: 0;
  }
  20% {
    transform: translate(-50%, -50%) scale(1.2) rotate(10deg);
    opacity: 1;
  }
  40% {
    transform: translate(-50%, -50%) scale(0.95) rotate(-5deg);
  }
  60% {
    transform: translate(-50%, -50%) scale(1.05) rotate(2deg);
  }
  80% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(0.8) rotate(0deg);
    opacity: 0;
  }
}

.form-success-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(34, 197, 94, 0.1);
  border: 2px solid #22c55e;
  border-radius: var(--radius);
  color: #22c55e;
  font-weight: 600;
  gap: 8px;
  animation: slideInFromTop 0.3s ease;
  margin-bottom: 16px;
}

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

.form-success-inline::before {
  content: '✓';
  font-size: 24px;
}

/* ========== COLLAPSIBLE FORM SECTIONS ========== */
.form-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: var(--spacing-md);
  background: var(--panel);
  overflow: hidden;
}

.form-section summary {
  padding: var(--spacing-md);
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: background 0.15s ease;
}

.form-section summary:hover {
  background: var(--pink-dim);
}

.form-section summary::after {
  content: '▼';
  font-size: 0.8rem;
  color: var(--text-dim);
  transition: transform 0.2s ease;
}

.form-section[open] summary::after {
  transform: rotate(-180deg);
}

.form-section summary::-webkit-details-marker {
  display: none;
}

.form-section-content {
  padding: var(--spacing-md);
  animation: slideDown 0.2s ease;
}

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

.form-section-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--pink-dim);
  color: var(--pink);
  margin-left: 8px;
}

.form-section-badge.required {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.form-section-badge.optional {
  background: var(--line);
  color: var(--text-dim);
}

/* ============================================================================
   HEADOS UX & FEATURE ENHANCEMENTS
   ============================================================================ */

/* ========== LINE ITEMS GRID ========== */
.line-items-section {
  margin: 24px 0;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.line-items-header {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.line-items-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.line-items-grid-row {
  transition: background 0.15s ease;
}

.line-items-grid-row:not(.header):hover {
  background: var(--line) !important;
}

.line-items-grid input,
.line-items-grid select {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.9rem;
}

.line-items-grid input:focus,
.line-items-grid select:focus {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 2px var(--pink-dim);
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background: var(--pink-dim);
  border-color: var(--pink);
}

/* ========== SUPPLY CHAIN MODULES ========== */
.module-icon-📦 {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.module-icon-📥 {
  background: linear-gradient(135deg, #10b981, #059669);
}

.module-icon-🚗 {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

/* ========== STATUS BADGES ========== */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Purchase Order statuses */
.status-badge.draft { 
  background: rgba(156, 163, 175, 0.2); 
  color: #9ca3af; 
}

.status-badge.sent { 
  background: rgba(59, 130, 246, 0.2); 
  color: #3b82f6; 
}

.status-badge.confirmed { 
  background: rgba(16, 185, 129, 0.2); 
  color: #10b981; 
}

.status-badge.received { 
  background: rgba(34, 197, 94, 0.2); 
  color: #22c55e; 
}

/* Goods Receipt statuses */
.status-badge.pending { 
  background: rgba(251, 191, 36, 0.2); 
  color: #fbbf24; 
}

.status-badge.verified { 
  background: rgba(59, 130, 246, 0.2); 
  color: #3b82f6; 
}

.status-badge.posted { 
  background: rgba(34, 197, 94, 0.2); 
  color: #22c55e; 
}

/* Packaging run statuses */
.status-badge.in_progress { 
  background: rgba(59, 130, 246, 0.2); 
  color: #3b82f6; 
}

.status-badge.completed { 
  background: rgba(34, 197, 94, 0.2); 
  color: #22c55e; 
}

.status-badge.on_hold { 
  background: rgba(251, 191, 36, 0.2); 
  color: #fbbf24; 
}

/* Visit outcome statuses */
.status-badge.successful { 
  background: rgba(34, 197, 94, 0.2); 
  color: #22c55e; 
}

.status-badge.follow_up_needed { 
  background: rgba(251, 191, 36, 0.2); 
  color: #fbbf24; 
}

.status-badge.not_interested { 
  background: rgba(239, 68, 68, 0.2); 
  color: #ef4444; 
}

.status-badge.order_placed { 
  background: rgba(34, 197, 94, 0.2); 
  color: #22c55e; 
}

.status-badge.cancelled { 
  background: rgba(239, 68, 68, 0.2); 
  color: #ef4444; 
}

/* ============================================================================
   END OF ENHANCEMENTS
   ============================================================================ */


/* ========== INLINE FORM COMPLETE FIX (v3.3) ========== */

/* Main inline form container */
.inline-form {
  background: var(--bg);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: var(--spacing-lg);
  margin: 20px 0;
  max-height: 75vh;
  overflow-y: auto;
  position: relative;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* Form fields grid */
.inline-form .form-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

/* Individual field wrapper */
.inline-form .form-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.inline-form .form-field label {
  font-weight: 500;
  color: var(--text);
  font-size: 0.9rem;
}

/* Form actions (buttons) */
.inline-form .form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  margin-top: 20px;
}

/* LINE ITEMS SECTION - Critical for visibility */
.inline-form .line-items-section {
  margin-top: 32px;
  padding: 24px;
  border-top: 3px solid var(--accent);
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius);
}

.inline-form .line-items-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.inline-form .line-items-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-form .line-items-title::before {
  content: "📋";
  font-size: 1.4rem;
}

.inline-form .line-items-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 80px;
}

.inline-form .line-items-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-style: italic;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg-dim);
}

/* Line item row */
.inline-form .line-item-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--bg-dim);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.inline-form .line-item-row:hover {
  border-color: var(--accent);
  background: var(--bg);
}

/* Styled scrollbar */
.inline-form::-webkit-scrollbar {
  width: 10px;
}

.inline-form::-webkit-scrollbar-track {
  background: var(--bg-dim);
  border-radius: 5px;
}

.inline-form::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 5px;
}

.inline-form::-webkit-scrollbar-thumb:hover {
  background: var(--text);
}

/* Table integration */
.data-table tbody .inline-form {
  grid-column: 1 / -1;
  margin: 16px;
}

/* Dim the row being edited */
.data-table tbody tr:has(+ * .inline-form) {
  opacity: 0.4;
}

/* Make form responsive */
@media (max-width: 768px) {
  .inline-form {
    max-height: 90vh;
    padding: var(--spacing-md);
  }

  .inline-form .form-fields {
    grid-template-columns: 1fr;
  }
}

/* === BRANDING & UX ENHANCEMENTS === */

/* Loading Spinner */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
}

.spinner-ring {
  width: 40px;
  height: 40px;
  border: 4px solid var(--line);
  border-top-color: var(--pink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.spinner-message {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  text-align: center;
}

.empty-icon {
  font-size: 3rem;
  opacity: 0.5;
}

.empty-message {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Error State */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  text-align: center;
}

.error-icon {
  font-size: 3rem;
  color: #ef4444;
}

.error-message {
  color: #ef4444;
  font-size: 0.95rem;
}

/* Form Validation */
.field-error {
  color: #ef4444;
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.input.error {
  border-color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.05);
}

.required {
  color: #ef4444;
  margin-left: 0.2rem;
}

/* Top Bar Branding */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

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

.vertical-icon {
  font-size: 1.5rem;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 12px var(--pink);
}

.brand-name {
  font-size: 1rem;
  font-weight: 600;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}

.tenant-badge {
  padding: 0.25rem 0.75rem;
  background: var(--pink-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}

.tenant-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.85rem;
}

.tenant-label {
  color: var(--muted);
}

.tenant-id {
  font-weight: 600;
  color: var(--pink);
}

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-top: 1px solid var(--line);
  background: var(--panel);
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: auto;
}

.footer-left,
.footer-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.footer-vertical {
  font-weight: 600;
  color: var(--text);
}

.footer-divider {
  opacity: 0.5;
}

.footer-brand {
  font-weight: 500;
}

.footer-tenant {
  font-family: monospace;
  background: var(--bg);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

/* Color Input */
.color-input {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.color-input input[type="color"] {
  width: 60px;
  height: 40px;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.color-preview {
  flex: 1;
  padding: 0.5rem;
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.85rem;
  color: #fff;
  text-shadow: 0 0 2px rgba(0,0,0,0.5);
}

/* Table Row Selection */
.table tbody tr.selected {
  background: var(--pink-dim) !important;
  outline: 2px solid var(--pink);
}

/* Button States */
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

