:root {
  --bg: #f7f6f2;
  --surface: #fffcf7;
  --ink: #102422;
  --muted: #48645e;
  --line: rgba(16, 36, 34, 0.14);
  --accent: #0e7c66;
  --accent-soft: #d3efe7;
  --warn: #bd5d00;
  --danger: #aa2f2f;
  --radius: 16px;
  --shadow: 0 12px 28px rgba(10, 38, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--ink);
  overflow-x: hidden;
  background: radial-gradient(circle at 18% 16%, #fffbe9 0%, rgba(255, 251, 233, 0) 46%),
    radial-gradient(circle at 88% 8%, #d9f3ee 0%, rgba(217, 243, 238, 0) 36%),
    var(--bg);
}

.background-shape {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  filter: blur(2px);
}

.shape-one {
  width: 300px;
  height: 300px;
  background: linear-gradient(135deg, #c8efe4, #e8f8e4);
  border-radius: 37% 63% 56% 44% / 41% 43% 57% 59%;
  top: -90px;
  right: -80px;
}

.shape-two {
  width: 240px;
  height: 240px;
  background: linear-gradient(135deg, #ffe6c8, #fff5e7);
  border-radius: 60% 40% 68% 32% / 44% 54% 46% 56%;
  bottom: -100px;
  left: -70px;
}

.page {
  position: relative;
  z-index: 1;
  width: min(1280px, 94vw);
  margin: 34px auto 54px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.6rem, 3.1vw, 2.4rem);
  line-height: 1.08;
}

.subtitle {
  margin-top: 8px;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.controls {
  margin-top: 18px;
  padding: 16px;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.87rem;
}

input[type="date"] {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.search-input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
  flex: 1;
  min-width: 250px;
}

select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.button,
.button-chip {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 14px;
  font: 600 0.9rem "Space Grotesk", sans-serif;
  cursor: pointer;
  transition: transform 130ms ease, background-color 130ms ease, border-color 130ms ease;
}

.button {
  background: var(--accent);
  color: #fff;
}

.button-danger {
  background: var(--danger);
  color: #fff;
}

.button:hover,
.button-chip:hover {
  transform: translateY(-1px);
}

.button-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.quick-filters {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bulk-toolbar {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(14, 124, 102, 0.18);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(211, 239, 231, 0.65), rgba(255, 255, 255, 0.85));
}

#bulkSelectionText {
  flex: 1;
}

#bulkDeleteBtn {
  margin-left: auto;
}

.bulk-selection-text {
  margin: 0;
  color: var(--muted);
}

.select-cell input,
.day-select-all {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.button-chip {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.button-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.range-text {
  margin: 12px 0 0;
  color: var(--muted);
}

.summary-grid {
  margin-top: 18px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.summary-card {
  padding: 14px;
}

.summary-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.summary-value {
  margin: 6px 0 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
}

.status {
  margin-top: 14px;
  min-height: 26px;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.days-container {
  margin-top: 12px;
  display: grid;
  gap: 14px;
}

.day-section {
  padding: 14px;
  min-width: 0;
  opacity: 0;
  transform: translateY(12px);
  animation: reveal 420ms ease forwards;
}

@keyframes reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.day-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.day-header .day-select-all {
  order: -1;
  margin-right: 8px;
  cursor: pointer;
}

.day-header h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.15rem;
}

.day-metrics {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.metric-pill {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 4px 10px;
  font-size: 0.78rem;
  color: var(--muted);
}

.label-table-wrap {
  width: 100%;
  max-width: 100%;
  display: block;
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.label-table {
  width: max-content;
  max-width: none;
  border-collapse: collapse;
  min-width: 1520px;
  table-layout: fixed;
}

.label-table th,
.label-table td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.label-table th:nth-child(1),
.label-table td:nth-child(1) {
  width: 40px;
}

.select-cell,
.label-table th.select-col {
  text-align: center;
  vertical-align: middle;
}

.label-table th.select-col {
  padding-left: 10px;
  padding-right: 10px;
}

.label-table th:nth-child(2),
.label-table td:nth-child(2) {
  width: 80px;
}

.label-table th:nth-child(3),
.label-table td:nth-child(3) {
  width: 100px;
}

.label-table th:nth-child(4),
.label-table td:nth-child(4) {
  width: 80px;
}

.label-table th:nth-child(5),
.label-table td:nth-child(5) {
  width: 70px;
}

.label-table th:nth-child(6),
.label-table td:nth-child(6) {
  width: 130px;
}

.label-table th:nth-child(7),
.label-table td:nth-child(7) {
  width: 180px;
  white-space: normal;
  word-break: break-word;
}

.label-table th:nth-child(8),
.label-table td:nth-child(8) {
  width: 100px;
}

.label-table th:nth-child(9),
.label-table td:nth-child(9) {
  width: 280px;
  white-space: normal;
  word-break: break-word;
}

.label-table th:nth-child(10),
.label-table td:nth-child(10) {
  width: 120px;
  white-space: normal;
  word-break: break-word;
}

.label-table th:nth-child(11),
.label-table td:nth-child(11) {
  width: 80px;
}

.label-table th:nth-child(12),
.label-table td:nth-child(12) {
  width: 80px;
}

.label-table th:nth-child(13),
.label-table td:nth-child(13) {
  width: 70px;
}

.label-table th:nth-child(14),
.label-table td:nth-child(14) {
  width: 120px;
white-space: normal;
word-break: break-word;
}

.label-table th:nth-child(15),
.label-table td:nth-child(15) {
  width: 70px;
}

.label-table th:nth-child(16),
.label-table td:nth-child(16) {
  width: 70px;
}

.label-table th:nth-child(17),
.label-table td:nth-child(17) {
  width: 90px;
}

.label-table th:nth-child(18),
.label-table td:nth-child(18) {
  width: 90px;
}

.label-table th:nth-child(19),
.label-table td:nth-child(19) {
  width: 220px;
  white-space: normal;
  word-break: break-word;
}

.label-row.selected {
  background: rgba(14, 124, 102, 0.06);
}

.actions-cell {
  display: table-cell; /* Restore default table behavior */
  vertical-align: middle; /* Center icons vertically */
  text-align: center; /* Center icons horizontally */
  height: auto; /* Let the row determine the height */

  display: flex;
  width: 100%;
  height: 100%;
  min-height: 100%;
  box-sizing: border-box;
  padding: 9px 8px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-direction: row;
  flex-wrap: nowrap;
}

.action-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.action-icon-btn:hover {
  transform: translateY(-1px);
}

.action-icon-btn.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.action-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
}

.action-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.action-icon-btn:first-child {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.action-icon-btn:last-child {
  background: #ffeaea;
  border-color: #efc2c2;
  color: #b22929;
}

.label-table th {
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.label-table th:last-child,
.label-table td:last-child {
  position: sticky;
  right: 0;
  padding: 0;
  background: var(--surface);
  z-index: 2;
  box-shadow: -10px 0 12px -12px rgba(0, 0, 0, 0.35);
}

.label-table td:last-child .actions-cell {
  background: var(--surface);
}

.label-table th:last-child {
  z-index: 3;
}

.status-badge {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-block;
  text-transform: uppercase;
}

.status-processed {
  background: #d4f4df;
  color: #185c34;
}

.status-failed {
  background: #fbd9d9;
  color: #7a2323;
}

.status-processing,
.status-received {
  background: #f3ead3;
  color: #735100;
}

.mono {
  font-family: "Space Grotesk", monospace;
}

.edit-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 18, 16, 0.48);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 40;
}

.edit-dialog-backdrop.open {
  display: flex;
}

.edit-dialog {
  width: min(920px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 18px;
}

.edit-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.edit-dialog-header h2 {
  margin: 4px 0 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.3rem;
}

.edit-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.edit-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

.edit-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.edit-field select,
.edit-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.edit-field textarea {
  resize: vertical;
}

.edit-modal-error {
  margin: 0 0 8px;
  min-height: 20px;
  color: var(--danger);
  font-size: 0.86rem;
  display: none;
}

.edit-modal-error.visible {
  display: block;
}

.edit-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  z-index: 60;
}

.toast {
  background: #123e35;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.86rem;
  box-shadow: 0 12px 24px rgba(5, 18, 16, 0.28);
  transition: opacity 220ms ease, transform 220ms ease;
}

.toast.error {
  background: #8b2323;
}

.toast.hide {
  opacity: 0;
  transform: translateY(8px);
}

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

  .edit-dialog-header {
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .page {
    margin-top: 24px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .button-ghost {
    align-self: flex-start;
  }
}
