/* =========================
   Design Tokens (shared)
   ========================= */

:root {
  /* Core */
  --c-text: #333;
  --c-bg: #fff;

  /* Neutrals */
  --c-border: #777;
  --c-border-soft: #ddd;
  --c-muted: #666;
  --c-muted-2: #9a9a9a;

  /* Links */
  --c-link: #0066cc;

  /* Accent (neutral default; set per-view) */
  --c-accent: #111;

  /* Radii */
  --r-sm: 0.25rem;
  --r-md: 0.5rem;
  --r-lg: 0.75rem;
  --r-xl: 1rem;

  /* Layout widths - responsive */
  --page-narrow: 32rem;      /* Mobile/forms: 512px */
  --page-wide: 64rem;        /* Tables/lists: 1024px - original */
  --page-max: 80rem;         /* Full-width views: 1280px */

  /* ── Subway Line Colors ── */
  --subway-orange:   #FF6319;   /* Receiving */
  --subway-blue:     #0139A6;   /* Delivery tracking */
  --subway-yellow:   #FCCC0B;   /* Requesting */
  --subway-magenta:  #B934AD;   /* Outgoing/BOL */
  --subway-green:    #01933C;   /* Completing */
  --subway-gray:     #A7A9AC;   /* Inventory views */
  --subway-brown:    #996634;   /* User management */
  --subway-purple:   #6E3667;   /* Invoicing */
  --subway-teal:     #2A7B9B;   /* Site management */
  --subway-red:      #EE352E;   /* Review/Approval */
  --subway-seagreen: #2E8B57;   /* Contractor portal */
  --subway-lime:     #6CBE45;   /* Approval queue */

  /* ── Header Icon System ── */
  --icon-size:       2rem;      /* 32px desktop */
  --icon-size-sm:    1.75rem;   /* 28px mobile */
  --icon-color:      #4A5568;   /* Slate */
  --icon-hover:      #2D3748;   /* Dark slate */
  --icon-touch-min:  2.75rem;   /* 44px WCAG minimum */

  /* ── Message / Alert Colors ── */
  --msg-success-bg:     #d4edda;
  --msg-success-border: #28a745;
  --msg-success-text:   #155724;
  --msg-error-bg:       #f8d7da;
  --msg-error-border:   #dc3545;
  --msg-error-text:     #721c24;
  --msg-warning-bg:     #fff3cd;
  --msg-warning-border: #ffc107;
  --msg-warning-text:   #856404;
  --msg-info-bg:        #d1ecf1;
  --msg-info-border:    #17a2b8;
  --msg-info-text:      #0c5460;

  /* ── Badge Colors ── */
  --badge-danger:  #e41e3f;    /* Notification count */
  --badge-bg:      #e9ecef;    /* Role badge background */
  --badge-text:    #495057;    /* Role badge text */

  /* ── Action Button Semantic Colors ── */
  --btn-success:         #28a745;
  --btn-success-hover:   #218838;
  --btn-success-disabled:#94d3a2;
  --btn-warning:         #ffc107;
  --btn-warning-hover:   #e0a800;
  --btn-danger:          #dc3545;
  --btn-danger-hover:    #c82333;
  --btn-disabled:        #A7A9AC;
}

/* =========================
   Messages / Alerts
   ========================= */

.messages {
  text-align: center;
  margin-bottom: 1rem;
}

.message {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: var(--r-md);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.message--success {
  background-color: var(--msg-success-bg);
  border: 1px solid var(--msg-success-border);
  color: var(--msg-success-text);
}

.message--error {
  background-color: var(--msg-error-bg);
  border: 1px solid var(--msg-error-border);
  color: var(--msg-error-text);
}

.message--warning {
  background-color: var(--msg-warning-bg);
  border: 1px solid var(--msg-warning-border);
  color: var(--msg-warning-text);
}

.message--info {
  background-color: var(--msg-info-bg);
  border: 1px solid var(--msg-info-border);
  color: var(--msg-info-text);
}

.warning-banner {
  padding: 0.75rem 1rem;
  border-radius: var(--r-md);
  background-color: var(--msg-warning-bg);
  border: 1px solid var(--msg-warning-border);
  color: var(--msg-warning-text);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* =========================
   View Accent Overrides
   (NYC subway palette idea)
   ========================= */

/* Default (neutral) */
body {
  --c-accent: #111;
}

/* Receive Batch */
body#view-receive-batch {
  --c-accent: var(--subway-orange);
}

/* Upcoming Deliveries */
body#view-upcoming-deliveries {
  --c-accent: var(--subway-blue);
}

/* Batch Status */
body#view-batch-status {
  --c-accent: var(--subway-blue);
}

/* Request Delivery */
body#view-request-delivery {
  --c-accent: var(--subway-yellow);
}

/* Record Outgoing BOL */
body#view-create-outgoing-bol {
  --c-accent: var(--subway-magenta);
}

body#view-create-outgoing-bol .truck-contents h3,
body#view-create-outgoing-bol .truck-contents-header,
body#view-create-outgoing-bol .form-section-title {
  border-top: none;
  padding-top: 0;
}

body#view-create-outgoing-bol .print-button {
  margin: 1.5rem 0 0;
  background-color: var(--c-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  padding: 0.8rem 1.5rem;
  font-weight: 600;
  border-radius: var(--r-md);
}

body#view-create-outgoing-bol .print-button:disabled {
  background-color: #A7A9AC;
  cursor: not-allowed;
  opacity: 0.7;
}

body#view-create-outgoing-bol .col-requested,
body#view-create-outgoing-bol .col-shipped,
body#view-create-outgoing-bol .col-remaining {
  text-align: center;
}

/* Complete Delivery */
body#view-complete-delivery {
  --c-accent: var(--subway-green);
}

/* View Batches / Inventory (neutral views) */
body#view-batches,
body#view-batch-detail {
  --c-accent: var(--subway-gray);
}

/* View Users / User Detail */
body#view-users,
body#view-user-detail {
  --c-accent: var(--subway-brown);
}

body#view-users .table-card {
  border: none;
  border-radius: 0;
}

body#view-users .email-link {
  text-decoration: underline;
  color: var(--c-accent);
}

body#view-users .users-table {
  margin-top: 0;
}

/* Create Invoice */
body#view-create-invoice {
  --c-accent: var(--subway-purple);
}

body#view-create-invoice .button.button--primary,
body#view-create-invoice .generate-btn {
  background-color: var(--c-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  padding: 0.8rem 1.5rem;
  font-weight: 600;
  border-radius: var(--r-md);
}

body#view-create-invoice .context-info h3 {
  padding-top: 0;
}

body#view-create-invoice .step.completed .step-number {
  background-color: #A7A9AC;
  color: #fff;
}

body#view-create-invoice .line-items-table .text-center,
body#view-create-invoice .line-items-table .qty-cell,
body#view-create-invoice .line-items-table .days-cell {
  text-align: center;
}

body#view-create-invoice .line-items-table input[type="number"] {
  padding: 0.2rem;
}

body#view-create-invoice .line-note-display {
  white-space: nowrap;
}

body#view-create-invoice .details-panel h2 {
  padding-top: 0;
}

body#view-create-invoice .details-panel textarea {
  width: 100%;
}

/* Approval Queue (review workflow) */
body#view-approval-queue {
  --c-accent: var(--subway-lime);
}

/* Approval Queue — mobile overrides */
@media (max-width: 768px) {
  body#view-approval-queue .stats-bar {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
  }
  body#view-approval-queue .stat-item {
    flex: 1;
    min-width: 0;
    text-align: center;
  }
  body#view-approval-queue .batches-table td:first-child {
    white-space: nowrap;
  }
  body#view-approval-queue .batches-table td:nth-child(4) {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Kickback Queue (review workflow) */
body#view-kickback-queue {
  --c-accent: var(--subway-red);
}

/* Contractor Portal */
body#view-contractor-portal {
  --c-accent: var(--subway-seagreen);
}

/* Site Management */
body#view-site-management {
  --c-accent: var(--subway-teal);
}

/* Warehouse Management */
body#view-warehouse-management {
  --c-accent: var(--subway-yellow);
}

body#view-site-management .contractor-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  align-items: baseline;
}

body#view-site-management .billing-info {
  border-top: none;
}

body#view-site-management .assign-dropdown {
  padding: 0.3rem 1.8rem 0.3rem 0.5rem;
}

body#view-site-management .edit-link {
  padding: 0 0.6rem;
}

body#view-site-management .add-btn {
  background-color: var(--c-accent);
  color: #fff;
  border: none;
  padding: 0.8rem 1.5rem;
  font-weight: 600;
  border-radius: var(--r-md);
  cursor: pointer;
}

/* View Invoices / Invoice Preview */
body#view-invoices,
body#view-invoice-preview {
  --c-accent: #000;
}

/* Invoices List */
body#view-invoices .filter-search {
  width: 100%;
  max-width: none;
}

body#view-invoices .tab-btn[href="?tab=paid"].active .tab-count {
  color: #fff;
}

body#view-invoices .invoices-table-wrap {
  overflow-x: auto;
}

body#view-invoices .invoices-table {
  width: 100%;
  table-layout: auto;
}

body#view-invoices .invoice-link {
  text-decoration: underline;
  color: var(--c-accent);
}

/* Invoice Preview */
body#view-invoice-preview .invoice-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

body#view-invoice-preview .invoice-actions .button,
body#view-invoice-preview .invoice-actions a,
body#view-invoice-preview .invoice-actions button {
  background-color: var(--c-accent);
  color: #fff;
  border: none;
  padding: 0.8rem 1.5rem;
  font-weight: 600;
  border-radius: var(--r-md);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

/* Profile */
body#user-profile {
  --c-accent: #000;
}

/* Edit User / Add User */
body#view-create-user {
  --c-accent: var(--subway-brown);
}



/* =========================
   Base
   ========================= */

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  color: var(--c-text);
  background-color: var(--c-bg);
}

/* =========================
   Layout & Page Structure
   ========================= */

.page {
  max-width: var(--page-narrow);
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

.page--wide {
  max-width: var(--page-wide);
}

.page--max {
  max-width: var(--page-max);
}

/* Tablet+ : more breathing room */
@media (min-width: 768px) {
  .page {
    padding: 2rem 2.5rem 3rem;
  }

  /* Forms can be wider on tablet/desktop */
  .page:not(.page--wide):not(.page--max) {
    max-width: 40rem; /* 640px - better for forms */
  }
}

/* Desktop: generous padding */
@media (min-width: 1024px) {
  .page {
    padding: 2.5rem 3rem 4rem;
  }
}

/* Large desktop: even more space for wide pages */
@media (min-width: 1440px) {
  .page--wide,
  .page--max {
    padding-left: 4rem;
    padding-right: 4rem;
  }
}

/* Small screens: constrain wide pages */
@media (max-width: 560px) {
  .page--wide {
    max-width: 100%;
  }
}

/* =========================
   Header
   ========================= */

.header {
  position: relative;
  text-align: center;
  margin-bottom: 1.25rem;
}

.logo {
  max-width: 8rem;
  margin: 0 auto;
  display: block;
}

.logo-link {
  display: block;
  margin: 0 auto;
  width: fit-content;
}

/* Header actions row (bell + sign out) */
.header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

/* Notification bell */
.notification-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--icon-color);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.notification-bell:hover {
  color: var(--icon-hover);
}

.notification-bell svg {
  width: var(--icon-size);
  height: var(--icon-size);
}

/* Badge count */
.notification-badge {
  position: absolute;
  bottom: 2px;
  right: -6px;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--badge-danger);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.25rem;
  text-align: center;
  text-decoration: none;
  pointer-events: none;
}

.notification-badge:empty {
  display: none;
}

/* Notification Dropdown */
.notification-bell-wrap {
  position: relative;
}

.notification-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
}

.notification-dropdown-item {
  display: block;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--c-border);
}

.notification-dropdown-item:hover {
  background: #f5f5f5;
}

.notification-dropdown-item--unread {
  background: #e8f4fd;
}

.notification-dropdown-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 0 0.15rem;
}

.notification-dropdown-message {
  font-size: 0.8rem;
  color: var(--c-muted);
  margin: 0 0 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-dropdown-time {
  font-size: 0.75rem;
  color: #999;
  margin: 0;
}

.notification-dropdown-more {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--c-muted);
  border-bottom: 1px solid var(--c-border);
}

.notification-dropdown-viewall {
  display: block;
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--c-accent);
  text-decoration: none;
  font-weight: 600;
}

.notification-dropdown-viewall:hover {
  background: #f5f5f5;
}

.notification-dropdown-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--c-muted);
  font-size: 0.85rem;
}

@media (max-width: 640px) {
  .notification-dropdown {
    position: fixed;
    top: auto;
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
  }
}

.sign-out {
  font-size: 0.9rem;
  text-decoration: underline;
  color: var(--c-link);
}

.user-menu {
  position: relative;
}

.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--icon-color);
  font-size: 0.9rem;
  padding: 0.5rem;
  border-radius: var(--r-md);
  min-height: var(--icon-touch-min);
}

.user-menu-toggle:hover {
  color: var(--icon-hover);
  background: rgba(0, 0, 0, 0.05);
}

.user-menu-toggle svg {
  width: var(--icon-size);
  height: var(--icon-size);
}

@media (max-width: 640px) {
  .notification-bell svg {
    width: var(--icon-size-sm);
    height: var(--icon-size-sm);
  }
  .user-menu-toggle svg {
    width: var(--icon-size-sm);
    height: var(--icon-size-sm);
  }
}

.user-menu-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  min-width: 140px;
  z-index: 100;
  overflow: hidden;
}

.user-menu-dropdown a {
  display: block;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  color: var(--c-text);
  text-decoration: none;
}

.user-menu-dropdown a:hover {
  background: #f5f5f5;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--c-accent);
  margin: 0;
}

.divider {
  height: 1px;
  background-color: var(--c-accent);
  margin: 1.25rem 0;
}

/* Desktop header improvements */
@media (min-width: 768px) {
  .header {
    margin-bottom: 1.5rem;
  }

  .logo {
    max-width: 10rem;
  }

  .header h1 {
    font-size: 1.75rem;
  }

  .divider {
    height: 2px;
    margin: 1.5rem 0;
  }
}

@media (min-width: 1024px) {
  .header {
    margin-bottom: 2rem;
  }

  .header h1 {
    font-size: 2rem;
  }

  .divider {
    margin: 1.75rem 0;
  }
}

/* =========================
   Form
   ========================= */

.form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group-row {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  width: 100%;
}

.form-group-row > .form-group {
  flex: 1 1 0;
  min-width: 0;
}

label {
  font-size: 0.95rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  box-sizing: border-box;
}

/* Strip native Safari/iOS form control styling */
input,
select,
textarea,
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

/* Restore native appearance for checkboxes and radios */
input[type="checkbox"],
input[type="radio"] {
  appearance: auto;
  -webkit-appearance: auto;
  -moz-appearance: auto;
  width: auto;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23333' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px 8px;
  padding-right: 2.25rem;
  background-color: #fff;
}

/* Flatpickr inputs */
.flatpickr-input,
.flatpickr-alt-input,
input.flatpickr-input {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #aaa;
}

/* Desktop form improvements */
@media (min-width: 768px) {
  .form {
    gap: 1.5rem;
  }

  .form-group-row {
    gap: 1.5rem;
  }

  label {
    font-size: 1rem;
  }

  input,
  select,
  textarea {
    padding: 0.85rem 1rem;
  }
}

@media (min-width: 1024px) {
  .form {
    gap: 1.75rem;
  }

  .form-group-row {
    gap: 2rem;
  }
}

/* =========================
   Toolbar / Buttons
   ========================= */

.toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 0.75rem 0 1rem;
}

.toolbar--between {
  justify-content: space-between;
  align-items: center;
}

/* ── Base Button ── */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.6rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: normal;
  text-align: center;
  text-decoration: none;
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  color: var(--c-text);
  background: transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

/* ── Variants ── */
.button--primary {
  background-color: var(--c-accent);
  border-color: var(--c-accent);
  color: #fff;
}

.button--primary:hover {
  opacity: 0.85;
}

.button--success {
  background-color: var(--btn-success);
  border-color: var(--btn-success);
  color: #fff;
}

.button--success:hover {
  background-color: var(--btn-success-hover);
  border-color: var(--btn-success-hover);
}

.button--warning {
  background-color: var(--btn-warning);
  border-color: var(--btn-warning);
  color: #212529;
}

.button--warning:hover {
  background-color: var(--btn-warning-hover);
  border-color: var(--btn-warning-hover);
}

.button--danger {
  background-color: var(--btn-danger);
  border-color: var(--btn-danger);
  color: #fff;
}

.button--danger:hover {
  background-color: var(--btn-danger-hover);
  border-color: var(--btn-danger-hover);
}

.button--secondary {
  background: transparent;
  border: 1px solid var(--c-border);
  color: var(--c-text);
}

.button--secondary:hover {
  background-color: #f5f5f5;
}

/* ── Focus (keyboard navigation) ── */
.button:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* ── Disabled States ── */
.button--primary:disabled,
.button--success:disabled,
.button--warning:disabled,
.button--danger:disabled {
  background-color: var(--btn-disabled);
  border-color: var(--btn-disabled);
  color: #fff;
  cursor: not-allowed;
  opacity: 0.7;
}

.button--secondary:disabled {
  color: var(--btn-disabled);
  border-color: var(--c-border-soft);
  cursor: not-allowed;
  opacity: 0.7;
}

/* ── Sizes ── */
.button--sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
}

.button--xs {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

/* ── Full-width variant ── */
.button--full {
  width: 100%;
}

/* Submit (kept as a “special” full-width button) */
.submit-button {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  background-color: var(--c-accent);
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
}

.submit-button:disabled {
  background-color: var(--btn-disabled);
  border-color: var(--btn-disabled);
  color: #fff;
  cursor: not-allowed;
  opacity: 0.7;
}

.filter-toggle,
button[type=”button”] {
  cursor: pointer;
}

.filter-row {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
}

.remove-photo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.required-note {
  font-size: 0.85rem;
  margin: 0;
}

/* Upload */
.upload-button {
  display: block;
  width: 100%;
  padding: 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  background-color: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  cursor: pointer;
}

/* Form Help Text */
.form-help {
  font-size: 0.85rem;
  color: var(--c-muted);
  margin-top: 0.25rem;
}

.approval-required-hint {
  color: #d97706;
  font-weight: bold;
}

.form-help--approval {
  color: #d97706;
  font-style: italic;
}

/* Form Section Title */
.form-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--c-accent);
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--c-border-soft);
}

/* (Button sizes now defined in the button system above) */

/* =========================
   Table (Users)
   ========================= */

.table-card {
  border-top: 1px solid var(--c-border);
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
}

.users-table th,
.users-table td {
  text-align: left;
  padding: 0.85rem 0.5rem;
  border-bottom: 1px solid var(--c-border);
  font-size: 0.95rem;
  vertical-align: middle;
}

.users-table th {
  font-weight: 700;
}

.email-link {
  color: var(--c-link);
  text-decoration: underline;
}

.col-last-active {
  white-space: nowrap;
}

/* Desktop table improvements */
@media (min-width: 768px) {
  .users-table th,
  .users-table td {
    padding: 1rem 0.75rem;
    font-size: 1rem;
  }
}

@media (min-width: 1024px) {
  .users-table th,
  .users-table td {
    padding: 1.1rem 1rem;
  }
}

/* Responsive column hiding */
@media (max-width: 900px) {
  .col-last-active {
    display: none;
  }
}
@media (max-width: 720px) {
  .col-active {
    display: none;
  }
}
@media (max-width: 560px) {
  .col-admin {
    display: none;
  }
}

/* =========================
   Modal
   ========================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-backdrop.active {
  display: flex;
}

.modal {
  background: #fff;
  width: 100%;
  max-width: 28rem;
  padding: 1.5rem;
  border-radius: var(--r-xl);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.modal--wide {
  max-width: 40rem;
}

.modal h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.modal-blurb {
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
  color: var(--c-text);
}

.modal label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.modal input[type="email"] {
  width: 100%;
  padding: 0.6rem 0.7rem;
  font-size: 0.95rem;
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* =========================
   Cards / Layout Helpers
   ========================= */

.card {
  border-top: 1px solid var(--c-border);
  padding: 1rem 0;
}

.card-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.card-row {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.card-field .label {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.card-field .value {
  font-size: 0.95rem;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 720px) {
  .grid-two {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* =========================
   Chips
   ========================= */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--c-border);
  font-size: 0.9rem;
}

.chip--subtle {
  background: #f5f5f5;
}

/* =========================
   Accordion
   ========================= */

.accordion {
  border-top: 1px solid var(--c-border);
}

.accordion:last-child {
  border-bottom: 1px solid var(--c-border);
}

.accordion-header {
  width: 100%;
  background: transparent;
  border: none;
  padding: 0.9rem 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
  cursor: pointer;
  font-size: 0.95rem;
}

.accordion-icon {
  font-weight: 800;
  width: 1.5rem;
  text-align: center;
}

.accordion-body {
  padding: 0 0 1rem 0;
}

.muted {
  color: #444;
  font-size: 0.92rem;
}

.activity-list {
  margin: 0.6rem 0 0 1.2rem;
}

/* =========================
   Form Grid / Toggles (modal layouts)
   ========================= */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 2rem;
}

@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.toggle-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.modal-section {
  margin-top: 1.25rem;
}

.section-title {
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem 1rem;
}

.checkbox-grid--small {
  grid-template-columns: repeat(5, minmax(2rem, 1fr));
}

@media (max-width: 560px) {
  .checkbox-grid {
    grid-template-columns: 1fr;
  }
  .checkbox-grid--small {
    grid-template-columns: repeat(3, minmax(2rem, 1fr));
  }
}

.checkbox {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* =========================
   Edit User modal spacing
   ========================= */

.form-basics {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
}

.basic-block {
  min-width: 16rem;
}

.basic-block--right {
  min-width: auto;
}

.checkbox--inline {
  margin-top: 0.25rem;
}

.modal-section--spaced {
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid #e0e0e0;
}

@media (max-width: 720px) {
  .form-basics {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .basic-block {
    min-width: 100%;
  }
}

/* =========================
   Recent Activity (muted)
   ========================= */

.activity-muted {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--c-border-soft);
  color: var(--c-muted);
}

.activity-toggle {
  background: transparent;
  border: none;
  padding: 0;
  color: #555;
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.95rem;
}

.activity-panel {
  margin-top: 0.6rem;
  background: #f6f6f6;
  border: 1px solid var(--c-border-soft);
  border-radius: 0.6rem;
  padding: 0.5rem 0.75rem;
}

.activity-list-simple {
  font-size: 0.82rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity-list-simple li {
  display: grid;
  grid-template-columns: 13.5rem 1fr;
  column-gap: 0.4rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--c-border-soft);
}

.activity-list-simple li:last-child {
  border-bottom: none;
}

.activity-ts {
  font-weight: 500;
  color: #555;
  white-space: nowrap;
}

.activity-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.8rem;
  color: var(--c-text);
}

@media (max-width: 720px) {
  .activity-list-simple li {
    grid-template-columns: 1fr;
  }

  .activity-ts {
    margin-bottom: 0.15rem;
    font-size: 0.75rem;
  }
}

/* =========================
   User Summary
   ========================= */

.user-summary {
  border-top: 1px solid var(--c-border);
  padding: 1rem 0 1.25rem;
}

.user-identity {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  flex-wrap: wrap;
}

.user-primary {
  min-width: 16rem;
}

.user-name {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.user-email {
  font-size: 0.95rem;
}

.user-meta {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.meta-item {
  font-size: 0.85rem;
}

.meta-label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.meta-value {
  white-space: nowrap;
}

@media (max-width: 720px) {
  .user-identity {
    flex-direction: column;
    gap: 0.75rem;
  }

  .user-meta {
    gap: 1.25rem;
  }
}

/* =========================
   View: Receive Batch
   ========================= */

body#view-receive-batch .form-group-row {
    display: flex;
    gap: 1rem;
    width: 100%;
}

body#view-receive-batch .form-group-row > .form-group {
    flex: 1 1 0;
    min-width: 0;
}

body#view-receive-batch .form-group input,
body#view-receive-batch .form-group select,
body#view-receive-batch .form-group textarea {
    width: 100%;
}

body#view-receive-batch .add-item-button,
body#view-receive-batch [x-show] .button {
  border: 1px solid var(--c-border);
  background: #F8F9FA;
  cursor: pointer;
}

body#view-receive-batch .form-group-row {
  padding-bottom: 1rem;
}

body#view-receive-batch .form-group-row > * {
  padding-bottom: 0;
}

body#view-receive-batch .form-section:first-of-type {
  margin-top: 0;
}

/* 3-up row behavior: stack only on truly tiny screens */
@media (max-width: 359px) {
    body#view-receive-batch .form-group-row--three {
        flex-direction: column;
    }
}


/* =========================
   View: Batch Status
   (scoped + clean)
   ========================= */

body#view-batch-status .batch-title {
  margin-top: 0.5rem;
}

body#view-batch-status .batch-id {
  font-weight: 700;
}

body#view-batch-status .status-timeline {
  max-width: 50rem;
  margin: 0 auto;
}

body#view-batch-status .status-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

body#view-batch-status .status-item {
  display: grid;
  grid-template-columns: 3.25rem 1fr auto;
  column-gap: 0.9rem;
  align-items: start;
  padding: 0.85rem 0;
}

body#view-batch-status .status-marker {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

body#view-batch-status .status-dot {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--c-accent);
  color: #fff;
  position: relative;
  z-index: 2;
}

body#view-batch-status .status-line {
  position: absolute;
  top: 2rem;
  bottom: -2rem;
  width: 0.22rem;
  background: var(--c-accent);
  border-radius: 999px;
}

body#view-batch-status .status-item:last-child .status-line {
  display: none;
}

body#view-batch-status .status-check {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
}

body#view-batch-status .status-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--c-accent);
  margin-bottom: 0.15rem;
}

body#view-batch-status .status-ts {
  color: var(--c-muted-2);
  font-size: 0.82rem;
  line-height: 1.25;
}

body#view-batch-status .status-detail-link {
  color: var(--c-accent);
  text-decoration: underline;
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
}

body#view-batch-status .status-action-spacer {
  display: inline-block;
  width: 6.2rem;
  height: 1rem;
}

/* states */
body#view-batch-status .status-item--pending .status-dot,
body#view-batch-status .status-item--pending .status-line {
  background: #bdbdbd;
}

body#view-batch-status .status-name--muted {
  color: #b0b0b0;
  font-weight: 700;
}

body#view-batch-status .status-item--active .status-check {
  display: none;
}

body#view-batch-status .status-active-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: #fff;
}

/* active transitions to gray line afterward */
body#view-batch-status .status-item--active .status-line {
  background: #bdbdbd;
}

body#view-batch-status .status-modal-body {
  border-top: 1px solid #e6e6e6;
  padding-top: 0.9rem;
  margin-top: 0.75rem;
  line-height: 1.45;
}

@media (max-width: 720px) {
  body#view-batch-status .status-item {
    grid-template-columns: 3rem 1fr auto;
    column-gap: 0.8rem;
  }

  body#view-batch-status .status-dot {
    width: 2.25rem;
    height: 2.25rem;
  }

  body#view-batch-status .status-name {
    font-size: 1.02rem;
  }

  body#view-batch-status .status-detail-link {
    font-size: 0.9rem;
  }
}

/* =========================
   Filters
   ========================= */

body#view-upcoming-deliveries .deliveries-filters {
  margin: 0 0 1rem;
}



body#view-upcoming-deliveries .filter-item,
body#view-upcoming-deliveries .filter-item--search {
  width: 100%;
  min-width: 0;
  margin: 0 0 0.85rem 0;
}

body#view-upcoming-deliveries .filter-item select,
body#view-upcoming-deliveries .filter-item input {
  width: 100%;
}

/* =========================
   Table
   ========================= */

body#view-upcoming-deliveries .deliveries-card {
  margin-top: 0.5rem;
}

body#view-upcoming-deliveries .deliveries-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0;
}

body#view-upcoming-deliveries .deliveries-table th,
body#view-upcoming-deliveries .deliveries-table td {
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--c-border);
  padding: 0.85rem 0.35rem;
  font-size: 0.9rem;
}

/* Column behavior */
body#view-upcoming-deliveries .col-date {
  width: 1%;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

body#view-upcoming-deliveries .col-action {
  width: 1%;
  white-space: nowrap;
}

body#view-upcoming-deliveries .col-status {
  color: var(--c-muted);
  white-space: normal;
  text-align: center;
}

/* =========================
   Batch link + phase
   ========================= */

body#view-upcoming-deliveries .batch-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}

body#view-upcoming-deliveries .batch-link:hover {
  color: var(--c-accent);
}

body#view-upcoming-deliveries .batch-phase {
  color: var(--c-muted);
  margin-left: 0.35rem;
}

/* =========================
   Items (single type)
   ========================= */

body#view-upcoming-deliveries .items-single {
  color: var(--c-muted);
  font-weight: 600;
  white-space: nowrap;
}

body#view-upcoming-deliveries .items-single strong {
  font-weight: 800;
}

/* =========================
   Buttons
   ========================= */

body#view-upcoming-deliveries .button--compact {
  padding: 0.42rem 0.8rem;
  font-size: 0.85rem;
  border-radius: 999px;
}

/* =========================
   Responsive Adjustments
   ========================= */

/* Hide Action column on small screens */
@media (max-width: 520px) {
  body#view-upcoming-deliveries th.col-action,
  body#view-upcoming-deliveries td.col-action {
    display: none;
  }

  body#view-upcoming-deliveries .deliveries-table th,
  body#view-upcoming-deliveries .deliveries-table td {
    padding: 0.85rem 0.3rem;
    font-size: 0.88rem;
  }
}

/* =========================
   View: Complete Delivery
   ========================= */

/* If you want a slightly larger notes box ONLY on this view */
body#view-complete-delivery textarea {
  min-height: 8rem;
}

/* =========================
   View: Request Delivery
   ========================= */

/* Delivery Address should be a larger box (desktop mockup style) */
body#view-request-delivery textarea {
  min-height: 8rem;
}

/* =========================
   View: Create Outgoing BOL
   ========================= */

/* =========================
   View: Upcoming Deliveries
   ========================= */

/* Basic layout hooks (only if you don't already have equivalents) */
body#view-upcoming-deliveries .page {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem;
}

body#view-upcoming-deliveries .header {
  position: relative;
  text-align: center;
  padding-top: 0.25rem;
}

body#view-upcoming-deliveries .sign-out {
  position: absolute;
  top: 0;
  right: 0;
  text-decoration: underline;
}


body#view-upcoming-deliveries .page-title {
  margin: 0.25rem 0 0.75rem;
  color: var(--c-accent);
}

body#view-upcoming-deliveries .page-rule {
  border: 0;
  border-top: 2px solid var(--c-accent);
  margin: 0.75rem 0 1.25rem;
}

/* Filters */
body#view-upcoming-deliveries .deliveries-filters {
  margin-bottom: 1.25rem;
}

body#view-upcoming-deliveries .filter-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

body#view-upcoming-deliveries .filter-search {
  width: 100%;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--c-border);
  border-radius: 6px;
}

/* Table container */
body#view-upcoming-deliveries .deliveries-table-wrap {
  border-top: 1px solid var(--c-border);
}

/* Table */
body#view-upcoming-deliveries .deliveries-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* enables predictable truncation */
  margin-top: 0;
}

body#view-upcoming-deliveries .deliveries-table th,
body#view-upcoming-deliveries .deliveries-table td {
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--c-border);
  padding: 0.85rem 0.55rem; /* column spacing */
  font-size: clamp(0.78rem, 2.2vw, 0.92rem);
  line-height: 1.25;

  /* allow our intentional 2-line stack */
  white-space: normal;
  overflow: hidden;
}

/* Column widths (stacked mobile-friendly) */
body#view-upcoming-deliveries th.col-batch,
body#view-upcoming-deliveries td.col-batch { width: 30%; }

body#view-upcoming-deliveries th.col-location,
body#view-upcoming-deliveries td.col-location { width: 34%; }

body#view-upcoming-deliveries th.col-status,
body#view-upcoming-deliveries td.col-status { width: 20%; }

body#view-upcoming-deliveries th.col-action,
body#view-upcoming-deliveries td.col-action {
  width: 16%;
  text-align: right;
}

/* Headings */
/* Status heading must NOT be muted */
body#view-upcoming-deliveries th.col-status {
  color: inherit;
}

/* Stacked cell lines: never wrap, always ellipsis */
body#view-upcoming-deliveries .cell-primary,
body#view-upcoming-deliveries .cell-sub {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body#view-upcoming-deliveries .cell-sub {
  color: var(--c-muted);
  font-size: 0.86em;
  margin-top: 0.12rem;
}

/* Batch link */
body#view-upcoming-deliveries .batch-link {
  color: inherit;
  font-weight: 600;
}

body#view-upcoming-deliveries .batch-link:hover,
body#view-upcoming-deliveries .batch-link:focus-visible {
  text-decoration: underline;
}

/* Muted rows (delivered/etc) */
body#view-upcoming-deliveries tr.row--muted td {
  color: #b0b0b0;
}

body#view-upcoming-deliveries tr.row--muted td .cell-sub {
  color: #b0b0b0;
}

/* Compact buttons for this view */
body#view-upcoming-deliveries .button--compact {
  padding: 0.42rem 0.8rem;
  font-size: 0.82rem;
  border-radius: 999px;
  white-space: nowrap;
  min-width: 6rem;
  text-align: center;
}

/* Filter toggle fixed width */
body#view-upcoming-deliveries .filter-toggle {
  min-width: 8rem;
  text-align: center;
  cursor: pointer;
}

/* Reduce expand-cell and child-indent */
body#view-upcoming-deliveries .expand-cell {
  width: 2rem;
  padding: 0.25rem;
}

body#view-upcoming-deliveries .child-indent {
  width: 1.5rem;
}

/* Multi-item batches each on own line */
body#view-upcoming-deliveries .item-list .item {
  display: block;
}

/* Status text no-wrap */
body#view-upcoming-deliveries .status-badge {
  white-space: nowrap;
}

/* If Action is too tight, drop it */
@media (max-width: 520px) {
  body#view-upcoming-deliveries th.col-action,
  body#view-upcoming-deliveries td.col-action {
    display: none;
  }

  body#view-upcoming-deliveries th.col-batch,
  body#view-upcoming-deliveries td.col-batch { width: 34%; }

  body#view-upcoming-deliveries th.col-location,
  body#view-upcoming-deliveries td.col-location { width: 40%; }

  body#view-upcoming-deliveries th.col-status,
  body#view-upcoming-deliveries td.col-status { width: 26%; }
}

/* Mobile overrides for upcoming deliveries */
@media (max-width: 768px) {
  body#view-upcoming-deliveries .deliveries-table {
    min-width: unset;
  }
  body#view-upcoming-deliveries .deliveries-table th:first-child,
  body#view-upcoming-deliveries .expand-cell,
  body#view-upcoming-deliveries .child-indent {
    display: none;
  }
  body#view-upcoming-deliveries .action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* =========================
   View: View Batches
   ========================= */

/* Layout hooks (only on this page) */
body#view-batches .page {
  margin: 0 auto;
  padding: 1rem;
}

body#view-batches .header {
  position: relative;
  text-align: center;
  padding-top: 0.25rem;
}

body#view-batches .sign-out {
  position: absolute;
  top: 0;
  right: 0;
  text-decoration: underline;
}


body#view-batches .page-title {
  margin: 0.25rem 0 0.75rem;
  color: var(--c-accent);
}

body#view-batches .page-rule {
  border: 0;
  border-top: 2px solid var(--c-accent);
  margin: 0.75rem 0 1.25rem;
}

/* Filters */
body#view-batches .batches-filters {
  margin-bottom: 1.25rem;
}

body#view-batches .filter-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

body#view-batches .filter-search {
  width: 100%;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--c-border);
  border-radius: 6px;
}

/* Table wrap */
body#view-batches .batches-table-wrap {
  border-top: 1px solid var(--c-border);
}

/* Table (unstacked cells) */
body#view-batches .batches-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* predictable truncation */
}

body#view-batches .batches-table th,
body#view-batches .batches-table td {
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--c-border);
  padding: 0.85rem 0.55rem; /* spacing between columns */
  font-size: clamp(0.78rem, 2.1vw, 0.92rem);
  line-height: 1.25;

  /* hard rule: no wrapping anywhere */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body#view-batches .batches-table th {
  font-weight: 700;
}

/* Column widths (desktop/tablet baseline) */
body#view-batches th.col-batch,
body#view-batches td.col-batch { width: 22%; }

body#view-batches th.col-po,
body#view-batches td.col-po { width: 22%; }

body#view-batches th.col-status,
body#view-batches td.col-status { width: 22%; }

body#view-batches th.col-received,
body#view-batches td.col-received { width: 17%; }

body#view-batches th.col-delivered,
body#view-batches td.col-delivered { width: 17%; }

/* Batch link */
body#view-batches .batch-link {
  color: inherit;
  font-weight: 800;
  text-decoration: none;
}

body#view-batches .batch-link:hover,
body#view-batches .batch-link:focus-visible {
  text-decoration: underline;
}

/* Optional muted row */
body#view-batches tr.row--muted td {
  color: #b0b0b0;
}

/* At small resolutions: both dates fall off */
@media (max-width: 560px) {
  body#view-batches th.col-received,
  body#view-batches td.col-received,
  body#view-batches th.col-delivered,
  body#view-batches td.col-delivered {
    display: none;
  }

  /* Rebalance remaining columns */
  body#view-batches th.col-batch,
  body#view-batches td.col-batch { width: 34%; }

  body#view-batches th.col-po,
  body#view-batches td.col-po { width: 33%; }

  body#view-batches th.col-status,
  body#view-batches td.col-status { width: 33%; }
}


body#view-batches .batch-link {
  text-decoration: underline;
}

/* =========================
   View: Batch Detail (Single Batch)
   ========================= */

/* Title formatting */
body#view-batch-detail .batch-page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--c-accent);
  margin: 0;
}

body#view-batch-detail .batch-page-id {
  font-weight: 800;
}

body#view-batch-detail .batch-page-status {
  font-weight: 700;
}

/* Sections */
body#view-batch-detail .batch-section {
  border-top: 1px solid var(--c-border);
  padding: 1rem 0 1.25rem;
}

body#view-batch-detail .batch-section:first-of-type {
  margin-top: 0.25rem;
}

body#view-batch-detail .batch-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.65rem;
}

body#view-batch-detail .batch-section-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

body#view-batch-detail .batch-section-edit {
  color: var(--c-text);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}

body#view-batch-detail .batch-section-spacer {
  width: 2rem;
}

/* Key/Value grid */
body#view-batch-detail .batch-kv-grid {
  display: grid;
  gap: 2rem;
}

body#view-batch-detail .batch-kv-grid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

body#view-batch-detail .batch-kv-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body#view-batch-detail .batch-kv {
  min-width: 0;
}

body#view-batch-detail .batch-k {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--c-muted);
  margin-bottom: 0.35rem;
}

body#view-batch-detail .batch-v {
  font-size: 1.1rem;
  font-weight: 500;
}

/* Contents grid */
body#view-batch-detail .batch-contents-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 2rem;
}

body#view-batch-detail .batch-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

body#view-batch-detail .batch-list li {
  font-size: 1.1rem;
  padding: 0.15rem 0;
}

/* Events */
body#view-batch-detail .batch-events {
  display: grid;
  gap: 0.7rem;
  padding-top: 0.25rem;
}

body#view-batch-detail .batch-event {
  display: grid;
  grid-template-columns: 1.6fr 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.25rem 0;
}

body#view-batch-detail .batch-event-name {
  font-size: 1.05rem;
  font-weight: 500;
}

body#view-batch-detail .batch-event-date {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 1.05rem;
}

body#view-batch-detail .batch-event-link {
  color: var(--c-text);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
  white-space: nowrap;
}

body#view-batch-detail .batch-event--muted {
  color: #b0b0b0;
}

body#view-batch-detail .batch-event--muted .batch-event-link {
  color: #b0b0b0;
}

/* Responsive */
@media (max-width: 980px) {
  body#view-batch-detail .batch-kv-grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
  }

  body#view-batch-detail .batch-kv-grid--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
  }

  body#view-batch-detail .batch-contents-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

@media (max-width: 560px) {
  body#view-batch-detail .batch-kv-grid--3 {
    grid-template-columns: 1fr;
  }

  body#view-batch-detail .batch-event {
    grid-template-columns: 1fr;
    gap: 0.25rem;
    align-items: start;
  }

  body#view-batch-detail .batch-event-link {
    justify-self: start;
  }
}

body#view-batch-detail .approval-actions h3 {
  padding-top: 0;
}

body#view-batch-detail .info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

body#view-batch-detail .save-changes-button,
body#view-batch-detail .request-delivery-button {
  background-color: #FCCC0A;
  color: #000;
  border-color: #FCCC0A;
}

/* =========================
   View: Notifications
   ========================= */

body#view-notifications .page {
  max-width: 40rem;
}

.notif-page {
  padding-top: 0.25rem;
}

.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.notif-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
}

.notif-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.notif-btn-mark-all {
  background: none;
  border: 1px solid var(--c-link);
  color: var(--c-link);
  padding: 0.3rem 0.7rem;
  border-radius: var(--r-sm);
  font-size: 0.8rem;
  cursor: pointer;
}

.notif-btn-mark-all:hover {
  background: var(--c-link);
  color: #fff;
}

.notif-unread-count {
  font-size: 0.85rem;
  color: var(--c-muted);
}

/* Filters */
.notif-filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.notif-filter {
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  text-decoration: none;
  background: #e4e6eb;
  color: var(--c-text);
}

.notif-filter:hover {
  background: #d0d2d6;
}

.notif-filter--active {
  background: var(--c-link);
  color: #fff;
}

/* Notification list */
.notif-list {
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-md);
  overflow: hidden;
}

.notif-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--c-border-soft);
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item--unread {
  background: #eef3ff;
}

.notif-item-body {
  flex: 1;
  min-width: 0;
}

.notif-item-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.notif-item-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.notif-new-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: var(--r-sm);
  background: #dbeafe;
  color: var(--c-link);
  font-size: 0.7rem;
  font-weight: 600;
}

.notif-item-message {
  margin: 0.15rem 0;
  font-size: 0.88rem;
  color: var(--c-muted);
}

.notif-item-time {
  font-size: 0.75rem;
  color: var(--c-muted-2);
}

.notif-item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.75rem;
  flex-shrink: 0;
}

.notif-link {
  font-size: 0.85rem;
  color: var(--c-link);
  text-decoration: none;
}

.notif-link:hover {
  text-decoration: underline;
}

.notif-btn-read {
  background: none;
  border: none;
  color: var(--c-muted-2);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--r-sm);
  display: inline-flex;
}

.notif-btn-read:hover {
  color: #28a745;
  background: #e8f5e9;
}

.notif-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--c-muted);
}

/* =========================
   View: Landing (Home)
   ========================= */

body#view-landing {
  --c-accent: #111; /* keep neutral for header/divider */
}

/* Layout - responsive */
body#view-landing .page {
  max-width: 40rem; /* mobile-first */
}

body#view-landing .landing {
  display: grid;
  gap: 1rem;
  padding-top: 0.25rem;
}

/* Tiles */
body#view-landing .landing-tile {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 4.25rem;
  padding: 1.25rem 1.5rem;

  border-radius: var(--r-md);
  border: 1px solid rgba(0, 0, 0, 0.28);

  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1.1;

  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

body#view-landing .landing-tile:hover,
body#view-landing .landing-tile:focus-visible {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  outline: none;
}

/* Tile Colors (subway palette) */
body#view-landing .landing-tile--receive    { background: var(--subway-orange); }
body#view-landing .landing-tile--upcoming   { background: var(--subway-blue); }
body#view-landing .landing-tile--bol        { background: var(--subway-magenta); }
body#view-landing .landing-tile--complete   { background: var(--subway-green); }
body#view-landing .landing-tile--batches    { background: var(--subway-gray); }
body#view-landing .landing-tile--approval   { background: var(--subway-lime); }
body#view-landing .landing-tile--kickback   { background: var(--subway-red); }
body#view-landing .landing-tile--invoice    { background: var(--subway-purple); }
body#view-landing .landing-tile--sites      { background: var(--subway-teal); }
body#view-landing .landing-tile--users      { background: var(--subway-brown); }
body#view-landing .landing-tile--warehouses { background: var(--subway-yellow); }
body#view-landing .landing-tile--contractor { background: var(--subway-seagreen); }
body#view-landing .landing-tile--invoices    { background: #000; }

/* =========================
   Crane Badge (global)
   ========================= */

.crane-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background-color: #f8d7da;
  color: #721c24;
  margin-left: 0.35rem;
  vertical-align: middle;
}


/* ==========================================================================
   Mobile Responsive Tables & Touch Targets
   ========================================================================== */

/* At 640px: remove fixed min-width, hide lower-priority columns */
@media (max-width: 640px) {
  .batches-table {
    min-width: 0 !important;
    table-layout: auto !important;
  }

  .batches-table .col-phase,
  .batches-table .col-count,
  .batches-table .col-shipped {
    display: none;
  }

  .batches-table th,
  .batches-table td {
    padding: 0.55rem 0.35rem;
    font-size: 0.85rem;
  }
}

/* At 480px: tighter spacing */
@media (max-width: 480px) {
  .batches-table th,
  .batches-table td {
    padding: 0.4rem 0.25rem;
    font-size: 0.82rem;
  }
}

/* Stats bar reflow (used in AWS portal, approval/kickback queues) */
@media (max-width: 640px) {
  .stats-bar {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .stats-bar .stat-item {
    flex: 1 1 45%;
    min-width: 0;
  }
}

@media (max-width: 375px) {
  .stats-bar .stat-item {
    flex: 1 1 100%;
  }
}

/* Touch targets for non-.button submit buttons */
button[type="submit"] {
  min-height: 44px;
}

/* Breadcrumbs */
.breadcrumb {
  padding: 0 0 1.5rem;
  font-size: 0.85rem;
  color: var(--c-muted);
}

.breadcrumb a {
  color: var(--c-accent);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb .separator {
  margin: 0 0.4rem;
  color: var(--c-muted);
}

/* =========================
   Dashboard Role Indicator
   ========================= */

.dashboard-role-indicator {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--c-muted);
  font-size: 0.95rem;
}

.dashboard-role-indicator p {
  margin: 0 0 0.25rem;
}

.role-badge {
  display: inline-block;
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #e9ecef;
  color: #495057;
}

/* Landing Section Headers (Admin tile grouping) */
.landing-section-header {
    grid-column: 1 / -1;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--c-muted);
    margin: 1rem 0 0.25rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--c-border);
}

.landing-section-header:first-of-type {
    margin-top: 0;
    border-top: none;
}

/* Contractor Stats Bar (Dashboard) */
.contractor-stats-bar .stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1rem;
    background: #f5f5f5;
    border-radius: var(--r-md);
}

.stat-card {
    text-align: center;
    flex: 1 1 0;
    min-width: 5rem;
}

.stat-card .stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--c-accent);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--c-muted);
}
