:root {
  --bg: #f3f1ec;
  --panel: #fffdf8;
  --ink: #1c1a17;
  --muted: #6b645b;
  --line: #d9d2c5;
  --accent: #2a5f8f;
  --accent-hover: #1f4a70;
  --danger: #9b2c2c;
  --ok: #2a5f8f;
  --warn-bg: #fff1d6;
  --err-bg: #fde8e8;
  --shadow: 0 1px 2px rgba(28, 26, 23, 0.06);
  font-family: "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 1.25rem 1.5rem 2.5rem;
  background:
    radial-gradient(circle at top left, #ebe4d6 0, transparent 40%),
    var(--bg);
  color: var(--ink);
}

/* —— App shell with left sidebar —— */
body.has-sidebar {
  padding: 0;
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
  min-height: 100vh;
  align-items: stretch;
}

.app-main {
  min-width: 0;
  padding: 1.15rem 1.35rem 2.5rem;
  background:
    radial-gradient(circle at top left, #ebe4d6 0, transparent 40%),
    var(--bg);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.1rem 0.85rem 1.25rem;
  background: #2a2620;
  color: #f4efe6;
  border-right: 1px solid #1a1713;
}

.sidebar-brand .eyebrow {
  color: #b7aea0;
}

.sidebar-product {
  margin: 0.15rem 0 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.sidebar-new-job {
  width: 100%;
  justify-content: center;
  margin: 0.15rem 0 0.25rem;
}

.sidebar-new-job.is-current {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.55rem;
    padding: 0.75rem 0.85rem;
    border-right: none;
    border-bottom: 1px solid #1a1713;
  }

  .sidebar-brand {
    flex: 1 1 auto;
  }

  .sidebar-new-job {
    width: auto;
    margin: 0;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.3rem;
    width: 100%;
  }

  .sidebar-section {
    display: none;
  }

  .sidebar-link {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .sidebar-footer {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    margin-top: 0;
    padding-top: 0.45rem;
  }

  .sidebar-footer .role-badge {
    width: 100%;
  }

  .sidebar-footer .btn,
  .sidebar-footer form {
    width: auto;
    flex: 1 1 auto;
  }

  .sidebar-footer form.inline .btn {
    width: 100%;
  }
}


.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1 1 auto;
  min-height: 0;
}

.sidebar-section {
  margin: 0.85rem 0 0.25rem;
  padding: 0 0.55rem;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9d9486;
}

.sidebar-section:first-child {
  margin-top: 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.48rem 0.65rem;
  border-radius: 8px;
  color: #e8e0d4;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-link.is-active {
  background: var(--accent);
  color: #fff;
  font-weight: 650;
}

.sidebar-link-billed.is-active {
  background: linear-gradient(180deg, #f0d060 0%, #d4a017 100%);
  color: #3d3200;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer .btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: #f4efe6;
}

.sidebar-footer .btn.secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

.sidebar-footer .role-badge {
  justify-content: center;
  text-align: center;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  color: #e8e0d4;
}

.sidebar-footer .role-badge.admin {
  background: rgba(42, 95, 143, 0.35);
  border-color: rgba(183, 205, 224, 0.35);
  color: #d7e8f6;
}

.sidebar-footer .role-badge.crew {
  background: rgba(90, 120, 70, 0.35);
  border-color: rgba(197, 212, 184, 0.35);
  color: #e4efd8;
}

.sidebar-footer .btn,
.sidebar-footer form {
  width: 100%;
}

.sidebar-footer .btn {
  justify-content: center;
}

.sidebar-footer form.inline {
  display: block;
  margin: 0;
}

.sidebar-footer form.inline .btn {
  width: 100%;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.page-header h1 {
  margin: 0.1rem 0 0;
}

.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.top-brand {
  min-width: 0;
}

.top-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  margin-bottom: 0.15rem;
}

.top-meta .eyebrow {
  margin: 0;
}

.btn-signout {
  padding: 0.28rem 0.6rem;
  font-size: 0.78rem;
}

.btn-change-pin {
  padding: 0.28rem 0.6rem;
  font-size: 0.78rem;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--muted);
}

h1 {
  margin: 0.15rem 0 0;
  font-size: 1.75rem;
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.tabs a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.tabs a.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.tabs a.tab-billed {
  color: #8a6a00;
  border-color: #e0c35a;
  background: #fff8e0;
}

.tabs a.tab-billed.active {
  color: #3d3200;
  background: linear-gradient(180deg, #f5d76e 0%, #e4b923 100%);
  border-color: #c9a227;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  background: #e8e2d6;
  color: var(--ink);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover { background: var(--accent-hover); }

.btn-new-job {
  padding: 0.7rem 1.25rem;
  font-size: 1.05rem;
  font-weight: 650;
  border-radius: 10px;
}

.btn.done {
  background: var(--accent);
  color: #fff;
}

.btn.done:hover {
  background: var(--accent-hover);
}

.btn.billed {
  background: linear-gradient(180deg, #f0d060 0%, #d4a017 100%);
  color: #3d3200;
  border-color: #c9a227;
  font-weight: 650;
}

.btn.billed:hover {
  background: linear-gradient(180deg, #f5d76e 0%, #e0b01a 100%);
}

.btn.secondary {
  background: var(--panel);
  border-color: var(--line);
}

.btn.danger {
  background: transparent;
  color: var(--danger);
  border-color: #e2b4b4;
}

.btn.danger:hover {
  background: var(--err-bg);
}

.flash {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.flash li {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  margin-bottom: 0.4rem;
}

.flash .ok { background: #e5eef6; color: var(--ok); }
.flash .error { background: var(--err-bg); color: var(--danger); }

.table-wrap {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  font-size: 0.88rem;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.65rem;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  background-clip: padding-box;
}

th {
  position: sticky;
  top: 0;
  background: #efe9dd;
  font-weight: 600;
  z-index: 1;
}

th a.th-sort {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  white-space: nowrap;
}

th a.th-sort:hover {
  color: var(--accent);
  text-decoration: underline;
}

th a.th-sort.is-active {
  color: var(--accent);
}

.sort-ind {
  font-size: 0.65rem;
  line-height: 1;
  opacity: 0.9;
}

.sort-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: end;
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.sort-bar-label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.sort-bar-label select {
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-width: 10rem;
}

@media (min-width: 901px) {
  .sort-bar {
    display: none;
  }
}

td.desc, td.notes {
  white-space: normal;
  min-width: 220px;
  max-width: 360px;
}

th.attach-col,
td.attach-col {
  width: 2.6rem;
  min-width: 2.6rem;
  max-width: 2.6rem;
  padding: 0.35rem 0.25rem;
  text-align: center;
  vertical-align: middle;
}

td.signals-col,
th.attach-col {
  width: auto;
  min-width: 3.4rem;
  max-width: none;
}

td.signals-col {
  white-space: nowrap;
}

.note-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  margin-right: 0.2rem;
  padding: 0;
  border: 1px solid #c9b27a;
  border-radius: 8px;
  background: #fff8e8;
  color: #7a5c12;
  cursor: pointer;
}

.note-btn:hover,
.note-btn.has-notes {
  border-color: #b8973a;
  background: #fff1d0;
}

.note-btn-label {
  font-size: 0.72rem;
  font-weight: 800;
}

.crew-done-tag {
  display: inline-block;
  margin-right: 0.3rem;
  padding: 0 0.3rem;
  border: 1px solid #4a6b3a;
  border-radius: 2px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.15;
  color: #2f4a24;
  background: #e8f0e2;
  vertical-align: text-top;
  white-space: nowrap;
}

.note-pill {
  display: inline-block;
  margin-right: 0.25rem;
  padding: 0 0.28rem;
  border: 1px solid #b8973a;
  border-radius: 2px;
  font-size: 0.62rem;
  font-weight: 800;
  color: #7a5c12;
  background: #fff8e8;
  vertical-align: text-top;
}

.notes-view-list {
  list-style: none;
  margin: 0 0 0.85rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  max-height: 18rem;
  overflow-y: auto;
}

.notes-view-item {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.notes-view-item:last-child {
  border-bottom: none;
}

.notes-view-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.notes-view-body {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.92rem;
  line-height: 1.4;
}

.notes-view-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.notes-mini-btn {
  padding: 0.3rem 0.55rem;
  font-size: 0.78rem;
}

.notes-edit-area {
  width: 100%;
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.55rem;
  background: #fff;
  resize: vertical;
  margin-top: 0.2rem;
}

.crew-job-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.75rem 0 0.25rem;
}

.crew-job-actions .btn {
  width: 100%;
  padding: 0.7rem 0.85rem;
}

.note-compose-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.note-compose-label textarea {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  background: #fff;
  resize: vertical;
}

tr.is-crew-done td {
  background: #eef5ea;
  color: #3d5234;
}

tr.crew-job-row {
  cursor: pointer;
}

tr.crew-job-row:hover td {
  background: #f5f9fd;
}

tr.crew-job-row.is-crew-done:hover td {
  background: #e4efdf;
}

.job-card-signals {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.attach-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.attach-btn:hover,
.attach-btn.has-files {
  color: var(--accent);
  border-color: #b7cde0;
  background: #f5f9fd;
}

.attach-icon {
  width: 1rem;
  height: 1rem;
}

.attach-count {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  min-width: 0.95rem;
  height: 0.95rem;
  padding: 0 0.2rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 0.95rem;
}

.attach-modal-card {
  max-width: min(32rem, 100%);
  max-height: min(90vh, 52rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.attach-job-label {
  margin-bottom: 0.75rem;
  color: var(--muted);
  flex-shrink: 0;
}

.attach-list {
  list-style: none;
  margin: 0 0 0.85rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: min(60vh, 36rem);
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.attach-modal-card .modal-actions {
  flex-shrink: 0;
  margin-top: 0;
}

.attach-item {
  display: block;
  padding: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.attach-item:last-child {
  border-bottom: none;
}

.attach-item .attach-link {
  display: block;
  padding: 0.65rem 0.75rem;
}

.attach-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-link:hover {
  text-decoration: underline;
}

.attach-remove {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0.15rem 0.25rem;
}

.attach-empty {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.attach-upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: flex-end;
  margin-bottom: 0.35rem;
}

.attach-file-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
  color: var(--muted);
  flex: 1;
  min-width: 12rem;
}

.attach-file-label input {
  font: inherit;
  font-size: 0.85rem;
}

.attach-error {
  margin: 0 0 0.5rem;
  color: var(--danger);
  font-size: 0.85rem;
}

td.actions,
th.actions {
  position: sticky;
  left: 0;
  background: var(--panel);
  z-index: 2;
  min-width: 240px;
  /* Keep display:table-cell so the cell stretches with tall (wrapped) rows.
     Flex on the <td> itself caused mid-row border lines on long descriptions. */
  vertical-align: middle;
}

th.actions {
  background: #efe9dd;
  z-index: 3;
}

td.actions .job-actions,
.job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.inline { display: inline; margin: 0; }

.link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  padding: 0.35rem 0.45rem;
}

.empty {
  padding: 2rem;
  color: var(--muted);
}

.job-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  max-width: min(1280px, 100%);
}

.form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 280px);
  gap: 1.15rem 1.25rem;
  align-items: stretch;
}

.form-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.form-top {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.1rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
}

.form-top label.wide {
  grid-column: auto;
}

.attach-section {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 0.9rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7f3ea;
}

.attach-heading {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  color: var(--ink);
}

.attach-lead {
  margin: 0 0 0.65rem;
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.35;
}

.existing-attach-list,
.pending-attach-list {
  list-style: none;
  margin: 0 0 0.65rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: min(40vh, 22rem);
  flex-shrink: 1;
  -webkit-overflow-scrolling: touch;
}

.existing-attach-item,
.pending-attach-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.existing-attach-item:last-child,
.pending-attach-item:last-child {
  border-bottom: none;
}

.existing-attach-item .attach-link {
  font-size: 0.8rem;
  word-break: break-word;
  white-space: normal;
  line-height: 1.3;
}

.existing-attach-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--danger);
  flex-shrink: 0;
}

.pending-attach-item {
  flex-direction: row;
  align-items: center;
}

.pending-attach-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
}

.drop-zone {
  flex: 1;
  min-height: 14rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed #c8bfb0;
  border-radius: 12px;
  padding: 1rem 0.75rem;
  text-align: center;
  background: #faf7f1;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.pending-attach-list {
  margin-top: 0.65rem;
  margin-bottom: 0;
}

.drop-zone:hover,
.drop-zone.is-dragover,
.drop-zone:focus-visible {
  border-color: var(--accent);
  background: #f5f9fd;
  outline: none;
}

.drop-zone-title {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
  font-size: 0.92rem;
}

.drop-zone-sub {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.drop-zone-browse {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}

.form-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(168px, 220px);
  gap: 1.15rem 1.35rem;
  align-items: start;
}

.form-main {
  min-width: 0;
}

.form-main-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1rem;
}

.form-main .notes-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.form-main .crew-section {
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.form-main .priority-section {
  margin-top: 1rem;
}

.form-side {
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7f3ea;
}

.form-side-heading {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--muted);
}

.form-side-note {
  margin: 0.25rem 0 0.65rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted);
}

.form-side label {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  margin-bottom: 0.55rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.form-side label:last-child {
  margin-bottom: 0;
}

.form-side input {
  padding: 0.38rem 0.48rem;
  font-size: 0.86rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

label.wide {
  grid-column: 1 / -1;
}

.crew-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.crew-heading {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--ink);
}

.crew-rows {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.crew-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 0.85rem 1rem;
  align-items: end;
}

input, textarea {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  background: #fff;
}

textarea { resize: vertical; }

.form-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.priority-section {
  margin-top: 1.1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #faf7f1;
}

.priority-check {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start;
  gap: 0.65rem !important;
  color: var(--ink);
  font-size: 0.92rem;
  cursor: pointer;
}

.priority-check input {
  margin-top: 0.2rem;
  width: 1.05rem;
  height: 1.05rem;
}

.priority-check small {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

/* High priority: compact tag only — no inset bar (avoids sticky-row border glitches) */
.prio-tag {
  display: inline-block;
  margin-right: 0.3rem;
  padding: 0 0.28rem;
  border: 1px solid #1c1a17;
  border-radius: 2px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.15;
  height: 1.15em;
  box-sizing: border-box;
  color: #1c1a17;
  background: #fff;
  vertical-align: text-top;
  white-space: nowrap;
}

td.customer {
  white-space: nowrap;
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .top { flex-direction: column; align-items: flex-start; }
  .crew-row { grid-template-columns: 1fr 1fr; }
  .form-layout { grid-template-columns: 1fr; }
  .form-body { grid-template-columns: 1fr; }
  .form-side { order: 2; }
  .attach-section { min-height: auto; }
  .drop-zone { min-height: 10rem; }
}

@media (max-width: 600px) {
  .crew-row { grid-template-columns: 1fr; }
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #efe9dd;
  color: var(--muted);
}

.role-badge.admin {
  background: #e5eef6;
  border-color: #b7cde0;
  color: var(--accent);
}

.role-badge.crew {
  background: #eef4ea;
  border-color: #c5d4b8;
  color: #3d5a2e;
}

.role-badge.employee {
  background: #efe9dd;
  color: var(--muted);
}

.view-note {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-shell {
  width: min(820px, 100%);
}

.login-header h1 {
  margin: 0.2rem 0 0.45rem;
}

.login-lead {
  margin: 0 0 1.25rem;
  color: var(--muted);
  max-width: 36rem;
  line-height: 1.45;
}

.login-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.name-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.name-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 0.85rem 0.9rem;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.name-chip:hover {
  border-color: #b7cde0;
}

.name-chip.selected {
  border-color: var(--accent);
  background: #e5eef6;
  box-shadow: 0 0 0 2px rgba(42, 95, 143, 0.2);
}

.name-chip.is-admin .name-chip-role {
  color: var(--accent);
}

.name-chip.is-crew .name-chip-role {
  color: #3d5a2e;
}

.name-chip-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.name-chip-role {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pin-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 360px;
}

.pin-selected {
  margin: 0;
  font-weight: 650;
  color: var(--ink);
}

.pin-label span {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.pin-label input {
  width: 100%;
  font-size: 1.4rem;
  letter-spacing: 0.35em;
  text-align: center;
  padding: 0.7rem;
}

.btn-signin {
  align-self: stretch;
  padding: 0.7rem 1rem;
  font-size: 1rem;
}

.users-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.users-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.users-add {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 1fr auto;
  gap: 0.65rem;
  align-items: end;
}

.users-add label,
.user-edit label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.users-add input,
.users-add select,
.user-edit input,
.user-edit select {
  font: inherit;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.user-edit {
  display: grid;
  grid-template-columns: 1.3fr 1fr auto 1fr auto;
  gap: 0.55rem;
  align-items: center;
  width: 100%;
}

.user-edit-row {
  padding: 0.55rem 0.65rem !important;
}

tr.inactive {
  opacity: 0.55;
}

.active-check {
  flex-direction: row !important;
  align-items: center;
  gap: 0.35rem !important;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .users-add,
  .user-edit {
    grid-template-columns: 1fr 1fr;
  }
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-card h2 {
  margin: 0;
  font-size: 1.2rem;
}

.login-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  flex: 1;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.login-card .btn {
  align-self: flex-start;
}

.admin-card {
  border-color: #b7cde0;
}

@media (max-width: 720px) {
  .login-cards { grid-template-columns: 1fr; }
}

/* Themed confirm modal */
body.modal-open {
  overflow: hidden;
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 26, 23, 0.45);
}

.modal-card {
  position: relative;
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(28, 26, 23, 0.18);
  padding: 1.25rem 1.35rem 1.2rem;
}

.modal-eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  color: var(--muted);
}

.modal-card h2 {
  margin: 0.25rem 0 0.55rem;
  font-size: 1.25rem;
  color: var(--ink);
}

.modal-body {
  margin: 0 0 1.15rem;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.95rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
}

.btn.danger.solid {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn.danger.solid:hover {
  background: #7f2323;
}

/* Admin assignment sheets */
.assign-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.assign-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem 1.2rem 1.35rem;
  box-shadow: var(--shadow);
  min-height: 280px;
}

.assign-card:hover {
  border-color: #b7cde0;
}

.assign-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  color: var(--accent);
}

.assign-card p {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.assign-card ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.45;
  flex: 1;
}

.assign-card .muted,
.assign-card .more {
  color: var(--muted);
}

@media (max-width: 900px) {
  .assign-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .assign-grid {
    grid-template-columns: 1fr;
  }
}

.sheet-page {
  background: #e8e2d6;
}

.sheet-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.sheet-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  flex: 1;
  justify-content: center;
}

.sheet-tab {
  text-decoration: none;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.84rem;
}

.sheet-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Full landscape letter sheet (11×8.5) — not a narrow card */
.assign-sheet {
  width: min(1100px, 100%);
  aspect-ratio: 11 / 8.5;
  min-height: 0;
  margin: 0 auto;
  background: #fff;
  color: #1c1a17;
  border: 2px solid #1c1a17;
  padding: 0.75rem 1.1rem 0.9rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 10px rgba(28, 26, 23, 0.08);
}

/* Printable sheet stays white paper — never inherit dark-mode light ink */
body.theme-dark .assign-sheet {
  color: #1c1a17;
  background: #fff;
}

body.theme-dark .assign-sheet .sheet-date,
body.theme-dark .assign-sheet .sheet-name,
body.theme-dark .assign-sheet .sheet-col-heads,
body.theme-dark .assign-sheet .sheet-table td,
body.theme-dark .assign-sheet .col-customer,
body.theme-dark .assign-sheet .col-desc,
body.theme-dark .assign-sheet .col-due {
  color: #1c1a17;
}

body.theme-dark .assign-sheet .empty-row td {
  color: #6b645b;
}

.sheet-date {
  text-align: center;
  font-size: 1.45rem;
  font-weight: 700;
  padding: 0.25rem 0 0.45rem;
  border-bottom: 1px solid #1c1a17;
  flex-shrink: 0;
}

.sheet-name-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: end;
  padding: 0.45rem 0 0.3rem;
  border-bottom: 1px solid #1c1a17;
  flex-shrink: 0;
}

.sheet-name {
  font-size: 1.5rem;
  font-weight: 700;
}

.sheet-col-heads {
  display: grid;
  grid-template-columns: 5.5rem 4.5rem;
  gap: 0.35rem;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.1rem;
  flex: 0 0 auto; /* natural row height — don't stretch job rows apart */
}

.sheet-table td {
  border-bottom: 1px solid #cfc7b8;
  padding: 0.28rem 0.4rem;
  vertical-align: top;
  font-size: 1rem;
  line-height: 1.25;
}

.sheet-table .col-customer {
  width: 20%;
  font-weight: 600;
}

.sheet-table .col-desc {
  width: auto;
}

.sheet-table .col-due,
.sheet-table .col-hours {
  width: 5.5rem;
  text-align: center;
  white-space: nowrap;
}

.sheet-table .col-hours {
  width: 4.5rem;
}

.sheet-table .blank-row td {
  height: 1.45rem;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
}

.sheet-table .empty-row td {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 1rem;
}

.sheet-notes {
  margin-top: auto;
  padding-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  flex-shrink: 0;
}

.sheet-notes .note-line {
  border-bottom: 1px solid #1c1a17;
  height: 1.15rem;
}

.print-sheet {
  margin-bottom: 1.5rem;
}

body.sheet-page.print-all .assign-sheet {
  margin-bottom: 0;
}

@media (max-width: 900px) {
  .assign-sheet {
    aspect-ratio: auto;
    min-height: 70vh;
  }
}

@media print {
  body {
    background: #fff !important;
    padding: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  .app-shell {
    display: block;
  }

  .app-main {
    padding: 0 !important;
    background: none !important;
  }

  .page-header {
    display: none !important;
  }

  .no-print {
    display: none !important;
  }

  .assign-sheet {
    width: 100%;
    max-width: none;
    aspect-ratio: auto;
    min-height: 0;
    height: auto;
    border-width: 2px;
    box-shadow: none;
    page-break-inside: avoid;
    padding: 0.35in 0.4in;
  }

  .print-sheet {
    page-break-after: always;
    margin: 0;
  }

  .print-sheet:last-child {
    page-break-after: auto;
  }

  /* Priority: black text/border only — readable in greyscale */
  .prio-tag {
    border-color: #000 !important;
    color: #000 !important;
    background: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* --- Workflow upgrades --- */
.filter-bar .grow {
  flex: 1 1 12rem;
  min-width: 10rem;
}

.filter-bar input[type="search"] {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-width: 12rem;
  width: 100%;
}

.filter-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: var(--ink);
  padding: 0.35rem 0.2rem;
  user-select: none;
}

.due-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.overdue-tag,
td.due.overdue,
.col-due.overdue,
dd.overdue {
  color: #9b1c1c;
}

.overdue-tag {
  background: #fde8e8;
  color: #9b1c1c;
  border: 1px solid #f0b4b4;
}

.today-tag {
  background: #fff4d6;
  color: #7a5b00;
  border: 1px solid #e0c35a;
}

tr.is-overdue td.due,
.job-card.is-overdue .job-card-meta .overdue {
  font-weight: 650;
}

.photo-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
}

.photo-btn:hover {
  border-color: var(--accent);
}

.photo-upload-label {
  cursor: pointer;
}

.attach-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.btn-notify.has-unread {
  border-color: #c9a227;
  background: #fff8e0;
}

.notify-count {
  display: inline-block;
  min-width: 1.2rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

.notify-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: #fff8e0;
  border: 1px solid #e0c35a;
  border-radius: 10px;
  color: #3d3200;
}

.notify-banner strong,
.notify-banner li {
  color: #3d3200;
}

.notify-banner ul {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
}

.notify-banner-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

body.theme-dark .notify-banner {
  background: #fff8e0;
  border-color: #e0c35a;
  color: #3d3200;
}

body.theme-dark .notify-banner strong,
body.theme-dark .notify-banner li {
  color: #3d3200;
}

body.theme-dark .notify-banner .btn.secondary {
  background: #fff;
  border-color: #d4c49a;
  color: #3d3200;
}

.notify-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.notify-item {
  display: grid;
  grid-template-columns: 6rem 1fr auto auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.75rem 0.9rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.notify-item.is-unread {
  border-color: #e0c35a;
  background: #fffdf5;
}

.notify-kind {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.notify-time {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.page-lead {
  color: var(--muted);
  margin: 0 0 1rem;
  max-width: 48rem;
}

.panel-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.panel-heading {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: end;
}

.inline-form label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.inline-form input,
.customers-edit input {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.inline-form .grow,
.customers-edit .grow {
  flex: 1 1 12rem;
}

.customer-edit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.customers-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  flex: 1;
  align-items: center;
}

.crew-rows-workers-only {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.crew-rows-workers-only .crew-row {
  display: block;
}

.job-form select {
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: 100%;
}

.delivery-section {
  margin-bottom: 1.5rem;
}

.delivery-section h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  margin: 0 0 0.75rem;
}

.count-pill {
  font-size: 0.8rem;
  font-weight: 650;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #efe9dd;
  color: var(--muted);
}

.delivery-overdue h2 { color: #9b1c1c; }
.delivery-today h2 { color: #7a5b00; }

.delivery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.75rem;
}

.delivery-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}

.delivery-card-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.delivery-desc {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.delivery-meta {
  display: grid;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
}

.delivery-meta div {
  display: grid;
  grid-template-columns: 5rem 1fr;
  gap: 0.35rem;
}

.delivery-meta dt {
  color: var(--muted);
  margin: 0;
}

.delivery-meta dd {
  margin: 0;
}

.qc-digital-meta {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: grid;
  gap: 0.25rem;
}

.qc-section {
  margin-bottom: 1.25rem;
}

.qc-section h2 {
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}

.qc-digital-table {
  width: 100%;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.qc-digital-table th,
.qc-digital-table td {
  white-space: normal;
}

.qc-digital-table th:nth-child(n+3),
.qc-digital-table td:nth-child(n+3) {
  text-align: center;
  width: 3rem;
}

.qc-status-row {
  margin-bottom: 1rem;
  max-width: 16rem;
}

.qc-status-row label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.qc-status-row select {
  font: inherit;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.sheet-col-heads-no-hours {
  grid-template-columns: 5.5rem;
}

.sheet-table .col-due {
  width: 6.5rem;
}

.backup-panel form {
  margin-top: 0.5rem;
}

@media (max-width: 700px) {
  .notify-item {
    grid-template-columns: 1fr;
  }
  .crew-rows-workers-only {
    grid-template-columns: 1fr;
  }
}

/* —— Per-user theme (light / dark) + profile color —— */
:root {
  --profile-color: var(--accent);
  --bg-glow: #ebe4d6;
}

body.theme-light,
body:not(.theme-dark) {
  --bg: #f3f1ec;
  --panel: #fffdf8;
  --ink: #1c1a17;
  --muted: #6b645b;
  --line: #d9d2c5;
  --warn-bg: #fff1d6;
  --err-bg: #fde8e8;
  --shadow: 0 1px 2px rgba(28, 26, 23, 0.06);
  --bg-glow: #ebe4d6;
}

body.theme-dark {
  --bg: #1a1c1f;
  --panel: #24282e;
  --ink: #e8e6e1;
  --muted: #9a958c;
  --line: #3a4048;
  --warn-bg: #3a3218;
  --err-bg: #3a2222;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --bg-glow: #2a3140;
  --danger: #e07a7a;
}

body.theme-dark,
body.theme-dark .app-main {
  background:
    radial-gradient(circle at top left, var(--bg-glow) 0, transparent 42%),
    var(--bg);
  color: var(--ink);
}

body.theme-light .app-main,
body:not(.theme-dark) .app-main {
  background:
    radial-gradient(circle at top left, var(--bg-glow) 0, transparent 40%),
    var(--bg);
}

body.theme-dark .table-wrap,
body.theme-dark .panel-card,
body.theme-dark .users-panel,
body.theme-dark .job-form,
body.theme-dark .sort-bar,
body.theme-dark .job-card,
body.theme-dark .delivery-card,
body.theme-dark .assign-card,
body.theme-dark .notify-item,
body.theme-dark .modal-card {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}

body.theme-dark th {
  background: #2e343c;
  color: var(--ink);
}

body.theme-dark td,
body.theme-dark th {
  border-color: var(--line);
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: #1c2026;
  color: var(--ink);
  border-color: var(--line);
}

body.theme-dark .btn.secondary {
  background: #2e343c;
  border-color: var(--line);
  color: var(--ink);
}

body.theme-dark .flash .ok {
  background: #243448;
  color: #9ec5e8;
}

body.theme-dark .tabs a {
  background: var(--panel);
  border-color: var(--line);
  color: var(--muted);
}

body.theme-dark .tabs a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

body.theme-dark .empty a {
  color: #9ec5e8;
}

.profile-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  margin-right: 0.35rem;
  background: var(--profile-color, var(--accent));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
  vertical-align: middle;
}

.sidebar-settings {
  margin-top: 0.15rem;
  font-weight: 650;
}

.sidebar-settings.is-active,
.sidebar-footer .sidebar-settings.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-width: 40rem;
}

.settings-section .panel-heading {
  margin-bottom: 0.25rem;
}

.settings-hint {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.theme-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  min-width: 8.5rem;
}

.theme-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-option.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}

.theme-swatch {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.theme-swatch-light {
  background: linear-gradient(135deg, #fffdf8, #ebe4d6);
}

.theme-swatch-dark {
  background: linear-gradient(135deg, #2a3140, #1a1c1f);
}

.accent-presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.accent-swatch {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
}

.accent-swatch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.accent-swatch.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}

.accent-chip {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--swatch);
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex: 0 0 auto;
}

.accent-label {
  font-size: 0.85rem;
}

.custom-accent {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.custom-accent input[type="color"] {
  width: 2.5rem;
  height: 2.2rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.custom-accent input[type="text"] {
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  width: 7rem;
}
