/* ===================================================
   DELIVERY PRO SYSTEM — UI Components
   forms, buttons, cards, tables, badges, modals, toasts
   =================================================== */

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 0.857rem; font-weight: 700;
  color: var(--text-2); margin-bottom: 6px;
  letter-spacing: 0.5px; text-transform: uppercase;
}
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--bg-3);
  border: 1px solid var(--border-2); border-radius: var(--radius);
  padding: 10px 14px; color: var(--text); font-size: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none; appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ghost);
}
.form-input::placeholder { color: var(--text-3); }
.form-select {
  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='%2371717A' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px; cursor: pointer;
}
.form-select option { background: var(--bg-3); color: var(--text); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* Enlarged checkboxes app-wide — row selects, select-all headers, status-filter
   dropdowns, export column picker, etc. — default browser size reads too small.
   Native checkboxes render with the OS's own white-ish box regardless of theme, so the
   default appearance is replaced with a themed box (bg-3/border-2, matching light or dark
   mode) and a manually-drawn checkmark for the checked state. */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px; height: 20px;
  background: var(--bg-3);
  border: 1.5px solid var(--border-2);
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: background var(--transition), border-color var(--transition);
}
input[type="checkbox"]:hover { border-color: var(--brand-light); }
input[type="checkbox"]:checked {
  background: var(--brand);
  border-color: var(--brand);
}
input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 6px; top: 2px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input[type="checkbox"]:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== INLINE CELL EDITING (double-click a shipments row cell) ===== */
.cell-editable { cursor: pointer; border-radius: 4px; transition: background var(--transition); }
.cell-editable:hover { background: var(--bg-3); box-shadow: inset 0 0 0 1px var(--border-2); }
.inline-edit-input {
  width: 100%; min-width: 70px; background: var(--bg-2);
  border: 1px solid var(--brand); border-radius: 4px;
  padding: 3px 6px; color: var(--text); font-size: 0.9em;
  outline: none; appearance: none; box-shadow: 0 0 0 2px var(--brand-ghost);
}
.inline-edit-input.form-select { padding-right: 28px; background-position: right 8px center; background-size: 10px; }

/* ===== PHONE FIELD (country flag + dial-code picker) ===== */
.phone-field { display: flex; align-items: stretch; gap: 6px; }
.phone-field .form-input { flex: 1; min-width: 0; }
.phone-field .dropdown { display: flex; flex: 0 0 auto; }
.phone-code-btn {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  background: var(--bg-3); border: 1px solid var(--border-2); border-radius: var(--radius);
  padding: 0 10px; color: var(--text); font-size: 0.929rem; cursor: pointer;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.phone-code-btn:hover { background: var(--bg-4); }
.phone-field .dropdown.open .phone-code-btn { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ghost); }
.phone-flag { font-size: 1.15rem; line-height: 1; display: inline-flex; align-items: center; }
.phone-dial { font-family: var(--mono); font-size: 0.857rem; color: var(--text-2); }
.phone-caret { font-size: 0.65rem; color: var(--text-3); }
.flag-icon { width: 20px; height: 15px; object-fit: cover; border-radius: 2px; vertical-align: middle; box-shadow: 0 0 0 1px rgba(255,255,255,0.08); }
.flag-icon-inline { width: 16px; height: 12px; }

.phone-dropdown-menu { padding: 8px; width: 270px; }
.phone-country-search {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius);
  padding: 7px 10px; color: var(--text); font-size: 0.857rem; outline: none;
  margin-bottom: 6px; transition: border-color var(--transition);
}
.phone-country-search:focus { border-color: var(--brand); }
.phone-country-list { max-height: 240px; overflow-y: auto; }
.phone-country-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px;
  cursor: pointer; font-size: 0.879rem; color: var(--text-2); transition: background var(--transition);
}
.phone-country-item:hover { background: var(--bg-4); color: var(--text); }
.phone-country-item .phone-flag { font-size: 1.15rem; }
.phone-country-item .phone-country-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone-country-item .phone-country-dial { font-family: var(--mono); color: var(--text-3); font-size: 0.8rem; }
.phone-country-empty { padding: 14px 8px; text-align: center; color: var(--text-3); font-size: 0.857rem; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px 20px; border-radius: var(--radius);
  font-size: 0.929rem; font-weight: 700; transition: all var(--transition);
  white-space: nowrap; cursor: pointer; border: 1px solid transparent;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--brand-grad); color: #fff;
  box-shadow: var(--shadow-glow);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 10px 32px rgba(79,110,245,0.4); }
.btn-secondary { background: var(--bg-4); color: var(--text); border-color: var(--border-2); }
.btn-secondary:hover { background: var(--bg-5); border-color: var(--border-2); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }
.btn-danger { background: var(--red-ghost); color: var(--red); border-color: rgba(255,77,106,0.25); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-success { background: var(--green-ghost); color: var(--green); border-color: rgba(46,212,122,0.25); }
.btn-success:hover { background: var(--green); color: #fff; }
.btn-quick-add {
  background: linear-gradient(135deg, #34E0A1 0%, #2ED47A 55%, #17A668 100%);
  color: #fff; border-color: transparent;
  animation: quick-add-pulse 1.6s ease-in-out infinite;
}
.btn-quick-add:hover { filter: brightness(1.1); animation-play-state: paused; }
@keyframes quick-add-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46,212,122,0.55), 0 4px 14px rgba(46,212,122,0.3); }
  50%      { box-shadow: 0 0 0 8px rgba(46,212,122,0), 0 4px 14px rgba(46,212,122,0.3); }
}
.btn-sm { padding: 6px 12px; font-size: 0.857rem; }
.btn-lg { padding: 14px 28px; font-size: 1.071rem; }
.btn-icon { padding: 8px; aspect-ratio: 1; border-radius: 8px; }
.btn-full { width: 100%; }

/* ===== QUICK ADD ORDER BAR =====
   Default: fields wrap onto multiple lines (min-width per field acts as the floor).
   >=1600px: force a single row and size each field proportionally to its
   default (min-width) value, so the row scales up to fill the wide screen
   while keeping every field's relative width the same. */
#ship-fast-order-bar .fo-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
#ship-fast-order-bar .fo-f-desc { flex: 1 1 0; }
@media (min-width: 1600px) {
  #ship-fast-order-bar .fo-row { flex-wrap: nowrap; }
  #ship-fast-order-bar .fo-row .form-group { flex-shrink: 1; flex-basis: 0; }
  #ship-fast-order-bar .fo-f-shipnum   { flex-grow: 100; }
  #ship-fast-order-bar .fo-f-price     { flex-grow: 110; }
  #ship-fast-order-bar .fo-f-priceleb  { flex-grow: 120; }
  #ship-fast-order-bar .fo-f-customer  { flex-grow: 110; }
  #ship-fast-order-bar .fo-f-phone     { flex-grow: 140; }
  #ship-fast-order-bar .fo-f-address   { flex-grow: 150; }
  #ship-fast-order-bar .fo-f-desc      { flex-grow: 150; }
  #ship-fast-order-bar .fo-submit-btn  { flex: 0 0 auto; }
}

/* ===== CARDS ===== */
.card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 20px; }
.card-title { font-size: 1rem; font-weight: 700; }

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { border-color: var(--border-2); transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::before {
  content: ''; position: absolute; top: 0; right: 0;
  width: 120px; height: 120px; border-radius: 50%;
  opacity: 0.16; filter: blur(20px); transform: translate(35%, -35%);
}
.stat-card.brand::before { background: var(--brand); }
.stat-card.green::before { background: var(--green); }
.stat-card.amber::before { background: var(--amber); }
.stat-card.blue::before { background: var(--blue); }
.stat-card.purple::before { background: var(--purple); }
.stat-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.357rem; margin-bottom: 12px; position: relative; z-index: 1;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.brand { background: var(--brand-ghost); border: 1px solid var(--brand-border); box-shadow: 0 0 0 4px var(--brand-ghost); color: var(--brand-light); }
.stat-icon.green { background: var(--green-ghost); border: 1px solid rgba(46,212,122,0.25); box-shadow: 0 0 0 4px var(--green-ghost); color: var(--green); }
.stat-icon.amber { background: var(--amber-ghost); border: 1px solid rgba(255,176,32,0.25); box-shadow: 0 0 0 4px var(--amber-ghost); color: var(--amber); }
.stat-icon.blue { background: var(--blue-ghost); border: 1px solid rgba(61,169,252,0.25); box-shadow: 0 0 0 4px var(--blue-ghost); color: var(--blue); }
.stat-icon.purple { background: var(--purple-ghost); border: 1px solid rgba(179,104,255,0.25); box-shadow: 0 0 0 4px var(--purple-ghost); color: var(--purple); }
.stat-label { font-size: 0.786rem; font-weight: 700; color: var(--text-3); letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 4px; }
.stat-value { font-size: 1.857rem; font-weight: 700; line-height: 1; }
.stat-value.mono { font-family: var(--mono); }
.stat-trend { font-size: 0.786rem; color: var(--text-3); margin-top: 4px; }
.stat-trend .up { color: var(--green); }
.stat-trend .down { color: var(--red); }

/* ===== TABLES ===== */
.table-container { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.table-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
}
.table-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.table-search { position: relative; display: flex; align-items: center; }
.table-search input {
  background: var(--bg-3); border: 1px solid var(--border-2);
  border-radius: 99px; padding: 7px 12px 7px 32px;
  color: var(--text); font-size: 0.929rem; outline: none; width: 200px;
  transition: border-color var(--transition); font-family: var(--font);
}
.table-search input:focus { border-color: var(--brand); }
.table-search .search-icon {
  position: absolute; left: 10px;
  color: var(--text-3); font-size: 0.929rem; pointer-events: none;
}
.table-scroll { overflow-x: auto; }
table { min-width: 600px; }
thead th {
  padding: 11px 16px; text-align: left;
  font-size: 0.786rem; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--text-3);
  background: var(--bg-3); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-3); }
tbody td { padding: 12px 16px; font-size: 0.929rem; color: var(--text); vertical-align: middle; }
.table-empty { text-align: center; padding: 48px 24px; color: var(--text-3); }
.table-empty .empty-icon { font-size: 2.571rem; margin-bottom: 12px; }
.table-empty p { font-size: 1rem; }
.table-footer {
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.857rem; color: var(--text-3); flex-wrap: wrap; gap: 8px;
}

/* ===== FILTER BAR ===== */
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
@media (min-width: 1600px) {
  .filter-bar { flex-wrap: nowrap; }
  .filter-bar > .dropdown       { flex: 13 1 0; min-width: 0; }
  .filter-bar > .dropdown > .filter-select { width: 100%; }
  .filter-bar > .filter-select  { flex: 14 1 0; min-width: 0; }
  .filter-bar > .filter-date    { flex: 10 1 0; min-width: 0; }
  .filter-bar > .table-search   { flex: 16 1 0; min-width: 0; }
  .filter-bar > .table-search input { width: 100%; min-width: 0; }
  .filter-bar > button          { flex: 0 0 auto; }
}
.filter-select {
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: 99px; padding: 7px 28px 7px 14px;
  color: var(--text); font-size: 0.929rem; outline: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2371717A' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  cursor: pointer; font-family: var(--font);
}
.filter-select:focus { border-color: var(--brand); outline: none; }
.filter-select option { background: var(--bg-3); }
.filter-date {
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: 99px; padding: 7px 14px;
  color: var(--text); font-size: 0.929rem; outline: none; font-family: var(--font);
}
.filter-date:focus { border-color: var(--brand); }

/* ===== BADGES / STATUS ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 99px;
  font-size: 0.786rem; font-weight: 700; white-space: nowrap;
}
.badge-green  { background: var(--green-ghost);  color: var(--green);  border: 1px solid rgba(46,212,122,0.25); }
.badge-amber  { background: var(--amber-ghost);  color: var(--amber);  border: 1px solid rgba(255,176,32,0.25); }
.badge-blue   { background: var(--blue-ghost);   color: var(--blue);   border: 1px solid rgba(61,169,252,0.25); }
.badge-red    { background: var(--red-ghost);    color: var(--red);    border: 1px solid rgba(255,77,106,0.25); }
.badge-purple { background: var(--purple-ghost); color: var(--purple); border: 1px solid rgba(179,104,255,0.25); }
.badge-gray   { background: var(--bg-4);         color: var(--text-2); border: 1px solid var(--border-2); }
.badge-brand  { background: var(--brand-ghost);  color: var(--brand-light); border: 1px solid var(--brand-border); }
/* ── Extra status colors matching the reference UI ── */
.badge-orange   { background: rgba(255,138,61,0.14);  color: #FF8A3D; border: 1px solid rgba(255,138,61,0.3); }
.badge-yellow   { background: rgba(255,213,66,0.14);  color: #FFD542; border: 1px solid rgba(255,213,66,0.35); }
.badge-darkblue { background: rgba(93,124,255,0.14);  color: #8FA6FF; border: 1px solid rgba(93,124,255,0.32); }
.badge-plain    { background: transparent; color: var(--text-3); border: 1px solid var(--border-2); letter-spacing: 1px; }

/* ── Compact status-count badges (report tables) ── */
.badge-mini {
  padding: 2px 7px; font-size: 0.7rem; gap: 3px; border-radius: 6px;
}
.status-breakdown-cell {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap; min-width: 220px;
}
.report-total-row td {
  background: var(--bg-3, rgba(255,255,255,0.04));
  border-top: 2px solid var(--border-2);
  padding: 18px 16px;
}

/* ===== MERGED COMPANY/CONTRACTOR RECONCILIATION (General Report) =====
   For institutes that act as both a client company and a delivery contractor at once —
   nets what we owe them (as company) against what they owe us (as contractor) into one
   settlement card per institute, instead of two easy-to-miss separate rows. */
.merged-report { margin-bottom: 24px; }
.merged-report-intro {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px; margin-bottom: 16px;
  background: var(--brand-grad); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glow); color: #fff;
}
.merged-report-intro-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  background: rgba(255,255,255,0.18); display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.merged-report-intro-title { font-size: 1.05rem; font-weight: 800; margin-bottom: 2px; }
.merged-report-intro-sub   { font-size: 0.83rem; opacity: 0.92; }

.merged-cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }

.merged-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.merged-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--bg-3);
}
.merged-card-name { font-size: 1rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.merged-card-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px;
  font-size: 0.7rem; font-weight: 800; background: var(--brand-ghost); color: var(--brand-light);
  border: 1px solid var(--brand-border); white-space: nowrap;
}
.merged-card-body { display: grid; grid-template-columns: 1fr 1fr; }
.merged-role-col { padding: 14px 18px; }
.merged-role-col + .merged-role-col { border-left: 1px solid var(--border); }
[dir="rtl"] .merged-role-col + .merged-role-col { border-left: none; border-right: 1px solid var(--border); }
.merged-role-label {
  font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px;
  margin-bottom: 10px; display: flex; align-items: center; gap: 6px;
}
.merged-role-label.company    { color: var(--green); }
.merged-role-label.contractor { color: var(--purple); }
.merged-role-row { display: flex; align-items: center; justify-content: space-between; font-size: 0.86rem; padding: 4px 0; gap: 8px; }
.merged-role-row span:first-child { color: var(--text-3); }
.merged-role-row span:last-child  { font-family: var(--mono); font-weight: 700; white-space: nowrap; }

.merged-settlement {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-top: 1px solid var(--border);
}
.merged-settlement.owe-them { background: var(--red-ghost); }
.merged-settlement.owe-us   { background: var(--green-ghost); }
.merged-settlement.even     { background: var(--bg-3); }
.merged-settlement-label { font-size: 0.83rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.merged-settlement-value { font-size: 1.15rem; font-weight: 800; font-family: var(--mono); }
.merged-settlement.owe-them .merged-settlement-label,
.merged-settlement.owe-them .merged-settlement-value { color: var(--red); }
.merged-settlement.owe-us .merged-settlement-label,
.merged-settlement.owe-us .merged-settlement-value   { color: var(--green); }
.merged-settlement.even .merged-settlement-label,
.merged-settlement.even .merged-settlement-value     { color: var(--text-2); }

.merged-profit-note { padding: 8px 18px 14px; font-size: 0.78rem; color: var(--text-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.merged-profit-note strong { color: var(--text); font-family: var(--mono); }

.merged-summary-strip {
  display: flex; flex-wrap: wrap; gap: 14px; margin-top: 16px; align-items: center;
  padding: 16px 20px; background: var(--bg-2); border: 1px dashed var(--border-2); border-radius: var(--radius-lg);
}
.merged-summary-item { flex: 1; min-width: 160px; }
.merged-summary-item .label { font-size: 0.72rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; font-weight: 700; }
.merged-summary-item .value { font-size: 1.2rem; font-weight: 800; font-family: var(--mono); }

@media (max-width: 640px) {
  .merged-card-body { grid-template-columns: 1fr; }
  .merged-role-col + .merged-role-col { border-left: none; border-top: 1px solid var(--border); }
  [dir="rtl"] .merged-role-col + .merged-role-col { border-right: none; border-top: 1px solid var(--border); }
}

/* ===== MODALS ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); z-index: 200;
  align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: linear-gradient(180deg, var(--bg-3) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl); width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 32px 80px rgba(3,6,16,0.75), inset 0 1px 0 rgba(255,255,255,0.04);
  animation: modal-in 0.2s ease;
}
.modal-lg { max-width: 800px; }
/* Per-entity general report popup: always show the full table, no horizontal scrollbar,
   no matter how wide the content (long names, big totals, many status badges) gets. */
.modal-report-fit { max-width: min(1100px, 96vw); }
.modal-report-fit .table-container { overflow-x: visible; }
.modal-report-fit table.report-fit-table {
  min-width: 0; width: 100%; table-layout: auto;
}
.modal-report-fit table.report-fit-table thead th {
  white-space: normal; word-break: break-word;
}
.modal-report-fit table.report-fit-table tbody td {
  white-space: normal; word-break: break-word;
}
.modal-report-fit table.report-fit-table tbody td.font-mono { white-space: nowrap; }
.modal-report-fit .status-breakdown-cell { min-width: 0; }
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1.143rem; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-4); color: var(--text-2); font-size: 1.143rem;
  cursor: pointer; transition: all var(--transition); border: none;
}
.modal-close:hover { background: var(--bg-5); color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
}

/* ===== TOASTS ===== */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--bg-3); border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  font-size: 0.929rem; color: var(--text); box-shadow: var(--shadow);
  animation: toast-in 0.3s ease; pointer-events: all; max-width: 340px;
}
.toast.success { border-color: rgba(34,197,94,0.3); }
.toast.error   { border-color: rgba(239,68,68,0.3); }
.toast.info    { border-color: rgba(59,130,246,0.3); }
.toast-icon { font-size: 1.143rem; flex-shrink: 0; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== QUICK ACTIONS (Dashboard) ===== */
.quick-actions {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.quick-action {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; transition: all var(--transition); text-align: center;
  box-shadow: var(--shadow-sm);
}
.quick-action:hover {
  border-color: var(--brand-border); background: var(--brand-ghost);
  transform: translateY(-2px); box-shadow: var(--shadow-glow);
}
.quick-action .qa-icon {
  font-size: 1.714rem; width: 48px; height: 48px;
  background: var(--bg-3); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-2); color: var(--brand-light);
}
.quick-action .qa-icon svg { width: 24px; height: 24px; }
.quick-action span { font-size: 0.857rem; font-weight: 700; color: var(--text-2); }

/* ===== SHIPMENT DETAIL ===== */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-label { font-size: 0.786rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-3); margin-bottom: 4px; }
.detail-value { font-size: 1rem; color: var(--text); }

/* ===== MOBILE CARDS ===== */
.mobile-cards { display: none; }
@media (max-width: 768px) {
  .desktop-table { display: none; }
  .mobile-cards { display: flex; flex-direction: column; gap: 10px; }
  .mobile-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow-sm); }
  .mobile-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .mobile-card-num { font-size: 1rem; font-weight: 700; font-family: var(--mono); }
  .mobile-card-body { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .mobile-card-label { font-size: 0.714rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-3); margin-bottom: 2px; }
  .mobile-card-value { font-size: 0.929rem; }
  .mobile-card-footer { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
}

/* ===== FINANCIAL SUMMARY ===== */
.financial-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; padding: 16px;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 16px;
}
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 768px) { .report-grid { grid-template-columns: 1fr; } }
.fin-item .fin-label { font-size: 0.786rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.fin-item .fin-value { font-size: 1.143rem; font-weight: 700; font-family: var(--mono); }
.fin-item .fin-value.positive { color: var(--green); }
.fin-item .fin-value.negative { color: var(--red); }
.fin-item .fin-value.neutral  { color: var(--amber); }

/* ===== SETTINGS ===== */
.settings-section { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 16px; overflow: hidden; box-shadow: var(--shadow-sm); }
.settings-section-title { padding: 14px 20px; font-size: 0.929rem; font-weight: 700; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.settings-row {
  padding: 14px 20px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--border);
  gap: 16px; flex-wrap: wrap;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-label { font-size: 0.929rem; font-weight: 700; }
.settings-row-desc { font-size: 0.857rem; color: var(--text-3); margin-top: 2px; }

/* ===== RESTORE MODE PICKER ===== */
.restore-mode-group { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.restore-mode-title { font-size: 0.857rem; font-weight: 700; color: var(--text-2); margin-bottom: 2px; }
.restore-mode-option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.restore-mode-option:hover { border-color: var(--brand-border); }
.restore-mode-option input[type="radio"] { margin-top: 3px; width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--brand); cursor: pointer; }
.restore-mode-option:has(input:checked) { border-color: var(--brand-border); background: var(--brand-ghost); }
.restore-mode-option-label { font-size: 0.857rem; font-weight: 700; }
.restore-mode-option-desc { font-size: 0.786rem; color: var(--text-3); margin-top: 2px; }

/* ===== IMPORT BY EXCEL ===== */
.import-intro {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px; margin-bottom: 16px;
  background: var(--brand-grad); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glow); color: #fff;
}
.import-intro-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  background: rgba(255,255,255,0.18); display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.import-intro-icon svg { width: 24px; height: 24px; }
.import-intro-title { font-size: 1.05rem; font-weight: 800; margin-bottom: 2px; }
.import-intro-sub   { font-size: 0.83rem; opacity: 0.92; }

.import-dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 34px 20px; text-align: center; cursor: pointer;
  border: 2px dashed var(--border-2); border-radius: var(--radius-lg);
  background: var(--bg-3); transition: border-color .15s, background .15s;
}
.import-dropzone:hover, .import-dropzone.dragover { border-color: var(--brand-border); background: var(--brand-ghost); }
.import-dropzone-icon { width: 40px; height: 40px; opacity: 0.85; margin-bottom: 4px; }
.import-dropzone-icon svg { width: 100%; height: 100%; }
.import-dropzone-text { font-size: 0.929rem; font-weight: 700; }
.import-dropzone-sub  { font-size: 0.786rem; color: var(--text-3); }
.import-file-chosen { font-size: 0.857rem; font-weight: 700; color: var(--brand-light); }

.import-mapping-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px; padding: 4px 20px 18px;
}
.import-mapping-item { display: flex; flex-direction: column; gap: 6px; }
.import-mapping-item.mapped .form-select { border-color: var(--green); }

.import-stat-pill {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; flex: 1; min-width: 100px; padding: 12px 10px;
  border-radius: var(--radius); background: var(--bg-3); border: 1px solid var(--border-2);
}
.import-stat-pill strong { font-size: 1.4rem; font-weight: 800; line-height: 1; }
.import-stat-pill span   { font-size: 0.75rem; color: var(--text-3); }
.import-stat-pill.green  strong { color: var(--green); }
.import-stat-pill.gray   strong { color: var(--text-2); }
.import-stat-pill.amber  strong { color: var(--amber); }
#import-review-stats { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

.import-review-section-title { font-size: 0.857rem; font-weight: 700; margin: 6px 0 8px; }
.import-review-list {
  max-height: 220px; overflow-y: auto; border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 4px; margin-bottom: 14px;
}

/* ===== DEMO MODE BANNER ===== */
#demo-mode-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; background: rgba(255,176,32,0.14);
  border-bottom: 1px solid rgba(255,176,32,0.35);
  color: #FFB020; font-size: 0.857rem; font-weight: 700;
  width: 100%;
}
#demo-mode-banner.hidden { display: none; }
.demo-banner-icon { width: 16px; height: 16px; flex-shrink: 0; }
.demo-banner-icon svg { width: 100%; height: 100%; }
.demo-banner-text { flex: 1; }
.demo-banner-close {
  width: 22px; height: 22px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: #FFB020; font-size: 0.786rem;
  cursor: pointer; transition: background var(--transition); flex-shrink: 0;
}
.demo-banner-close:hover { background: rgba(255,176,32,0.18); }

/* ===== ACCESS DENIED ===== */
.access-denied { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px 24px; text-align: center; }
.access-denied .ad-icon { font-size: 3.429rem; margin-bottom: 16px; }
.access-denied h2 { font-size: 1.429rem; font-weight: 700; margin-bottom: 8px; }
.access-denied p { color: var(--text-3); font-size: 1rem; }

/* ===== PAGE HEADER + BREADCRUMB ===== */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 14px;
}
.page-header-title-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page-header-title { font-size: 1.571rem; font-weight: 800; letter-spacing: -0.2px; }
.breadcrumb {
  display: flex; align-items: center; gap: 6px; margin-top: 0;
  font-size: 0.857rem; color: var(--text-3); flex-wrap: wrap;
}
.breadcrumb a, .breadcrumb span.crumb {
  color: var(--text-3); cursor: pointer; transition: color var(--transition);
}
.breadcrumb a:hover, .breadcrumb span.crumb:hover { color: var(--brand-light); }
.breadcrumb .crumb-current { color: var(--text-2); font-weight: 700; cursor: default; }
.breadcrumb .crumb-current:hover { color: var(--text-2); }
.breadcrumb-sep { color: var(--text-3); opacity: 0.5; font-size: 0.786rem; }
.page-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== TOOLBAR (elevated filter surface) ===== */
.toolbar {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  margin-bottom: 16px; box-shadow: var(--shadow-sm);
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.toolbar .filter-bar { margin-bottom: 0; flex: 1; }
.toolbar-divider { width: 1px; align-self: stretch; background: var(--border); margin: 0 2px; }

/* ===== DROPDOWN MENU ===== */
.dropdown { position: relative; display: inline-flex; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); z-index: 60;
  background: var(--bg-3); border: 1px solid var(--border-2);
  border-radius: var(--radius); box-shadow: var(--shadow);
  min-width: 180px; padding: 6px; display: none;
  animation: modal-in 0.15s ease;
}
.dropdown.open .dropdown-menu { display: block; }
[dir="ltr"] .dropdown-menu { right: 0; }
[dir="rtl"] .dropdown-menu { left: 0; }
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; font-size: 0.929rem;
  color: var(--text-2); cursor: pointer; transition: all var(--transition);
}
.dropdown-item:hover { background: var(--bg-4); color: var(--text); }