@import url('https://fonts.googleapis.com/css2?family=Gochi+Hand&display=swap');

/* ============================================================
   AFI WATER — Factory Portal & Order Slip Digitization
   ============================================================ */

/* CSS Reset additions */
body {
  margin: 0;
  background: var(--off-white);
  min-height: 100vh;
}

/* ========== DASHBOARD CONTAINER LAYOUT ========== */
.dashboard-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--navy);
  background: var(--off-white);
}

/* Navbar Styling */
.top-navbar {
  width: 100%;
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
  z-index: 100;
}

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

.navbar-brand .nav-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--white);
  font-size: 1.4rem;
  font-weight: 700;
  text-decoration: none;
}

.nav-logo-img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.portal-badge {
  background: rgba(37, 99, 235, 0.2);
  color: var(--cyan-light);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 4px 10px;
  border-radius: 20px;
}

.navbar-menu {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
}

.menu-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--white);
}

.menu-btn.active {
  background: var(--mid-blue);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.menu-btn .icon {
  font-size: 1.1rem;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.lang-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lang-label {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.lang-toggle-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--white);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition);
}

.lang-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.back-link {
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color var(--transition);
}

.back-link:hover {
  color: var(--white);
}

/* Workspace styling */
.workspace {
  flex: 1;
  padding: 3rem;
  overflow-y: auto;
}

.workspace-header {
  margin-bottom: 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.workspace-header h2 {
  font-family: var(--font-main);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 4px;
}

.workspace-header .subtitle {
  font-size: 0.95rem;
  color: var(--gray);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeUp 0.4s ease both;
}

/* Split view for New Order */
.split-view {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 2.5rem;
  align-items: start;
}

/* ========== FORMS & CARDS ========== */
.form-card {
  background: var(--white);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 2.4rem 2.6rem;
  box-shadow: var(--shadow);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem;
  margin-bottom: 0.4rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 1.5rem;
}

.input-group label {
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--navy);
}

.input-group input[type="text"],
.input-group input[type="number"],
.input-group input[type="date"] {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 13px 16px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: var(--off-white);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-group input:focus {
  border-color: var(--cyan-light);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
  background: var(--white);
}

/* ========== CUSTOM AUTOCOMPLETE ========== */
.ac-wrap {
  position: relative;
}

.ac-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.06);
  z-index: 500;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
  animation: acSlideIn 0.15s ease;
}

.ac-dropdown.ac-open {
  display: block;
}

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

.ac-item {
  padding: 10px 14px;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--navy);
  cursor: pointer;
  transition: background 0.12s ease;
  border-bottom: 1px solid #f1f5f9;
}

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

.ac-item:hover,
.ac-item.ac-active {
  background: rgba(37, 99, 235, 0.06);
  color: var(--mid-blue);
}

.ac-item mark {
  background: rgba(37, 99, 235, 0.15);
  color: var(--mid-blue);
  font-weight: 700;
  border-radius: 3px;
  padding: 0 1px;
}

.ac-dropdown::-webkit-scrollbar { width: 4px; }
.ac-dropdown::-webkit-scrollbar-track { background: transparent; }
.ac-dropdown::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* Serial badge wrap */
.serial-display-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.serial-display-wrap input {
  flex: 1;
  padding-right: 54px !important;
}

.serial-badge {
  position: absolute;
  right: 10px;
  background: #1e40af;
  color: #fff;
  font-family: var(--font-main);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  padding: 2px 8px;
  border-radius: 20px;
  pointer-events: none;
}

/* ========== MATERIAL ITEMS SECTION ========== */
.items-section {
  margin-top: 2rem;
  margin-bottom: 1.8rem;
}

.items-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.items-section-title {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--navy);
  margin-right: 8px;
}

.items-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(37, 99, 235, 0.1);
  color: var(--mid-blue);
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.72rem;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 20px;
}

.btn-add-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--mid-blue);
  color: #fff;
  border: none;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 9px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.btn-add-item:hover {
  background: #1e40af;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-add-item:active {
  transform: translateY(0);
}

/* ---- Preset chips ---- */
.presets-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
  padding: 12px 14px;
  background: rgba(37, 99, 235, 0.03);
  border: 1px dashed rgba(37, 99, 235, 0.18);
  border-radius: 10px;
}

.presets-label {
  font-family: var(--font-main);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.presets-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-chip {
  background: var(--white);
  border: 1px solid var(--glass-border);
  color: var(--deep-blue);
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.preset-chip:hover {
  background: rgba(37, 99, 235, 0.06);
  border-color: var(--mid-blue);
  color: var(--mid-blue);
  transform: translateY(-1px);
}

.preset-chip:active {
  transform: translateY(0);
}

/* ---- Item cards ---- */
#item-cards-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.item-card {
  background: var(--off-white);
  border: 1.5px solid var(--glass-border);
  border-radius: 14px;
  padding: 18px 20px;
  transition: border-color 0.2s, box-shadow 0.2s, opacity 0.22s, transform 0.22s;
  opacity: 0;
  transform: translateY(8px);
}

.item-card-visible {
  opacity: 1;
  transform: translateY(0);
}

.item-card-removing {
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
}

.item-card:focus-within {
  border-color: var(--cyan-light);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.12);
}

.item-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.item-card-number {
  font-family: var(--font-main);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--mid-blue);
  background: rgba(37, 99, 235, 0.08);
  padding: 2px 9px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

.item-card-remove {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  transition: all 0.15s ease;
  padding: 0;
}

.item-card-remove:hover {
  background: #fef2f2;
  color: #ef4444;
}

.item-card-fields {
  display: grid;
  grid-template-columns: 1.8fr 1fr 1fr;
  gap: 14px;
}

.item-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.item-field label {
  font-family: var(--font-main);
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--gray);
  white-space: nowrap;
}

.item-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 13px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  font-family: var(--font-body);
  font-size: 0.9rem;
  background: var(--white);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

.item-field input:focus {
  border-color: var(--cyan-light);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.13);
}

/* ---- Empty state ---- */
.items-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 36px 24px;
  border: 2px dashed var(--glass-border);
  border-radius: 14px;
  text-align: center;
}

.empty-icon {
  font-size: 2.4rem;
  opacity: 0.45;
}

.items-empty-state p {
  font-size: 0.85rem;
  color: var(--gray);
  margin: 0;
  max-width: 280px;
  line-height: 1.6;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  border-top: 1px solid var(--glass-border);
  padding-top: 1.8rem;
  margin-top: 0.5rem;
}

/* Save button saving animation */
.btn-saving {
  animation: btnPulse 0.6s ease;
}

@keyframes btnPulse {
  0% { transform: scale(1); }
  40% { transform: scale(0.95); }
  70% { transform: scale(1.03); }
  100% { transform: scale(1); }
}


/* ========== LIVE PREVIEW PANEL ========== */
.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.preview-header span {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-icon-print {
  background: var(--white);
  border: 1px solid var(--glass-border);
  color: var(--navy);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
  transition: all var(--transition);
}

.btn-icon-print:hover {
  background: var(--ice-blue);
  border-color: var(--cyan-light);
}

.btn-icon-png {
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.15);
  color: var(--mid-blue);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
  transition: all var(--transition);
}

.btn-icon-png:hover {
  background: var(--mid-blue);
  color: var(--white);
}

.btn-icon-wa {
  background: rgba(37, 211, 102, 0.1);
  border: 1px solid rgba(37, 211, 102, 0.3);
  color: #128C7E;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
  transition: all var(--transition);
}

.btn-icon-wa:hover {
  background: #25D366;
  border-color: #25D366;
  color: #fff;
}

/* Phone input field */
.phone-input-group {
  margin-bottom: 0.6rem;
}

.phone-input-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--off-white);
  transition: border-color 0.18s, box-shadow 0.18s;
}

.phone-input-wrap:focus-within {
  border-color: #25D366;
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.12);
  background: var(--white);
}

.phone-prefix {
  padding: 11px 12px;
  background: rgba(37, 211, 102, 0.08);
  color: #128C7E;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 700;
  border-right: 1px solid var(--glass-border);
  white-space: nowrap;
  flex-shrink: 0;
}

.phone-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 11px 13px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--navy);
}

.phone-hint {
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0 12px;
  white-space: nowrap;
}

.optional-tag {
  font-family: var(--font-main);
  font-size: 0.68rem;
  font-weight: 600;
  color: #94a3b8;
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 20px;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* WhatsApp button in history card actions */
.btn-sm-wa {
  background: rgba(37, 211, 102, 0.1) !important;
  border-color: rgba(37, 211, 102, 0.3) !important;
  color: #128C7E !important;
}

.btn-sm-wa:hover {
  background: #25D366 !important;
  border-color: #25D366 !important;
  color: #fff !important;
}

.preview-canvas {
  background: #cbd5e1;
  background-image: radial-gradient(rgba(15, 23, 42, 0.08) 1px, transparent 0), radial-gradient(rgba(15, 23, 42, 0.08) 1px, transparent 0);
  background-size: 8px 8px;
  background-position: 0 0, 4px 4px;
  border-radius: var(--radius);
  padding: 2rem;
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.05);
  overflow-x: auto;
}

/* ========== EXACT SLIP REPLICA STYLING ========== */
.replica-slip {
  width: 100%;
  max-width: 560px; /* Increased from 480px to prevent the too-tall aspect ratio */
  background: #ffffff;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.15);
  font-family: var(--font-body);
  color: #0f172a;
  border-radius: 4px;
}

.replica-border-outer {
  border: 4px double #1e40af;
  padding: 14px; /* Reduced from 16px to prevent excess height */
}

.replica-border-inner {
  border: none;
}

/* Slip Header */
.replica-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  border-bottom: 2px solid #1e40af;
  padding-bottom: 8px;
  margin-bottom: 12px;
  gap: 16px;
}

.replica-logo-wrap {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.replica-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.replica-company-title {
  font-family: var(--font-main);
  font-size: 1.05rem;
  font-weight: 900;
  color: #1e40af;
  margin: 0;
  letter-spacing: -0.2px;
  line-height: 1.1;
  white-space: nowrap;
}

.replica-form-title {
  font-family: var(--font-main);
  font-size: 0.7rem;
  font-weight: 700;
  color: #1e40af;
  margin: 0;
  letter-spacing: 0.3px;
  line-height: 1.1;
  white-space: nowrap;
}

.replica-dept-badge {
  display: inline-block;
  background: #1e40af;
  color: #ffffff;
  font-family: var(--font-main);
  font-weight: 800;
  font-size: 0.6rem;
  padding: 2px 10px;
  border-radius: 50px;
  align-self: flex-start;
  margin-top: 2px;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.replica-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
}

.replica-serial-label {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.6rem;
  color: #64748b;
  text-transform: uppercase;
}

.replica-serial-number {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 1.4rem;
  color: #dc2626;
  line-height: 1;
  letter-spacing: 1px;
}

/* Slip Metadata Fields */
.replica-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.replica-meta-row {
  display: flex;
  align-items: flex-end;
}

.replica-meta-label {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.78rem;
  color: #0f172a;
  white-space: nowrap;
  margin-right: 8px;
  line-height: 1.4;
}

.replica-meta-line {
  flex: 1;
  border-bottom: 1.5px dotted #1e40af;
  padding-bottom: 2px;
  min-height: 22px;
  line-height: 1.1;
  font-family: 'Gochi Hand', cursive, sans-serif;
  font-size: 1.3rem;
  color: #1d4ed8;
  font-weight: 500;
}

/* Slip Table Grid */
.replica-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}

.replica-table th {
  border: 1.5px solid #1e40af;
  background: rgba(30, 64, 175, 0.03);
  font-family: var(--font-main);
  font-size: 0.78rem;
  font-weight: 800;
  color: #1e40af;
  text-align: center;
  padding: 6px;
  vertical-align: middle;
}

.replica-table td {
  border: 1.5px solid #1e40af;
  padding: 2px 10px;
  font-size: 0.8rem;
  height: 38px;
  text-align: left;
  vertical-align: bottom;
  padding-bottom: 4px;
}

.replica-table tbody td {
  font-family: 'Gochi Hand', cursive, sans-serif;
  font-size: 1.3rem;
  color: #1d4ed8;
  font-weight: 500;
  line-height: 1;
}

/* Slip Signatures */
.replica-signatures {
  display: flex;
  justify-content: space-between;
  margin-top: 10px; /* Reduced from 24px */
  padding-top: 4px; /* Reduced from 10px */
  gap: 24px;
}

.replica-sig-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.replica-sig-label {
  font-family: var(--font-main);
  font-size: 0.65rem;
  font-weight: 700;
  color: #475569;
}

.replica-sig-line {
  border-bottom: 1px solid #1e40af;
  height: 18px; /* Reduced from 24px */
}

/* ========== TAB 2: ORDER HISTORY DATABASE ========== */
.db-controls {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

#search-input {
  flex: 1;
  max-width: 400px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  background: var(--white);
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

#search-input:focus {
  border-color: var(--cyan-light);
  box-shadow: 0 4px 20px rgba(96, 165, 250, 0.08);
}

.table-container {
  background: var(--white);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.db-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.db-table th {
  padding: 1rem 1.5rem;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--glass-border);
  background: var(--white);
}

.db-table td {
  padding: 1rem 1.5rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--glass-border);
  color: var(--deep-blue);
}

.db-table tr:hover {
  background: var(--off-white);
}

.db-table tbody td {
  vertical-align: middle;
}

.db-serial {
  font-family: var(--font-main);
  font-weight: 700;
  color: #dc2626;
  background: #fef2f2;
  padding: 4px 10px;
  border-radius: 6px;
}

.db-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-sm-action {
  background: var(--off-white);
  border: 1px solid var(--glass-border);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.78rem;
  font-weight: 600;
  transition: all var(--transition);
}

.btn-sm-action:hover {
  background: var(--ice-blue);
  border-color: var(--cyan-light);
}

.btn-sm-delete {
  background: #fef2f2;
  border-color: #fee2e2;
  color: #ef4444;
}

.btn-sm-delete:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* ========== TAB 3: ANALYTICS ========== */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.mini-slip-wrapper {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
  border: 1px solid var(--glass-border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: all var(--transition);
}

.mini-slip-wrapper.today-slip {
  border: 2px solid #22c55e;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.15);
}

.metric-card {
  background: var(--white);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 1.8rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  transition: transform var(--transition);
}

.metric-card:hover {
  transform: translateY(-2px);
}

.metric-icon {
  width: 52px;
  height: 52px;
  background: rgba(37, 99, 235, 0.06);
  border-radius: 12px;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-info h3 {
  font-family: var(--font-main);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--navy);
  margin: 0;
}

.metric-info p {
  font-size: 0.8rem;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
  margin-top: 2px;
}

.analytics-charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.chart-card {
  background: var(--white);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 1.8rem;
  box-shadow: var(--shadow);
}

.chart-card h4 {
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 1.8rem;
}

/* Custom CSS Bar Chart */
.bar-chart-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chart-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.chart-label {
  width: 140px;
  font-size: 0.88rem;
  color: var(--deep-blue);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-bar-wrap {
  flex: 1;
  background: var(--off-white);
  height: 16px;
  border-radius: 8px;
  overflow: hidden;
}

.chart-bar-fill {
  background: linear-gradient(90deg, var(--cyan-light), var(--mid-blue));
  height: 100%;
  border-radius: 8px;
  transition: width 1s ease-out;
}

.chart-value {
  width: 40px;
  font-size: 0.85rem;
  color: var(--gray);
  font-weight: 600;
  text-align: right;
}

/* ========== PRINTING LAYOUT RULES ========== */
.print-only {
  display: none !important;
}

@media print {
  /* Hide the rest of the application dashboard */
  .no-print,
  .dashboard-container,
  .workspace,
  aside,
  header {
    display: none !important;
  }

  /* Reset body margins and padding */
  body, html {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
  }

  /* Show and size the print container */
  .print-only {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .replica-slip {
    box-shadow: none !important;
    border: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 10px !important;
    background: #ffffff !important;
  }

  .replica-border-outer {
    border: 4px double #1e40af !important;
    padding: 15px !important;
    border-radius: 0 !important;
  }

  .replica-meta-line {
    border-bottom: 1px dotted #1e40af !important;
  }

  .replica-table th {
    border: 1px solid #1e40af !important;
    background-color: #f1f5f9 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .replica-table td {
    border: 1px solid #1e40af !important;
    height: 32px !important;
  }

  .replica-sig-line {
    border-bottom: 1px solid #1e40af !important;
  }
}

/* ========== RESPONSIVENESS ========== */
@media (max-width: 1200px) {
  .split-view {
    grid-template-columns: 1fr;
  }
  .preview-panel {
    order: -1; /* Move preview above form */
  }
}

@media (max-width: 768px) {
  .dashboard-container {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    padding: 1rem 1.5rem;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-direction: column;
    gap: 1rem;
  }
  .sidebar-brand {
    margin-bottom: 0;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .sidebar-menu {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 5px;
    gap: 10px;
  }
  .menu-btn {
    white-space: nowrap;
    padding: 10px 14px;
    font-size: 0.85rem;
  }
  .sidebar-footer {
    padding-top: 0;
    border-top: none;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
  }
  .workspace {
    padding: 1rem;
  }
  .workspace-header {
    margin-bottom: 1.5rem;
  }
  .form-card {
    padding: 1.2rem;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .items-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .preview-canvas {
    padding: 1rem;
    overflow-x: auto;
    justify-content: flex-start;
  }
  .db-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .analytics-grid {
    grid-template-columns: 1fr;
  }
  .metric-card {
    padding: 1.5rem;
  }
  .item-card-fields {
    grid-template-columns: 1fr;
  }
  .presets-chips {
    gap: 5px;
  }
}

/* ========== TOAST NOTIFICATIONS ========== */
#toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  min-width: 240px;
  max-width: 360px;
  padding: 13px 18px;
  border-radius: 10px;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
  transform: translateX(110%);
  opacity: 0;
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.28s ease;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

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

.toast-hiding {
  transform: translateX(110%);
  opacity: 0;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

.toast-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.toast-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.toast-warn {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.toast-info {
  background: var(--ice-blue);
  color: #1e3a5f;
  border: 1px solid var(--cyan-light);
}

/* ========== CUSTOM CONFIRM MODAL ========== */
.confirm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.confirm-modal-overlay.modal-visible {
  opacity: 1;
}

.confirm-modal-box {
  background: var(--white);
  border-radius: 16px;
  padding: 2rem 2.5rem;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  text-align: center;
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.confirm-modal-overlay.modal-visible .confirm-modal-box {
  transform: scale(1);
}

.confirm-modal-icon {
  font-size: 2.4rem;
  margin-bottom: 0.8rem;
}

.confirm-modal-msg {
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.confirm-modal-actions {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
}

.confirm-btn {
  min-width: 100px;
  padding: 10px 22px;
}

/* ========== SAVE SUCCESS OVERLAY ========== */
.save-success-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.save-success-overlay.save-success-visible {
  opacity: 1;
}

.save-success-overlay.save-success-hiding {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.save-success-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: #ffffff;
  border-radius: 20px;
  padding: 2.8rem 3rem;
  box-shadow: 0 32px 80px rgba(15, 23, 42, 0.22);
  transform: scale(0.85);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
  max-width: 320px;
}

.save-success-overlay.save-success-visible .save-success-box {
  transform: scale(1);
}

.save-success-circle {
  width: 80px;
  height: 80px;
}

.save-success-svg {
  width: 80px;
  height: 80px;
}

/* Circle draw animation */
.save-success-circle-bg {
  stroke-dasharray: 157;
  stroke-dashoffset: 157;
  animation: drawCircle 0.5s ease 0.1s forwards;
}

@keyframes drawCircle {
  to { stroke-dashoffset: 0; }
}

/* Check draw animation */
.save-success-check {
  stroke-dasharray: 36;
  stroke-dashoffset: 36;
  animation: drawCheck 0.4s ease 0.55s forwards;
}

@keyframes drawCheck {
  to { stroke-dashoffset: 0; }
}

.save-success-title {
  font-family: var(--font-main);
  font-size: 1.3rem;
  font-weight: 800;
  color: #15803d;
  margin: 0;
}

.save-success-msg {
  font-family: var(--font-main);
  font-size: 0.88rem;
  color: #64748b;
  margin: 0;
  line-height: 1.5;
}

/* Make the save btn flex so SVG + text align */
#btn-save-print {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
