:root {
  --layera: #173f37;
  --layera-strong: #102d28;
  --layera-accent: #2fbf9f;
  --layera-soft: #edf8f4;
  --ink: #17211f;
  --muted: #64736f;
  --line: #dfe7e3;
  --surface: #ffffff;
  --surface-subtle: #f8fbfa;
  --page: #f3f6f5;
}

* {
  letter-spacing: 0;
}

body {
  background:
    linear-gradient(180deg, #f7faf9 0, var(--page) 280px),
    var(--page);
  color: var(--ink);
  font-size: .95rem;
}

.app-container {
  max-width: 1480px;
}

.app-main {
  padding-bottom: 2rem;
  padding-top: 1.25rem;
}

.app-navbar {
  background: var(--layera);
  border-bottom: 1px solid rgb(255 255 255 / 10%);
  box-shadow: 0 10px 30px rgb(16 45 40 / 16%);
}

.app-navbar .navbar-toggler {
  border-color: rgb(255 255 255 / 20%);
}

.app-navbar .navbar-toggler-icon {
  filter: invert(1) grayscale(1);
}

.navbar-brand {
  align-items: center;
  color: #fff;
  display: inline-flex;
  font-weight: 800;
  gap: .6rem;
}

.navbar-brand:hover {
  color: #fff;
}

.brand-mark {
  align-items: center;
  background: var(--layera-accent);
  border-radius: 8px;
  color: var(--layera-strong);
  display: inline-flex;
  font-size: .9rem;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.app-nav {
  gap: .15rem;
}

.app-nav .nav-link {
  border-radius: 8px;
  color: rgb(255 255 255 / 72%);
  font-size: .9rem;
  font-weight: 650;
  padding: .45rem .7rem;
}

.app-nav .nav-link:hover,
.app-nav .nav-link.active,
.app-nav .show > .nav-link {
  background: rgb(255 255 255 / 11%);
  color: #fff;
}

.dropdown-menu {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgb(16 45 40 / 14%);
}

.user-menu {
  align-items: center;
  display: flex;
  gap: .65rem;
}

.user-chip {
  background: rgb(255 255 255 / 10%);
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 8px;
  color: rgb(255 255 255 / 82%);
  font-size: .82rem;
  font-weight: 650;
  padding: .35rem .55rem;
}

.user-chip:hover,
.user-chip:focus {
  background: rgb(255 255 255 / 15%);
  color: #fff;
}

.user-chip:focus-visible {
  box-shadow: 0 0 0 .2rem rgb(255 255 255 / 16%);
  outline: none;
}

.user-menu .dropdown-menu {
  min-width: 160px;
}

.user-menu form {
  margin: 0;
}

.bg-layera {
  background: var(--layera);
}

.btn {
  border-radius: 8px;
  font-weight: 650;
}

.btn-layera {
  --bs-btn-bg: var(--layera);
  --bs-btn-border-color: var(--layera);
  --bs-btn-color: #fff;
  --bs-btn-hover-bg: var(--layera-strong);
  --bs-btn-hover-border-color: var(--layera-strong);
  --bs-btn-focus-shadow-rgb: 47, 191, 159;
}

.btn-outline-secondary {
  --bs-btn-color: #3d4d49;
  --bs-btn-border-color: #cdd8d4;
  --bs-btn-hover-bg: #edf4f1;
  --bs-btn-hover-border-color: #becbc6;
  --bs-btn-hover-color: #22302d;
}

.login-shell {
  min-height: calc(100vh - 3rem);
  display: grid;
  place-items: center;
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgb(16 45 40 / 13%);
  padding: 2rem;
  width: min(420px, 92vw);
}

.login-panel h1,
.page-head h1 {
  font-weight: 800;
  letter-spacing: 0;
  margin: 0;
}

.page-head {
  align-items: flex-end;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.page-head h1 {
  font-size: clamp(1.45rem, 2vw, 2rem);
}

.page-head p {
  color: var(--muted);
  margin: .25rem 0 0;
}

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

.toolbar-search {
  display: flex;
  gap: .5rem;
}

.toolbar-search .form-control {
  min-width: 240px;
}

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

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgb(24 45 40 / 6%);
}

.metric {
  border-left: 4px solid transparent;
  padding: 1rem;
}

.metric-accent {
  border-left-color: var(--layera-accent);
}

.metric-success {
  border-left-color: #2f9e6f;
}

.metric-warning {
  border-left-color: #e3a008;
}

.metric-danger {
  border-left-color: #d94f4f;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: .78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.metric strong {
  color: var(--ink);
  display: block;
  font-size: 1.55rem;
  line-height: 1.2;
  margin-top: .35rem;
}

.panel {
  overflow: hidden;
  padding: 1rem;
}

.panel h2 {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: .85rem;
}

.panel-heading {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .85rem;
}

.panel-heading h2 {
  margin-bottom: .15rem;
}

.panel-heading p {
  color: var(--muted);
  margin: 0;
}

.production-filters,
.order-filters,
.finance-filters {
  align-items: center;
  display: grid;
  gap: .75rem;
  grid-template-columns: minmax(0, 1fr);
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.filter-tabs .btn {
  min-height: 42px;
}

.filter-status {
  min-width: 0;
}

.filter-apply {
  min-width: 92px;
}

.date-filter-fields {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.period-card {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(2, minmax(150px, 220px));
  padding: .85rem;
}

.order-filters .toolbar-search,
.production-filters .toolbar-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
}

@media (min-width: 1180px) {
  .production-filters,
  .order-filters {
    grid-template-columns: minmax(0, 1fr) minmax(180px, 240px) minmax(320px, 520px);
  }

  .finance-filters {
    align-items: end;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .period-card {
    grid-column: 1 / -1;
    width: fit-content;
  }
}

.table {
  margin-bottom: 0;
}

.table-pagination {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: .75rem;
  justify-content: space-between;
  padding-top: .85rem;
  margin-top: .85rem;
}

.table-pagination-summary {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

.page-link {
  border-color: #d8e1dd;
  color: var(--layera);
}

.page-link:hover {
  background: var(--layera-soft);
  border-color: #c8d8d2;
  color: var(--layera-strong);
}

.active > .page-link,
.page-link.active {
  background: var(--layera);
  border-color: var(--layera);
}

.table thead th {
  background: var(--surface-subtle);
  border-bottom-color: var(--line);
  color: #53635f;
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.table thead th.sortable {
  cursor: pointer;
  padding-right: 1.45rem;
  position: relative;
  user-select: none;
}

.table thead th.sortable::after {
  color: #9aa8a4;
  content: "↕";
  font-size: .7rem;
  position: absolute;
  right: .55rem;
  top: 50%;
  transform: translateY(-50%);
}

.table thead th.sortable[data-sort-direction="asc"]::after {
  color: var(--layera);
  content: "↑";
}

.table thead th.sortable[data-sort-direction="desc"]::after {
  color: var(--layera);
  content: "↓";
}

.table thead th.sortable:focus-visible {
  box-shadow: inset 0 0 0 2px rgb(47 191 159 / 35%);
  outline: none;
}

.table tbody td {
  border-color: #edf1ef;
  vertical-align: middle;
}

.table tbody tr:hover > td {
  background: #fbfdfc;
}

.table .collapse td,
tr.collapse td {
  background: #fff;
}

.badge {
  border-radius: 8px;
  font-weight: 750;
  padding: .45em .6em;
}

.badge-soft {
  background: var(--layera-soft);
  color: var(--layera-strong);
}

.text-bg-warning {
  color: #332400 !important;
}

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

.edit-surface {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.field {
  min-width: 0;
}

.field .form-label,
.login-panel .form-label {
  color: #40504c;
  font-size: .8rem;
  font-weight: 800;
  margin-bottom: .35rem;
}

.form-control,
.form-select {
  border-color: #d8e1dd;
  border-radius: 8px;
  min-height: 42px;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--layera-accent);
  box-shadow: 0 0 0 .2rem rgb(47 191 159 / 14%);
}

.field-check {
  background: #fff;
  border: 1px solid #d8e1dd;
  border-radius: 8px;
  margin-bottom: 0;
  min-height: 42px;
  padding: .55rem .75rem .55rem 2.25rem;
}

.product-upload {
  background: #fff;
  border: 1px solid #d8e1dd;
  border-radius: 8px;
  padding: .8rem;
}

.product-upload-control {
  display: grid;
  gap: .35rem;
}

.product-upload-control span {
  color: var(--muted);
  font-size: .82rem;
}

.product-photo-grid {
  display: grid;
  gap: .65rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: .8rem;
}

.product-photo-item {
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: .5rem;
  min-width: 0;
  padding: .5rem;
}

.product-photo-item img {
  aspect-ratio: 4 / 3;
  background: #eef4f1;
  border-radius: 6px;
  object-fit: cover;
  width: 100%;
}

.product-photo-link {
  align-items: center;
  aspect-ratio: 4 / 3;
  background: #eef4f1;
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  font-size: .78rem;
  overflow-wrap: anywhere;
  padding: .65rem;
}

.product-photo-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: .78rem;
  gap: .5rem;
  justify-content: space-between;
  min-width: 0;
}

.product-photo-meta > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pricing-helper {
  background: #fff9e8;
  border: 1px solid #f1dea5;
  border-radius: 8px;
  padding: .9rem;
}

.pricing-helper-head {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: .75rem;
}

.pricing-helper-head strong {
  display: block;
  font-weight: 800;
}

.pricing-helper-head span {
  color: var(--muted);
  display: block;
  font-size: .82rem;
  margin-top: .15rem;
}

.pricing-helper-head output {
  color: #6f4c00;
  font-size: .88rem;
  font-weight: 800;
  text-align: right;
}

.pricing-helper-grid {
  display: grid;
  gap: .6rem;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.pricing-helper-grid label {
  color: #40504c;
  font-size: .76rem;
  font-weight: 800;
}

.pricing-helper-grid .form-control {
  margin-top: .25rem;
  min-height: 36px;
}

.form-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}

.grid-wide {
  grid-column: 1 / -1;
}

textarea.form-control {
  min-height: 84px;
}

.modal-content {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgb(16 45 40 / 18%);
}

.modal-header,
.modal-footer {
  background: var(--surface-subtle);
  border-color: var(--line);
}

.modal-title {
  font-weight: 800;
}

.alert {
  border-radius: 8px;
  box-shadow: 0 12px 30px rgb(24 45 40 / 7%);
}

.text-muted {
  color: var(--muted) !important;
}

@media (max-width: 992px) {
  .app-navbar .navbar-collapse {
    padding-top: .75rem;
  }

  .app-nav {
    gap: .25rem;
  }

  .user-menu {
    align-items: stretch;
    margin-top: .75rem;
  }

  .table-pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .table-pagination .pagination {
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  .app-main {
    padding-top: 1rem;
  }

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

  .page-actions,
  .toolbar-search,
  .production-filters,
  .order-filters,
  .finance-filters,
  .date-filter-fields,
  .period-card,
  .filter-tabs {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .production-filters,
  .order-filters,
  .finance-filters,
  .date-filter-fields,
  .period-card,
  .order-filters .toolbar-search,
  .production-filters .toolbar-search {
    display: flex;
  }

  .toolbar-search .form-control {
    min-width: 0;
  }

  .page-head .btn,
  .page-head input {
    min-height: 42px;
  }

  .filter-apply {
    width: 100%;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .pricing-helper-head {
    flex-direction: column;
  }

  .pricing-helper-head output {
    text-align: left;
  }
}
