:root {
  --bg: #eef3f0;
  --surface: #ffffff;
  --surface-soft: #f6faf7;
  --ink: #14201a;
  --muted: #6c7770;
  --line: #dfe8e1;
  --primary: #059669;
  --primary-dark: #047857;
  --accent: #d97706;
  --danger: #dc2626;
  --success: #16a34a;
  --steel: #475569;
  --sidebar: #fbfdfb;
  --sidebar-line: #dfe8e1;
  --shadow: 0 18px 40px rgba(20, 32, 26, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f6faf7 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: var(--sidebar);
  color: var(--ink);
  padding: 22px;
  border-right: 1px solid var(--sidebar-line);
  box-shadow: 16px 0 36px rgba(20, 32, 26, 0.04);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
}

.nav-list {
  display: grid;
  gap: 7px;
}

.nav-link {
  position: relative;
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #53615a;
}

.nav-link:hover,
.nav-link.active {
  background: #e8f7ef;
  border-color: #bdebd1;
  color: var(--primary-dark);
  box-shadow: 0 10px 20px rgba(5, 150, 105, 0.08);
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 12px;
  bottom: 12px;
  width: 4px;
  border-radius: 0 999px 999px 0;
  background: var(--primary);
}

.nav-link span {
  font-weight: 800;
}

.nav-link small {
  color: #7a8981;
  font-size: 0.78rem;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: 1.78rem;
}

.eyebrow,
.section-kicker {
  color: var(--primary-dark);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions,
.section-actions,
.actions {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}

.user-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--surface-soft);
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 800;
  font-size: 0.8rem;
  white-space: nowrap;
}

.badge.good {
  color: var(--success);
  background: #e8f6ec;
}

.badge.warning {
  color: #8a5707;
  background: #fff2d3;
}

.badge.critical {
  color: var(--danger);
  background: #ffe5e1;
}

.badge.muted {
  color: var(--muted);
}

.btn,
button.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  font-weight: 850;
  white-space: nowrap;
}

.btn:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  color: var(--ink);
  background: #ffffff;
  border-color: var(--line);
}

.btn.secondary:hover {
  border-color: var(--primary);
}

.btn.danger {
  background: #fff;
  border-color: #f1bab4;
  color: var(--danger);
}

.notice {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 12px 14px;
  color: var(--steel);
  font-weight: 700;
}

.notice.error {
  border-left-color: var(--danger);
}

.notice.success {
  border-left-color: var(--success);
}

.section,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 4px 0 0;
  font-size: 1.1rem;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
  min-height: 104px;
  display: grid;
  align-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.stat-card strong {
  font-size: 1.44rem;
  font-variant-numeric: tabular-nums;
}

.dashboard-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  border: 1px solid #b7ddd5;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #dff8f4 0%, #fff0c2 48%, #e8edff 100%);
  box-shadow: 0 22px 46px rgba(23, 32, 30, 0.1);
  padding: 20px;
}

.dashboard-hero h2 {
  margin: 4px 0 4px;
  font-size: 1.55rem;
}

.dashboard-hero p {
  margin: 0;
  color: var(--steel);
  font-weight: 800;
}

.dashboard-hero-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.dashboard-stats {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 16px;
}

.dashboard-stats .stat-card {
  position: relative;
  min-height: 96px;
  overflow: hidden;
  border: 0;
  color: #ffffff;
  box-shadow: 0 20px 40px rgba(23, 32, 30, 0.13);
}

.dashboard-stats .stat-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.45);
}

.dashboard-stats .stat-card span,
.dashboard-stats .stat-card strong {
  position: relative;
  z-index: 1;
  color: #ffffff;
}

.dashboard-stats .stat-card span {
  opacity: 0.88;
}

.dashboard-stats .stat-card.tone-teal {
  background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%);
}

.dashboard-stats .stat-card.tone-rose {
  background: linear-gradient(135deg, #b42318 0%, #f9735b 100%);
}

.dashboard-stats .stat-card.tone-blue {
  background: linear-gradient(135deg, #1d4ed8 0%, #38bdf8 100%);
}

.dashboard-stats .stat-card.tone-amber {
  background: linear-gradient(135deg, #9a6518 0%, #f59e0b 100%);
}

.dashboard-stats .stat-card.tone-violet {
  background: linear-gradient(135deg, #6d28d9 0%, #a855f7 100%);
}

.dashboard-main {
  align-items: start;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.dashboard-left,
.dashboard-right {
  display: grid;
  gap: 16px;
  align-content: start;
}

.dashboard-layout .section,
.dashboard-layout .review-panel {
  margin-bottom: 0;
}

.dashboard-ai-panel {
  border: 0;
  border-left: 6px solid #6d28d9;
  background:
    linear-gradient(135deg, rgba(109, 40, 217, 0.12), rgba(20, 184, 166, 0.1)),
    #ffffff;
  box-shadow: 0 18px 40px rgba(109, 40, 217, 0.12);
}

.dashboard-ai-panel .review-heading strong {
  color: #5b21b6;
}

.dashboard-ai-panel .review-row {
  border: 1px solid rgba(109, 40, 217, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  padding: 8px;
}

.dashboard-main .section,
.dashboard-recent-section {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.dashboard-watch-section {
  border-top: 4px solid var(--primary);
  background: linear-gradient(180deg, #ffffff 0%, #effdfa 100%);
}

.watch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.watch-card {
  --watch: var(--primary);
  display: grid;
  gap: 16px;
  border: 1px solid color-mix(in srgb, var(--watch) 28%, var(--line));
  border-left: 6px solid var(--watch);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #ffffff 0%, color-mix(in srgb, var(--watch) 12%, #ffffff) 100%);
  padding: 15px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.watch-card:hover {
  border-color: var(--watch);
  box-shadow: 0 18px 36px color-mix(in srgb, var(--watch) 20%, transparent);
  transform: translateY(-1px);
}

.watch-card.category-stretch-film {
  --watch: #0f766e;
}

.watch-card.category-bopp-tape {
  --watch: #2563eb;
}

.watch-card.category-other {
  --watch: #7c3aed;
}

.watch-card.status-critical {
  --watch: #b42318;
}

.watch-card.status-low {
  --watch: #d97706;
}

.watch-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.watch-card-head > div strong,
.watch-card-head > div span {
  display: block;
}

.watch-card-head > div strong {
  margin-bottom: 4px;
  font-size: 1.05rem;
}

.watch-card-head > div span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.watch-metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.watch-metrics span {
  display: grid;
  gap: 4px;
  border: 1px solid color-mix(in srgb, var(--watch) 20%, var(--line));
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  padding: 9px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.watch-metrics span:first-child {
  background: var(--watch);
  color: #ffffff;
}

.watch-metrics span:first-child strong {
  color: #ffffff;
  font-size: 1.28rem;
}

.watch-metrics strong {
  color: var(--watch);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  text-transform: none;
}

.dashboard-category-section {
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(37, 99, 235, 0.08)),
    #ffffff;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.category-card {
  --category: var(--primary);
  display: grid;
  gap: 14px;
  border: 1px solid color-mix(in srgb, var(--category) 24%, var(--line));
  border-top: 5px solid var(--category);
  border-radius: var(--radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--category) 10%, #ffffff) 0%, #ffffff 72%);
  padding: 14px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.category-card:hover {
  border-color: var(--category);
  box-shadow: 0 14px 30px color-mix(in srgb, var(--category) 15%, transparent);
  transform: translateY(-1px);
}

.category-card.category-stretch-film {
  --category: #0f766e;
}

.category-card.category-bopp-tape {
  --category: #2563eb;
}

.category-card.category-other {
  --category: #7c3aed;
}

.category-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.category-card-head > div strong,
.category-card-head > div span {
  display: block;
}

.category-card-head > div strong {
  font-size: 1.04rem;
}

.category-card-head > div span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.category-sale-strip {
  display: grid;
  gap: 4px;
  border-radius: var(--radius);
  background: var(--category);
  color: #ffffff;
  padding: 12px;
}

.category-sale-strip span {
  font-size: 0.72rem;
  font-weight: 900;
  opacity: 0.9;
  text-transform: uppercase;
}

.category-sale-strip strong {
  font-size: 1.46rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.metric-list span {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.dashboard-category-metrics span {
  border: 1px solid color-mix(in srgb, var(--category) 18%, var(--line));
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  padding: 8px;
}

.metric-list strong {
  color: var(--category, var(--ink));
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  text-transform: none;
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.quick-links.compact {
  grid-template-columns: 1fr;
}

.quick-link {
  --entry: var(--primary);
  min-height: 74px;
  display: grid;
  align-content: center;
  gap: 5px;
  border: 1px solid color-mix(in srgb, var(--entry) 25%, var(--line));
  border-left: 5px solid var(--entry);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #ffffff 0%, color-mix(in srgb, var(--entry) 10%, #ffffff) 100%);
  padding: 12px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.quick-link:hover {
  border-color: var(--entry);
  box-shadow: 0 12px 24px color-mix(in srgb, var(--entry) 14%, transparent);
  transform: translateY(-1px);
}

.quick-link.entry-purchase {
  --entry: #0f766e;
}

.quick-link.entry-consumed {
  --entry: #d97706;
}

.quick-link.entry-production {
  --entry: #2563eb;
}

.quick-link.entry-sale {
  --entry: #b42318;
}

.quick-link strong {
  color: var(--entry);
  font-size: 0.96rem;
}

.quick-link span {
  color: var(--muted);
  font-size: 0.8rem;
}

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

.form-grid .wide,
.form-actions,
.filter-grid .wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 92px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
}

.check-row input[type="checkbox"] {
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  accent-color: var(--primary);
}

.check-row span,
.check-row strong,
.check-row small {
  display: block;
}

.check-row strong {
  color: var(--ink);
}

.check-row small {
  margin-top: 3px;
  color: var(--muted);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.table-wrap {
  overflow: auto;
  width: 100%;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

td {
  font-size: 0.92rem;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-state {
  min-height: 150px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 750;
}

.empty-state.compact {
  min-height: 92px;
}

.compact-table {
  min-width: 520px;
}

.review-panel {
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 13px;
  margin-bottom: 16px;
}

.review-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.review-heading strong {
  font-size: 0.98rem;
}

.review-heading span:not(.badge) {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.review-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.review-list {
  display: grid;
  gap: 8px;
}

.review-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.review-row > span {
  display: inline-flex;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.review-row.critical > span {
  background: #ffe5e1;
  color: var(--danger);
}

.review-row.warning > span {
  background: #fff2d3;
  color: #8a5707;
}

.review-row.advice > span {
  background: #e8f6ec;
  color: var(--success);
}

.review-row strong {
  display: block;
  margin-bottom: 3px;
}

.log-details {
  margin-top: 7px;
}

.log-details summary {
  color: var(--primary-dark);
  cursor: pointer;
  font-weight: 850;
}

.log-details pre {
  max-width: 520px;
  max-height: 260px;
  overflow: auto;
  margin: 8px 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 10px;
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: min(920px, 100%);
  min-height: 540px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.login-brand {
  display: grid;
  align-content: end;
  gap: 12px;
  padding: 34px;
  background: var(--sidebar);
  color: #ffffff;
}

.login-brand .brand-mark {
  width: 68px;
  height: 68px;
}

.login-brand h1 {
  margin: 0;
  font-size: 2.1rem;
}

.login-brand p {
  margin: 0;
  color: #bdd2cb;
}

.login-form {
  display: grid;
  align-content: center;
  gap: 15px;
  padding: 34px;
}

.login-form h2 {
  margin: 4px 0 0;
  font-size: 1.9rem;
}

@media (max-width: 1180px) {
  .grid.four,
  .grid.three,
  .quick-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell,
  .login-card {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .dashboard-hero,
  .watch-card-head,
  .category-card-head {
    flex-direction: column;
  }

  .grid.two,
  .grid.three,
  .grid.four,
  .quick-links,
  .form-grid,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .section-actions,
  .topbar-actions {
    width: 100%;
  }

  .btn {
    width: 100%;
  }

  .review-row {
    grid-template-columns: 1fr;
  }

  .watch-metrics {
    grid-template-columns: 1fr;
  }

  .dashboard-hero-actions {
    width: 100%;
  }
}
