:root {
  --ink: #172126;
  --muted: #647176;
  --line: #d8e0df;
  --panel: #ffffff;
  --surface: #f4f7f6;
  --accent: #166f68;
  --accent-dark: #0e504b;
  --gold: #a96f19;
  --red: #a4362f;
  --blue: #2d668f;
  --shadow: 0 18px 48px rgba(22, 33, 38, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.landing-screen {
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(rgba(244, 247, 246, 0.86), rgba(244, 247, 246, 0.92)),
    repeating-linear-gradient(90deg, rgba(22, 111, 104, 0.08) 0 1px, transparent 1px 92px),
    repeating-linear-gradient(0deg, rgba(45, 102, 143, 0.07) 0 1px, transparent 1px 72px),
    #f4f7f6;
}

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
}

.landing-nav .brand-block {
  margin-bottom: 0;
  color: var(--ink);
}

.landing-nav .brand-block p {
  color: var(--muted);
}

.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr);
  align-items: center;
  gap: 48px;
  max-width: 1180px;
  min-height: calc(100vh - 110px);
  margin: 0 auto;
  padding: 42px 0 32px;
}

.landing-copy h1 {
  margin: 0;
  font-size: clamp(48px, 8vw, 104px);
  line-height: 0.95;
}

.landing-lead {
  max-width: 680px;
  margin: 20px 0 0;
  color: #425156;
  font-size: 20px;
  line-height: 1.55;
}

.landing-actions,
.landing-points {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.landing-points span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.landing-company {
  display: grid;
  gap: 5px;
  max-width: 620px;
  margin-top: 24px;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.landing-company strong {
  color: var(--ink);
  font-size: 15px;
}

.landing-company .license-owner {
  color: var(--accent-dark);
}

.landing-visual {
  min-width: 0;
}

.landing-dashboard {
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid rgba(22, 111, 104, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.dash-header,
.dash-metrics,
.dash-table div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.dash-header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
}

.dash-header strong,
.dash-metrics strong,
.dash-table strong {
  color: var(--ink);
}

.dash-metrics {
  align-items: stretch;
}

.dash-metrics div {
  display: grid;
  gap: 8px;
  min-width: 0;
  flex: 1;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.dash-metrics span,
.dash-table span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dash-metrics strong {
  font-size: 30px;
}

.dash-table {
  display: grid;
  gap: 10px;
}

.dash-table div {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.help-page {
  display: grid;
  gap: 18px;
  max-width: 1050px;
  padding: 8px 0;
}

.help-section {
  display: grid;
  gap: 10px;
}

.help-section h3 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
}

.help-section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.help-steps div {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.help-steps strong {
  color: var(--accent-dark);
}

.help-steps span {
  color: var(--muted);
  line-height: 1.45;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 6px;
}

.contact-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(135deg, #f4f7f6 0%, #e4eeeb 100%);
}

.license-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 18px;
  background: #eef3f1;
}

.license-screen[hidden] {
  display: none;
}

.license-card {
  display: grid;
  gap: 14px;
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.license-card h1,
.license-card p {
  margin: 0;
}

.license-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.license-card input {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.menu-license-owner {
  display: block;
  margin-top: 3px;
  color: #9ed6ce;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.25;
}

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

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.login-card input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--ink);
}

.login-brand {
  margin-bottom: 6px;
  color: var(--ink);
}

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

.login-error {
  margin: 0;
  color: var(--red);
  font-weight: 750;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  background: #102326;
  color: #f5faf8;
  padding: 24px 18px;
}

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

.app-brand-link {
  cursor: pointer;
  border-radius: 8px;
}

.app-brand-link:focus-visible {
  outline: 2px solid #d69b2d;
  outline-offset: 4px;
}

.storage-badge {
  margin-left: auto;
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.storage-badge.online {
  color: #063d33;
  background: #b8f4df;
}

.storage-badge.offline {
  color: #5c3504;
  background: #ffe2a6;
}

#logoutBtn {
  order: 99;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: #1b6d65;
  font-weight: 800;
}

.brand-block h1,
.brand-block p,
.topbar h2,
.dialog-header h2,
.empty-state h3 {
  margin: 0;
}

.brand-block h1 {
  font-size: 21px;
}

.brand-block p {
  color: #b7c8c5;
  font-size: 13px;
}

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

.nav-group {
  margin: 5px 0;
  padding: 8px 0 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 12px 5px;
  color: #9ed6ce;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  list-style: none;
  text-transform: uppercase;
}

.nav-group-title::-webkit-details-marker {
  display: none;
}

.nav-group-title::after {
  color: #dbe8e5;
  content: ">";
  font-size: 16px;
  line-height: 1;
  transition: transform 160ms ease;
}

.nav-group[open] .nav-group-title::after {
  transform: rotate(90deg);
}

.nav-submenu {
  display: grid;
  gap: 3px;
  margin-top: 5px;
}

.nav-button.nav-submenu-button {
  min-height: 38px;
  padding: 8px 12px 8px 24px;
  color: #c8d9d6;
  font-size: 13px;
}

.nav-button.nav-submenu-button::before {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #75b9af;
  content: "";
  flex: 0 0 auto;
}

.nav-button.nav-submenu-button.active::before {
  background: #ffffff;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  color: #dbe8e5;
  background: transparent;
  text-align: left;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: #9ed6ce;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.topbar,
.dialog-header,
.dialog-footer,
.section-toolbar,
.metrics-row {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.topbar h2,
.dialog-header h2 {
  font-size: 30px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-actions,
.dialog-footer {
  display: flex;
  gap: 10px;
}

.top-actions {
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mobile-menu-button {
  display: none;
}

.user-chip {
  align-self: center;
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.session-panel {
  display: grid;
  gap: 2px;
  min-width: 190px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.session-panel strong {
  color: var(--ink);
  font-size: 12px;
}

.quick-transaction-actions {
  display: flex;
  gap: 8px;
  padding-right: 4px;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button,
.quick-transaction-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 13px;
  font-weight: 750;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

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

.quick-transaction-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #e8f4f1;
  border-color: #bedbd5;
  color: var(--accent-dark);
}

.quick-transaction-button:hover,
.quick-transaction-button.active {
  background: var(--accent);
  color: #ffffff;
}

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

.danger-button {
  background: #fff6f5;
  border-color: #efc8c4;
  color: var(--red);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  padding: 0;
  background: #ffffff;
  border-color: var(--line);
}

.icon-only {
  display: inline-grid;
  place-items: center;
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
}

.button-icon {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.danger-button .button-icon {
  color: var(--red);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  pointer-events: none;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metric {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 28px;
}

.data-band {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.section-toolbar {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  width: min(420px, 100%);
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
}

.report-select {
  min-height: 42px;
  width: min(560px, 100%);
  flex: 1 1 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 700;
}

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

.report-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 8px;
  flex: 1;
  min-width: min(620px, 100%);
}

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

#reportCustomerFilter[multiple] {
  min-height: 116px;
  padding: 4px;
}

#reportCustomerFilter[multiple] option {
  padding: 5px 7px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

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

th {
  color: #455155;
  background: #eef4f2;
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

tr.total-row td {
  background: #eef4f2;
  color: var(--ink);
  font-weight: 800;
}

.table-wrap[data-module="units"] th:nth-child(3),
.table-wrap[data-module="units"] td:nth-child(3) {
  width: 190px;
}

.table-wrap[data-module="units"] th:nth-child(4),
.table-wrap[data-module="units"] td:nth-child(4),
.table-wrap[data-module="units"] th:nth-child(5),
.table-wrap[data-module="units"] td:nth-child(5) {
  width: 110px;
  white-space: nowrap;
}

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

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e7f3f1;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

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

.empty-state {
  padding: 38px 20px;
  text-align: center;
}

.empty-state p {
  margin: 7px 0 0;
  color: var(--muted);
}

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

dialog::backdrop {
  background: rgba(8, 18, 20, 0.48);
}

#recordForm {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 34px);
}

#databaseEditorForm {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 34px);
}

#externalImportForm {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 34px);
}

#lastBillDateLotForm,
#emptySelectedTableForm {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 34px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.utility-panel {
  display: grid;
  gap: 14px;
  overflow: auto;
  padding: 20px 22px;
}

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

.utility-table-wrap {
  max-height: 56vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.utility-table-wrap table {
  min-width: 980px;
}

.utility-table-wrap input[type="date"] {
  width: 150px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
}

.danger-panel {
  background: #fffafa;
}

.empty-table-summary {
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid #efc8c4;
  border-radius: 8px;
  background: #fff6f5;
}

.empty-table-summary strong {
  color: var(--red);
}

.empty-table-summary span {
  color: #7c4944;
  font-weight: 750;
}

.danger-confirm {
  border-color: #efc8c4;
}

.external-import-grid {
  grid-template-columns: 1fr;
}

.import-diagnostics {
  display: grid;
  gap: 8px;
}

.import-diagnostics > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.external-preview-table-wrap {
  max-height: 54vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.external-preview-table {
  min-width: 1400px;
}

.external-preview-table th,
.external-preview-table td {
  padding: 8px 10px;
  white-space: nowrap;
}

.external-preview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.database-editor {
  display: grid;
  gap: 16px;
  overflow: auto;
  padding: 20px 22px;
}

.database-section {
  display: grid;
  gap: 8px;
}

.database-section h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  font-size: 15px;
}

.database-section h3 span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

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

.database-edit-table {
  min-width: 980px;
}

.database-edit-table th,
.database-edit-table td {
  padding: 8px;
}

.database-edit-table input,
.database-edit-table textarea {
  width: 180px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  background: #ffffff;
  color: var(--ink);
}

.database-edit-table textarea {
  min-height: 70px;
  resize: both;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.dialog-header {
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}

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

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

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

.field.group-title {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--blue);
  font-weight: 850;
}

.rate-table-field {
  gap: 10px;
}

.rate-table-title {
  margin-top: 8px;
}

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

.rate-entry-table {
  min-width: 480px;
}

.rate-entry-table th,
.rate-entry-table td {
  padding: 9px 10px;
}

.rate-entry-table th:nth-child(2),
.rate-entry-table td:nth-child(2),
.rate-entry-table th:nth-child(3),
.rate-entry-table td:nth-child(3) {
  width: 135px;
}

.period-rate-table th:nth-child(2),
.period-rate-table td:nth-child(2) {
  width: 90px;
  white-space: nowrap;
}

.period-rate-table th:nth-child(3),
.period-rate-table td:nth-child(3) {
  width: 150px;
}

.rate-checking-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.rate-checking-toolbar label {
  display: grid;
  gap: 6px;
  min-width: min(340px, 100%);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.rate-checking-toolbar select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #ffffff;
  color: var(--ink);
  text-transform: none;
  font-size: 14px;
  font-weight: 700;
}

.embedded-table-row > td {
  padding: 0;
}

.rate-checking-table {
  min-width: 1100px;
}

.rate-checking-table th:nth-child(7),
.rate-checking-table td:nth-child(7),
.rate-checking-table th:nth-child(8),
.rate-checking-table td:nth-child(8) {
  width: 120px;
}

.rate-checking-table input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
}

.rate-checking-table input[type="number"] {
  max-width: 110px;
}

.lot-history-shell,
.movement-dashboard {
  display: grid;
  gap: 18px;
}

.lot-history-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.lot-history-card > header,
.movement-panel > header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.lot-history-card h3,
.movement-panel h3,
.lot-history-section h3 {
  margin: 0;
  font-size: 16px;
}

.lot-history-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.lot-history-meta span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7faf9;
}

.lot-history-section {
  display: grid;
  gap: 8px;
}

.lot-history-table {
  min-width: 980px;
}

.movement-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.movement-toolbar,
.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.movement-toolbar label,
.pagination-controls label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.movement-toolbar input,
.pagination-controls select {
  width: 82px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
}

.pagination-row td {
  background: #f8fbfa;
}

.dashboard-page {
  display: grid;
  gap: 18px;
}

.dashboard-license {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #ffffff;
}

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

.dashboard-license strong {
  display: block;
  color: var(--ink);
  text-align: right;
}

.dashboard-license small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
  text-align: right;
}

.party-stock-toolbar,
.party-stock-legend,
.help-chat-row {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.party-stock-toolbar label {
  display: grid;
  gap: 6px;
}

.party-stock-toolbar select,
.help-chat-row input {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.help-chat-row input {
  flex: 1 1 300px;
}

.help-chat-answer {
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  line-height: 1.55;
}

.party-stock-legend span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 750;
}

.age-under, .age-row-under { background: #e8f6ec; }
.age-60, .age-row-60 { background: #fff4cc; }
.age-90, .age-row-90 { background: #fde2e2; }

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

.dashboard-metrics div,
.dashboard-menu-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.dashboard-metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.dashboard-metrics strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

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

.dashboard-insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.dashboard-menu-group h3,
.dashboard-insight-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.dashboard-menu-group > div {
  display: grid;
  gap: 8px;
}

.dashboard-insight-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.dashboard-insight-card > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid #edf1f2;
}

.dashboard-insight-card > div span {
  min-width: 0;
  color: var(--text);
  font-weight: 700;
}

.dashboard-insight-card > div strong {
  white-space: nowrap;
}

.dashboard-menu-button {
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--text);
  text-align: left;
}

.dashboard-menu-button strong,
.dashboard-menu-button span {
  display: block;
}

.dashboard-menu-button span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-menu-button:hover {
  border-color: #1f6f63;
  background: #eef7f4;
}

.movement-summary div,
.movement-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.movement-summary span,
.movement-panel header span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.movement-summary strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.movement-bars {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.movement-row {
  display: grid;
  grid-template-columns: 32px minmax(140px, 220px) minmax(180px, 1fr) 82px;
  align-items: center;
  gap: 10px;
}

.movement-rank {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #eef4f2;
  font-weight: 800;
}

.movement-label {
  font-weight: 800;
}

.movement-track {
  height: 13px;
  border-radius: 999px;
  background: #edf1f2;
  overflow: hidden;
}

.movement-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1f6f63, #d69b2d);
}

.movement-value {
  text-align: right;
  font-weight: 800;
}

.rate-entry-table input {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  text-align: right;
}

.automation-entry-table {
  min-width: 420px;
}

.permissions-entry-table {
  min-width: 760px;
}

.permissions-entry-table th:not(:first-child),
.permissions-entry-table td:not(:first-child) {
  width: 120px;
  text-align: center;
}

.automation-entry-table th:nth-child(2),
.automation-entry-table td:nth-child(2) {
  width: 110px;
  text-align: center;
}

.transaction-charge-table {
  min-width: 540px;
}

.transaction-charge-table th:nth-child(2),
.transaction-charge-table td:nth-child(2),
.transaction-charge-table th:nth-child(3),
.transaction-charge-table td:nth-child(3),
.transaction-charge-table th:nth-child(4),
.transaction-charge-table td:nth-child(4) {
  width: 125px;
}

.transaction-charge-table input[readonly] {
  background: #f4f7f6;
  color: var(--muted);
}

.stock-out-lot-qty-table {
  min-width: 620px;
}

.invoice-preview-table {
  min-width: 1280px;
}

.invoice-preview-table .charge-detail {
  display: grid;
  gap: 3px;
  min-width: 86px;
  white-space: nowrap;
}

.invoice-preview-table .charge-detail span {
  color: var(--muted);
  font-size: 11px;
}

.invoice-preview-table .charge-detail strong {
  color: var(--ink);
  font-size: 12px;
}

.stock-out-lot-qty-table th:nth-child(3),
.stock-out-lot-qty-table td:nth-child(3),
.stock-out-lot-qty-table th:nth-child(4),
.stock-out-lot-qty-table td:nth-child(4) {
  width: 130px;
  white-space: nowrap;
}

.field input[readonly] {
  background: #f4f7f6;
  color: var(--muted);
}

.table-checkbox {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  font-weight: 750;
}

.table-checkbox input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.inline-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.field label {
  color: #435155;
  font-size: 13px;
  font-weight: 750;
}

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

.field select[multiple] {
  min-height: 132px;
}

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

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 750;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.number-field {
  max-width: 190px;
}

.file-field {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
}

.file-field .icon-only {
  flex: 0 0 auto;
}

.form-image-preview,
.table-image {
  display: block;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.form-image-preview {
  width: 72px;
  height: 48px;
}

.table-image {
  width: 54px;
  height: 38px;
}

.file-hint {
  display: grid;
  place-items: center;
  width: 72px;
  height: 48px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.lot-detail-row td,
.lot-closing-row td {
  font-weight: 700;
}

.dialog-footer {
  justify-content: flex-end;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--line);
}

@media (max-width: 840px) {
  .landing-hero,
  .help-steps {
    grid-template-columns: 1fr;
  }

  .landing-hero {
    gap: 28px;
    align-items: start;
    min-height: auto;
  }

  .landing-lead {
    font-size: 17px;
  }

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(310px, 86vw);
    overflow: auto;
    padding: 16px;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 18px 0 42px rgba(8, 18, 20, 0.24);
  }

  body.mobile-menu-open .sidebar {
    transform: translateX(0);
  }

  .nav-list {
    grid-template-columns: 1fr;
  }

  .mobile-menu-button {
    display: inline-grid;
  }

  .workspace {
    padding: 18px 14px;
  }

  .topbar,
  .section-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .report-select,
  .report-filters,
  .report-actions {
    width: 100%;
  }

  .report-select {
    flex: 0 0 auto;
  }

  .report-filters {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .quick-transaction-actions {
    width: 100%;
  }

  .report-actions button,
  .quick-transaction-actions button,
  .top-actions button,
  .section-toolbar button {
    flex: 1;
  }

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

  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar h2,
  .dialog-header h2 {
    font-size: 24px;
  }
}

@media (max-width: 640px) {
  body {
    overflow-x: hidden;
  }

  .dashboard-license {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-license strong {
    text-align: left;
  }

  .dashboard-license small {
    text-align: left;
  }

  .landing-screen,
  .login-screen {
    padding: 14px;
  }

  .landing-nav {
    align-items: flex-start;
    flex-direction: column;
  }

  .landing-copy h1 {
    font-size: 46px;
    line-height: 1;
  }

  .landing-dashboard {
    padding: 14px;
  }

  .dash-metrics {
    flex-direction: column;
  }

  .login-card {
    padding: 20px;
  }

  .sidebar {
    padding: 12px;
  }

  .brand-block {
    margin-bottom: 14px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

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

  .brand-block p,
  .storage-badge {
    font-size: 11px;
  }

  .nav-button {
    min-height: 40px;
    padding: 9px 8px;
    font-size: 13px;
  }

  .workspace {
    padding: 14px 10px;
  }

  .topbar {
    gap: 12px;
    margin-bottom: 14px;
  }

  .topbar h2,
  .dialog-header h2 {
    font-size: 21px;
  }

  .top-actions,
  .quick-transaction-actions,
  .report-actions,
  .section-toolbar {
    gap: 7px;
  }

  .user-chip,
  .session-panel,
  .search-box,
  .report-select,
  .report-filters input,
  .report-filters select {
    font-size: 13px;
  }

  .search-box,
  .report-select,
  .report-filters input,
  .report-filters select,
  .primary-button,
  .ghost-button,
  .danger-button,
  .quick-transaction-button {
    min-height: 44px;
  }

  .icon-only {
    width: 42px;
    min-width: 42px;
    height: 42px;
  }

  .metrics-row {
    gap: 8px;
    margin-bottom: 14px;
  }

  .metric {
    padding: 12px;
  }

  .metric strong {
    font-size: 24px;
  }

  .table-wrap,
  .database-table-wrap,
  .external-preview-table-wrap,
  .rate-table-wrap {
    border-radius: 6px;
    max-width: calc(100vw - 20px);
  }

  table {
    min-width: 720px;
  }

  .table-wrap[data-module="contactUs"] table,
  .table-wrap[data-module="help"] table,
  .table-wrap[data-module="dashboard"] table,
  .table-wrap[data-module="utilities"] table,
  .table-wrap[data-module="tallyExports"] table {
    min-width: 0;
  }

  th,
  td {
    padding: 9px 10px;
    font-size: 12px;
  }

  th {
    font-size: 11px;
  }

  .row-actions {
    min-width: 138px;
    gap: 6px;
  }

  .pagination-controls {
    align-items: stretch;
    flex-wrap: wrap;
    gap: 8px;
  }

  .pagination-controls label,
  .pagination-controls select {
    width: 100%;
  }

  dialog {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }

  #recordForm,
  #databaseEditorForm,
  #externalImportForm,
  #lastBillDateLotForm,
  #emptySelectedTableForm {
    max-height: calc(100vh - 16px);
  }

  .dialog-header,
  .dialog-footer,
  .dialog-head {
    padding: 14px;
  }

  .form-grid,
  .database-editor,
  .utility-panel {
    padding: 14px;
  }

  .utility-filter-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    gap: 12px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .dashboard-metrics,
  .dashboard-menu,
  .dashboard-insights,
  .movement-summary {
    grid-template-columns: 1fr;
  }
}
