@import url('./styles/print.css');

:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #eef5f1;
  --text: #17201c;
  --muted: #65716c;
  --border: #dce5df;
  --green-900: #0a3d31;
  --green-700: #0f6b4f;
  --green-600: #12845f;
  --green-500: #18a86f;
  --green-100: #e7f7ef;
  --blue: #2d6cdf;
  --blue-soft: #e8f0ff;
  --amber: #b7791f;
  --amber-soft: #fff4d8;
  --red: #c2413a;
  --red-soft: #ffe8e6;
  --shadow: 0 18px 45px rgba(23, 32, 28, 0.08);
  --shadow-soft: 0 8px 24px rgba(23, 32, 28, 0.06);
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar: 278px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.theme-dark {
  color-scheme: dark;
  --bg: #101614;
  --surface: #18211d;
  --surface-soft: #202d28;
  --text: #edf7f1;
  --muted: #9ca9a3;
  --border: #304138;
  --green-900: #d6f5e6;
  --green-700: #7cd8ad;
  --green-600: #55c293;
  --green-500: #37b783;
  --green-100: #1d3a2e;
  --blue-soft: #1b2a47;
  --amber-soft: #392c13;
  --red-soft: #3b1f1d;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.24);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(24, 168, 111, 0.08), transparent 34%),
    var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: inherit;
}

img,
svg {
  display: block;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

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

code {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  background: var(--surface-soft);
}

.gateway-page,
.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-page {
  overflow-x: hidden;
  background:
    linear-gradient(160deg, rgba(10, 61, 49, 0.96), rgba(6, 92, 56, 0.92) 48%, rgba(244, 247, 245, 0.96) 48.2%, rgba(255, 255, 255, 0.98));
}

.auth-page #auth-app,
.auth-page #setup-owner-app {
  width: min(100%, 430px);
}

.gateway-shell {
  width: min(100%, 520px);
}

.gateway-card,
.boot-panel,
.auth-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.gateway-card {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.gateway-logo,
.auth-logo {
  width: 92px;
  height: 92px;
  border-radius: 18px;
  object-fit: cover;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-700);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.gateway-card h1,
.auth-panel h1,
.auth-panel h2 {
  margin: 0;
  line-height: 1.08;
}

.loader-bar {
  overflow: hidden;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-soft);
}

.loader-bar span {
  display: block;
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green-700), var(--green-500));
  animation: load 1.25s ease-in-out infinite;
}

@keyframes load {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(240%); }
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  overflow: hidden;
  border: 1px solid rgba(220, 229, 223, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-panel {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.brand-side {
  display: flex;
  min-height: 620px;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  background:
    linear-gradient(145deg, rgba(15, 107, 79, 0.92), rgba(10, 61, 49, 0.96)),
    var(--green-900);
  color: #fff;
}

.brand-side p {
  max-width: 460px;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.7;
}

.auth-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.auth-highlights span,
.role-chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.auth-highlights span {
  background: rgba(255, 255, 255, 0.14);
}

.form-side {
  padding: 34px;
  background: var(--surface);
}

.auth-brand-simple {
  display: grid;
  justify-items: center;
  gap: 18px;
  margin-bottom: 26px;
  text-align: center;
}

.auth-brand-simple h1 {
  max-width: 320px;
  margin: 0;
  color: var(--text);
  font-size: 30px;
  line-height: 1.08;
}

.auth-panel h2 {
  margin: 0;
  font-size: 18px;
  text-align: center;
}

.auth-tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  background: var(--surface-soft);
}

.auth-tabs.compact {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  width: 100%;
}

.auth-tabs button {
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.auth-tabs button.active {
  background: var(--surface);
  color: var(--green-700);
  box-shadow: var(--shadow-soft);
}

.auth-form,
.entity-form {
  display: grid;
  gap: 16px;
  margin-top: 0;
}

.auth-form {
  gap: 14px;
}

.auth-submit {
  width: 100%;
  min-height: 46px;
  justify-content: center;
}

.auth-note {
  margin-top: 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.auth-actions-inline {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.auth-link {
  color: var(--green-700);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.auth-link:hover {
  text-decoration: underline;
}

.text-success {
  color: var(--green-700);
}

.text-danger {
  color: var(--danger);
}

.login-role-catalog {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.login-role-catalog span {
  border: 1px solid rgba(24, 168, 111, 0.22);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(24, 168, 111, 0.1);
  color: var(--green-700);
  font-size: 11px;
  font-weight: 900;
}

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

.form-field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.form-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.form-field input,
.form-field select,
.form-field textarea,
.search-field {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: 0;
}

.form-field input,
.form-field select,
.form-field textarea {
  min-height: 42px;
  padding: 10px 12px;
}

.form-field textarea {
  min-height: 96px;
  resize: vertical;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.search-field:focus-within {
  border-color: var(--green-500);
  box-shadow: 0 0 0 4px rgba(24, 168, 111, 0.12);
}

.btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
  transition: 0.18s ease;
}

.btn.primary {
  background: var(--green-700);
  color: #fff;
}

.btn.primary:hover {
  background: var(--green-600);
  transform: translateY(-1px);
}

.btn.ghost {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.btn.primary-soft {
  background: rgba(24, 168, 111, 0.12);
  color: var(--green-700);
}

.btn.danger,
.btn.danger-soft {
  background: var(--red);
  color: #fff;
}

.btn.danger-soft {
  background: var(--red-soft);
  color: var(--red);
}

.btn.mini {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}

.icon-btn {
  width: 40px;
  padding: 0;
  border-color: var(--border);
  background: var(--surface);
  color: var(--muted);
}

.icon-btn:hover {
  color: var(--green-700);
  border-color: rgba(24, 168, 111, 0.35);
}

.loading {
  position: relative;
  color: transparent !important;
}

.loading::after {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: #fff;
  border-radius: 999px;
  content: "";
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.app-boot {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.boot-panel {
  width: min(100%, 460px);
  padding: 28px;
}

.boot-panel img {
  width: 64px;
  height: 64px;
  margin-bottom: 22px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  height: 100vh;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
}

.theme-dark .sidebar,
.theme-dark .gateway-card,
.theme-dark .auth-panel,
.theme-dark .boot-panel {
  background: rgba(24, 33, 29, 0.9);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px;
}

.brand-block img {
  width: 48px;
  height: 48px;
}

.brand-block strong,
.user-menu strong,
.panel-title h3,
.section-header h2 {
  display: block;
  margin: 0;
  color: var(--text);
  font-weight: 900;
}

.brand-block span,
.user-menu span,
.panel-title span,
.section-header p,
.table-count,
.sidebar-footer small {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 14px;
  scrollbar-width: thin;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  border-radius: var(--radius);
  padding: 11px 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  background: var(--green-100);
  color: var(--green-700);
}

.sidebar-footer {
  display: grid;
  flex-shrink: 0;
  gap: 8px;
  margin-top: auto;
  padding: 18px 22px 22px;
}

.role-chip {
  align-self: start;
  background: var(--green-100);
  color: var(--green-700);
}

.main-area {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(240px, 440px) auto auto minmax(230px, auto);
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 14px 22px;
  background: rgba(244, 247, 245, 0.86);
  backdrop-filter: blur(16px);
}

.theme-dark .topbar {
  background: rgba(16, 22, 20, 0.86);
}

.mobile-menu {
  display: none;
}

.topbar-title h1 {
  margin: 2px 0 0;
  font-size: 22px;
  line-height: 1.1;
}

.topbar-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 12px;
}

.search-field.compact {
  max-width: 320px;
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: 0;
}

.badge-btn {
  position: relative;
}

.badge-btn span {
  position: absolute;
  top: -7px;
  right: -5px;
  display: grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border: 2px solid var(--bg);
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
}

.user-menu {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-menu > div {
  min-width: 0;
}

.user-menu strong,
.user-menu span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--green-700), var(--green-500));
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.view {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.section-header,
.panel-title,
.table-toolbar,
.modal-header,
.modal-footer,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-header {
  margin-bottom: 2px;
}

.section-header h2 {
  font-size: 24px;
}

.section-header p {
  margin: 6px 0 0;
  font-size: 14px;
}

.section-actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.muted-text {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.role-access-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-soft);
}

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

.role-access-head strong {
  color: var(--text);
  font-size: 14px;
}

.role-access-head small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.role-access-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  max-height: 210px;
  overflow-y: auto;
  padding-right: 3px;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.check-line input {
  width: 16px;
  height: 16px;
  accent-color: var(--green-700);
}

.check-line span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(8, minmax(110px, 1fr));
  gap: 10px;
  align-items: end;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.filter-panel label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.filter-panel span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.filter-panel select,
.filter-panel input {
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  outline: 0;
}

.filter-panel select:focus,
.filter-panel input:focus {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(24, 168, 111, 0.12);
}

.process-filter-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.process-filter-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
}

.process-filter-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
}

.process-filter-tab strong {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.process-filter-tab span {
  display: grid;
  min-width: 28px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.process-filter-tab.active {
  border-color: var(--green-600);
  background: var(--green-700);
  color: #fff;
}

.process-filter-tab.active span {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.inline-filter {
  margin: 10px 0 14px;
  max-width: 360px;
}

.inline-filter label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.inline-filter select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

.bom-builder,
.formula-document {
  display: grid;
  gap: 14px;
}

.bom-entry {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface-soft);
}

.bom-entry > strong,
.bom-entry-head strong {
  font-size: 13px;
}

.bom-entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-list a {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--surface-soft);
  color: var(--green-700);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

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

.signature-preview-grid > div {
  display: grid;
  gap: 8px;
}

.signature-preview-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 14px;
}

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

.metric-card,
.panel,
.mini-stat {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.metric-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 136px;
  padding: 16px;
}

.metric-card span,
.mini-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.metric-card strong,
.mini-stat strong {
  display: block;
  margin-top: 7px;
  font-size: 28px;
  line-height: 1;
}

.metric-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.metric-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--green-100);
  color: var(--green-700);
}

.tone-blue .metric-icon,
.metric-card.tone-blue {
  --tone-bg: var(--blue-soft);
  --tone-color: var(--blue);
}

.tone-amber .metric-icon,
.metric-card.tone-amber {
  --tone-bg: var(--amber-soft);
  --tone-color: var(--amber);
}

.tone-red .metric-icon,
.metric-card.tone-red {
  --tone-bg: var(--red-soft);
  --tone-color: var(--red);
}

.metric-card.tone-blue .metric-icon,
.metric-card.tone-amber .metric-icon,
.metric-card.tone-red .metric-icon {
  background: var(--tone-bg);
  color: var(--tone-color);
}

.content-grid {
  display: grid;
  gap: 18px;
}

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

.span-2 {
  grid-column: span 2;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-title {
  margin-bottom: 14px;
}

.panel-title h3 {
  font-size: 16px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 12px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.data-table th {
  background: var(--surface-soft);
}

.data-table th button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-align: left;
  text-transform: uppercase;
}

.data-table th button span {
  color: var(--green-700);
  font-size: 10px;
}

.data-table td strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 850;
}

.data-table td small {
  display: block;
  color: var(--muted);
  line-height: 1.45;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table select {
  max-width: 150px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-pill.success,
.status-pill.approved {
  background: var(--green-100);
  color: var(--green-700);
}

.status-pill.warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.danger {
  background: var(--red-soft);
  color: var(--red);
}

.status-pill.info {
  background: var(--blue-soft);
  color: var(--blue);
}

.status-pill.neutral {
  background: var(--surface-soft);
  color: var(--muted);
}

.progress {
  position: relative;
  overflow: hidden;
  min-width: 130px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-soft);
}

.progress span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green-700), var(--green-500));
}

.progress b {
  position: relative;
  z-index: 1;
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--text);
  font-size: 11px;
  font-weight: 900;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
  align-items: end;
  gap: 14px;
  min-height: 260px;
  padding: 14px 4px 0;
}

.bar-item {
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 8px;
  min-height: 220px;
  text-align: center;
}

.bar-track {
  display: flex;
  align-items: end;
  justify-content: center;
  min-height: 160px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.bar-track span {
  display: block;
  width: min(34px, 72%);
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, var(--green-500), var(--green-700));
}

.bar-item strong {
  font-size: 12px;
}

.bar-item small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(180px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.compact-kanban {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
}

.production-kanban {
  grid-template-columns: repeat(11, minmax(190px, 1fr));
}

.kanban-column {
  display: grid;
  gap: 10px;
  min-width: 180px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-soft);
}

.kanban-column header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
}

.kanban-column header strong {
  font-size: 12px;
  line-height: 1.25;
}

.kanban-column header span:last-child {
  display: grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

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

.kanban-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--surface);
}

.kanban-card strong,
.kanban-card span,
.kanban-card small {
  display: block;
}

.kanban-card span,
.kanban-card small,
.kanban-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.activity-list,
.batch-list,
.stock-alert-list,
.shipment-map,
.checklist,
.workflow-stack,
.process-timeline {
  display: grid;
  gap: 10px;
}

.activity-list.compact {
  gap: 8px;
}

.activity-item,
.batch-row,
.stock-alert-list article,
.shipment-map article {
  display: grid;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
}

.activity-item {
  grid-template-columns: 10px 1fr;
}

.activity-item > span {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--green-500);
}

.activity-item strong,
.stock-alert-list strong,
.shipment-map strong {
  display: block;
  font-size: 13px;
}

.activity-item p,
.stock-alert-list span,
.shipment-map p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.batch-row {
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 240px) auto;
  align-items: center;
}

.stock-alert-list article {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.shipment-map {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.checklist label {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 750;
}

.workflow-stack article {
  display: grid;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
}

.workflow-stack article strong {
  font-size: 18px;
}

.workflow-stack article small {
  color: var(--muted);
  line-height: 1.45;
}

.workflow-timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.workflow-timeline article {
  display: grid;
  min-width: 120px;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-soft);
}

.workflow-timeline article.complete {
  border-color: rgba(24, 168, 111, 0.36);
  background: var(--green-100);
}

.workflow-timeline span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--green-700);
  font-size: 12px;
  font-weight: 900;
}

.workflow-timeline strong {
  font-size: 13px;
  line-height: 1.25;
}

.workflow-timeline small {
  color: var(--muted);
  font-size: 11px;
}

.approval-card,
.formula-document,
.process-detail {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface-soft);
}

.approval-card strong,
.approval-card span,
.approval-card p,
.approval-card em {
  display: block;
}

.approval-card span,
.approval-card p,
.approval-card em,
.formula-document p,
.process-detail p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.formula-document h3,
.process-detail h3 {
  margin: 14px 0 6px;
  font-size: 13px;
}

.invoice-template-preview {
  margin: 10px 0 0;
  padding: 12px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: "Courier New", monospace;
  font-size: 12px;
  line-height: 1.55;
}

.operator-template,
.qc-template {
  display: grid;
  gap: 8px;
  grid-column: 1 / -1;
  border: 1px solid rgba(15, 107, 79, 0.18);
  border-radius: var(--radius);
  padding: 14px;
  background: linear-gradient(135deg, rgba(24, 168, 111, 0.1), rgba(255, 255, 255, 0.72));
}

.operator-template span,
.qc-template span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.operator-template strong,
.qc-template strong {
  color: var(--text);
  font-size: 18px;
}

.operator-template p,
.qc-template p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.operator-template.locked {
  border-color: rgba(199, 66, 56, 0.25);
  background: rgba(199, 66, 56, 0.08);
}

.lock-note {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
  font-weight: 850;
}

.operator-btn {
  min-height: 48px;
  padding-inline: 18px;
  font-size: 14px;
}

.operator-actions {
  align-items: stretch;
}

.operator-actions .btn {
  min-height: 36px;
}

.operator-actions .btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.signature-preview {
  width: min(100%, 360px);
  min-height: 96px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  object-fit: contain;
}

.ready-shipping-list {
  display: grid;
  gap: 10px;
}

.ready-shipping-list article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
}

.ready-shipping-list strong,
.ready-shipping-list span {
  display: block;
}

.ready-shipping-list span {
  color: var(--muted);
  font-size: 12px;
}

.process-timeline article {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
}

.process-timeline span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.process-timeline p {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
}

.production-progress-map {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 0;
  margin: 14px 0 18px;
  overflow-x: auto;
  padding: 4px 0 8px;
}

.production-progress-map article {
  position: relative;
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  padding: 0 12px 10px;
  background: transparent;
}

.production-progress-map article::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border);
}

.production-progress-map article:first-child::before {
  left: 50%;
}

.production-progress-map article:last-child::before {
  right: 50%;
}

.production-progress-map article.is-complete {
  color: var(--green-700);
}

.production-progress-map article.is-active {
  color: #a96500;
}

.production-progress-map article.is-reject {
  color: #b72b2b;
}

.production-progress-map article.is-complete::before {
  background: rgba(24, 168, 111, 0.55);
}

.production-progress-map article.is-active::before {
  background: rgba(217, 147, 21, 0.55);
}

.production-progress-map article.is-reject::before {
  background: rgba(200, 57, 57, 0.55);
}

.production-progress-map span {
  position: relative;
  z-index: 1;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  justify-self: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--green-700);
  border: 2px solid var(--border);
  font-size: 12px;
  font-weight: 900;
}

.production-progress-map article.is-complete span {
  background: var(--green-600);
  border-color: var(--green-600);
  color: white;
}

.production-progress-map article.is-active span {
  background: #fff7e6;
  border-color: rgba(217, 147, 21, 0.78);
  color: #a96500;
}

.production-progress-map article.is-reject span {
  background: #fff1f1;
  border-color: rgba(200, 57, 57, 0.78);
  color: #b72b2b;
}

.production-progress-map strong,
.production-progress-map small,
.production-progress-map em {
  min-width: 0;
  text-align: center;
}

.production-progress-map small {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
}

.production-progress-map em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.process-timeline .upload-preview {
  margin-top: 10px;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
}

.timeline.dense {
  display: grid;
}

.timeline.dense li {
  align-items: start;
}

.timeline.dense .timeline-copy {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.timeline.dense .timeline-copy .status-pill {
  width: max-content;
  max-width: 100%;
  min-height: 24px;
  line-height: 1.2;
  white-space: normal;
}

.timeline.dense small {
  color: var(--muted);
}

.upload-preview {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  min-height: 86px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-soft);
}

.upload-preview > span {
  align-self: center;
  color: var(--muted);
  font-size: 13px;
}

.upload-preview article {
  display: grid;
  gap: 6px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--surface);
}

.upload-preview img,
.file-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--green-100);
}

.file-preview {
  display: grid;
  place-items: center;
  color: var(--green-700);
  font-weight: 900;
}

.upload-preview strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.upload-preview small {
  color: var(--muted);
  font-size: 11px;
}

.signature-field {
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
}

.signature-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.signature-field canvas {
  width: 100%;
  min-height: 150px;
  border: 1px dashed rgba(15, 107, 79, 0.38);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
  touch-action: none;
  user-select: none;
}

.signature-field small {
  color: var(--muted);
  font-size: 12px;
}

.camera-capture-field {
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-soft);
}

.camera-capture-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.camera-file-input {
  width: 100%;
}

.camera-live-preview {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #0b1310;
  aspect-ratio: 16 / 9;
}

.camera-live-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-capture-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.camera-capture-field small {
  color: var(--muted);
  font-size: 12px;
}

.checklist input {
  accent-color: var(--green-700);
}

.mini-stat {
  padding: 18px;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--green-100);
  color: var(--green-700);
}

.empty-state h3,
.empty-state p {
  margin: 0;
}

.empty-state p {
  max-width: 360px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.skeleton-stack {
  display: grid;
  gap: 12px;
}

.skeleton-line {
  height: 14px;
  width: 72%;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.skeleton-line.wide {
  width: 100%;
}

.skeleton-line::after {
  display: block;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  content: "";
  animation: load 1.3s ease-in-out infinite;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 10, 7, 0.52);
}

.modal {
  display: flex;
  flex-direction: column;
  width: min(100%, 620px);
  max-height: min(860px, 92vh);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal.lg {
  width: min(100%, 880px);
}

.modal-header,
.modal-footer {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.modal-footer {
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.modal-copy {
  color: var(--muted);
  line-height: 1.65;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.detail-grid div {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-soft);
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.detail-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 13px;
}

.timeline {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  align-items: center;
}

.timeline li span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.timeline li.done span,
.timeline li.active span {
  border-color: transparent;
  background: var(--green-700);
  color: #fff;
}

.timeline li.active p {
  color: var(--green-700);
  font-weight: 900;
}

.timeline p {
  margin: 0;
  font-size: 13px;
}

.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 36px));
}

.toast {
  transform: translateY(12px);
  opacity: 0;
  border: 1px solid var(--border);
  border-left: 4px solid var(--green-500);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: 0.22s ease;
}

.toast.danger {
  border-left-color: var(--red);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast strong,
.toast span {
  display: block;
}

.toast span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.error-panel h1 {
  margin: 0 0 8px;
}

.error-panel p {
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 1280px) {
  .dashboard-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .topbar {
    grid-template-columns: minmax(170px, 1fr) minmax(220px, 320px) auto auto minmax(220px, auto);
  }

  .filter-panel {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .user-menu {
    grid-column: auto;
    justify-self: stretch;
  }
}

@media (max-width: 980px) {
  .auth-shell,
  .content-grid.two {
    grid-template-columns: 1fr;
  }

  .brand-side {
    min-height: auto;
    padding: 34px;
  }

  .span-2 {
    grid-column: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-104%);
    width: min(86vw, 310px);
    transition: transform 0.22s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu {
    display: inline-flex;
  }

  .topbar {
    grid-template-columns: auto 1fr auto auto;
  }

  .global-search {
    grid-column: 1 / -1;
    order: 2;
    max-width: none;
  }

  .user-menu {
    grid-column: 1 / -1;
    justify-self: stretch;
    order: 3;
  }
}

@media (max-width: 720px) {
  body {
    background: var(--bg);
  }

  body.auth-page {
    background:
      linear-gradient(165deg, rgba(10, 61, 49, 0.96), rgba(6, 92, 56, 0.92) 42%, rgba(255, 255, 255, 0.98) 42.2%, rgba(255, 255, 255, 1));
  }

  .gateway-page,
  .auth-page {
    padding: 12px;
  }

  .form-side,
  .brand-side {
    padding: 24px;
  }

  .auth-brand-simple h1 {
    font-size: 25px;
  }

  .auth-tabs.compact {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .dashboard-grid,
  .filter-panel,
  .detail-grid,
  .batch-row,
  .stock-alert-list article {
    grid-template-columns: 1fr;
  }

  .topbar {
    gap: 8px;
    padding: 12px;
  }

  .topbar-title h1 {
    font-size: 18px;
  }

  .view {
    padding: 14px;
  }

  .section-header,
  .panel-title,
  .table-toolbar,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .section-actions,
  .row-actions,
  .ready-shipping-list article {
    width: 100%;
  }

  .ready-shipping-list article {
    grid-template-columns: 1fr;
  }

  .section-actions .btn,
  .row-actions .btn,
  .form-actions .btn {
    flex: 1 1 auto;
  }

  .modal-backdrop {
    padding: 8px;
  }

  .modal {
    max-height: 96vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
