/* =============================================
   SERVICE ORDERS PAGE — service-ordem.css
   Contém tudo que a página de ordens de serviço
   precisa além do sistema.css:
   layout, page header, tabela, search, ações,
   botões, empty state, badges de status e modal
   ============================================= */

/* ============================================
   PAGE HEADER
   ============================================ */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-color);
  margin: 0;
}

.page-subtitle {
  font-size: 0.875rem;
  color: #999;
  margin: 0;
}

body.dark .page-subtitle {
  color: #888;
}

/* ============================================
   TABLE CONTROLS BAR
   ============================================ */

.table-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.search-field {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.search-field .search-icon {
  position: absolute;
  left: 0.7rem;
  font-size: 1.1rem;
  color: #aaa;
  pointer-events: none;
  line-height: 1;
}

.search-field input {
  padding: 0.5rem 0.75rem 0.5rem 2.2rem;
  min-width: 260px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-color);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

body.dark .search-field input {
  background-color: #1A182A;
  border-color: var(--border);
  color: var(--text-color);
}

body.dark .search-field input::placeholder {
  color: #555;
}

.filter-select {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-color);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

body.dark .filter-select {
  background-color: #1A182A;
  border-color: var(--border);
  color: var(--text-color);
}

/* ── Finance-style pagination ─────────────────────────────────────── */
.finance-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem 0.25rem 0;
  margin-top: 0.6rem;
  border-top: 1px solid var(--border, #eeeeee);
}
body.dark .finance-pagination { border-top-color: #2e2f30; }
.pagination-perpage {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: #aaa;
}
body.dark .pagination-perpage { color: #666; }
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.pagination-controls .pagination-info {
  font-size: 0.8rem;
  color: #aaa;
}
.pagination-perpage select {
  padding: 0.28rem 0.5rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-color);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.pagination-perpage select:focus { outline: none; border-color: var(--primary-color); }
body.dark .pagination-perpage select { background: #2a2b2c; border-color: #3a3b3c; color: var(--text-color); }
.pagination-pages {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
#so-page-indicator,
#quote-page-indicator {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-color);
  min-width: 48px;
  text-align: center;
}
.page-prev,
.page-next { width: 30px; height: 30px; font-size: 1.2rem; color: var(--text-color); }
.page-prev:disabled,
.page-next:disabled { opacity: 0.3; cursor: not-allowed; }
.page-prev:not(:disabled):hover,
.page-next:not(:disabled):hover {
  background-color: rgba(29,78,216,0.14);
  color: var(--primary-color);
}

/* ── Filter button badge ─────────────────────────────────────────── */
.so-filter-btn { position: relative; }
.filter-active-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background-color: var(--primary-color, #1d4ed8);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  margin-left: 0.2rem;
}
.filter-btn-active {
  border-color: var(--primary-color, #1d4ed8) !important;
  color: #1E40AF !important;
}
body.dark .filter-btn-active { color: var(--primary-color) !important; }

/* ── Filter modal (reuses finance fin-* pattern) ─────────────────── */
.fin-confirm-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.18s ease;
}
.fin-confirm-overlay.visible { opacity: 1; }
.fin-confirm-dialog {
  background: white; border-radius: 16px; padding: 2rem 2.25rem;
  width: 420px; max-width: calc(100vw - 2rem);
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  transform: scale(0.95); transition: transform 0.18s ease;
}
.fin-confirm-overlay.visible .fin-confirm-dialog { transform: scale(1); }
body.dark .fin-confirm-dialog { background: #242526; }
.fin-filter-dialog {
  text-align: left !important;
  width: 480px;
  max-width: calc(100vw - 2rem);
}
.fin-filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.fin-filter-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-color);
  margin: 0;
}
.fin-filter-body {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  margin-bottom: 1.5rem;
}
.fin-filter-section h4 {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.65px;
  color: #bbb;
  margin: 0 0 0.55rem;
}
body.dark .fin-filter-section h4 { color: #666; }
.fin-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.fin-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1.5px solid var(--border, #e2e8f0);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-color);
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
  user-select: none;
}
.fin-pill input { display: none; }
.fin-pill:has(input:checked) {
  border-color: var(--primary-color, #1d4ed8);
  background-color: rgba(29,78,216,0.13);
  color: #1E40AF;
  font-weight: 700;
}
body.dark .fin-pill { border-color: #3a3b3c; }
body.dark .fin-pill:has(input:checked) {
  border-color: var(--primary-color);
  background-color: rgba(29,78,216,0.10);
  color: var(--primary-color);
}
.fin-filter-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}
.fin-filter-range {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.fin-filter-range > span { font-size: 0.85rem; color: #aaa; flex-shrink: 0; }
.fin-filter-range input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-color);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.fin-filter-range input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.12);
}
body.dark .fin-filter-range input { background: #2a2b2c; border-color: #3a3b3c; color: var(--text-color); }
.modal-close-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: none; border-radius: 8px;
  background: transparent; color: #aaa; cursor: pointer; font-size: 1.35rem;
  flex-shrink: 0; transition: background-color 0.15s ease, color 0.15s ease;
}
.modal-close-btn:hover { background-color: rgba(0,0,0,0.07); color: var(--text-color); }
body.dark .modal-close-btn:hover { background-color: rgba(255,255,255,0.08); }

/* ============================================
   TABLE
   ============================================ */

/* Override sistema.css: remove gray thead, use clean borderless header */
.admin-table thead {
  background-color: transparent !important;
}

body.dark .admin-table thead {
  background-color: transparent !important;
}

.admin-table th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.55px;
  color: #999;
  padding: 0.65rem 0.75rem;
  border-bottom: 2px solid #e8e8e8 !important;
  border-top: none !important;
  white-space: nowrap;
}

body.dark .admin-table th {
  color: #545454;
  border-bottom-color: #2e2f30 !important;
}

.admin-table td {
  font-size: 0.875rem;
  vertical-align: middle;
  border-bottom: 1px solid #eeeeee;
  padding: 0.7rem 0.75rem;
}
body.dark .admin-table td {
  border-bottom-color: #2e2f30;
}
.admin-table tbody tr:nth-child(even)           { background-color: rgba(0,0,0,0.022); }
body.dark .admin-table tbody tr:nth-child(even) { background-color: rgba(255,255,255,0.022); }
.admin-table tbody tr:hover { background-color: rgba(29,78,216,0.1) !important; }
body.dark .admin-table tbody tr:hover { background-color: rgba(29,78,216,0.08) !important; }

/* Clean card: use card design tokens */
.admin-panel {
  border-radius: 14px;
  padding: 1.5rem;
  border: 1px solid var(--border) !important;
  background: var(--card-bg) !important;
  box-shadow: var(--card-shadow) !important;
}
body.dark .admin-panel {
  background: var(--card-bg) !important;
  border-color: var(--border) !important;
  box-shadow: var(--card-shadow) !important;
}
}

.admin-table th.col-actions,
.admin-table td.col-actions {
  text-align: right;
  white-space: nowrap;
}

/* ============================================
   ICON ACTION BUTTONS
   ============================================ */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  background-color: transparent;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.icon-btn:hover {
  transform: scale(1.08);
}

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

.edit-btn:hover {
  background-color: rgba(29, 78, 216, 0.15);
}

.delete-btn {
  color: #cc4c4c;
}

.delete-btn:hover {
  background-color: rgba(204, 76, 76, 0.12);
}

body.dark .delete-btn {
  color: #EF9A9A;
}

body.dark .delete-btn:hover {
  background-color: rgba(239, 154, 154, 0.1);
}

/* ============================================
   SECONDARY / CANCEL BUTTON
   ============================================ */

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.55rem 1rem;
  background-color: transparent;
  color: var(--text-color);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  font-family: inherit;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  text-decoration: none;
}

.btn-secondary:hover {
  background-color: rgba(0, 0, 0, 0.05);
  border-color: #ccc;
}

body.dark .btn-secondary {
  border-color: #555;
  color: var(--text-color);
}

body.dark .btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.06);
  border-color: #666;
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: #999;
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
  display: block;
}

.empty-state p {
  margin: 0;
}

.empty-hint {
  font-size: 0.85rem;
  color: #bbb;
  margin-top: 0.35rem;
}

body.dark .empty-state {
  color: #666;
}

/* ============================================
   ORDER STATUS BADGES
   ============================================ */

.order-badge {
  display: inline-block;
  padding: 0.22rem 0.7rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.order-open {
  background-color: #E3F2FD;
  color: #1565C0;
}

.order-in-progress {
  background-color: #FFF3E0;
  color: #E65100;
}

.order-done {
  background-color: #E8F5E9;
  color: #2E7D32;
}

.order-cancelled {
  background-color: #FFEBEE;
  color: #C62828;
}

body.dark .order-open {
  background-color: rgba(21, 101, 192, 0.2);
  color: #90CAF9;
}

body.dark .order-in-progress {
  background-color: rgba(230, 81, 0, 0.2);
  color: #FFB74D;
}

body.dark .order-done {
  background-color: rgba(46, 125, 50, 0.2);
  color: #81C784;
}

body.dark .order-cancelled {
  background-color: rgba(198, 40, 40, 0.2);
  color: #EF9A9A;
}

/* ============================================
   TEXT HELPERS
   ============================================ */

.text-muted {
  color: #bbb;
  font-size: inherit;
}

body.dark .text-muted {
  color: #555;
}

.required {
  color: var(--primary-color);
}

/* ============================================
   SERVICE ORDER MODAL — OVERLAY
   ============================================ */

.so-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  backdrop-filter: blur(3px);
}

.so-modal-overlay .so-modal {
  margin: auto;
}

.hidden {
  display: none !important;
}

.so-modal-overlay.hidden {
  display: none;
}

body.modal-open {
  overflow: hidden;
}

/* ============================================
   SERVICE ORDER MODAL — CONTAINER
   ============================================ */

.so-modal {
  width: min(96vw, 920px);
  background: var(--sidebar-color);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2rem);
  animation: soSlideIn 0.22s ease-out;
}

body.dark .so-modal {
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

@keyframes soSlideIn {
  from {
    transform: scale(0.96) translateY(-18px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* ============================================
   SERVICE ORDER MODAL — HEADER
   ============================================ */

.so-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: linear-gradient(
    135deg,
    rgba(29, 78, 216, 0.08) 0%,
    rgba(29, 78, 216, 0.02) 100%
  );
}

body.dark .so-modal-header {
  background: linear-gradient(
    135deg,
    rgba(29, 78, 216, 0.1) 0%,
    rgba(29, 78, 216, 0.03) 100%
  );
}

.so-modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-color);
}

.modal-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background-color: transparent;
  color: var(--text-color);
  font-size: 1.4rem;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
  flex-shrink: 0;
  line-height: 1;
}

.modal-close-btn:hover {
  background-color: rgba(0, 0, 0, 0.07);
  color: #cc4c4c;
}

body.dark .modal-close-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #EF9A9A;
}

/* ============================================
   SERVICE ORDER MODAL — SCROLLABLE BODY
   ============================================ */

.so-modal form {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.so-modal .modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  flex: 1;
}

/* ============================================
   FORM FIELDS
   ============================================ */

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

.form-field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-color);
  letter-spacing: 0.2px;
}

.form-field input,
.form-field select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--sidebar-color);
  color: var(--text-color);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.form-field input:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}

body.dark .form-field input,
body.dark .form-field select {
  background-color: #2a2b2c;
  border-color: #3a3b3c;
  color: var(--text-color);
}

body.dark .form-field input::placeholder {
  color: #666;
}

body.dark .form-field input:focus,
body.dark .form-field select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

/* 2-column form grid */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

@media (max-width: 480px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Form section divider */
.form-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--primary-color);
  margin: 0.25rem 0 0;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

body.dark .form-section-title {
  border-bottom-color: var(--border);
}

/* ============================================
   PRODUCT PICKER (inside modal)
   ============================================ */

.product-picker {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.6rem;
  align-items: flex-end;
}

.product-picker .form-field {
  margin: 0;
}

.product-picker .btn-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 0.85rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  transition: filter 0.2s ease;
  align-self: flex-end;
}

.product-picker .btn-add:hover {
  filter: brightness(0.92);
}

/* Selected products mini-table */
.order-items-wrapper {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 600px;
  min-height: 120px;
}

body.dark .order-items-wrapper {
  border-color: var(--border);
}

.order-items-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.order-items-table th {
  padding: 0.5rem 0.75rem;
  background-color: var(--body-color);
  color: var(--text-color);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 1;
}

body.dark .order-items-table th {
  background-color: var(--sidebar-color);
  border-bottom-color: var(--border);
}

.order-items-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-color);
  vertical-align: middle;
}

body.dark .order-items-table td {
  border-color: var(--border);
}

.order-items-table tr:last-child td {
  border-bottom: none;
}

.order-items-table .remove-item-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  background-color: transparent;
  color: #cc4c4c;
  transition: background-color 0.15s ease;
}

.order-items-table .remove-item-btn:hover {
  background-color: rgba(204, 76, 76, 0.12);
}

body.dark .order-items-table .remove-item-btn {
  color: #EF9A9A;
}

.no-items-row td {
  padding: 1rem 0.75rem;
  text-align: center;
  color: #aaa;
  font-style: italic;
  font-size: 0.85rem;
}

/* ============================================
   ORDER TOTAL BOX
   ============================================ */

.order-total-box {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.85rem 1rem;
  background-color: rgba(29, 78, 216, 0.06);
  border: 1px solid rgba(29, 78, 216, 0.25);
  border-radius: 10px;
}

body.dark .order-total-box {
  background-color: rgba(29, 78, 216, 0.08);
  border-color: rgba(29, 78, 216, 0.2);
}

.order-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-color);
}

.order-total-row.grand-total {
  padding-top: 0.4rem;
  margin-top: 0.1rem;
  border-top: 1px dashed rgba(29, 78, 216, 0.4);
  font-size: 1rem;
  font-weight: 700;
}

.order-total-row .label {
  color: #888;
}

.order-total-row.grand-total .label {
  color: var(--text-color);
}

.order-total-row .value {
  font-weight: 600;
  color: var(--text-color);
}

.order-total-row.grand-total .value {
  color: var(--primary-color);
  font-size: 1.1rem;
}

/* ============================================
   MODAL ERROR
   ============================================ */

.form-error {
  color: #c62828;
  font-size: 0.82rem;
  margin-top: 0.25rem;
  padding: 0.6rem 0.85rem;
  background-color: rgba(198, 40, 40, 0.08);
  border-radius: 8px;
  border-left: 3px solid #c62828;
}

body.dark .form-error {
  background-color: rgba(198, 40, 40, 0.18);
  color: #EF9A9A;
  border-left-color: #EF9A9A;
}

/* ============================================
   MODAL FOOTER
   ============================================ */

.so-modal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background-color: var(--sidebar-color);
  flex-shrink: 0;
}

body.dark .so-modal .modal-footer {
  border-top-color: var(--border);
  background-color: var(--sidebar-color);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 600px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .product-picker {
    grid-template-columns: 1fr;
  }

  .product-picker .btn-add {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================
   MODAL — wider to fit items table
   ============================================ */

.so-modal {
  width: min(96vw, 920px);
}

/* ============================================
   AUTOCOMPLETE — client + item search
   ============================================ */

.so-autocomplete-wrap {
  position: relative;
}

.so-ac-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  color: #aaa;
  pointer-events: none;
  z-index: 1;
}

.so-autocomplete-wrap input[type="text"] {
  width: 100%;
  padding: 0.55rem 0.75rem 0.55rem 2.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--sidebar-color);
  color: var(--text-color);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.so-autocomplete-wrap input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}

body.dark .so-autocomplete-wrap input[type="text"] {
  background: #2a2b2c;
  border-color: #3a3b3c;
  color: var(--text-color);
}

body.dark .so-autocomplete-wrap input[type="text"]::placeholder { color: #666; }

/* Dropdown list */
.so-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--sidebar-color);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  z-index: 200;
  max-height: 200px;
  overflow-y: auto;
}

body.dark .so-dropdown {
  background: #1e1f20;
  border-color: #3a3b3c;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.so-drop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.87rem;
  cursor: pointer;
  color: var(--text-color);
  transition: background-color 0.12s ease;
}

.so-drop-item:hover,
.so-drop-item:focus {
  background-color: rgba(29, 78, 216, 0.1);
}

body.dark .so-drop-item:hover { background-color: rgba(29, 78, 216, 0.12); }

.ddi-name { font-weight: 500; }

.ddi-meta {
  font-size: 0.78rem;
  color: #999;
  white-space: nowrap;
}

body.dark .ddi-meta { color: #666; }

/* ============================================
   ITEM PICKER ROW
   ============================================ */

.so-item-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-bottom: 0;
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: var(--sidebar-color);
  padding: 0.4rem 0 0.6rem;
  border-bottom: 1px solid var(--border);
  margin-left: -1.25rem;
  margin-right: -1.25rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.so-item-search-wrap {
  flex: 1 1 180px;
  min-width: 160px;
}

.so-qty-input {
  width: 64px;
  padding: 0.52rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--sidebar-color);
  color: var(--text-color);
  font-family: inherit;
  font-size: 0.9rem;
  text-align: center;
  flex-shrink: 0;
}

.so-qty-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}

body.dark .so-qty-input { background: #2a2b2c; border-color: #3a3b3c; }

.so-picker-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.btn-add-item,
.btn-add-service {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.52rem 0.85rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.btn-add-item {
  background-color: var(--primary-color);
  color: #fff;
}

.btn-add-service {
  background-color: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.btn-add-item:hover   { filter: brightness(0.92); }
.btn-add-service:hover { background-color: rgba(29, 78, 216, 0.1); }

body.dark .btn-add-service { color: var(--primary-color); border-color: var(--primary-color); }

body.dark .so-item-picker {
  background-color: var(--sidebar-color);
  border-bottom-color: var(--border);
}

/* ============================================
   ITEMS TABLE — inline editing
   ============================================ */

.col-item-name  { width: 44%; }
.col-item-qty   { width: 10%; text-align: center; }
.col-item-price { width: 16%; text-align: right; }
.col-item-sub   { width: 16%; text-align: right; font-weight: 600; }
.col-item-del   { width: 14%; text-align: right; }

/* Inline inputs inside table rows */
.item-inp {
  width: 100%;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--sidebar-color);
  color: var(--text-color);
  font-family: inherit;
  font-size: 0.83rem;
  box-sizing: border-box;
}

.item-inp:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.15);
}

body.dark .item-inp { background: #2a2b2c; border-color: #3a3b3c; }

.item-inp-qty,
.item-inp-price { text-align: right; }

.item-name-cell {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
}

.item-name-txt  { font-size: 0.87rem; }
.item-price-txt { font-size: 0.87rem; }

/* Item type badges in the table */
.item-type-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.it-product {
  background-color: rgba(21, 101, 192, 0.1);
  color: #1565C0;
}

.it-service {
  background-color: rgba(230, 81, 0, 0.1);
  color: #E65100;
}

.it-manual {
  background-color: rgba(46, 125, 50, 0.1);
  color: #2E7D32;
}

body.dark .it-product { background-color: rgba(21,101,192,0.2);  color: #90CAF9; }
body.dark .it-service { background-color: rgba(230,81,0,0.2);    color: #FFB74D; }
body.dark .it-manual  { background-color: rgba(46,125,50,0.2);   color: #81C784; }

/* ============================================
   TABLE — ID column
   ============================================ */

.col-order-id { white-space: nowrap; }

.order-id-text {
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  color: #888;
  letter-spacing: 0.3px;
}

body.dark .order-id-text { color: #666; }

/* ============================================
   NOTES TEXTAREA
   ============================================ */

.form-field textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--sidebar-color);
  color: var(--text-color);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 56px;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-field textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}

body.dark .form-field textarea {
  background: #2a2b2c;
  border-color: #3a3b3c;
  color: var(--text-color);
}

body.dark .form-field textarea::placeholder { color: #666; }

.notes-char-counter {
  display: block;
  text-align: right;
  font-size: 0.72rem;
  color: #bbb;
  margin-top: 0.2rem;
  transition: color 0.2s ease;
}
.notes-char-counter.notes-counter-warn { color: #e65c00; }
body.dark .notes-char-counter { color: #555; }
body.dark .notes-char-counter.notes-counter-warn { color: #ffb074; }

/* ============================================
   QUICK-CREATE — field label row
   (label + inline quick-link button)
   ============================================ */

.so-field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

/* Override the gap from form-field so the label row
   already provides the spacing */
.so-field-label-row + .so-autocomplete-wrap {
  margin-top: 0;
}

.so-field-label-row label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-color);
  margin: 0;
}

.btn-quick-link {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--primary-color);
  white-space: nowrap;
  transition: opacity 0.15s ease;
  line-height: 1;
}

.btn-quick-link i { font-size: 0.85rem; }
.btn-quick-link:hover { opacity: 0.7; }

/* ============================================
   QUICK-CREATE — "Novo no estoque" button
   ============================================ */

.btn-new-stock {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.52rem 0.85rem;
  border: 1px dashed var(--primary-color);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  background: transparent;
  color: var(--primary-color);
  transition: background-color 0.15s ease, border-style 0.15s ease;
}

.btn-new-stock:hover {
  background-color: rgba(29, 78, 216, 0.1);
  border-style: solid;
}

body.dark .btn-new-stock {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* ============================================
   QUICK-CREATE — Mini-modal overlay
   (stacks above the main SO modal, z=1100)
   ============================================ */

.so-mini-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}

.so-mini-overlay.hidden {
  display: none;
}

/* ============================================
   QUICK-CREATE — Mini-modal container
   ============================================ */

.so-mini-modal {
  width: min(100%, 480px);
  background: var(--sidebar-color);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  animation: soSlideIn 0.2s ease-out;
}

body.dark .so-mini-modal {
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
}

/* Reuse the header style already defined for .so-modal */
.so-mini-modal .so-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.so-mini-modal .so-modal-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-color);
  margin: 0;
}

.so-mini-modal .modal-body {
  padding: 1.1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.so-mini-modal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background-color: var(--sidebar-color);
  flex-shrink: 0;
}

/* ============================================
   QUICK-CREATE — Toggle (controlsStock)
   ============================================ */

.so-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-color);
  user-select: none;
}

.so-toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-color);
  cursor: pointer;
  flex-shrink: 0;
}

/* ============================================
   QUICK-CREATE — Mini-modal subtitle
   ============================================ */

.so-mini-subtitle {
  font-size: 0.72rem;
  color: #999;
  margin: 0.1rem 0 0;
  font-weight: 400;
  line-height: 1.2;
}

body.dark .so-mini-subtitle {
  color: #666;
}

/* Keep the header top-area flex-column for title + subtitle */
.so-mini-modal .so-modal-header > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ============================================
   QUICK-CREATE — Auto-select flash feedback
   Green border flash confirms client/item was
   auto-selected after quick-create
   ============================================ */

@keyframes soFlashSelected {
  0%   {
    border-color: #4caf50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.28);
    background-color: rgba(76, 175, 80, 0.04);
  }
  60%  { border-color: #4caf50; box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1); }
  100% { border-color: var(--border); box-shadow: none; background-color: transparent; }
}

.so-autocomplete-wrap.flash-selected input[type="text"] {
  animation: soFlashSelected 0.9s ease-out forwards;
}

body.dark .so-autocomplete-wrap.flash-selected input[type="text"] {
  animation: soFlashSelected 0.9s ease-out forwards;
}

/* ============================================
   QUICK-CREATE — Button loading state
   ============================================ */

button[disabled].admin-button {
  opacity: 0.65;
  cursor: not-allowed;
}



.col-order-id, .col-quote-id { white-space: nowrap; }

.col-name {
  font-weight: 500;
}

/* ============================================
   INLINE STATUS SELECT
   Badge becomes a select on click
   ============================================ */

.status-badge {
  cursor: pointer;
  user-select: none;
  transition: filter 0.15s ease, box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.status-badge:hover {
  filter: brightness(0.93);
  box-shadow: 0 0 0 1.5px currentColor;
}

.status-badge-chevron {
  font-size: 0.75rem;
  opacity: 0.6;
  transition: opacity 0.15s ease, transform 0.15s ease;
  line-height: 1;
  flex-shrink: 0;
}

.status-badge:hover .status-badge-chevron {
  opacity: 1;
  transform: translateY(1px);
}

/* ============================================
   STATUS CUSTOM DROPDOWN
   ============================================ */

.status-drop {
  position: absolute;
  z-index: 9001;
  background: var(--sidebar-color, #fff);
  border: 1px solid #e4e4e4;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.13), 0 2px 6px rgba(0, 0, 0, 0.07);
  padding: 0.3rem;
  min-width: 165px;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  animation: statusDropIn 0.13s ease-out;
}

body.dark .status-drop {
  border-color: #2a2b2c;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

@keyframes statusDropIn {
  from { opacity: 0; transform: translateY(-5px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.status-drop-item {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  border-radius: 7px;
  text-align: left;
  display: flex;
  align-items: center;
  transition: background-color 0.1s ease;
  width: 100%;
}

.status-drop-item:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

body.dark .status-drop-item:hover {
  background-color: rgba(255, 255, 255, 0.07);
}

.status-drop-item--active {
  background-color: rgba(0, 0, 0, 0.04);
}

body.dark .status-drop-item--active {
  background-color: rgba(255, 255, 255, 0.06);
}

.status-inline-select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  outline: none;
  background: transparent;
  color: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 0.22rem 0.6rem;
  border-radius: 6px;
  min-width: 0;
  width: auto;
}

.status-inline-select option {
  background: var(--sidebar-color);
  color: var(--text-color);
  font-weight: 500;
}

/* ============================================
   APP TOAST NOTIFICATION (shared)
   ============================================ */

.app-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.1rem;
  background: #1E1E1E;
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  font-size: 0.88rem;
  font-weight: 500;
  animation: toastSlideUp 0.22s ease-out;
  max-width: 360px;
}

.app-toast.app-toast-error {
  background: #3B1C1C;
  border-left: 3px solid #EF5350;
}

.app-toast-icon {
  font-size: 1.15rem;
  color: #81C784;
  flex-shrink: 0;
}

.app-toast-error-icon {
  color: #EF5350;
}

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

/* ============================================
   CLOSE ORDER BUTTON
   ============================================ */

.close-order-btn {
  color: #2E7D32;
}

.close-order-btn:hover {
  background-color: rgba(46, 125, 50, 0.12);
}

body.dark .close-order-btn {
  color: #81C784;
}

body.dark .close-order-btn:hover {
  background-color: rgba(129, 199, 132, 0.12);
}

/* ============================================
   CLOSE ORDER MODAL
   Wider than mini-modal to fit items tables
   ============================================ */

.so-close-modal {
  width: min(96vw, 780px);
  background: var(--sidebar-color);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 94vh;
  animation: soSlideIn 0.22s ease-out;
}

body.dark .so-close-modal {
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.so-close-modal .so-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: linear-gradient(
    135deg,
    rgba(46, 125, 50, 0.07) 0%,
    rgba(46, 125, 50, 0.02) 100%
  );
}

body.dark .so-close-modal .so-modal-header {
  background: linear-gradient(
    135deg,
    rgba(46, 125, 50, 0.1) 0%,
    rgba(46, 125, 50, 0.03) 100%
  );
}

.so-close-modal .so-modal-header > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.so-close-modal .modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow-y: auto;
  flex: 1;
}

.so-close-modal .modal-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background-color: var(--sidebar-color);
  flex-shrink: 0;
}


/*  Title column in table  */
.col-order-title,
.col-quote-title {
  max-width: 220px;
}

.order-title-text,
.quote-title-text {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  font-weight: 500;
  color: var(--text-color, #1e293b);
}

.text-muted { color: var(--text-muted, #64748b); }