:root {
  color-scheme: dark;
  --bg: #080808;
  --bg-soft: #0f0f10;
  --panel: #151517;
  --panel-strong: #1c1c1f;
  --panel-alt: #1f2024;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(147, 255, 148, 0.24);
  --text: #f5f7f8;
  --muted: #98a2ae;
  --muted-soft: #6b7380;
  --accent: #9af66b;
  --accent-deep: #3f6b35;
  --accent-soft: rgba(154, 246, 107, 0.12);
  --success: #50d184;
  --warning: #ffc857;
  --danger: #ff6b6b;
  --shadow: 0 16px 32px rgba(0, 0, 0, 0.38);
  --radius: 20px;
  --radius-sm: 12px;
  --control-height: 50px;
  --filter-gap: 12px;
  --mobile-nav-height: 68px;
  --z-mobile-nav: 80;
  --z-quick-actions: 90;
  --z-drawer-backdrop: 100;
  --z-mobile-drawer: 110;
  --z-modal: 200;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background:
    radial-gradient(circle at top left, rgba(154, 246, 107, 0.08), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, #0a0a0b 100%);
  color: var(--text);
  font-family: "Inter", sans-serif;
}

button,
input,
select {
  font: inherit;
}

select {
  color-scheme: dark;
}

option {
  background-color: #1c1c1f;
  color: #f5f7f8;
}

option:checked,
option:hover {
  background-color: #34363a;
  color: #ffffff;
}

img {
  max-width: 100%;
  height: auto;
}

input,
select,
textarea {
  max-width: 100%;
}

button {
  cursor: pointer;
  max-width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
  transition: grid-template-columns 0.28s ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  min-width: 0;
  background: rgba(15, 15, 16, 0.96);
  border-right: 1px solid var(--line);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  transition: transform 0.28s ease, opacity 0.28s ease, padding 0.28s ease, border-color 0.28s ease, width 0.28s ease;
}

.app-shell.sidebar-collapsed .sidebar {
  width: 0;
  padding: 0;
  border-right-width: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-100%);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.08em;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(154, 246, 107, 0.3), rgba(154, 246, 107, 0.08));
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 0 18px rgba(154, 246, 107, 0.1);
}

.eyebrow,
.section-label,
.tiny-label,
.greeting {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--muted);
}

.brand-block h1,
.topbar h2,
.header-row h3,
.panel-header h4,
.report-value,
.view h3,
.modal-header h3 {
  margin: 0;
}

.brand-block h1 {
  font-size: 0.9rem;
  line-height: 1.3;
  letter-spacing: 0.08em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item,
.mobile-item,
.quick-item {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  transition: 0.2s ease;
}

.nav-item {
  width: 100%;
}

.nav-item:hover,
.mobile-item:hover,
.quick-item:hover,
.primary-button:hover,
.close-button:hover {
  transform: translateY(-1px);
}

.nav-item.active {
  background: rgba(154, 246, 107, 0.08);
  border-color: var(--line-strong);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(154, 246, 107, 0.08);
}

.sidebar-footer {
  margin-top: auto;
}

.tiny-card {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.tiny-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.1rem;
}

.desktop-nav-toggle {
  position: static;
  z-index: auto;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  min-width: 46px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(19, 19, 20, 0.9);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.24);
  padding: 10px;
  cursor: pointer;
  color: var(--text);
  flex-shrink: 0;
}

.desktop-nav-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.desktop-nav-toggle .menu-icon {
  grid-area: 1 / 1;
  width: 22px;
  height: 22px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.desktop-nav-toggle .menu-icon-open {
  opacity: 1;
}

.desktop-nav-toggle .menu-icon-close {
  opacity: 0;
  transform: scale(0.9);
}

.desktop-nav-toggle[aria-expanded="true"] .menu-icon-open {
  opacity: 0;
  transform: scale(0.9);
}

.desktop-nav-toggle[aria-expanded="true"] .menu-icon-close {
  opacity: 1;
  transform: scale(1);
}

.main-panel {
  min-width: 0;
  padding: 0 28px 28px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin: 0 -28px 28px;
  padding: 18px 28px 16px;
  background: rgba(10, 10, 11, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

.topbar-title-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  flex: 1 1 auto;
}

.greeting {
  margin-bottom: 8px;
}

.topbar h2 {
  font-size: clamp(1.6rem, 2vw, 2.2rem);
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex: 0 0 auto;
  min-width: 0;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.73rem;
  white-space: nowrap;
  cursor: pointer;
  background: transparent;
  font-family: inherit;
  letter-spacing: 0.01em;
}

.connection-status[data-status="checking"] {
  color: var(--warning);
}

.connection-status[data-status="outdated"] {
  color: var(--warning);
  border-color: rgba(255, 190, 92, 0.35);
}

.connection-status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  content: "";
}

.connection-status[data-status="connected"] {
  color: var(--success);
  border-color: rgba(80, 209, 132, 0.24);
}

.connection-status[data-status="connected"]::before {
  background: var(--success);
}

.connection-status[data-status="offline"] {
  color: var(--muted);
}

.connection-status[data-status="offline"]::before {
  background: var(--danger);
}

.connection-status[data-status="outdated"]::before {
  background: var(--warning);
}

.date-pill,
.chip {
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font-size: 0.8rem;
}

.primary-button {
  border: 1px solid rgba(154, 246, 107, 0.3);
  background: linear-gradient(135deg, rgba(154, 246, 107, 0.13), rgba(154, 246, 107, 0.05));
  color: var(--text);
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(154, 246, 107, 0.08);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.site-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 100%;
  min-width: 0;
  margin-top: 36px;
  padding: 20px 12px 8px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.site-footer-brand {
  color: var(--accent-deep);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.site-footer-tagline {
  max-width: 100%;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 16px;
}

.header-row h3 {
  font-size: clamp(1.2rem, 2vw, 1.8rem);
}

.kpi-grid,
.reports-grid,
.stock-grid {
  display: grid;
  gap: 18px;
}

.kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 22px;
}

.metric-card,
.panel,
.stock-card,
.report-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), rgba(17, 17, 18, 0.2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px 18px 16px;
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
}

.metric-card .label {
  display: block;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.metric-card .trend {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.metric-card .trend.up {
  background: rgba(80, 209, 132, 0.12);
  color: var(--success);
}

.metric-card .trend.down {
  background: rgba(255, 107, 107, 0.1);
  color: var(--danger);
}

.metric-value {
  font-weight: 800;
  font-size: clamp(1.7rem, 2vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.06em;
}

.metric-meta {
  margin-top: 10px;
  font-size: 0.74rem;
  color: var(--muted);
}

.two-column-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  padding: 18px 18px 16px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.chip.success {
  background: rgba(80, 209, 132, 0.08);
  color: var(--success);
  border-color: rgba(80, 209, 132, 0.2);
}

.chip.neutral {
  color: var(--muted);
  border-color: var(--line);
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 220px;
  padding-top: 12px;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  height: 100%;
}

.bar {
  width: 100%;
  min-height: 32px;
  max-width: 42px;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(180deg, rgba(154, 246, 107, 0.9), rgba(154, 246, 107, 0.26));
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.04);
}

.bar-label {
  color: var(--muted);
  font-size: 0.7rem;
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stack-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
}

.stack-item span {
  color: var(--muted);
}

.data-table {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.section-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
}

.record-filter-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  container-type: inline-size;
  gap: 10px;
  margin: 0 0 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
}

.record-filter-panel,
.record-date-range,
.report-filter-grid,
.report-date-range {
  min-width: 0;
}

.record-date-range {
  display: grid;
  flex: 2 1 320px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.record-filter-panel .search-field {
  flex: 2 1 260px;
  width: auto;
}

input[type="date"],
input[type="search"],
input[type="number"],
select,
textarea {
  background-color: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
}

input[type="date"] {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: var(--control-height);
  box-sizing: border-box;
  padding: 0 12px;
  color-scheme: dark;
  font-size: 16px;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: 0.9;
  cursor: pointer;
}

.record-filter-field {
  display: grid;
  flex: 1 1 140px;
  min-width: 0;
  width: 100%;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

.record-filter-field input,
.record-filter-field .filter-select {
  width: 100%;
  min-width: 0;
  min-height: var(--control-height);
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  background: var(--panel);
  color: var(--text);
  color-scheme: dark;
  font: inherit;
  font-size: 0.8rem;
}

.record-filter-field input[type="date"] {
  font-size: 16px;
}

.record-filter-panel > .clear-record-filters {
  min-height: 48px;
  white-space: nowrap;
}

.record-filter-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.76rem;
}

.record-filter-summary > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.filter-feedback {
  min-height: 0;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.76rem;
}

.filter-feedback:empty {
  display: none;
}

.filter-feedback.has-error {
  color: var(--danger);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 9px;
  width: min(100%, 420px);
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
}

.search-field input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  text-overflow: ellipsis;
}

.filter-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  text-overflow: ellipsis;
}

.record-cards {
  display: none;
}

.customer-picker {
  position: relative;
}

.customer-picker-control {
  display: flex;
  gap: 6px;
}

.customer-picker-control input {
  flex: 1;
  width: 0;
}

.customer-picker-toggle {
  flex: 0 0 44px;
  min-height: 44px;
  padding: 0;
}

.customer-picker-options {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 5;
  max-height: 240px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.customer-picker-option,
.customer-picker-add {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.customer-picker-option:hover,
.customer-picker-add:hover {
  background: rgba(255, 255, 255, 0.06);
}

.customer-picker-option small {
  color: var(--muted);
}

.customer-picker-add {
  justify-content: flex-start;
  margin-top: 4px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  color: var(--accent);
}

.record-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.record-card-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.record-card-heading h4 {
  min-width: 0;
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.record-card-heading > div {
  min-width: 0;
}

.record-card-kicker {
  color: var(--muted);
  font-size: 0.74rem;
}

.record-card-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 15px;
}

.record-card-details > div {
  min-width: 0;
}

.record-card-details span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.record-card-details strong {
  overflow-wrap: anywhere;
  font-size: 0.84rem;
}

.record-card-actions,
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.record-card-actions {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.empty-records {
  color: var(--muted);
}

.danger-button {
  border: 1px solid rgba(255, 107, 107, 0.35);
  border-radius: 10px;
  background: rgba(255, 107, 107, 0.1);
  color: var(--danger);
  padding: 10px 14px;
}

.app-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--z-modal);
  max-width: min(420px, calc(100vw - 32px));
  padding: 13px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel-strong);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.app-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.app-toast[data-type="error"] {
  border-color: rgba(255, 107, 107, 0.45);
}

button[aria-busy="true"] {
  cursor: progress;
  opacity: 0.75;
}

.form-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.72rem;
}

.status-pill.success {
  color: var(--success);
  border-color: rgba(80, 209, 132, 0.2);
  background: rgba(80, 209, 132, 0.08);
}

.status-pill.warning {
  color: var(--warning);
  border-color: rgba(255, 200, 87, 0.2);
  background: rgba(255, 200, 87, 0.08);
}

.status-pill.danger {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.2);
  background: rgba(255, 107, 107, 0.08);
}

.status-pill.partial {
  color: #ffe18a;
  border-color: rgba(255, 200, 87, 0.28);
  background: rgba(255, 200, 87, 0.1);
}

.status-button {
  cursor: pointer;
  font-family: inherit;
}

.status-button:hover,
.text-button:hover {
  filter: brightness(1.15);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.25);
  text-underline-offset: 3px;
}

.payment-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.payment-summary > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.payment-summary span,
.history-total span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  margin-bottom: 6px;
}

.payment-summary strong,
.history-total strong {
  font-size: 0.95rem;
}

.payment-history {
  margin: 0 0 16px;
}

.payment-history h4 {
  margin: 0 0 10px;
}

.payment-history th,
.payment-history td {
  padding: 9px 8px;
}

.history-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 8px 0;
}

.history-total span {
  margin-bottom: 0;
}

.empty-history,
.payment-settled {
  color: var(--muted);
  font-size: 0.84rem;
}

.form-error {
  color: var(--danger);
  margin: 12px 0 0;
  font-size: 0.84rem;
}

.form-actions .primary-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.stock-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stock-card {
  padding: 16px;
}

.stock-card h4 {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.stock-card strong {
  display: block;
  font-size: 1.6rem;
  letter-spacing: -0.04em;
}

.stock-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.reports-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.report-value {
  margin-top: 14px;
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.06em;
}

.report-actions,
.report-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.report-filters {
  margin-bottom: 18px;
}

.report-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  container-type: inline-size;
}

.report-date-range {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
}

.report-filter-grid select,
.report-filter-grid input,
.report-search input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  padding: 11px 12px;
  box-sizing: border-box;
}

.report-filter-grid input[type="date"] {
  height: 50px;
  padding: 0 12px;
  font-size: 16px;
}

.report-custom-date[hidden] {
  display: none;
}

.report-date-feedback {
  grid-column: 1 / -1;
  min-height: 0;
  margin: 0;
  color: var(--danger);
  font-size: 0.8rem;
}

.report-date-feedback:empty {
  display: none;
}

.record-filter-field input[aria-invalid="true"],
.report-date-range input[aria-invalid="true"] {
  border-color: var(--danger);
}

.record-filter-field input:focus-visible,
.report-date-range input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.report-filter-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

.reports-content {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.report-period-note,
.report-section-heading p,
.report-table-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.report-period-note {
  padding: 0 2px;
}

.report-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 14px;
}

.report-metric-card,
.report-section,
.report-chart {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(17, 17, 18, 0.22));
  box-shadow: var(--shadow);
}

.report-metric-card {
  padding: 17px;
}

.report-metric-card h4,
.report-chart h4,
.report-table-heading h4 {
  margin: 0;
  font-size: 0.92rem;
}

.report-metric-value {
  display: block;
  margin-top: 12px;
  color: var(--accent);
  font-size: clamp(1.2rem, 2.2vw, 1.75rem);
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
}

.report-metric-card p {
  min-height: 2.6em;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.report-comparison {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.72rem;
}

.report-section {
  padding: 18px;
}

.report-section-heading,
.report-table-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.report-section-heading h3 {
  margin: 0 0 5px;
  font-size: 1.05rem;
}

.report-section-heading > strong {
  color: var(--accent);
  white-space: nowrap;
}

.report-chart-grid,
.report-two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.report-chart {
  padding: 15px;
  box-shadow: none;
}

.report-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 190px;
  margin-top: 14px;
  overflow-x: auto;
  padding: 8px 2px 0;
}

.report-bar-column {
  display: flex;
  flex: 1 0 42px;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  height: 100%;
  min-width: 0;
}

.report-bar-column > strong {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-bar {
  display: block;
  width: min(100%, 34px);
  height: var(--bar-height);
  min-height: 2px;
  border-radius: 7px 7px 2px 2px;
  background: linear-gradient(180deg, var(--accent), rgba(154, 246, 107, 0.28));
}

.report-bar.amber {
  background: linear-gradient(180deg, var(--warning), rgba(255, 200, 87, 0.25));
}

.report-bar.negative {
  background: linear-gradient(180deg, var(--danger), rgba(255, 107, 107, 0.25));
}

.report-paired-bars .report-bar-column {
  justify-content: flex-end;
}

.report-pair {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 100%;
}

.report-pair .report-bar {
  width: min(42%, 18px);
}

.report-bar-column small {
  color: var(--muted);
  font-size: 0.64rem;
  text-align: center;
  white-space: nowrap;
}

.report-legend {
  display: flex;
  gap: 16px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.report-legend span::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.report-legend span + span::before {
  background: var(--warning);
}

.report-inline-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.report-inline-summary > span {
  display: flex;
  flex: 1 1 155px;
  flex-direction: column;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.72rem;
}

.report-inline-summary strong {
  color: var(--text);
  font-size: 0.98rem;
}

.report-table-block {
  min-width: 0;
  margin-top: 14px;
}

.report-table-heading {
  align-items: center;
  margin-bottom: 9px;
}

.report-table-heading > div {
  display: grid;
  gap: 4px;
}

.report-search {
  flex: 0 1 230px;
}

.report-search input {
  padding: 8px 10px;
  font-size: 0.76rem;
}

.report-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.report-table-scroll table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

.report-table-scroll th,
.report-table-scroll td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.report-table-scroll th {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.report-table-scroll th button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.report-table-scroll td {
  font-size: 0.76rem;
}

.report-table-scroll tbody tr:last-child td {
  border-bottom: 0;
}

.report-empty {
  margin: 12px 0 0;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

@media (max-width: 768px) {
  .report-actions {
    width: 100%;
  }

  .report-actions > button {
    flex: 1 1 130px;
  }

  .report-chart-grid,
  .report-two-column {
    grid-template-columns: minmax(0, 1fr);
  }

  .report-section {
    padding: 14px;
  }

  .report-table-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .report-search {
    flex-basis: auto;
    width: 100%;
  }
}

@media print {
  body:has(#reportsView.active) * {
    visibility: hidden !important;
  }

  body:has(#reportsView.active) #reportsView,
  body:has(#reportsView.active) #reportsView * {
    visibility: visible !important;
  }

  body:has(#reportsView.active) #reportsView {
    position: absolute;
    inset: 0;
    display: block !important;
    padding: 0;
    color: #111;
    background: #fff;
  }

  body:has(#reportsView.active) .report-actions,
  body:has(#reportsView.active) .report-filters,
  body:has(#reportsView.active) .report-search,
  body:has(#reportsView.active) .report-table-scroll th button span {
    display: none !important;
  }

  body:has(#reportsView.active) .report-metric-card,
  body:has(#reportsView.active) .report-section,
  body:has(#reportsView.active) .report-chart {
    break-inside: avoid;
    color: #111;
    background: #fff;
    box-shadow: none;
  }

  body:has(#reportsView.active) .report-table-scroll {
    overflow: visible;
  }

  body:has(#reportsView.active) .report-table-scroll table {
    min-width: 0;
  }

  body:has(#reportsView.active) .report-table-scroll td,
  body:has(#reportsView.active) .report-section-heading h3,
  body:has(#reportsView.active) .report-metric-value {
    color: #111;
  }
}

.settings-panel {
  display: block;
  padding: 0;
  overflow: hidden;
}

.settings-navigation {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.settings-navigation a {
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.78rem;
}

.settings-navigation a:hover,
.settings-navigation a:focus-visible {
  border-color: var(--accent);
  color: var(--text);
}

.settings-form {
  display: grid;
  gap: 0;
}

.settings-section {
  padding: 22px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 16px;
}

.settings-section-heading {
  margin-bottom: 16px;
}

.settings-section-heading h4 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.settings-section-heading p,
.setting-field small {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.settings-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.setting-field {
  display: grid;
  align-content: start;
  gap: 7px;
  color: var(--muted);
  font-size: 0.8rem;
}

.setting-field input:not([type="checkbox"]):not([type="file"]),
.setting-field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.setting-field option {
  background: #111214;
  color: var(--text);
}

.setting-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.setting-check input {
  accent-color: var(--accent);
}

.settings-logo-field {
  grid-column: 1 / -1;
}

.settings-logo-field img {
  width: 88px;
  height: 88px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.settings-info {
  display: grid;
  gap: 5px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.settings-info strong {
  color: var(--text);
  font-size: 0.82rem;
}

.settings-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: #111214;
}

.settings-actions p {
  flex: 1;
  margin: 0;
  color: #ff8c8c;
  font-size: 0.8rem;
}

.setting-item {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
}

.setting-item label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.setting-item input {
  width: 100%;
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  z-index: var(--z-modal);
  padding: 12px;
}

.modal.hidden,
.quick-actions.hidden {
  display: none;
}

.modal-card {
  width: min(560px, calc(100% - 28px));
  max-height: min(90vh, 760px);
  max-height: min(90dvh, 760px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #111214;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.modal-header {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 18px 20px 12px;
  background: #111214;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
}

#entryForm {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 20px 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field.full-width {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 0.82rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  padding: 11px 12px;
}

.add-product-link {
  align-self: flex-start;
  margin-top: 2px;
  color: var(--accent);
}

.field textarea {
  resize: vertical;
  font: inherit;
}

.form-actions {
  position: sticky;
  bottom: -20px;
  z-index: 1;
  flex-wrap: wrap;
  margin-top: 18px;
  padding: 12px 0 0;
  background: #111214;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.secondary-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
}

.quick-actions {
  position: fixed;
  right: 20px;
  bottom: 82px;
  z-index: var(--z-quick-actions);
  max-width: calc(100vw - 24px);
}

.quick-menu {
  max-height: calc(100dvh - 110px);
  overflow-y: auto;
  background: rgba(19, 19, 20, 0.96);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
  padding: 10px;
}

.quick-item {
  min-width: 150px;
  text-align: left;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
}

.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  width: 100%;
  max-width: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
  padding: 6px 8px env(safe-area-inset-bottom);
  background: rgba(9, 9, 10, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
  z-index: var(--z-mobile-nav);
}

.mobile-item {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 44px;
  white-space: nowrap;
  text-align: center;
  color: var(--muted);
  padding: 4px 2px;
  font-size: 0.76rem;
}

.mobile-item.active {
  color: var(--text);
}

.mobile-icon {
  display: block;
  min-height: 20px;
  font-size: 1.15rem;
  line-height: 20px;
}

.mobile-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  line-height: 1.1;
}

.mobile-primary {
  justify-self: center;
  width: 48px;
  max-width: 48px;
  min-height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(154, 246, 107, 0.2), rgba(154, 246, 107, 0.05));
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 3px 0;
}

.mobile-primary .mobile-icon {
  font-size: 1.65rem;
  line-height: 18px;
}

.mobile-primary .mobile-label {
  font-size: 0.58rem;
}

.drawer-close,
.drawer-backdrop {
  display: none;
}

@media (max-width: 768px) {
  .desktop-nav-toggle {
    display: none;
  }

  .app-shell.sidebar-collapsed .sidebar {
    width: min(300px, calc(100vw - 56px));
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-105%);
  }
}

@media (min-width: 769px) and (max-width: 980px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .sidebar {
    padding: 20px 14px;
  }

  .main-panel {
    padding: 22px 20px;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .two-column-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  #salesView > .panel,
  #customersView > .panel {
    display: none;
  }

  #salesView > .record-cards,
  #customersView > .record-cards {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .section-tools {
    align-items: stretch;
  }

  .section-tools .search-field {
    flex: 1;
    width: auto;
  }

  .record-card-details {
    gap: 8px;
  }

  .app-shell {
    display: block;
    min-height: 100vh;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: var(--z-mobile-drawer);
    display: flex;
    width: min(300px, calc(100vw - 56px));
    height: 100vh;
    height: 100dvh;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 0.24s ease, visibility 0.24s ease;
  }

  .app-shell.sidebar-collapsed .sidebar.is-open {
    transform: translateX(0);
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  .brand-block {
    width: 100%;
  }

  .drawer-close {
    display: grid;
    flex: 0 0 40px;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-left: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font-size: 1.5rem;
  }

  .drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-drawer-backdrop);
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.64);
    cursor: default;
  }

  .drawer-backdrop[hidden] {
    display: none;
  }

  body.drawer-open {
    overflow: hidden;
  }

  .main-panel {
    width: 100%;
    padding: 20px 16px calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 24px);
  }

  .site-footer {
    margin-top: 28px;
    padding: 18px 8px 8px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    margin: 0 -16px 24px;
    padding: 14px 16px 12px;
  }

  .topbar-title-wrap {
    width: 100%;
    min-width: 0;
  }

  .greeting {
    margin-bottom: 6px;
    letter-spacing: 0.08em;
    font-size: 0.66rem;
    line-height: 1.3;
    white-space: nowrap;
  }

  .topbar h2 {
    font-size: clamp(1.4rem, 5vw, 2rem);
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
  }

  .date-pill,
  .connection-status {
    min-width: 0;
    padding-left: 18px;
    padding-right: 18px;
    line-height: 1.3;
  }

  .date-pill {
    flex: 0 1 auto;
  }

  .connection-status {
    flex: 1 1 100%;
    width: 100%;
    justify-content: center;
    white-space: normal;
  }

  .record-filter-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: var(--filter-gap);
  }

  .record-date-range {
    grid-column: 1 / -1;
  }

  .record-filter-panel .search-field {
    grid-column: 1 / -1;
    width: 100%;
  }

  .record-filter-field {
    min-width: 0;
  }

  .record-filter-field input,
  .record-filter-field .filter-select,
  .record-filter-panel .search-field input,
  .report-filter-grid input[type="date"] {
    font-size: 16px;
  }

  .record-filter-panel > .clear-record-filters {
    grid-column: 1 / -1;
    width: 100%;
  }

  .header-row {
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
  }

  .header-row > button {
    min-height: 44px;
  }

  .record-filter-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr));
    gap: 8px 12px;
    font-size: 0.8rem;
    line-height: 1.4;
  }

  .record-card-actions > button,
  .record-card-actions .text-button {
    min-height: 44px;
  }

  .kpi-grid,
  .two-column-grid,
  .stock-grid,
  .reports-grid,
  .settings-panel {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .settings-section { padding: 18px 14px; }
  .settings-fields,
  .settings-status-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-actions { padding: 12px 14px; }

  .metric-card,
  .panel,
  .stock-card {
    min-width: 0;
    padding: 16px;
  }

  .panel-header {
    gap: 10px;
  }

  .bar-chart {
    gap: 8px;
  }

  .stack-item {
    min-width: 0;
    gap: 12px;
  }

  .stack-item > div {
    min-width: 0;
  }

  .stack-item strong,
  .stack-item span {
    overflow-wrap: anywhere;
  }

  .mobile-nav {
    display: grid;
  }

  .quick-actions {
    left: 50%;
    right: auto;
    bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 12px);
    max-width: calc(100vw - 24px);
    transform: translateX(-50%);
  }

  .quick-menu {
    width: max-content;
    min-width: min(220px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - var(--mobile-nav-height) - env(safe-area-inset-bottom) - 24px);
  }

  .quick-item {
    min-height: 44px;
    white-space: normal;
  }

  .modal {
    place-items: center;
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  }

  .modal-card {
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - max(24px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
    border-radius: 18px;
  }

  #entryForm {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
  }

  .modal-form-scroll {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
  }

  .form-grid,
  .payment-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .field input,
  .field select,
  .field textarea,
  .setting-item input {
    min-height: 44px;
    font-size: 16px;
  }

  .form-actions {
    position: relative;
    bottom: auto;
    flex: 0 0 auto;
    margin-top: 0;
    padding: 12px 16px max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
  }

  .form-actions > button {
    min-height: 44px;
  }

  .date-pill,
  .primary-button {
    font-size: 0.82rem;
  }
}

@media (max-width: 430px) {
  .section-tools {
    flex-wrap: wrap;
  }

  .section-tools .search-field {
    flex-basis: 100%;
  }

  .main-panel {
    padding-right: 12px;
    padding-left: 12px;
  }

  .topbar {
    margin-right: -12px;
    margin-left: -12px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .topbar h2 {
    font-size: 1.55rem;
    overflow-wrap: anywhere;
  }

  .topbar {
    gap: 12px;
    margin-bottom: 18px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: center;
    justify-content: stretch;
    gap: 8px;
  }

  .date-pill {
    display: flex;
    align-items: center;
    justify-self: start;
    max-width: 100%;
    min-height: 44px;
    padding: 8px 10px;
  }

  .connection-status {
    width: 100%;
    min-height: 44px;
    padding: 7px 10px;
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 0.7rem;
  }

  .record-filter-panel {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--filter-gap);
    padding: 16px;
  }

  .record-filter-panel > *,
  .record-filter-panel .record-date-range,
  .record-filter-panel .record-filter-field,
  .record-filter-panel .search-field,
  .record-filter-panel > .clear-record-filters {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .record-date-range {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--filter-gap);
  }

  .record-filter-field {
    gap: 8px;
    font-size: 0.8rem;
  }

  .record-filter-field input,
  .record-filter-field .filter-select,
  .record-filter-panel .search-field input {
    font-size: 16px;
  }

  .record-filter-panel .search-field {
    min-height: 48px;
  }

  .record-filter-panel .search-field input {
    flex: 1 1 0;
  }

  .record-filter-panel > .clear-record-filters {
    min-height: 48px;
    white-space: normal;
  }

  .report-filter-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--filter-gap);
  }

  .report-date-range {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--filter-gap);
  }

  .header-row {
    align-items: center;
    gap: 10px;
  }

  .header-row > div {
    min-width: 0;
  }

  .header-row > button {
    flex: 0 0 auto;
    min-height: 48px;
    padding: 10px 12px;
  }

  .sale-record-card .record-card-heading {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
  }

  .sale-record-card .record-card-heading > div {
    flex: 1 1 140px;
  }

  .sale-record-card .record-card-heading > .status-button {
    flex: 0 0 auto;
  }

  .sale-record-card .record-card-details,
  .customer-record-card .record-card-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .mobile-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .mobile-item {
    width: 100%;
    max-width: 100%;
    padding-right: 2px;
    padding-left: 2px;
  }

  .metric-card .metric-value {
    font-size: clamp(1.65rem, 8vw, 2.1rem);
  }

  .panel-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .chip {
    white-space: nowrap;
  }
}

@media (max-width: 390px) {
  .record-filter-panel {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 359px) {
  :root {
    --filter-gap: 10px;
  }

  .record-filter-panel {
    padding: 12px;
  }

  .sale-record-card,
  .customer-record-card {
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
