/* ==========================================================================
   Spare Part Service — layout & components (colours in themes.css)
   ========================================================================== */

/* Bootstrap overrides */
body.tally-theme {
  font-family: var(--tally-font);
  font-size: 0.9rem;
  color: var(--tally-text);
  background: var(--tally-content);
  margin: 0;
}

.tally-theme .btn {
  border-radius: var(--tally-radius);
  font-weight: 600;
  border-width: 1px;
}

.tally-theme .btn-primary {
  background-color: var(--tally-primary);
  border-color: var(--tally-border);
  color: #fff;
}
.tally-theme .btn-primary:hover,
.tally-theme .btn-primary:focus {
  background-color: var(--tally-primary-hover);
  border-color: var(--tally-border);
  color: #fff;
}

.tally-theme .btn-secondary,
.tally-theme .sps-btn-cancel {
  background-color: #fff;
  border-color: var(--tally-border);
  color: var(--tally-header, #1a1a1a);
}
.tally-theme .btn-secondary:hover,
.tally-theme .btn-secondary:focus,
.tally-theme .sps-btn-cancel:hover,
.tally-theme .sps-btn-cancel:focus {
  background-color: var(--tally-menu-green);
  border-color: var(--tally-border);
  color: var(--tally-header, #1a1a1a);
}

.sps-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.25rem;
}
.sps-form-actions.flex-column {
  align-items: stretch;
}
.sps-form-actions.flex-column .btn {
  width: 100%;
  justify-content: center;
}
.sps-form-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.sps-form-actions form {
  display: contents;
}

.tally-theme .btn-outline-primary {
  color: var(--tally-primary);
  border-color: var(--tally-primary);
  background: #fff;
}
.tally-theme .btn-outline-primary:hover {
  background: var(--tally-menu-green);
  color: var(--tally-primary);
}

.tally-theme .btn-outline-secondary,
.tally-theme .btn-outline-danger {
  border-radius: var(--tally-radius);
}

.tally-theme .btn-outline-danger {
  color: var(--tally-danger);
  border-color: var(--tally-danger);
}

.tally-theme .form-control,
.tally-theme .form-select {
  border-radius: var(--tally-radius);
  border: 1px solid var(--tally-border-light);
  background-color: #fff;
}
.tally-theme .form-control:focus,
.tally-theme .form-select:focus {
  border-color: var(--tally-primary);
  box-shadow: 0 0 0 0.15rem rgba(0, 66, 54, 0.2);
}

.tally-theme .form-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--tally-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.2rem;
}

/* ----- App shell ----- */
.app-wrapper {
  min-height: 100vh;
  border: 1px solid var(--tally-border);
}

/* Top menu strip (Tally-style) */
.app-menubar {
  background: var(--tally-menu-green);
  border-bottom: 1px solid var(--tally-border);
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--tally-header);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}
.app-menubar-title {
  font-weight: 700;
  margin-right: 0.25rem;
}
.shortcut-hint {
  white-space: nowrap;
}

/* Shortcut badge beside menu labels and buttons */
.sps-shortcut-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.05rem;
  margin-left: 0.35rem;
  vertical-align: middle;
  flex-shrink: 0;
  line-height: 1;
}
.sps-shortcut-badge kbd {
  background: #1a1a1a;
  color: #fff;
  border: 1px solid var(--tally-border);
  padding: 0.05rem 0.3rem;
  font-size: 0.62rem;
  font-weight: 700;
  border-radius: 2px;
  min-width: 1.1em;
  text-align: center;
  box-shadow: 0 1px 0 var(--tally-border-light);
}
.sps-shortcut-badge .sps-kbd-mod {
  min-width: auto;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}
.sps-kbd-plus {
  color: var(--tally-text-muted, #666);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0 0.05rem;
}
.app-sidebar .nav-link {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.35rem;
}
.app-sidebar-label-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
  gap: 0.2rem;
  overflow: visible;
}
.app-sidebar-label-wrap .app-sidebar-text {
  display: block;
  width: 100%;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-sidebar .nav-link .sps-shortcut-badge {
  margin-left: 0;
  opacity: 0.95;
  flex-shrink: 0;
  max-width: 100%;
  flex-wrap: wrap;
}
.app-sidebar .sps-shortcut-badge--menu kbd {
  padding: 0.04rem 0.22rem;
  font-size: 0.56rem;
  min-width: 0.85em;
}
.app-sidebar .sps-shortcut-badge--menu .sps-kbd-mod {
  padding-left: 0.18rem;
  padding-right: 0.18rem;
}
.app-sidebar .sps-shortcut-badge--menu .sps-kbd-plus {
  font-size: 0.5rem;
}
.app-sidebar-brand-link {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-width: 0;
  flex: 1 1 auto;
  overflow: visible;
  white-space: normal;
}
.app-sidebar-brand-text {
  line-height: 1.2;
  max-width: 100%;
}
.app-sidebar-brand-link .sps-shortcut-badge {
  margin-left: 0;
  margin-top: 0;
}
html.app-sidebar-unpinned .app-sidebar:not(:hover) .app-sidebar-label-wrap .sps-shortcut-badge {
  display: none;
}
html.app-sidebar-unpinned .app-sidebar:hover .app-sidebar-label-wrap .sps-shortcut-badge,
html.app-sidebar-unpinned .app-sidebar .app-sidebar-submenu .sps-shortcut-badge {
  display: inline-flex;
}
.btn .sps-shortcut-badge {
  margin-left: 0.5rem;
}
.btn-link .sps-shortcut-badge kbd,
.btn-secondary .sps-shortcut-badge kbd,
.sps-btn-cancel .sps-shortcut-badge kbd {
  background: #444;
}
.tally-theme kbd,
.tally-theme .shortcut-hint kbd {
  background: #1a1a1a;
  color: #fff;
  border: 1px solid var(--tally-border);
  padding: 0.1rem 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 2px;
  min-width: 1.4em;
  display: inline-block;
  text-align: center;
  box-shadow: 0 1px 0 var(--tally-border-light);
}
/* Keyboard shortcuts help modal */
#shortcutHelpModal .modal-body {
  line-height: 1.55;
}
#shortcutHelpModal .modal-body > p {
  line-height: 1.65;
}
#shortcutHelpModal .modal-body kbd {
  display: inline-block;
  vertical-align: baseline;
  line-height: 1.35;
  margin: 0 0.08em;
  position: relative;
  top: -0.02em;
}
#shortcutHelpModal .shortcut-help-notes li {
  margin-bottom: 0.85rem;
  line-height: 1.75;
  padding-bottom: 0.1rem;
}
#shortcutHelpModal .shortcut-help-notes li:last-child {
  margin-bottom: 0;
}
#shortcutHelpModal .sps-shortcut-badge {
  display: inline-flex;
  vertical-align: middle;
  margin: 0.15em 0;
  line-height: 1.4;
}
#shortcutHelpModal .table td {
  vertical-align: middle;
  line-height: 1.5;
  padding: 0.5rem 0.55rem;
}
#shortcutHelpModal .table td .sps-shortcut-badge {
  margin: 0.2em 0;
}

.btn-shortcut-help {
  background: var(--tally-header);
  color: #fff;
  border: 1px solid var(--tally-border);
  border-radius: 0;
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
}
.btn-shortcut-help:hover {
  background: #fff;
  color: var(--tally-header);
}
.btn-help-demo {
  border-color: var(--tally-menu-green);
}
.btn-help-demo:hover {
  background: var(--tally-menu-green);
  color: #fff;
}

/* Help Demo (Driver.js) — tally theme */
.sps-help-demo-popover.driver-popover {
  background: #fff;
  color: var(--tally-text, #1a1a1a);
  border: 1px solid var(--tally-border);
  border-radius: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  max-width: min(22rem, 92vw);
  font-family: inherit;
}
.sps-help-demo-popover .driver-popover-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--tally-header);
}
.sps-help-demo-popover .driver-popover-description {
  font-size: 0.82rem;
  line-height: 1.45;
}
.sps-help-demo-popover .driver-popover-progress-text {
  font-size: 0.72rem;
  color: #666;
}
.sps-help-demo-popover button {
  border-radius: 0;
  font-size: 0.75rem;
  text-shadow: none;
}
.sps-help-demo-popover .driver-popover-next-btn,
.sps-help-demo-popover .driver-popover-done-btn {
  background: var(--tally-header);
  color: #fff;
  border: 1px solid var(--tally-header);
}
.sps-help-demo-popover .driver-popover-prev-btn,
.sps-help-demo-popover .driver-popover-close-btn {
  background: #f4f4f4;
  color: var(--tally-header);
  border: 1px solid var(--tally-border);
}
.driver-active-element {
  outline: 2px solid var(--tally-menu-green) !important;
}
html.sps-help-demo-active .driver-overlay {
  pointer-events: none;
}
.shortcut-toast {
  position: fixed;
  bottom: 3rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--tally-header);
  color: #fff;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--tally-menu-green);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.shortcut-toast.show {
  opacity: 1;
}
.text-muted-me {
  color: var(--tally-text-muted);
  font-weight: 500;
}

.app-body-row {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width-expanded);
  min-height: calc(100vh - 88px);
  background: var(--tally-sidebar);
  border-right: 1px solid var(--tally-border);
  flex-shrink: 0;
  transition: width 0.2s ease;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  z-index: 100;
}
.app-sidebar-nav {
  overflow: visible;
}

.app-sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  background: var(--tally-header);
  color: var(--tally-header-text);
  padding: 0.5rem 0.5rem 0.5rem 0.85rem;
  border-bottom: 1px solid var(--tally-border);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  min-height: 2.75rem;
}
.app-sidebar-brand-link {
  color: inherit;
  text-decoration: none;
}
.app-sidebar-brand-short {
  display: none;
  font-size: 1rem;
  letter-spacing: 0.08em;
}

.app-sidebar-pin-btn {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.9);
  padding: 0.2rem 0.35rem;
  line-height: 1;
  border: none;
  background: transparent;
  border-radius: 0;
}
.app-sidebar-pin-btn:hover,
.app-sidebar-pin-btn:focus {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}
.app-sidebar-pin-icon-unpinned {
  display: none;
}
html.app-sidebar-unpinned .app-sidebar-pin-icon-pinned {
  display: none;
}
html.app-sidebar-unpinned .app-sidebar-pin-icon-unpinned {
  display: inline-block;
}

.app-sidebar .nav-link {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  color: rgba(255, 255, 255, 0.92);
  border-radius: 0;
  padding: 0.5rem 0.65rem 0.5rem 0.75rem;
  font-size: 0.85rem;
  border-left: 3px solid transparent;
  margin: 0;
  overflow: visible;
}
.app-sidebar .app-sidebar-icon {
  flex-shrink: 0;
  width: 1.15rem;
  text-align: center;
}
.app-sidebar .nav-link:hover {
  background: var(--tally-sidebar-hover);
  color: #fff;
}
.app-sidebar .nav-link.active,
.app-sidebar .nav-item.show > .nav-link {
  background: rgba(0, 0, 0, 0.2);
  border-left-color: var(--tally-menu-green);
  color: #fff;
}
.app-sidebar .nav .nav .nav-link {
  padding-left: 1.35rem;
  padding-right: 0.5rem;
  font-size: 0.8rem;
}
.app-sidebar-flyout-title {
  display: none;
}

/* Sidebar — unpinned (icon rail) */
html.app-sidebar-unpinned .app-sidebar {
  width: var(--sidebar-width-collapsed);
  overflow: visible;
  z-index: 1100;
}
html.app-sidebar-unpinned .app-sidebar-brand {
  flex-direction: column;
  align-items: center;
  padding: 0.45rem 0.25rem;
  gap: 0.25rem;
}
html.app-sidebar-unpinned .app-sidebar-brand-text {
  display: none;
}
html.app-sidebar-unpinned .app-sidebar-brand-short {
  display: block;
}
html.app-sidebar-unpinned .app-sidebar-brand-link {
  text-align: center;
  flex: 0 0 auto;
}
html.app-sidebar-unpinned .app-sidebar > .app-sidebar-nav > .nav-item > .nav-link .app-sidebar-text {
  display: none !important;
}
html.app-sidebar-unpinned .app-sidebar-submenu .app-sidebar-text {
  display: inline !important;
}
html.app-sidebar-unpinned .app-sidebar .nav-link {
  justify-content: center;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}
html.app-sidebar-unpinned .app-sidebar .nav .nav .nav-link {
  justify-content: flex-start;
  padding-left: 0.85rem;
  text-align: left;
}
html.app-sidebar-unpinned .app-sidebar-flyout-title {
  display: block;
  background: var(--tally-header);
  color: var(--tally-header-text);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--tally-border);
}
html.app-sidebar-unpinned .app-sidebar .nav-item.has-children {
  position: relative;
}
html.app-sidebar-unpinned .app-sidebar .nav-item.has-children > .app-sidebar-submenu {
  display: none !important;
  position: absolute;
  left: 100%;
  top: 0;
  z-index: 1100;
  min-width: 11.5rem;
  background: var(--tally-sidebar);
  border: 1px solid var(--tally-border);
  box-shadow: 4px 2px 14px rgba(0, 0, 0, 0.28);
  height: auto !important;
  overflow: visible;
}
html.app-sidebar-unpinned .app-sidebar .nav-item.has-children:hover > .app-sidebar-submenu,
html.app-sidebar-unpinned .app-sidebar .nav-item.has-children:focus-within > .app-sidebar-submenu,
html.app-sidebar-unpinned .app-sidebar .nav-item.has-children.flyout-open > .app-sidebar-submenu {
  display: block !important;
}
html.app-sidebar-unpinned .app-sidebar .nav-item.has-children.flyout-open > .app-sidebar-parent {
  background: var(--tally-sidebar-hover);
  border-left-color: var(--tally-menu-green);
}
html.app-sidebar-unpinned .app-sidebar .nav-item.has-children > .app-sidebar-submenu.collapsing {
  display: none !important;
  transition: none;
}
html.app-sidebar-unpinned .app-sidebar .nav-item.has-children > .app-sidebar-submenu.show {
  visibility: visible;
}

/* Main column */
.app-main {
  background: var(--tally-content);
  min-width: 0;
}

.app-topbar {
  background: var(--tally-header) !important;
  color: var(--tally-header-text);
  border-bottom: 2px solid var(--tally-border) !important;
  padding: 0.5rem 1rem !important;
}
.app-topbar h1 {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.app-topbar .badge {
  background: var(--tally-menu-green) !important;
  color: var(--tally-header) !important;
  border: 1px solid var(--tally-border-light);
  border-radius: 0;
  font-weight: 600;
}
.app-topbar .text-muted {
  color: rgba(255, 255, 255, 0.85) !important;
}
.app-topbar .btn-logout {
  background: var(--tally-menu-green);
  color: var(--tally-header);
  border: 1px solid var(--tally-border);
  font-weight: 600;
  font-size: 0.8rem;
}
.app-topbar .btn-logout:hover {
  background: #fff;
  color: var(--tally-header);
}

.app-content {
  padding: 1rem !important;
  background: var(--tally-content);
}

/* Footer action bar + status */
.app-footer-bar {
  background: var(--tally-menu-green);
  border-top: 1px solid var(--tally-border);
  padding: 0.35rem 1rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--tally-header);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
}
.app-statusbar {
  background: #e8e4d9;
  border-top: 1px solid var(--tally-border-light);
  padding: 0.2rem 1rem;
  font-size: 0.7rem;
  color: var(--tally-text-muted);
}

/* Cards → Tally panels */
.tally-theme .card {
  border-radius: var(--tally-radius);
  border: 1px solid var(--tally-border);
  box-shadow: none;
  background: var(--tally-panel);
}
.tally-theme .card.border-0 {
  border: 1px solid var(--tally-border) !important;
}
.tally-theme .card-header {
  background: var(--tally-panel-teal) !important;
  border-bottom: 1px solid var(--tally-border);
  color: var(--tally-header);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.5rem 0.85rem;
  border-radius: 0;
}
.tally-theme .card-footer {
  background: var(--tally-menu-green) !important;
  border-top: 1px solid var(--tally-border);
  border-radius: 0;
}

.tally-panel-peach .card-header {
  background: var(--tally-panel-alt) !important;
}

/* Tables */
.tally-theme .table {
  margin-bottom: 0;
  color: var(--tally-text);
}
.tally-theme .table thead th,
.tally-theme .table-light th {
  background: var(--tally-panel-teal) !important;
  color: var(--tally-header);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-color: var(--tally-border-light) !important;
  border-bottom: 2px solid var(--tally-border) !important;
}
.tally-theme .table td,
.tally-theme .table th {
  border-color: var(--tally-border-light);
  vertical-align: middle;
}
.tally-theme .table-hover tbody tr:hover {
  background-color: var(--tally-menu-green) !important;
}

.card-table td {
  vertical-align: middle;
}

/* Table row actions — Edit / Delete side by side */
.td-actions {
  width: 1%;
  white-space: nowrap;
  vertical-align: middle !important;
}
.table-actions {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  flex-wrap: nowrap;
}
.table-actions form {
  display: inline-flex;
  margin: 0;
  padding: 0;
  vertical-align: middle;
}
.table-actions .btn {
  white-space: nowrap;
  min-width: 4.25rem;
}
.table-actions .btn-sm {
  padding: 0.2rem 0.55rem;
  font-size: 0.8rem;
  line-height: 1.35;
}

/* Badges */
.tally-theme .badge {
  border-radius: 0;
  font-weight: 600;
}
.tally-theme .badge.text-bg-info,
.tally-theme .badge.text-bg-secondary {
  background-color: var(--tally-accent) !important;
}
.tally-theme .badge.text-bg-success {
  background-color: var(--tally-primary) !important;
}
.tally-theme .badge.text-bg-light {
  background-color: var(--tally-menu-green) !important;
  color: var(--tally-header) !important;
  border: 1px solid var(--tally-border-light);
}

/* Alerts */
.tally-theme .alert {
  border-radius: 0;
  border-width: 1px;
}
.tally-theme .alert-success {
  background: var(--tally-success-bg);
  border-color: var(--tally-primary);
  color: var(--tally-text);
}
.tally-theme .alert-danger {
  background: #f8d7da;
  border-color: var(--tally-danger);
  color: var(--tally-danger);
}
.tally-theme .alert-warning {
  background: var(--tally-warning-bg);
  border-color: #856404;
}
.tally-theme .alert-info {
  background: var(--tally-panel-teal);
  border-color: var(--tally-border);
  color: var(--tally-text);
}

/* List group (audit roles etc.) */
.tally-theme .list-group-item {
  border-color: var(--tally-border-light);
  border-radius: 0;
}
.tally-theme .list-group-item.active {
  background: var(--tally-header);
  border-color: var(--tally-border);
}

/* Modals */
.tally-theme .modal-content {
  border-radius: 0;
  border: 2px solid var(--tally-border);
}
.tally-theme .modal-header {
  background: var(--tally-header);
  color: #fff;
  border-radius: 0;
}
.tally-theme .modal-header .btn-close {
  filter: invert(1);
}
.tally-theme .nav-tabs .nav-link {
  border-radius: 0;
  color: var(--tally-primary);
  font-weight: 600;
}
.tally-theme .nav-tabs .nav-link.active {
  background: var(--tally-panel-teal);
  border-color: var(--tally-border);
  color: var(--tally-header);
}

/* Pagination */
.tally-theme .pagination .page-link {
  border-radius: 0;
  color: var(--tally-primary);
  border-color: var(--tally-border-light);
}
.tally-theme .pagination .page-item.active .page-link {
  background: var(--tally-header);
  border-color: var(--tally-border);
  color: #fff;
}

/* Login */
body.login-page.tally-theme {
  min-height: 100vh;
  margin: 0;
  border: none;
  background-color: var(--tally-header);
  background-image: url('../images/login-bg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  position: relative;
}

body.login-page.tally-theme::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

body.login-page.tally-theme > .tally-login-box {
  position: relative;
  z-index: 1;
}

.tally-login-box {
  width: 100%;
  max-width: 560px;
  min-width: min(100%, 320px);
  border: 2px solid var(--tally-border);
  background: #fff;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.tally-login-header {
  background: var(--tally-header);
  color: #fff;
  padding: 1.15rem 1.5rem;
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: 0.02em;
  text-align: center;
  border-bottom: 1px solid var(--tally-border);
}

.tally-login-body {
  padding: 2rem 2.25rem 2.25rem;
  background: var(--tally-panel-teal);
}

.tally-login-tagline {
  font-size: 1.05rem !important;
  margin-bottom: 1.5rem !important;
}

.tally-login-body .form-label {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tally-header);
  margin-bottom: 0.45rem;
}

.tally-login-body .form-control {
  padding: 0.7rem 0.9rem;
  font-size: 1.1rem;
  min-height: 3rem;
}

.tally-login-body .mb-3 {
  margin-bottom: 1.35rem !important;
}

.tally-login-body .btn-primary {
  padding: 0.85rem 1rem;
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.tally-login-body .alert {
  font-size: 0.95rem;
}

.login-captcha-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.login-captcha-image {
  border: 1px solid var(--tally-border);
  border-radius: 0.25rem;
  background: #fff;
}

.login-captcha-refresh {
  min-width: 3rem;
  min-height: 3rem;
  font-size: 1.35rem;
  line-height: 1;
  padding: 0;
  color: var(--tally-header);
  border-color: var(--tally-border);
}

.login-captcha-refresh:hover {
  background: var(--tally-header);
  border-color: var(--tally-header);
  color: #fff;
}

.tally-login-footer {
  background: var(--tally-menu-green);
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
  color: var(--tally-header);
  border-top: 1px solid var(--tally-border);
  text-align: center;
}

@media (min-width: 768px) {
  .tally-login-box {
    max-width: 600px;
  }

  .tally-login-header {
    font-size: 1.5rem;
    padding: 1.25rem 1.75rem;
  }

  .tally-login-body {
    padding: 2.25rem 2.5rem 2.5rem;
  }
}

/* Audit JSON viewer */
.audit-json-view {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--tally-border-light);
  padding: 0.75rem;
}
.audit-json-view .json-key { color: #004236; font-weight: 600; }
.audit-json-view .json-string { color: #055160; }
.audit-json-view .json-number { color: #664d03; }
.audit-json-view .json-boolean { color: #6f42c1; }
.audit-json-view .json-null { color: #6c757d; }

/* Dashboard stat cards */
.tally-stat-card {
  border: 1px solid var(--tally-border);
  background: #fff;
  padding: 1rem;
}
.tally-stat-card .stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--tally-text-muted);
}
.tally-stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--tally-header);
}

/* Scrap collection — grade IN / OUT / on-hand summary */
.scrap-grade-stock-card .scrap-flow-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-top: 0.35rem;
  line-height: 1.35;
}
.scrap-grade-stock-card .scrap-flow-tag {
  flex: 0 0 3.6rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tally-text-muted);
}
.scrap-grade-stock-card .scrap-flow-in .scrap-flow-tag { color: #0a7a55; }
.scrap-grade-stock-card .scrap-flow-out .scrap-flow-tag { color: #a65d00; }
.scrap-grade-stock-card .scrap-flow-onhand {
  margin-top: 0.55rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--tally-border);
}
.scrap-grade-stock-card .scrap-flow-onhand .scrap-flow-tag {
  color: var(--tally-header);
  flex-basis: 4.2rem;
}
.scrap-grade-stock-card .scrap-flow-detail {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--tally-header);
}
.scrap-grade-stock-card .scrap-onhand-value {
  font-size: 1.15rem;
  line-height: 1.2;
}
.scrap-grade-stock-card .scrap-onhand-amount {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--tally-text-muted);
}

/* Scrap collection — amount reference callout */
.tally-theme .scrap-amount-reference {
  margin-top: 0.5rem;
  padding: 0;
  background: linear-gradient(135deg, var(--tally-panel-teal) 0%, #fff 55%);
  border: 2px solid var(--tally-border);
  border-radius: var(--tally-radius, 0);
  box-shadow: 0 2px 8px rgba(0, 66, 54, 0.08);
  overflow: hidden;
  font-size: 0.875rem;
}
.tally-theme .scrap-amount-reference-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.85rem;
  background: var(--tally-header);
  color: #fff;
}
.tally-theme .scrap-amount-reference-badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
}
.tally-theme .scrap-amount-reference-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
}
.tally-theme .scrap-amount-reference-formula {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.45rem;
  padding: 0.75rem 0.85rem 0.85rem;
  line-height: 1.35;
}
.tally-theme .scrap-amount-ref-chip {
  flex: 1 1 5.5rem;
  min-width: 5.5rem;
  padding: 0.45rem 0.55rem;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--tally-border-light);
  border-radius: var(--tally-radius, 0);
}
.tally-theme .scrap-amount-ref-chip strong {
  color: var(--tally-header);
  font-size: 0.95rem;
}
.tally-theme .scrap-amount-ref-result {
  flex: 1.35 1 7rem;
  background: #fff;
  border: 2px solid var(--tally-primary);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}
.tally-theme .scrap-amount-ref-result strong {
  font-size: 1.1rem;
  color: var(--tally-primary);
}
.tally-theme .scrap-amount-ref-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tally-text-muted);
  margin-bottom: 0.2rem;
}
.tally-theme .scrap-amount-ref-value {
  display: block;
  white-space: nowrap;
}
.tally-theme .scrap-amount-ref-op {
  display: flex;
  align-items: center;
  align-self: center;
  color: var(--tally-primary);
  font-weight: 800;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0 0.1rem;
}
.tally-theme .scrap-amount-reference-adjust {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin: 0;
  padding: 0.65rem 0.85rem;
  border-top: 1px solid var(--tally-border-light);
  font-size: 0.8125rem;
}
.tally-theme .scrap-amount-adjust-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: inherit;
  opacity: 0.85;
  margin-bottom: 0.1rem;
}
.tally-theme .scrap-amount-adjust-value {
  font-size: 0.95rem;
}
.tally-theme .scrap-amount-adjust-sep {
  width: 1px;
  align-self: stretch;
  min-height: 2rem;
  background: currentColor;
  opacity: 0.25;
}
.tally-theme .scrap-amount-adjust-highlight strong {
  font-size: 0.92rem;
}
.tally-theme .scrap-amount-ref-match {
  background: var(--tally-success-bg);
  color: var(--tally-text);
}
.tally-theme .scrap-amount-ref-match .scrap-amount-adjust-match {
  font-weight: 600;
}
.tally-theme .scrap-amount-ref-discount {
  background: var(--tally-success-bg);
  color: #155724;
}
.tally-theme .scrap-amount-ref-discount .scrap-amount-adjust-highlight strong {
  color: #146c43;
}
.tally-theme .scrap-amount-ref-surcharge {
  background: var(--tally-warning-bg);
  color: #856404;
}
.tally-theme .scrap-amount-ref-surcharge .scrap-amount-adjust-highlight strong {
  color: #b45309;
}

/* Feature backlog — status chart & colors */
.fb-status-chart-wrap,
.fb-summary-chart-wrap {
  position: relative;
  max-width: 100%;
  height: 150px;
}
.fb-summary-legend {
  max-height: 3.25rem;
  overflow-y: auto;
}
.sps-chart-type-select-wrap .sps-chart-type-select {
  width: auto;
  min-width: 9.5rem;
  max-width: 11rem;
}
.fb-status-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--tally-text-muted);
  font-weight: 600;
}
.fb-status-swatch {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}
.fb-status-swatch-open { background-color: #2563eb; }
.fb-status-swatch-in-progress { background-color: #06b6d4; }
.fb-status-swatch-verification { background-color: #8b5cf6; }
.fb-status-swatch-hold { background-color: #eab308; }
.fb-status-swatch-parked { background-color: #f97316; }
.fb-status-swatch-closed { background-color: #22c55e; }

.fb-status-badge {
  font-weight: 600;
  border: none;
}
.fb-status-open { background-color: #2563eb !important; color: #fff !important; }
.fb-status-in-progress { background-color: #06b6d4 !important; color: #fff !important; }
.fb-status-verification { background-color: #8b5cf6 !important; color: #fff !important; }
.fb-status-hold { background-color: #eab308 !important; color: #1a2e2a !important; }
.fb-status-parked { background-color: #f97316 !important; color: #fff !important; }
.fb-status-closed { background-color: #22c55e !important; color: #fff !important; }

.fb-scroll-anchor {
  display: block;
  height: 0;
  overflow: hidden;
  scroll-margin-top: 5rem;
}
.fb-list-filtered {
  outline: 2px solid var(--tally-primary);
  outline-offset: 0;
}

/* Service request status chart & badges */
.tally-theme .badge.svc-status-badge,
.badge.svc-status-badge {
  font-weight: 600;
  border: none;
}
.svc-status-swatch-received { background-color: #2563eb; }
.svc-status-swatch-in-service { background-color: #06b6d4; }
.svc-status-swatch-ready { background-color: #14b8a6; }
.svc-status-swatch-notified { background-color: #8b5cf6; }
.svc-status-swatch-paid { background-color: #eab308; }
.svc-status-swatch-closed { background-color: #22c55e; }
.svc-status-swatch-cancelled { background-color: #94a3b8; }
.tally-theme .badge.svc-status-received,
.badge.svc-status-received {
  background-color: #2563eb !important;
  color: #fff !important;
  --bs-badge-color: #fff;
}
.tally-theme .badge.svc-status-in-service,
.badge.svc-status-in-service {
  background-color: #06b6d4 !important;
  color: #fff !important;
  --bs-badge-color: #fff;
}
.tally-theme .badge.svc-status-ready,
.badge.svc-status-ready {
  background-color: #14b8a6 !important;
  color: #fff !important;
  --bs-badge-color: #fff;
}
.tally-theme .badge.svc-status-notified,
.badge.svc-status-notified {
  background-color: #8b5cf6 !important;
  color: #fff !important;
  --bs-badge-color: #fff;
}
.tally-theme .badge.svc-status-paid,
.badge.svc-status-paid {
  background-color: #eab308 !important;
  color: #1a2e2a !important;
  --bs-badge-color: #1a2e2a;
}
.tally-theme .badge.svc-status-closed,
.badge.svc-status-closed {
  background-color: #22c55e !important;
  color: #fff !important;
  --bs-badge-color: #fff;
}
.tally-theme .badge.svc-status-cancelled,
.badge.svc-status-cancelled {
  background-color: #94a3b8 !important;
  color: #fff !important;
  --bs-badge-color: #fff;
}

/* Mandatory daily pricing modal */
body.daily-pricing-blocked .modal-backdrop {
  z-index: 1990;
  background-color: rgba(0, 66, 54, 0.65);
  opacity: 1;
}
#dailyPricingModal {
  z-index: 2000;
}
#dailyPricingModal .daily-pricing-modal {
  border: 2px solid var(--tally-border);
  border-radius: 0;
  overflow: hidden;
}
#dailyPricingModal .daily-pricing-modal .modal-header {
  background: var(--tally-header) !important;
  color: #fff !important;
  border-bottom: 2px solid var(--tally-border);
  padding: 0.85rem 1.15rem;
}
#dailyPricingModal .daily-pricing-modal .modal-header .modal-title {
  color: #fff !important;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
}
#dailyPricingModal .daily-pricing-modal .modal-header .bi {
  color: var(--tally-menu-green);
  font-size: 1.25rem;
}
#dailyPricingModal .daily-pricing-modal .modal-body {
  background: #fff;
  padding: 1.15rem 1.25rem;
  color: var(--tally-text);
}
#dailyPricingModal .daily-pricing-lead {
  color: var(--tally-text-muted);
  font-size: 0.875rem;
  margin-bottom: 0;
  line-height: 1.45;
}
#dailyPricingModal .daily-pricing-lead strong {
  color: var(--tally-primary);
}
#dailyPricingModal .daily-pricing-modal .form-label {
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tally-text-muted);
  margin-bottom: 0.35rem;
}
#dailyPricingModal .daily-pricing-modal .form-control {
  border-color: var(--tally-border-light);
  background: #fff;
}
#dailyPricingModal .daily-pricing-modal .form-control:disabled {
  background: var(--tally-content);
  color: var(--tally-text);
  opacity: 1;
}
#dailyPricingModal .daily-pricing-modal-footer {
  background: var(--tally-menu-green);
  border-top: 2px solid var(--tally-border);
  padding: 0.85rem 1.15rem;
  gap: 0.5rem;
}
#dailyPricingModal .daily-pricing-modal-footer .btn-primary {
  min-width: 6.5rem;
  font-weight: 700;
}
#dailyPricingModal .daily-pricing-modal-footer .btn-outline-secondary {
  background: #fff;
  border-color: var(--tally-border-light);
  color: var(--tally-text);
  font-weight: 600;
}
#dailyPricingModal .daily-pricing-modal-footer .btn-outline-secondary:hover {
  background: var(--tally-content);
  border-color: var(--tally-border);
  color: var(--tally-primary);
}
body.daily-pricing-blocked .app-wrapper {
  pointer-events: none;
  user-select: none;
  filter: grayscale(0.12);
}
body.daily-pricing-blocked #dailyPricingModal,
body.daily-pricing-blocked #dailyPricingModal *,
body.daily-pricing-blocked #dailyPricingHistoryModal,
body.daily-pricing-blocked #dailyPricingHistoryModal * {
  pointer-events: auto;
  user-select: auto;
  filter: none;
}
#dailyPricingHistoryModal.show,
#dailyPricingHistoryModal.showing {
  z-index: 2020 !important;
}
body.daily-pricing-blocked.daily-pricing-history-open .modal-backdrop:last-child {
  z-index: 2010 !important;
}
#dailyPricingHistoryModal .daily-pricing-history-modal {
  border: 2px solid var(--tally-border);
  border-radius: 0;
  overflow: hidden;
}
#dailyPricingHistoryModal .daily-pricing-history-modal .modal-header {
  background: var(--tally-header) !important;
  color: #fff !important;
  border-bottom: 2px solid var(--tally-border);
  padding: 0.85rem 1.15rem;
}
#dailyPricingHistoryModal .daily-pricing-history-modal .modal-header .modal-title {
  color: #fff !important;
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
}
#dailyPricingHistoryModal .daily-pricing-history-modal .modal-header .bi {
  color: var(--tally-menu-green);
}
#dailyPricingHistoryModal .daily-pricing-history-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
#dailyPricingHistoryModal .daily-pricing-delta {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
}
#dailyPricingHistoryModal .daily-pricing-copy-btn {
  min-width: 4.25rem;
  font-weight: 600;
}

/* ----- Section maximize (form / list / page workspace) ----- */
.sps-page-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  min-height: 1.75rem;
}
.sps-page-toolbar-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--tally-text-muted);
  margin-right: auto;
}

.sps-panel-maximize-btn {
  padding: 0.1rem 0.4rem;
  line-height: 1;
  color: var(--tally-header);
  border: 1px solid var(--tally-border-light);
  background: rgba(255, 255, 255, 0.65);
  border-radius: 0;
}
.sps-panel-maximize-btn:hover,
.sps-panel-maximize-btn:focus {
  background: #fff;
  color: var(--tally-primary);
  border-color: var(--tally-border);
}
.sps-panel-maximize-btn[aria-pressed="true"] {
  background: var(--tally-header);
  color: #fff;
  border-color: var(--tally-border);
}

.sps-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.sps-panel-header .sps-panel-title {
  flex: 1;
  min-width: 0;
}

.sps-workspace {
  min-height: 0;
}
.sps-workspace-panels {
  min-height: 0;
}
.sps-workspace-has-maximized .sps-panel-col-hidden,
.sps-panel-sibling-hidden {
  display: none !important;
}
.sps-workspace-has-maximized .sps-panel-col-maximized {
  flex: 0 0 100%;
  max-width: 100%;
  width: 100%;
}

.sps-panel-maximized.card {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 12rem);
}
.sps-panel-maximized .card-body,
.sps-panel-maximized .sps-panel-body-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.sps-panel-maximized.table-responsive {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.sps-backup-table-scroll {
  max-height: 20rem;
  overflow-y: auto;
}
.sps-backup-table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--tally-table-head, #e8f5f0);
  box-shadow: 0 1px 0 var(--tally-border-light);
}

.sps-page-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sps-page-content-maximized {
  flex: 1 1 auto;
  min-height: calc(100vh - 5.5rem);
}
.sps-main-page-maximized .app-content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding-bottom: 0.5rem !important;
}
.sps-main-page-maximized .app-footer-bar,
.sps-main-page-maximized .app-statusbar {
  display: none;
}
.sps-page-content-maximized .sps-workspace {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sps-page-content-maximized .sps-workspace-panels {
  flex: 1 1 auto;
  min-height: 0;
}
.sps-page-content-maximized .sps-workspace-has-maximized .sps-panel-maximized.card {
  min-height: 0;
  flex: 1 1 auto;
}

@media (max-width: 991.98px) {
  .sps-panel-maximized.card {
    min-height: calc(100vh - 14rem);
  }
}

/* Responsive */
@media (max-width: 991.98px) {
  .app-body-row {
    flex-direction: column;
  }
  .app-sidebar {
    width: 100%;
    min-height: auto;
  }
  html.app-sidebar-unpinned .app-sidebar {
    width: 100%;
  }
  html.app-sidebar-unpinned .app-sidebar-brand {
    flex-direction: row;
    padding: 0.5rem 0.85rem;
  }
  html.app-sidebar-unpinned .app-sidebar-brand-text {
    display: block;
  }
  html.app-sidebar-unpinned .app-sidebar-brand-short {
    display: none;
  }
  html.app-sidebar-unpinned .app-sidebar-text {
    display: inline !important;
  }
  html.app-sidebar-unpinned .app-sidebar .nav-link {
    justify-content: flex-start;
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
  html.app-sidebar-unpinned .app-sidebar-flyout-title {
    display: none;
  }
  html.app-sidebar-unpinned .app-sidebar .nav-item.has-children > .app-sidebar-submenu {
    position: static;
    display: block !important;
    box-shadow: none;
    border: none;
    min-width: 0;
  }
  html.app-sidebar-unpinned .app-sidebar .nav-item.has-children > .app-sidebar-submenu {
    position: static;
  }
  html.app-sidebar-unpinned .app-sidebar .nav-item.has-children:not(.flyout-open) > .app-sidebar-submenu {
    display: none !important;
  }
  html.app-sidebar-unpinned .app-sidebar .nav-item.has-children.flyout-open > .app-sidebar-submenu {
    display: block !important;
  }
}

/* Sales report: keep line-item columns aligned across order blocks */
.report-sales-lines .report-sales-lines-table {
  table-layout: fixed;
  width: 100%;
}

.report-sales-lines .report-sales-lines-table th:nth-child(1),
.report-sales-lines .report-sales-lines-table td:nth-child(1) { width: 14%; }

.report-sales-lines .report-sales-lines-table th:nth-child(2),
.report-sales-lines .report-sales-lines-table td:nth-child(2) { width: 14%; }

.report-sales-lines .report-sales-lines-table th:nth-child(3),
.report-sales-lines .report-sales-lines-table td:nth-child(3) { width: 36%; }

.report-sales-lines .report-sales-lines-table th:nth-child(4),
.report-sales-lines .report-sales-lines-table td:nth-child(4) { width: 10%; }

.report-sales-lines .report-sales-lines-table th:nth-child(5),
.report-sales-lines .report-sales-lines-table td:nth-child(5) { width: 13%; }

.report-sales-lines .report-sales-lines-table th:nth-child(6),
.report-sales-lines .report-sales-lines-table td:nth-child(6) { width: 13%; }

.report-sales-lines .report-sales-lines-table td:nth-child(3) {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Report print layout — match Download PDF (clean page, no chrome/borders).
   @page margin:0 removes browser header/footer slots (URL, date).
   body padding = page-1 top + L/R; repeating thead/tfoot = top/bottom on every page. */
.report-stock-table tfoot.report-stock-print-spacer,
.report-stock-table tr.report-stock-print-spacer {
  display: none;
}

@page {
  margin: 0;
  size: auto;
}

@media print {
  .app-sidebar,
  .app-menubar,
  .app-topbar,
  .app-footer-bar,
  .app-statusbar,
  .report-actions,
  .report-toolbar,
  .btn-logout,
  .sps-panel-maximize-btn,
  .modal,
  .sps-page-toolbar,
  .flash-messages,
  .card-header,
  .sps-panel .card-header,
  .sps-panel-header,
  .alert {
    display: none !important;
  }

  html,
  body,
  body.tally-theme {
    background: #fff !important;
    color: #000 !important;
    margin: 0 !important;
    /* Top + L/R for page 1 / content width; bottom comes from repeating tfoot */
    padding: 0.4in 0.4in 0 0.4in !important;
  }

  .app-wrapper,
  .app-body-row,
  .app-main,
  .app-content,
  .sps-page-content,
  .sps-workspace,
  .sps-workspace-panels,
  .sps-panel-col:not(.d-print-none),
  .card,
  .sps-panel.card,
  .card-body,
  .table-responsive {
    display: block !important;
    float: none !important;
    min-height: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    overflow: visible !important;
  }

  /* Keep Bootstrap print utilities working (filters, screen-only cols, etc.) */
  .d-print-none {
    display: none !important;
  }

  .d-print-inline {
    display: inline !important;
  }

  .d-print-block {
    display: block !important;
  }

  .d-print-table-cell {
    display: table-cell !important;
  }

  /* Theme forces border on .border-0 cards — clear it for print */
  .tally-theme .card,
  .tally-theme .card.border-0,
  .tally-theme .sps-panel.card {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
  }

  .report-print-header {
    display: block !important;
    margin: 0.4rem !important;
    padding: 0 !important;
    border: none !important;
    /* Offset thead padding-top so page 1 title→table gap stays tight */
    margin-bottom: -0.3in !important;
  }

  .report-print-header h2,
  .report-print-header .h5 {
    font-size: 14pt !important;
    font-weight: 700 !important;
    margin: 0 0 0.25rem 0 !important;
    color: #000 !important;
  }

  .report-print-header p {
    font-size: 9pt !important;
    margin: 0 !important;
    color: #000 !important;
  }

  /* PDF-like stock table: header underline only, no grid/zebra */
  .report-stock-table {
    width: 100% !important;
    font-size: 8.5pt !important;
    border-collapse: collapse !important;
    border: none !important;
  }

  .report-stock-table thead {
    display: table-header-group !important;
  }

  .report-stock-table tfoot {
    display: table-footer-group !important;
  }

  .report-stock-table tfoot.report-stock-print-spacer {
    display: table-footer-group !important;
  }

  .report-stock-table tr.report-stock-print-spacer {
    display: table-row !important;
  }

  .report-stock-table > :not(caption) > * > * {
    border: none !important;
  }

  .report-stock-table th,
  .report-stock-table td {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0.15rem 0.35rem 0.15rem 0 !important;
    color: #000 !important;
    vertical-align: top !important;
  }

  .report-stock-table thead th {
    font-weight: 700 !important;
    background: transparent !important;
    border-bottom: 1px solid #000 !important;
    /* Becomes the top margin when the header repeats on page 2+ */
    padding-top: 0.4in !important;
    padding-bottom: 0.35rem !important;
  }

  /* Matching bottom margin on every printed page (incl. page 1…N) */
  .report-stock-table tfoot.report-stock-print-spacer td,
  .report-stock-table tr.report-stock-print-spacer td {
    padding: 0.4in 0 0 0 !important;
    border: none !important;
    line-height: 0 !important;
    font-size: 0 !important;
  }

  .report-stock-table tfoot.table-light td {
    border-top: 1px solid #000 !important;
    font-weight: 700 !important;
    padding-top: 0.35rem !important;
  }

  .report-sales-order-block {
    break-inside: avoid;
    page-break-inside: avoid;
    border-top: none !important;
    padding-top: 0.4rem !important;
    margin-bottom: 0.75rem !important;
  }

  .report-sales-order-block + .report-sales-order-block {
    border-top: 1px solid #333 !important;
    padding-top: 0.6rem !important;
  }

  .report-stock-table tbody tr,
  .report-stock-table.table-striped > tbody > tr:nth-of-type(odd) > *,
  .report-stock-table.table-hover > tbody > tr:hover > *,
  .report-stock-table tbody tr.table-danger > *,
  .report-stock-table tbody tr.table-danger,
  .report-stock-table tbody tr.table-secondary > *,
  .report-stock-table tbody tr.table-secondary {
    background: transparent !important;
    --bs-table-bg-type: transparent !important;
    --bs-table-bg-state: transparent !important;
    --bs-table-bg: transparent !important;
    color: #000 !important;
  }

  .report-stock-table tbody tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-sales-table thead th {
    background: #eee !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .report-sales-table th,
  .report-sales-table td {
    border: 1px solid #333 !important;
    padding: 0.2rem 0.35rem !important;
  }

  .report-scrap-table-wrap {
    overflow: visible !important;
  }

  .report-scrap-table {
    table-layout: fixed;
    width: 100% !important;
    max-width: 100% !important;
    font-size: 9pt;
  }

  .report-scrap-table thead {
    display: table-header-group;
  }

  .report-scrap-table tfoot {
    display: table-footer-group;
  }

  .report-scrap-table tbody tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-scrap-table .scrap-order-no {
    font-size: 8.5pt;
    white-space: nowrap;
  }

  /* 8 visible columns — hidden cols collapsed; widths sum to 100% */
  .report-scrap-table th:nth-child(1),
  .report-scrap-table td:nth-child(1) { width: 5%; }

  .report-scrap-table th:nth-child(2),
  .report-scrap-table td:nth-child(2) { width: 17%; }

  .report-scrap-table th:nth-child(3),
  .report-scrap-table td:nth-child(3) { width: 14%; }

  .report-scrap-table th:nth-child(4),
  .report-scrap-table td:nth-child(4) { width: 6%; }

  .report-scrap-table th:nth-child(5),
  .report-scrap-table td:nth-child(5) { width: 6%; }

  .report-scrap-table th:nth-child(6),
  .report-scrap-table td:nth-child(6) { width: 26%; }

  .report-scrap-table th:nth-child(7),
  .report-scrap-table td:nth-child(7) { width: 10%; }

  .report-scrap-table th:nth-child(9),
  .report-scrap-table td:nth-child(9) { width: 16%; }

  .report-scrap-table th:nth-child(8),
  .report-scrap-table td:nth-child(8),
  .report-scrap-table th:nth-child(10),
  .report-scrap-table td:nth-child(10),
  .report-scrap-table th:nth-child(11),
  .report-scrap-table td:nth-child(11) {
    display: none !important;
    width: 0 !important;
    padding: 0 !important;
    border: none !important;
  }

  .report-scrap-table th,
  .report-scrap-table td {
    white-space: normal;
    overflow-wrap: anywhere;
    vertical-align: top;
  }

  .report-scrap-table th:nth-child(2),
  .report-scrap-table td:nth-child(2),
  .report-scrap-table th:nth-child(3),
  .report-scrap-table td:nth-child(3),
  .report-scrap-table th:nth-child(9),
  .report-scrap-table td:nth-child(9) {
    white-space: nowrap;
  }

  .report-scrap-table th.report-scrap-col-weight {
    white-space: nowrap;
    font-size: 8pt;
  }

  .report-sales-order-block {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .shortcut-print-area {
    font-size: 10pt;
  }

  .shortcut-print-header {
    border-bottom: 2px solid #333;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
  }

  .shortcuts-print-table th,
  .shortcuts-print-table td {
    border: 1px solid #333 !important;
    padding: 0.25rem 0.4rem !important;
    vertical-align: top;
  }

  .shortcuts-print-table thead th {
    background: #eee !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .shortcuts-print-table tbody tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* Copper price widget (top bar) */
.app-topbar .btn-copper-price {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #fff;
  border: 1px solid var(--tally-border-light);
  color: var(--tally-text);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--tally-radius);
}
.app-topbar .btn-copper-price:hover,
.app-topbar .btn-copper-price:focus {
  background: var(--tally-menu-green);
  border-color: var(--tally-border);
  color: var(--tally-text);
}
#copperPriceModal .table th {
  width: 38%;
  background: var(--tally-content);
}
#copperPriceModal .modal-body > p {
  line-height: 1.45;
}

/* Theme picker (top bar) */
.sps-theme-picker .btn-theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #fff;
  border: 1px solid var(--tally-border-light);
  color: var(--tally-text);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--tally-radius);
}
.sps-theme-picker .btn-theme-picker:hover,
.sps-theme-picker .btn-theme-picker:focus {
  background: var(--tally-menu-green);
  border-color: var(--tally-border);
  color: var(--tally-text);
}
.sps-theme-swatch {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}
.sps-theme-menu {
  min-width: 16rem;
  border-radius: 0;
  border: 1px solid var(--tally-border);
  background: #fff;
  color: var(--tally-text);
}
.app-topbar .sps-theme-menu .dropdown-header {
  color: var(--tally-text-muted) !important;
}
.sps-theme-option-form {
  margin: 0;
}
.sps-theme-option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  white-space: normal;
  color: var(--tally-text) !important;
}
.sps-theme-option:hover,
.sps-theme-option:focus {
  background: var(--tally-content) !important;
  color: var(--tally-text) !important;
}
.sps-theme-option.active,
.sps-theme-option.active:hover,
.sps-theme-option.active:focus {
  background: var(--tally-menu-green) !important;
  color: var(--tally-text) !important;
}
.sps-theme-option-text strong {
  font-size: 0.85rem;
  color: inherit;
}
.sps-theme-option-text small,
.app-topbar .sps-theme-menu .sps-theme-option .text-muted {
  font-size: 0.72rem;
  line-height: 1.3;
  color: var(--tally-text-muted) !important;
  opacity: 1;
}

/* Sales / purchase order line tables — cap item search width */
.order-lines-table {
  table-layout: fixed;
  width: 100%;
}
.order-lines-table th.col-item,
.order-lines-table td.line-item-cell {
  width: 25%;
  max-width: 25%;
}
.order-lines-table td.line-item-cell {
  position: relative;
  overflow: visible;
}
.order-lines-table .line-item-search {
  width: 100%;
  min-width: 0;
}
.item-suggest.item-suggest-floating {
  position: fixed;
  z-index: 1060;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--tally-border, #ced4da);
  border-radius: var(--tally-radius, 0.25rem);
  box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.15);
}
