:root {
  --bg: #3d3d3b;
  --panel: #343432;
  --panel-soft: #474744;
  --line: rgba(255, 255, 255, 0.16);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.72);
  --green: #94c11f;
  --green-dark: #6f9317;
  --danger: #ff6868;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.26);
  font-family: "Nexa", Arial, Helvetica, sans-serif;
}

@font-face {
  font-family: "Nexa";
  src: url("/assets/Nexa-Light.otf") format("opentype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Nexa";
  src: url("/assets/Nexa-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Nexa", Arial, Helvetica, sans-serif;
  font-weight: 300;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: var(--bg);
}

.login-screen.is-hidden {
  display: none;
}

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

.login-form img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.login-form label {
  display: grid;
  gap: 8px;
}

.login-form label span {
  font-size: 13px;
  font-weight: 700;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 36px;
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 22px;
}

.brand img {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  width: 100%;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.nav-item:hover,
.nav-item:focus-visible,
.nav-item.is-active {
  border-color: rgba(148, 193, 31, 0.72);
  background: rgba(148, 193, 31, 0.16);
  outline: none;
}

.content {
  min-width: 0;
  padding: 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}

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

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.1;
}

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

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

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  white-space: nowrap;
}

.status-pill.is-connected {
  border-color: rgba(148, 193, 31, 0.8);
  background: rgba(148, 193, 31, 0.15);
}

.status-pill.is-error {
  border-color: rgba(255, 104, 104, 0.85);
  background: rgba(255, 104, 104, 0.14);
}

.view {
  display: none;
  min-width: 0;
}

.view.is-visible {
  display: block;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-head p {
  margin-bottom: 0;
}

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.subnav-item,
.mode-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-weight: 700;
}

.subnav-item:hover,
.subnav-item:focus-visible,
.subnav-item.is-active,
.mode-button:hover,
.mode-button:focus-visible,
.mode-button.is-active {
  border-color: rgba(148, 193, 31, 0.76);
  background: rgba(148, 193, 31, 0.16);
  outline: none;
}

.stats-pane {
  display: none;
}

.stats-pane.is-visible,
.billing-pane.is-visible {
  display: block;
}

.billing-pane {
  display: none;
}

.mode-control {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.month-control {
  display: grid;
  grid-template-columns: auto minmax(150px, 200px) auto;
  gap: 8px;
}

.select-field,
.settings-form label {
  display: grid;
  gap: 8px;
  color: var(--text);
}

.select-field span,
.settings-form label span {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

select,
input,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(148, 193, 31, 0.2);
}

input::placeholder {
  color: rgba(255, 255, 255, 0.46);
}

textarea {
  min-height: 130px;
  padding: 12px;
  resize: vertical;
}

.chart-panel,
.settings-form {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.chart-panel {
  padding: 22px;
}

.dashboard-panel {
  margin-top: 18px;
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 18px;
  width: min(980px, 100%);
}

.metric {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.metric strong {
  display: block;
  font-size: 25px;
  line-height: 1.1;
  font-weight: 700;
}

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

.metric-button {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.metric-button strong {
  font-size: 25px;
  line-height: 1.1;
  font-weight: 700;
}

.metric-button span {
  color: var(--muted);
}

.metric-button:hover strong,
.metric-button:focus-visible strong {
  color: var(--green);
}

.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 6px;
  color: var(--text);
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--green);
  background: var(--green-dark);
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--green);
  outline: none;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: var(--green);
  outline: none;
}

.chart-area {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 12px;
}

.chart-scale {
  position: relative;
  height: 280px;
  margin-top: 12px;
  border-right: 1px solid var(--line);
}

.chart-scale span {
  position: absolute;
  right: 10px;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.64);
  font-size: 12px;
  white-space: nowrap;
}

.chart {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(42px, 1fr));
  align-items: end;
  gap: 12px;
  min-height: 360px;
  padding-top: 12px;
  overflow-x: auto;
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.14) 1px, transparent 1px) 0 12px / 100% 62.5px no-repeat,
    linear-gradient(to bottom, rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 74.5px / 100% 62.5px no-repeat,
    linear-gradient(to bottom, rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 137px / 100% 62.5px no-repeat,
    linear-gradient(to bottom, rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 199.5px / 100% 62.5px no-repeat,
    linear-gradient(to bottom, rgba(255, 255, 255, 0.16) 1px, transparent 1px) 0 262px / 100% 62.5px no-repeat;
}

.line-chart {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(58px, 1fr);
  align-items: end;
  gap: 12px;
  min-height: 360px;
  padding-top: 12px;
  overflow-x: auto;
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.14) 1px, transparent 1px) 0 12px / 100% 62.5px no-repeat,
    linear-gradient(to bottom, rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 74.5px / 100% 62.5px no-repeat,
    linear-gradient(to bottom, rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 137px / 100% 62.5px no-repeat,
    linear-gradient(to bottom, rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 199.5px / 100% 62.5px no-repeat,
    linear-gradient(to bottom, rgba(255, 255, 255, 0.16) 1px, transparent 1px) 0 262px / 100% 62.5px no-repeat;
}

.revenue-svg {
  width: 100%;
  min-width: 720px;
  height: 340px;
}

.revenue-svg text {
  fill: var(--text);
  font-family: "Nexa", Arial, Helvetica, sans-serif;
  font-size: 13px;
}

.revenue-year-bar {
  min-width: 64px;
}

.year-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 22px;
}

.year-checks.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.check-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.check-pill span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--text);
  font-weight: 700;
}

.check-pill input:checked + span {
  border-color: var(--green);
  background: rgba(148, 193, 31, 0.24);
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.inline-check input {
  width: 16px;
  min-height: 16px;
}

.bar-group {
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 8px;
  min-width: 42px;
  height: 340px;
}

.bar-stack {
  display: flex;
  flex-direction: column-reverse;
  align-items: stretch;
  justify-content: flex-start;
  height: 280px;
  border-bottom: 1px solid var(--line);
}

.bar-segment {
  width: 100%;
  min-height: 0;
}

.bar-segment:first-child {
  border-radius: 0 0 3px 3px;
}

.bar-segment:last-child {
  border-radius: 5px 5px 0 0;
}

.bar-invoice {
  background: rgba(255, 255, 255, 0.88);
}

.bar-order {
  background: #7aa516;
}

.bar-offer {
  background: var(--green);
}

.bar-value,
.bar-label {
  min-height: 18px;
  color: var(--text);
  font-size: 12px;
  text-align: center;
}

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

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 18px;
  color: var(--text);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend i {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.legend-total {
  background: linear-gradient(180deg, var(--green) 0 33%, #7aa516 33% 66%, rgba(255, 255, 255, 0.88) 66%);
}

.legend-orders {
  background: #7aa516;
}

.legend-invoices {
  background: rgba(255, 255, 255, 0.78);
}

.legend-offers {
  background: var(--green);
}

.settings-form {
  display: grid;
  gap: 18px;
  max-width: 920px;
  padding: 22px;
}

.embedded-form {
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.admin-server-panel {
  margin-top: 20px;
}

.compact-head {
  margin-bottom: 0;
}

.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.table-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.search-field {
  display: grid;
  gap: 8px;
  width: min(460px, 100%);
}

.search-field span,
.table-count {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  max-height: 68vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

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

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-soft);
  font-weight: 700;
}

.data-table td {
  color: rgba(255, 255, 255, 0.86);
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.04);
}

.clickable-row {
  cursor: pointer;
}

.table-message {
  height: 140px;
  text-align: center !important;
  vertical-align: middle !important;
  color: var(--muted) !important;
}

.detail-panel {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px;
}

.detail-panel[hidden] {
  display: none;
}

.defect-grid,
.device-flow {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 20px;
  align-items: start;
}

.device-flow {
  grid-template-columns: 1fr;
  margin-bottom: 22px;
}

.device-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.device-flow > [hidden] {
  display: none !important;
}

.device-result,
.defect-form {
  position: relative;
}

.icon-close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.icon-close-button:hover,
.icon-close-button:focus-visible {
  border-color: var(--green);
  outline: none;
}

.device-manual,
.defect-form {
  max-width: none;
}

.device-id-label {
  max-width: 420px;
}

.device-id-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(72px, 0.45fr);
  align-items: center;
  max-width: 420px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  overflow: hidden;
}

.device-id-input input {
  min-height: 46px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: center;
}

.device-id-input input:focus {
  box-shadow: none;
}

.device-id-separator {
  min-height: 46px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
}

.device-result-summary h3 {
  margin: 0 0 8px;
  font-size: 24px;
}

.device-result-summary p:last-child {
  margin-bottom: 18px;
  color: var(--muted);
  font-weight: 700;
}

.defect-photo-preview {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
}

.defect-photo-preview[hidden] {
  display: none;
}

.defect-photo-preview img,
.defect-photo-thumb {
  width: 96px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
  background: #262624;
}

.defect-photo-preview strong,
.defect-photo-preview span {
  display: block;
}

.defect-photo-preview span {
  color: var(--muted);
  font-size: 13px;
}

.defect-photo-link {
  display: inline-block;
  margin-top: 10px;
}

.muted-cell {
  color: var(--muted);
  font-size: 0.92em;
}

.defect-scanner {
  display: grid;
  gap: 14px;
}

.defect-scanner video,
.scanner-placeholder {
  width: 100%;
  max-width: 100%;
  max-height: min(62vh, 520px);
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #262624;
  object-fit: cover;
}

.scanner-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.scanner-hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.detail-head h2 {
  margin-bottom: 0;
}

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

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

.device-list {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.billing-runs {
  margin-top: 22px;
}

.billing-runs h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.device-list[hidden] {
  display: none;
}

.description-block h3,
.device-list h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.debug-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.debug-head h3 {
  margin: 0;
}

.json-debug {
  max-height: 420px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #262624;
  color: rgba(255, 255, 255, 0.9);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre;
}

.description-block p {
  margin: 0;
  color: rgba(255, 255, 255, 0.84);
  line-height: 1.5;
  white-space: pre-wrap;
}

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

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.billing-capable-hours {
  color: var(--green);
  font-weight: 700;
}

.is-positive,
.data-table td.is-positive {
  color: var(--green);
  font-weight: 700;
}

.is-negative,
.data-table td.is-negative {
  color: var(--danger);
  font-weight: 700;
}

.wide-panel {
  width: 100%;
  max-width: none;
}

.compact-form {
  margin-bottom: 18px;
  max-width: none;
}

.employee-create-form {
  grid-template-columns: minmax(240px, 420px) auto;
  margin-bottom: 18px;
}

.employee-contract-list {
  display: grid;
  gap: 18px;
}

.employee-contract-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
}

.employee-contract-head {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto;
  gap: 12px;
  margin-bottom: 14px;
}

.contract-grid {
  display: grid;
  grid-template-columns: 120px 130px 130px repeat(5, minmax(105px, 1fr)) 150px 220px;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  overflow-x: auto;
}

.contract-grid-head {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.contract-new {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

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

.filter-row th {
  padding-top: 6px;
}

.filter-row select {
  width: 100%;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.filter-stack {
  display: grid;
  gap: 6px;
}

.entry-detail-row td {
  background: rgba(255, 255, 255, 0.04);
}

.entry-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.entry-detail-grid span {
  color: var(--muted);
}

.entry-detail-grid strong {
  display: block;
  color: var(--text);
}

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

.billing-form {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr auto;
  gap: 12px;
}

.message {
  min-height: 22px;
  color: var(--text);
}

.message.is-error {
  color: var(--danger);
}

.loading {
  display: grid;
  place-items: center;
  min-height: 260px;
  color: var(--text);
}

.inline-loading {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  color: var(--muted);
}

.throbber {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.dashboard-controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.dashboard-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
}

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

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    max-width: 100vw;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand span {
    font-size: 18px;
  }

  .brand img {
    width: 42px;
    height: 42px;
  }

  .nav {
    flex-direction: row;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-item {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 12px;
  }

  .content {
    width: 100%;
    max-width: 100vw;
    padding: 22px 16px;
    overflow-x: hidden;
  }

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

  .entry-detail-grid {
    grid-template-columns: 1fr 1fr;
  }

  .employee-create-form,
  .employee-contract-head,
  .contract-grid {
    grid-template-columns: 1fr;
  }

  .contract-grid-head {
    display: none;
  }

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

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

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

  .chart-panel,
  .settings-form,
  .detail-panel {
    padding: 16px;
  }

  .table-wrap {
    max-height: none;
  }

  .data-table {
    min-width: 640px;
  }

  .dashboard-panel .data-table,
  .defect-grid .data-table {
    min-width: 560px;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .defect-grid,
  .device-flow {
    grid-template-columns: 1fr;
  }


  .defect-scanner video,
  .scanner-placeholder {
    max-height: 48vh;
  }

  .detail-head {
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 28px;
  }

  .sidebar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .brand {
    min-height: 42px;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(92px, 1fr));
    overflow-x: auto;
  }

  .nav-item {
    text-align: center;
  }

  .content {
    padding: 18px 10px;
  }

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

  .top-actions {
    justify-content: stretch;
  }

  .top-actions > * {
    flex: 1 1 auto;
  }

  .section-head.compact {
    gap: 12px;
  }

  .dashboard-controls,
  .form-actions,
  .pager {
    align-items: stretch;
    flex-direction: column;
  }

  .chart-panel,
  .settings-form,
  .detail-panel {
    padding: 14px;
  }

  .data-table {
    min-width: 560px;
  }

  .dashboard-panel .data-table {
    min-width: 520px;
  }

  .defect-grid .data-table {
    min-width: 500px;
  }

  .device-actions {
    flex-direction: column;
  }

  .device-id-label,
  .device-id-input {
    max-width: none;
  }

  .defect-scanner video,
  .scanner-placeholder {
    aspect-ratio: 3 / 4;
    max-height: 54vh;
  }

  .defect-photo-preview {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .defect-photo-preview img,
  .defect-photo-thumb {
    width: 72px;
    height: 54px;
  }

  .defect-photo-preview button {
    grid-column: 1 / -1;
  }

  .chart {
    grid-template-columns: repeat(12, 46px);
  }

  .chart-area {
    grid-template-columns: 54px minmax(0, 1fr);
  }

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

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

  .month-control {
    grid-template-columns: 1fr;
  }

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

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