* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Outfit", "Noto Sans JP", "Noto Sans", "Vazirmatn", sans-serif;
  background: #f4f1ec;
  color: #1f1f1f;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  background: #1f2a2e;
  color: #f9f4ef;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 20pt;
  text-transform: none;
  color: inherit;
  text-decoration: none;
}

.brand:visited {
  color: inherit;
}

.brand-mark {
  width: 75px;
  display: block;
}

nav a {
  color: #f9f4ef;
  text-decoration: none;
  margin-left: 0;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-gear {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-gear-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  color: #f9f4ef;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.nav-gear-button svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.nav-gear-button:hover {
  color: #ffffff;
}

.nav-gear-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.6rem);
  display: none;
  min-width: 180px;
  padding: 0.5rem;
  border-radius: 10px;
  background: #1f2a2e;
  box-shadow: 0 12px 20px rgba(31, 42, 46, 0.3);
  z-index: 10;
}

.nav-gear-menu.is-open {
  display: grid;
  gap: 0.25rem;
}

.nav-gear-menu .nav-link {
  display: block;
  margin: 0;
}

nav a:hover {
  background: rgba(249, 244, 239, 0.18);
  color: #ffffff;
}

nav a.is-active {
  background: #f4d03f;
  color: #1f2a2e;
}

main {
  padding: 2rem;
}

h1,
h2 {
  margin-top: 0;
}

h1 {
  font-size: 1.6rem;
  font-weight: 700;
}

.grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-bottom: 2rem;
}

.card {
  background: #ffffff;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(31, 42, 46, 0.08);
}

.card--table {
  padding: 0;
  border-radius: 12px;
  overflow: visible;
}

.stat-card {
  display: grid;
  gap: 0.5rem;
  text-align: center;
}

.stat-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b6b6b;
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  text-align: center;
}

.stat-unit {
  font-size: 0.85rem;
  font-weight: 600;
  margin-left: 0.35rem;
  color: #6b6b6b;
}

.stat-card--teal {
  background: #fff2e5;
  border: 1px solid #f8b97e;
}

.stat-card--amber {
  background: #fff8db;
  border: 1px solid #f2d36d;
}

.stat-card--indigo {
  background: #e9f6ff;
  border: 1px solid #8fd0f3;
}

.stat-card--sage {
  background: #f4ecff;
  border: 1px solid #c7a6f2;
}

.stat-card--rose {
  background: #ffe8ee;
  border: 1px solid #f7a3b4;
}

.throughput-card {
  display: grid;
  gap: 1rem;
}

.throughput-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.throughput-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.throughput-controls {
  display: inline-flex;
  gap: 0.5rem;
}

.toggle-button {
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  border: 1px solid #c4c4c4;
  background: #ffffff;
  color: #1f2a2e;
  font-size: 0.85rem;
  font-weight: 600;
}

.toggle-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.toggle-button.is-active {
  background: #1f2a2e;
  color: #ffffff;
  border-color: #1f2a2e;
}

.toggle-button:hover {
  border-color: #1f2a2e;
}

.throughput-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
}

.throughput-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.throughput-chart {
  display: grid;
  gap: 1.25rem;
  position: relative;
  height: 260px;
  padding-bottom: 1rem;
  width: 100%;
  min-width: 0;
}

.chart-trend {
  margin-top: 0.5rem;
  font-weight: 600;
  color: #1f2a2e;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

@media (max-width: 720px) {
  .throughput-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

.chart-trend--up {
  color: #1f4d30;
}

.chart-trend--down {
  color: #7a1e1e;
}

.chart-trend-arrow {
  font-size: 0.9rem;
}

.throughput-axis {
  display: grid;
  grid-template-columns: 70px 1fr 60px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b6b6b;
}

.throughput-axis-label {
  text-align: right;
}

.throughput-axis-label:first-child {
  text-align: left;
}

.throughput-row {
  display: grid;
  grid-template-columns: 70px 1fr 60px;
  gap: 0.75rem;
  align-items: center;
}

.throughput-hour {
  font-weight: 600;
  color: #1f2a2e;
}

.throughput-kg {
  text-align: right;
  font-weight: 600;
}

.throughput-bar {
  display: grid;
  gap: 0.5rem;
}

.throughput-bar-header {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  color: #1f2a2e;
}

.throughput-bar-track {
  background: #efe6d8;
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

.throughput-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #1f2a2e, #f4d03f);
}

.throughput-item {
  background: #f8f4ed;
  border-radius: 10px;
  padding: 1rem;
  display: grid;
  gap: 0.35rem;
}

.throughput-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b6b6b;
}

.throughput-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.alert-chip {
  background: #a83a32;
  color: #ffffff;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.block-performance-card {
  margin-top: 1.5rem;
}

.block-performance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.block-performance-table td.variance-good {
  background: #e6f4ea;
  color: #1f4d30;
  font-weight: 600;
}

.block-performance-table td.variance-neutral {
  background: #f2f0eb;
  color: #5b5b5b;
  font-weight: 600;
}

.block-performance-table td.variance-bad {
  background: #fdecec;
  color: #7a1e1e;
  font-weight: 600;
}

.packhouse-card {
  margin-top: 1.5rem;
}

.packhouse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.packhouse-charts {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
  width: 100%;
  min-width: 0;
}

.packhouse-chart h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: #1f2a2e;
}

.packhouse-chart {
  position: relative;
  height: 260px;
  padding-bottom: 0.75rem;
  width: 100%;
  min-width: 0;
}

.chart-canvas {
  display: block;
  width: 100%;
  height: 100% !important;
  max-height: 100% !important;
}

.yield-card {
  margin-top: 1.5rem;
}

.yield-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.yield-controls {
  display: inline-flex;
  gap: 0.5rem;
}

.yield-chart {
  position: relative;
  height: 300px;
  margin-top: 1rem;
  padding-bottom: 1rem;
}

@media (max-width: 900px) {
  .packhouse-charts {
    grid-template-columns: 1fr;
  }
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-actions button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.page-actions svg {
  width: 16px;
  height: 16px;
}

label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 600;
}

input,
select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-top: 0.4rem;
  border-radius: 8px;
  border: 1px solid #c4c4c4;
  font-size: 1rem;
  background: #ffffff;
  color: #1f2a2e;
}

button,
.button-link {
  background: #1f2a2e;
  color: #ffffff;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 400;
  font-size: 1rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

button[hidden],
.button-link[hidden] {
  display: none !important;
}

button.danger {
  background: #a83a32;
}

.actions-row {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.actions {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  justify-content: flex-end;
  vertical-align: bottom;
}

.row-actions {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin: 0 auto;
  width: max-content;
}

.actions-toggle {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #6b7280;
}

.actions-toggle:hover {
  background: #f3f4f6;
}

.actions-toggle:hover .actions-dot {
  background: #111827;
}

.actions-toggle.is-open {
  background: #e5e7eb;
}

.actions-toggle.is-open .actions-dot {
  background: #111827;
  transform: scale(1.1);
}

.actions-dot {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: #9ca3af;
  display: block;
}

.actions-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  min-width: 160px;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.4rem;
  box-shadow:
    0 10px 15px -3px rgba(15, 23, 42, 0.1),
    0 4px 6px -4px rgba(15, 23, 42, 0.1);
  z-index: 10;
}

.actions-menu.is-open {
  display: flex;
}

.actions-menu .button-link,
.actions-menu button {
  width: 100%;
  background: transparent;
  color: #111827;
  border: none;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  text-align: left;
  font-size: inherit;
  line-height: inherit;
}

.actions-menu .button-link:hover,
.actions-menu button:hover {
  background: #f3f4f6;
}

.actions-menu button.danger {
  color: #b91c1c;
}

.actions-menu button.danger:hover {
  background: #fee2e2;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid #e2e2e2;
}

th:first-child,
td:first-child {
  padding-left: 1.25rem;
}

th:last-child,
td:last-child {
  padding-right: 1.25rem;
}

.bulk-actions,
.bulk-select {
  text-align: center;
  width: 1%;
}

.bulk-actions {
  padding: 0.5rem;
}

.employee-select {
  width: 18px;
  height: 18px;
  accent-color: #1f2a2e;
  cursor: pointer;
}

.bulk-delete-button {
  background: transparent;
  border: none;
  color: #b91c1c;
  padding: 0.2rem;
  border-radius: 6px;
  cursor: pointer;
}

.bulk-delete-button:hover {
  background: #fee2e2;
}

.bulk-delete-button svg {
  width: 20px;
  height: 20px;
  display: block;
}

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

.notice {
  padding: 0.75rem 1rem;
  background: #e6f0e9;
  border-radius: 8px;
  color: #2c5330;
  margin-bottom: 1rem;
}

.alert {
  padding: 0.75rem 1rem;
  background: #f5d6d1;
  border-radius: 8px;
  color: #7f2f28;
  margin-bottom: 1rem;
}

.hint {
  margin: 0;
  display: block;
  font-size: 0.9rem;
  color: #4f4f4f;
  font-weight: 400;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid #d7dce2;
  background: #f8fafc;
  color: #1f2a2e;
  font-size: 0.85rem;
  line-height: 1.2;
  white-space: nowrap;
}

.tag-pill--row,
.tag-pill--option {
  background: #f8fafc;
}

.tag-pill--filter,
.tag-pill--selected {
  background: #eef6ec;
  border-color: #bfd7b8;
}

.tag-pill--selected {
  border-radius: 8px;
  border-color: #1f2a2e;
  background: #1f2a2e;
  color: #ffffff;
}

.tag-pill__label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-pill__remove,
.tag-pill__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
}

.tag-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.bulk-context-bar {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e2e2e2;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  background: #f8fafc;
  flex-wrap: wrap;
}

.bulk-context-bar[hidden] {
  display: none;
}

.bulk-context-bar__primary {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.bulk-context-bar__selection {
  display: flex;
  align-items: center;
  justify-content: center;
}

.bulk-context-bar__selection input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.bulk-context-bar__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.dropdown-trigger::after {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  transform-origin: center;
}

.context-dropdown {
  position: relative;
}

.context-dropdown__panel {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  z-index: 15;
  margin: 0;
}

.context-dropdown[data-apply-tags-dropdown] .context-dropdown__panel {
  top: calc(100% + 0.6rem);
  right: 0;
}

.import-tag-dropdown {
  margin-bottom: 1rem;
}

.import-tag-dropdown > .dropdown-trigger {
  width: 100%;
  justify-content: space-between;
  background: #ffffff;
  color: #1f2a2e;
  border: 1px solid #c4c4c4;
}

.import-tag-dropdown__button-copy {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-height: 1.5rem;
}

.import-tag-dropdown__panel {
  top: calc(100% + 0.4rem);
  bottom: auto;
  left: 0;
  right: auto;
  width: min(100%, 28rem);
}

.import-tag-dropdown__panel .action-dropdown {
  width: 100%;
  max-width: min(100vw - 6rem, 28rem);
  background: #ffffff;
  border: 1px solid #d7dce2;
}

.import-tag-dropdown__panel .action-dropdown__options {
  width: 100%;
  max-height: 14rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.import-tag-dropdown__option-label {
  color: #1f2a2e;
  font-size: 0.95rem;
  line-height: 1.35;
}

.context-dropdown__panel[hidden] {
  display: none;
}

.action-dropdown {
  position: relative;
  display: grid;
  gap: 0.75rem;
  width: fit-content;
  min-width: 18rem;
  max-width: min(100vw - 4rem, 28rem);
  padding: 0.85rem;
  border: 1px solid #d7dce2;
  border-radius: 12px;
  background: #ffffff;
  box-shadow:
    0 18px 28px -18px rgba(15, 23, 42, 0.4),
    0 12px 18px -18px rgba(15, 23, 42, 0.25);
}

.action-dropdown__search {
  width: 100%;
}

.action-dropdown__options {
  display: grid;
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
}

.action-dropdown__option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  max-width: 100%;
}

.action-dropdown__option input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.qr {
  width: 72px;
  height: 72px;
  display: block;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(31, 42, 46, 0.55);
  z-index: 20;
}

.modal.is-open {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
}

#import-csv-modal .modal-content {
  overflow: visible;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.modal-close {
  background: transparent;
  color: #1f2a2e;
  border: 1px solid #c4c4c4;
}

@media (max-width: 720px) {
  .bulk-context-bar {
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: stretch;
  }

  .bulk-context-bar__actions {
    grid-column: 1 / -1;
    width: 100%;
  }

  .context-dropdown__panel {
    right: 0;
  }
}
