:root {
  --ink: #202a36;
  --muted: #667385;
  --line: #d8dee8;
  --surface: #ffffff;
  --band: #f3f6fa;
  --teal: #25705c;
  --blue: #2b5d88;
  --gold: #b68434;
  --red: #b94d44;
  --focus: #1f6fb2;
  --shadow: 0 12px 34px rgba(32, 42, 54, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  background: var(--band);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus), transparent 65%);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #edf2f7;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel .brand-mark {
  margin-bottom: 4px;
}

.login-panel p {
  color: var(--muted);
}

.login-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.login-panel input {
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-error {
  min-height: 20px;
  color: var(--red);
  font-weight: 700;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: block;
  object-fit: contain;
  object-position: center;
  background: transparent;
  border-radius: 8px;
}

.brand-block strong,
.brand-block span {
  display: block;
  line-height: 1.2;
}

.brand-block strong {
  font-size: 18px;
}

.brand-block span {
  color: var(--muted);
  font-size: 13px;
}

.user-badge {
  color: var(--muted);
  font-size: 13px;
}

.new-menu {
  position: relative;
}

.new-menu summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  cursor: pointer;
}

.new-menu summary::-webkit-details-marker {
  display: none;
}

.new-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  display: none;
  width: min(380px, calc(100vw - 24px));
  max-height: min(620px, calc(100vh - 110px));
  overflow: auto;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.new-menu[open] .new-menu-panel,
.new-menu:hover .new-menu-panel,
.new-menu:focus-within .new-menu-panel {
  display: block;
}

.new-menu-group + .new-menu-group {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.new-menu-group h3 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.new-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
  font-weight: 700;
}

.new-menu-item:hover,
.new-menu-item:focus-visible {
  background: #eef3f8;
  border-color: var(--line);
}

.new-menu-item span {
  color: var(--teal);
  font-weight: 900;
}

.top-actions,
.toolbar,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.sidebar {
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  overflow: auto;
  padding: 18px 14px 28px;
  background: #e8edf4;
  border-right: 1px solid var(--line);
}

.nav-group {
  margin-top: 18px;
}

.nav-group h2 {
  margin: 14px 10px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  margin: 2px 0;
  padding: 9px 10px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.72);
}

.nav-item.active {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 3px 10px rgba(32, 42, 54, 0.06);
}

.nav-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  background: var(--blue);
  border-radius: 50%;
}

.nav-item[data-section="inventory"] .nav-dot {
  background: var(--gold);
}

.nav-item[data-section="finance"] .nav-dot {
  background: var(--red);
}

.nav-item[data-section="production"] .nav-dot {
  background: var(--teal);
}

.workspace {
  min-width: 0;
}

.dashboard-band,
.content-band {
  padding: 24px;
}

.dashboard-band {
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.dashboard-heading,
.content-heading,
.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 22px;
  line-height: 1.2;
}

.dashboard-heading p {
  margin-top: 6px;
  color: var(--muted);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
}

.metric-card {
  min-height: 104px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: 26px;
  line-height: 1;
}

.content-band {
  background: var(--surface);
}

.toolbar input {
  width: min(280px, 38vw);
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-meta {
  min-height: 20px;
  margin: -8px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button {
  padding: 0 14px;
  color: #fff;
  background: var(--teal);
}

.secondary-button {
  padding: 0 14px;
  color: var(--ink);
  background: #eef3f8;
  border-color: var(--line);
}

.danger-button {
  padding: 0 14px;
  color: #fff;
  background: var(--red);
}

.icon-button {
  min-width: 38px;
  padding: 0 9px;
  color: var(--ink);
  background: #eef3f8;
  border-color: var(--line);
  font-size: 20px;
  line-height: 1;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f6f8fb;
  font-size: 13px;
  font-weight: 800;
}

td {
  background: var(--surface);
  max-width: 320px;
}

tr:hover td {
  background: #fbfcfe;
}

.row-actions {
  display: flex;
  gap: 8px;
  min-width: 156px;
}

.small-button {
  min-height: 30px;
  padding: 0 10px;
  color: var(--ink);
  background: #eef3f8;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 700;
}

.empty-state {
  margin-top: 18px;
  padding: 22px;
  color: var(--muted);
  background: #f8fafc;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.import-options {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 1fr);
  gap: 14px 16px;
  margin-bottom: 16px;
}

.import-source {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.import-source textarea {
  width: 100%;
  min-height: 130px;
  padding: 10px 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
}

.import-source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.import-options label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.import-options select {
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.import-checkbox {
  align-self: end;
  color: var(--ink) !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  padding-top: 0;
}

.dialog-note {
  margin-top: 6px;
  color: var(--muted);
}

.import-preview-wrap {
  max-height: 280px;
}

dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 36px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(32, 42, 54, 0.42);
}

.record-form {
  padding: 22px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  max-height: min(62vh, 620px);
  overflow: auto;
  padding-right: 4px;
}

.field {
  display: grid;
  gap: 6px;
}

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

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding-top: 20px;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
}

.dialog-actions {
  margin-top: 18px;
}

.dialog-spacer {
  flex: 1;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  transform: translateY(16px);
  opacity: 0;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  color: #fff;
  background: var(--ink);
  border-radius: 8px;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    padding: 12px 14px;
  }

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

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 12px;
  }

  .nav-group {
    grid-column: 1 / -1;
  }

  .dashboard-band,
  .content-band {
    padding: 18px 14px;
  }

  .dashboard-heading,
  .content-heading,
  .dialog-heading {
    display: grid;
  }

  .metric-grid,
  .form-grid,
  .import-options {
    grid-template-columns: 1fr;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar input {
    width: 100%;
  }
}
