/* Root Design Tokens */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --input-focus: #3b82f6;
  --btn-danger: #ef4444;
  --btn-danger-hover: #dc2626;
  --btn-success: #10b981;
  --btn-success-hover: #059669;
  --app-font: "Noto Sans Thai Looped", sans-serif;
  
  /* Bill Specific Tokens (matches classic spreadsheet look) */
  --bill-font: var(--app-font);
}

[v-cloak] {
  display: none !important;
}

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

body {
  font-family: var(--app-font);
  font-optical-sizing: auto;
  font-style: normal;
  font-variation-settings: "wdth" 100;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button,
input,
textarea,
select,
option,
::file-selector-button {
  font-family: inherit;
  font-optical-sizing: inherit;
  font-style: inherit;
  font-variation-settings: inherit;
}

/* App Header */
.app-header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 24px;
  display: flex;
  height: 72px;
  justify-content: space-between;
  align-items: center;
}

.app-title {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-title svg {
  color: var(--primary-color);
}

/* Header Actions & Dropdown Styles */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-success {
  background-color: var(--btn-success);
  color: white;
  border: none;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-success:hover {
  background-color: var(--btn-success-hover);
}

.dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.dropdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 998;
  background: transparent;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  width: 220px;
  padding: 6px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: #334155;
  text-align: left;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dropdown-item svg {
  color: #64748b;
  transition: color 0.15s ease;
}

.dropdown-item:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

.dropdown-item:hover svg {
  color: #334155;
}

.dropdown-item.danger {
  color: var(--btn-danger);
}

.dropdown-item.danger svg {
  color: var(--btn-danger);
  opacity: 0.8;
}

.dropdown-item.danger:hover {
  background-color: #fef2f2;
  color: var(--btn-danger-hover);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 6px 0;
}

.dropdown-trigger .chevron-icon {
  margin-left: 2px;
  transition: transform 0.2s ease;
}

.dropdown-wrapper:focus-within .chevron-icon {
  transform: rotate(180deg);
}

.mobile-only-item {
  display: none;
}

@media (max-width: 767px) {
  .header-actions .header-btn {
    display: none;
  }
  .mobile-only-item {
    display: flex;
  }
  .dropdown-divider.mobile-only-item {
    display: block;
  }
}

/* Mobile Tabs Navigation */
.mobile-tabs {
  display: none;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  padding: 14px;
  border: none;
  background: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.tab-btn.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  background-color: rgba(37, 99, 235, 0.03);
}

/* Main Container (Split Screen) */
.main-container {
  display: flex;
  flex: 1;
  height: calc(100vh - 73px);
  overflow: hidden;
}

/* Scrollable Columns */
.editor-panel {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  border-right: 1px solid var(--border-color);
  background-color: var(--bg-card);
  container-type: inline-size;
}

.preview-panel {
  flex: 1.2;
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: #f1f5f9;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Form Styling */
.form-section {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.grid-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-main);
  background-color: #ffffff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Date input wrapper & Today button */
.date-input-wrapper {
  display: flex;
  gap: 8px;
  width: 100%;
}

.date-input-wrapper input {
  flex: 1;
  min-width: 0;
}

.btn-today {
  background-color: #ffffff;
  color: #334155;
  border: 1px solid var(--border-color);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-today:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

/* Table Items Editor v2 */
.items-editor-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.items-editor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.col-hdr-index { width: 30px; text-align: center; }
.col-hdr-desc { flex: 1; }
.col-hdr-qty { width: 48px; text-align: center; }
.col-hdr-unit { width: 82px; }
.col-hdr-total { width: 86px; text-align: right; }
.col-hdr-actions { width: 48px; text-align: center; }

.items-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-secondary.items-add-bottom {
  align-self: flex-end;
  margin-top: 4px;
  padding: 6px 12px;
  font-size: 13px;
}

.item-editor-row-v2 {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #ffffff;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.item-editor-row-v2:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}

.item-index-badge {
  width: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-muted);
  background: #f1f5f9;
  height: 24px;
  border-radius: 12px;
  flex-shrink: 0;
  margin-top: 8px;
}

.item-index-badge.multiline {
  color: var(--primary-color);
  background: #eff6ff;
}

.item-desc-group { flex: 1; }
.item-desc-group textarea {
  min-height: 42px;
  line-height: 1.45;
  resize: vertical;
}
.item-desc-group .item-desc-textarea {
  min-height: 118px;
}
.item-qty-group { width: 48px; flex-shrink: 0; }
.item-qty-group input { padding: 10px 6px; text-align: center; }
.item-unit-group { width: 82px; flex-shrink: 0; }
.item-unit-group input { text-align: right; }

.item-qty-group input::-webkit-outer-spin-button,
.item-qty-group input::-webkit-inner-spin-button,
.item-unit-group input::-webkit-outer-spin-button,
.item-unit-group input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.item-qty-group input[type="number"],
.item-unit-group input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.item-line-total {
  width: 86px;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  flex-shrink: 0;
  padding-top: 10px;
}

.item-row-actions {
  display: flex;
  gap: 4px;
  width: 48px;
  justify-content: center;
  flex-shrink: 0;
  padding-top: 3px;
  position: relative;
  z-index: 2;
}

.item-editor-row-v2.item-menu-open {
  position: relative;
  z-index: 10;
}

.item-action-dropdown {
  position: relative;
}

.btn-row-menu {
  width: 36px;
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-row-menu:hover,
.btn-row-menu[aria-expanded="true"] {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn-row-menu svg {
  color: var(--text-muted);
}

.item-action-overlay {
  position: fixed;
  inset: 0;
  z-index: 996;
  background: transparent;
}

.item-action-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 997;
  width: 180px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 12px 18px -8px rgba(15, 23, 42, 0.22), 0 6px 8px -6px rgba(15, 23, 42, 0.12);
}

.item-action-menu-item {
  width: 100%;
  border: none;
  background: transparent;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.item-action-menu-item:hover:not(:disabled) {
  background: #f1f5f9;
  color: #0f172a;
}

.item-action-menu-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.item-action-menu-item svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.item-action-menu-item.danger {
  color: var(--btn-danger);
}

.item-action-menu-item.danger svg {
  color: var(--btn-danger);
}

.item-action-menu-item.danger:hover {
  background: #fef2f2;
  color: var(--btn-danger-hover);
}

.item-action-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

.mobile-only-label {
  display: none;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background-color: #f1f5f9;
  color: var(--text-main);
}

.btn-icon.danger:hover {
  background-color: #fef2f2;
  color: var(--btn-danger);
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.btn-secondary {
  background-color: #ffffff;
  color: #334155;
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-secondary:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

/* Service Editor */
.service-editor-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

/* File Import Input Hidden */
.hidden-file-input {
  display: none;
}

/* Bill A4 Live Preview Container */
.bill-paper-container {
  width: 100%;
  display: flex;
  justify-content: center;
  overflow: visible;
  height: calc(var(--bill-paper-height, 1123px) * var(--bill-scale, 1));
  transition: height 0.1s ease;
}

.bill-pages-wrapper {
  width: 794px;
  min-width: 794px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: scale(var(--bill-scale, 1));
  transform-origin: top center;
  box-sizing: border-box;
}

.bill-paper {
  width: 794px;
  min-width: 794px; /* Prevents text/table reflow on mobile */
  height: auto;
  min-height: 1123px;
  padding: 57px; /* 15mm equivalent at 96 DPI - equal top/bottom margins */
  background-color: #ffffff;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
  font-family: var(--bill-font);
  color: #000000;
  position: relative;
  overflow-y: visible;
  flex-shrink: 0;
}

/* Compact layout for 21-25 items to fit on 1 page */
.bill-paper.compact-layout {
  padding: 38px 57px; /* 10mm top/bottom, 15mm left/right */
}

.bill-paper.compact-layout .bill-header-grid {
  margin-bottom: 12px;
}

.bill-paper.compact-layout .bill-table-container {
  margin-top: 5px;
}

.bill-paper.compact-layout .item-row td {
  padding: 2px 8px;
}

.bill-no-row {
  display: flex;
  justify-content: flex-end;
  font-size: 14px;
  margin-bottom: 12px;
  font-weight: 500;
}

.bill-header-grid {
  display: grid;
  grid-template-columns: 64% 22% 14%;
  gap: 0;
  margin-bottom: 24px;
  font-size: 13.5px;
  line-height: 1.45;
}

.bill-col {
  display: flex;
  flex-direction: column;
}

.bill-row {
  height: 25px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bill-date-row {
  overflow: visible;
  text-align: right;
  font-size: 12.5px;
}

.bill-span-2 {
  grid-column: span 2;
}

.bill-customer-title {
  font-weight: bold;
  font-size: 14.5px;
}

.bill-value {
  margin-left: 6px;
  font-weight: normal;
}

/* Bill Table */
.bill-table-container {
  width: 100%;
  margin-top: 10px;
}

.bill-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-left: 1px solid #000000;
  border-top: 1px solid #000000;
  font-size: 13.5px;
}

.bill-table th, 
.bill-table td {
  border-right: 1px solid #000000;
  border-bottom: 1px solid #000000;
  padding: 5px 8px;
  vertical-align: middle;
  line-height: 1.2;
}

.bill-table th {
  font-weight: normal;
  text-align: center;
  background-color: transparent;
  height: 32px;
}

/* Table Column Widths */
.col-item {
  width: 8%;
  text-align: center;
}

.col-desc {
  width: 56%;
  text-align: left;
  white-space: pre-line;
}

.col-qty {
  width: 8%;
  text-align: center;
}

.col-unit {
  width: 14%;
  text-align: right;
}

.col-amount {
  width: 14%;
  text-align: right;
}

/* Item Rows Styling */
.item-row td {
  height: 28px;
}

.item-row.multiline-item td {
  vertical-align: top;
  padding-top: 6px;
  padding-bottom: 6px;
}

.item-row.multiline-item td.col-desc {
  line-height: 1.6;
}

.item-row td.col-item,
.item-row td.col-qty {
  text-align: center;
}

.item-row td.col-unit,
.item-row td.col-amount {
  text-align: right;
}

/* Lower Table Sections */
.subtotal-row td,
.service-row td,
.total-row td {
  height: 30px;
}

.total-row td {
  padding-block: 8px;
  font-size: 14.5px;
}

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

.bill-table td.service-desc-cell {
  vertical-align: top !important;
  text-align: left;
  padding-top: 6px;
  padding-bottom: 12px;
  padding-left: calc(8% + 8px) !important;
  line-height: 1.6;
  white-space: pre-wrap;
}

.bill-table td.service-desc-cell.no-service-amount-divider {
  border-right: none !important;
}

.service-amount-cell {
  vertical-align: top !important;
  text-align: right;
  padding-top: 6px;
}

.hide-amount .service-amount-cell {
  padding-top: calc(6px + 1.6em);
}

.bill-table td.total-label-cell {
  font-weight: normal;
  text-align: left;
  padding-left: calc(8% + 8px) !important;
}

.total-amount-cell {
  font-weight: normal;
  text-align: right;
}

/* Responsive Rules */
@media (max-width: 1024px) {
  .mobile-tabs {
    display: flex;
  }
  
  .main-container {
    flex-direction: column;
    height: calc(100vh - 127px); /* Subtract header and tab bar */
  }
  
  .editor-panel,
  .preview-panel {
    flex: 1;
    width: 100%;
    overflow-y: auto;
  }
  
  /* Show/Hide based on Active Tab in Mobile */
  .editor-panel {
    display: block;
  }
  .preview-panel {
    display: flex;
  }
  
  /* When a specific tab is active */
  .main-container.tab-edit .preview-panel {
    display: none;
  }
  .main-container.tab-preview .editor-panel {
    display: none;
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 12px 16px;
  }
  
  .app-title {
    font-size: 17px;
  }
  
  .editor-panel {
    padding: 16px;
  }

  .form-section {
    padding: 16px;
  }
  
  .grid-inputs {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
}

/* Container Query for Items list (switches layout based on editor panel width) */
@container (max-width: 680px) {
  .items-editor-header {
    display: none;
  }

  .item-editor-row-v2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
  }

  .item-index-badge {
    grid-row: 1;
    grid-column: 1;
    margin-left: 0;
    margin-top: 0;
    align-self: center;
  }

  .item-row-actions {
    grid-row: 1;
    grid-column: 2;
    width: auto;
    justify-content: flex-end;
    align-self: center;
    padding-top: 0;
  }

  .item-action-menu {
    width: min(180px, calc(100vw - 48px));
  }

  .item-desc-group {
    grid-row: 2;
    grid-column: span 2;
  }

  .item-qty-group {
    grid-row: 3;
    grid-column: 1;
    width: auto;
  }

  .item-qty-group input {
    text-align: left;
  }

  .item-unit-group {
    grid-row: 3;
    grid-column: 2;
    width: auto;
  }

  .item-unit-group input {
    text-align: left;
  }

  .item-line-total {
    grid-row: 4;
    grid-column: span 2;
    width: 100%;
    text-align: right;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px dashed var(--border-color);
    padding-top: 8px;
    margin-top: 4px;
  }

  .mobile-only-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
  }
}

@media (max-width: 600px) {
  .items-add-bottom {
    width: 100%;
  }
  
  .service-editor-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

@media (max-width: 360px) {
  .tab-btn {
    font-size: 13px;
    padding: 10px;
  }
}

/* Custom Border Classes for Subtotal / Service merging */
.no-border-bottom {
  border-bottom: none !important;
}

.no-border-top {
  border-top: none !important;
}

.spacer-line {
  height: 20px;
}

/* Print CSS Configurations */
@media print {
  /* Hide all UI elements */
  body, html {
    background-color: #ffffff !important;
    height: auto !important;
    overflow: visible !important;
  }
  
  .app-header,
  .mobile-tabs,
  .editor-panel,
  .preview-actions-bar {
    display: none !important;
  }
  
  .main-container {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  /* Reset layout for bill paper */
  .preview-panel {
    padding: 0 !important;
    margin: 0 !important;
    background-color: #ffffff !important;
    overflow: visible !important;
    display: block !important;
    width: 210mm !important;
  }
  
  .bill-paper-container {
    height: auto !important;
    overflow: visible !important;
    display: block !important;
    width: 210mm !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .bill-pages-wrapper {
    width: 210mm !important;
    transform: none !important;
    gap: 0 !important;
    display: block !important;
  }

  .bill-paper {
    transform: none !important;
    width: 210mm !important;
    height: auto !important;
    min-height: 297mm !important;
    padding: 15mm !important;
    margin: 0 !important;
    box-shadow: none !important;
    position: relative !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    page-break-after: always !important;
    page-break-inside: avoid !important;
    box-sizing: border-box !important;
    overflow: visible !important;
  }

  .bill-paper:last-child {
    page-break-after: auto !important;
  }

  .bill-paper.compact-layout {
    padding: 10mm 15mm 10mm 15mm !important;
  }

  .bill-table tr {
    page-break-inside: avoid !important;
  }
  
  @page {
    size: A4;
    margin: 0;
  }
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background-color: #ffffff;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  padding: 28px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.btn-option {
  background-color: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.btn-option:hover {
  border-color: var(--primary-color);
  background-color: #f0f9ff;
}

.option-title {
  font-weight: 700;
  font-size: 16px;
  color: #0f172a;
}

.option-desc {
  font-size: 14px;
  color: #64748b;
  line-height: 1.4;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* --- Added Settings & Validation Styles --- */

/* Alert Notification Icon Button on Header */
.btn-alert-trigger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.2s ease;
  margin-right: 4px;
}

.btn-alert-trigger.critical {
  color: var(--btn-danger);
  background-color: #fef2f2;
  border: 1px solid #fca5a5;
  animation: pulse-red 2.0s infinite;
}

.btn-alert-trigger.critical:hover {
  background-color: #fee2e2;
}

.btn-alert-trigger.warning {
  color: #d97706; /* Amber-600 */
  background-color: #fffbeb;
  border: 1px solid #fde68a;
}

.btn-alert-trigger.warning:hover {
  background-color: #fef3c7;
}

.btn-alert-trigger .alert-count {
  position: absolute;
  top: -4px;
  right: -4px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  border-radius: 9999px;
  padding: 1px 5px;
  line-height: 1;
  border: 1.5px solid var(--bg-card);
}

.btn-alert-trigger.critical .alert-count {
  background-color: var(--btn-danger);
}

.btn-alert-trigger.warning .alert-count {
  background-color: #d97706;
}

@keyframes pulse-red {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* Modal Headers & List Styling */
.modal-header-v2 {
  margin-bottom: 18px;
}

.alert-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 4px;
}

.alert-item-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid;
  font-size: 14px;
  line-height: 1.45;
}

.alert-item-card.critical {
  background-color: #fef2f2;
  border-color: #fee2e2;
  color: #991b1b;
}

.alert-item-card.warning {
  background-color: #fffbeb;
  border-color: #fef3c7;
  color: #92400e;
}

.alert-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.alert-badge.critical {
  background-color: #ef4444;
  color: #ffffff;
}

.alert-badge.warning {
  background-color: #f59e0b;
  color: #ffffff;
}

.alert-msg {
  flex: 1;
}

.text-danger {
  color: var(--btn-danger);
}

.text-warning {
  color: #f59e0b;
}

/* Settings Modal Elements */
.settings-options-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.setting-toggle-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 14px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.setting-toggle-card:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  padding-right: 16px;
}

.setting-label {
  font-weight: 700;
  font-size: 16px;
  color: #0f172a;
}

.setting-desc {
  font-size: 14px;
  color: #64748b;
  line-height: 1.4;
}

/* Switch Toggle Design */
.switch-wrapper {
  position: relative;
  width: 46px;
  height: 24px;
  flex-shrink: 0;
}

.switch-checkbox {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .3s;
  border-radius: 24px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.switch-checkbox:checked + .switch-slider {
  background-color: var(--primary-color);
}

.switch-checkbox:checked + .switch-slider:before {
  transform: translateX(22px);
}

/* Hide Qty and Unit Table Adjustments */
.hide-qty-unit .col-desc {
  width: 78% !important;
}

/* Settings Modal visual dependency */
.disabled-setting-card {
  opacity: 0.65;
  cursor: not-allowed !important;
}

.disabled-setting-card .switch-slider {
  cursor: not-allowed !important;
}

.badge-auto-selected {
  font-size: 12px;
  font-weight: 700;
  background-color: var(--primary-color);
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  display: inline-block;
  vertical-align: middle;
}

/* Form Helper Badges / Mini Banners */
.badge-status-danger {
  font-size: 13px;
  font-weight: 700;
  background-color: #fee2e2;
  color: #ef4444;
  padding: 4px 10px;
  border-radius: 9999px;
  border: 1px solid #fca5a5;
  display: inline-block;
}

.alert-info-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  line-height: 1.45;
}

.alert-info-mini svg {
  color: #2563eb;
  flex-shrink: 0;
}

/* Table columns & styling adjustments when hiding service sections */
.hide-service-total .total-label-cell,
.no-total-amount-divider .total-label-cell {
  border-left: none !important;
  border-right: none !important;
}
