* {
  box-sizing: border-box;
}

:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #657080;
  --line: #d8dee6;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #b91c1c;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

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

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

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

label {
  display: grid;
  gap: 7px;
  font-size: 0.9rem;
  font-weight: 700;
}

small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.sort-link.active {
  color: var(--accent-dark);
}

.sort-link span {
  font-size: 0.95rem;
}

pre {
  max-width: 420px;
  max-height: 180px;
  margin: 0;
  overflow: auto;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.app-body {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  gap: 18px;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.brand-block h1 {
  margin-bottom: 0;
  font-size: 1.5rem;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.main-nav {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.main-nav a {
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
}

.main-nav a.active,
.main-nav a:hover {
  background: #dbeafe;
  color: var(--accent-dark);
}

.account-area {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.app-main {
  width: 100%;
  margin: 0 auto;
  padding: 24px 28px 48px;
}

.panel,
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
  margin-bottom: 20px;
}

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

.panel-head h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 20px;
}

.stat-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

.stat-card strong {
  font-size: 2.4rem;
  line-height: 1;
}

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

.chart-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 22px;
  align-items: center;
}

.pie-chart {
  width: 240px;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: inset 0 0 0 24px #ffffff, 0 0 0 1px var(--line);
}

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

.legend-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.history-table {
  min-width: 1100px;
}

.filter-form,
.inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 14px;
  align-items: end;
}

.stack-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.form-actions,
.row-actions,
.role-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.role-form select {
  min-width: 140px;
}

.secondary-button,
.secondary-link {
  min-height: 40px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.danger-button {
  background: #fee2e2;
  color: var(--danger);
}

.user-chip,
.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #dbeafe;
  color: var(--accent-dark);
  font-size: 0.86rem;
  font-weight: 800;
}

.status-chip {
  background: #dcfce7;
  color: #166534;
}

.status-chip.warning {
  background: #fef3c7;
  color: #92400e;
}

.touch-entry {
  display: grid;
  gap: 20px;
}

.touch-band {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

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

.touch-head > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.step-badge {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #111827;
  color: #ffffff;
  font-weight: 900;
}

.selection-label {
  min-width: 120px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #ecfdf5;
  color: #166534;
  font-weight: 800;
  text-align: center;
}

.entry-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.entry-tab {
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-weight: 900;
}

.entry-tab.active {
  border-color: #2563eb;
  background: #dbeafe;
  color: #1d4ed8;
}

.entry-tab-panel[hidden],
.master-tab-panel[hidden],
.ocr-bulk-panel[hidden] {
  display: none;
}

.compact-head {
  margin-bottom: 10px;
}

.compact-head h3 {
  margin: 0;
}

.ocr-bulk-panel {
  display: grid;
  gap: 12px;
}

.ocr-bulk-table th,
.ocr-bulk-table td {
  vertical-align: middle;
}

.ocr-bulk-table select,
.ocr-bulk-table input {
  min-width: 130px;
}

.ocr-bulk-actions {
  margin-top: 0;
}

.manual-entry-status {
  grid-column: 1 / -1;
  margin: 0;
}

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

.touch-search {
  width: min(360px, 100%);
}

.touch-grid {
  display: grid;
  gap: 12px;
}

.worker-grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.category-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.touch-card {
  min-height: 104px;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  box-shadow: none;
}

.touch-card strong {
  font-size: 1.1rem;
}

.touch-card span,
.touch-card em {
  color: var(--muted);
  font-style: normal;
}

.touch-card.selected {
  border-color: #16a34a;
  background: #ecfdf5;
  color: #14532d;
}

.touch-card:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.scanner-modal[hidden] {
  display: none;
}

.scanner-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.68);
}

.scanner-panel {
  width: min(620px, 100%);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.scanner-video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  background: #111827;
  object-fit: cover;
}

.scanner-video-wrap {
  position: relative;
}

.barcode-guide {
  position: absolute;
  left: 3%;
  right: 3%;
  top: 38%;
  height: 24%;
  display: grid;
  place-items: center;
  border: 2px solid rgba(34, 197, 94, 0.92);
  border-radius: 6px;
  box-shadow: 0 0 0 999px rgba(15, 23, 42, 0.26);
  pointer-events: none;
}

.barcode-guide span {
  width: 100%;
  border-top: 2px solid rgba(239, 68, 68, 0.9);
}

.scanner-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--accent-dark);
  font-weight: 800;
}

.ocr-capture-progress[hidden] {
  display: none;
}

.ocr-capture-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.ocr-capture-progress-track {
  height: 14px;
  overflow: hidden;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
}

.ocr-capture-progress-bar {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #16a34a);
  transition: width 180ms ease;
}

.ocr-capture-progress span {
  color: var(--accent-dark);
  font-size: 0.86rem;
  font-weight: 900;
  text-align: right;
}

.scanner-result[hidden] {
  display: none;
}

.scanner-result {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: #f0fdf4;
}

.scanner-result span {
  color: #166534;
  font-size: 0.86rem;
  font-weight: 800;
}

.scanner-result strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #14532d;
  font-size: 1.15rem;
}

.scanner-manual {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}

.ocr-panel {
  width: min(860px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.ocr-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr);
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}

.ocr-video-wrap {
  position: relative;
}

.ocr-overlay-canvas[hidden] {
  display: none;
}

.ocr-overlay-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
  pointer-events: none;
}

.ocr-guide {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.ocr-guide-frame {
  width: 78%;
  aspect-ratio: 210 / 99;
  border: 3px solid rgba(37, 99, 235, 0.86);
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.08);
  box-shadow: 0 0 0 999px rgba(15, 23, 42, 0.18);
}

.ocr-guide span {
  position: absolute;
  bottom: 16px;
  left: 50%;
  max-width: calc(100% - 40px);
  transform: translateX(-50%);
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.78);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.ocr-preview-canvas[hidden],
.ocr-results[hidden] {
  display: none;
}

.ocr-preview-canvas {
  display: block;
  width: 100%;
  max-height: 220px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
  object-fit: contain;
}

.ocr-results {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.ocr-result-row {
  display: grid;
  grid-template-columns: 34px 110px 150px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: #f0fdf4;
  color: #14532d;
  text-align: left;
}

.ocr-result-row:disabled {
  border-color: var(--line);
  background: #f3f4f6;
  color: var(--muted);
  cursor: not-allowed;
}

.ocr-result-row span,
.ocr-result-row strong,
.ocr-result-row em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ocr-result-row em {
  font-style: normal;
  font-size: 0.9rem;
}

.ocr-raw-debug {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
  color: var(--text);
}

.ocr-raw-debug summary {
  cursor: pointer;
  font-weight: 800;
}

.ocr-raw-debug pre {
  max-height: 120px;
  margin: 8px 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.82rem;
}

.ocr-result-debug-canvas {
  display: block;
  width: 100%;
  max-height: 360px;
  margin: 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  object-fit: contain;
}

.ocr-raw-debug-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ocr-raw-debug-grid span {
  padding: 4px 6px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.78rem;
}

.time-summary {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.time-summary span {
  min-width: 118px;
  padding: 9px 12px;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--accent-dark);
  font-weight: 900;
  text-align: center;
}

.compact-button {
  min-height: 38px;
  padding: 8px 12px;
}

.time-board {
  display: grid;
  gap: 12px;
}

.time-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dbeafe;
}

.time-row:nth-child(even) {
  background: #dcfce7;
}

.time-hour {
  display: grid;
  place-items: center;
  min-height: 54px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 1.55rem;
  font-weight: 900;
}

.time-row:nth-child(even) .time-hour {
  background: #16a34a;
}

.time-quarter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.time-button {
  min-height: 54px;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 2px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font-weight: 900;
}

.time-button strong {
  font-size: 1.18rem;
  line-height: 1;
}

.time-button span {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.time-button.in-range {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #14532d;
}

.time-button.selected-start {
  border-color: var(--accent);
  background: var(--accent);
}

.time-button.selected-end {
  border-color: #16a34a;
  background: #16a34a;
}

.time-button.selected-start,
.time-button.selected-end,
.time-button.selected-start span,
.time-button.selected-end span {
  color: #ffffff;
}

.start-dock {
  position: sticky;
  bottom: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 260px);
  gap: 14px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.08);
}

.start-button,
.stop-button {
  min-height: 64px;
  font-size: 1.25rem;
}

.start-button {
  background: #16a34a;
}

.start-button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.stop-button {
  background: #dc2626;
}

.stop-button.wide {
  width: 100%;
}

.running-list {
  display: grid;
  gap: 12px;
}

.running-list.compact {
  gap: 10px;
}

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

.running-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.running-card {
  display: grid;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.running-card h2 {
  margin: 10px 0 4px;
  font-size: 1.55rem;
}

.running-card p {
  margin-bottom: 4px;
  font-size: 1.1rem;
  font-weight: 800;
}

.running-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.running-meta strong {
  font-size: 1.55rem;
}

.work-filter-form {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr)) auto;
  gap: 14px;
  align-items: end;
}

.masters-stack {
  display: grid;
  gap: 20px;
}

.ocr-settings-form {
  display: grid;
  gap: 14px;
}

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

.ocr-free-grid label {
  display: grid;
  gap: 6px;
}

.ocr-preset-option {
  min-height: 118px;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.ocr-preset-option:hover,
.ocr-preset-option.selected {
  border-color: #2563eb;
  background: #eff6ff;
}

.ocr-preset-option span {
  color: var(--muted);
  line-height: 1.45;
}

.ocr-preset-option strong {
  color: var(--text);
}

.ocr-preset-option small {
  color: var(--muted);
  line-height: 1.45;
}

.ocr-settings-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.master-form,
.master-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr)) 90px auto;
  gap: 8px;
  align-items: center;
}

.master-form {
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.compact-master-form,
.compact-master-row {
  grid-template-columns: 220px 90px 64px 64px;
}

.final-master-form,
.final-master-row {
  grid-template-columns: 96px 180px 150px 180px 120px 82px 64px 64px;
}

.worker-master-form,
.worker-master-row {
  grid-template-columns: 110px 120px 170px 120px 74px 64px 64px;
}

.area-master-form,
.area-master-row {
  grid-template-columns: 130px 220px 80px 64px 64px;
}

.site-master-form,
.site-master-row {
  grid-template-columns: 110px 170px 150px 74px 92px 120px 84px 140px 130px 64px 64px;
}

.site-master-form .barcode-enabled-field,
.site-master-row .barcode-enabled-field,
.site-master-form .barcode-format-field,
.site-master-row .barcode-format-field,
.site-master-form .barcode-fixed-length-field,
.site-master-row .barcode-fixed-length-field,
.site-master-form .barcode-classification-field,
.site-master-row .barcode-classification-field {
  grid-row: 1;
}

.site-master-form .barcode-enabled-field,
.site-master-row .barcode-enabled-field {
  grid-column: 5;
}

.site-master-form .barcode-format-field,
.site-master-row .barcode-format-field {
  grid-column: 6;
}

.site-master-form .barcode-fixed-length-field,
.site-master-row .barcode-fixed-length-field {
  grid-column: 7;
}

.site-master-form .barcode-classification-field,
.site-master-row .barcode-classification-field {
  grid-column: 8;
}

.site-master-form .ocr-preset-field,
.site-master-row .ocr-preset-field {
  grid-column: 9;
  grid-row: 1;
}

.site-master-form .site-save-action,
.site-master-row .site-save-action {
  grid-column: 10;
  grid-row: 1;
}

.site-master-row .site-delete-action {
  grid-column: 11;
  grid-row: 1;
}

.master-list {
  display: grid;
  gap: 0;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #ffffff;
}

.master-row {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9fafb;
}

.master-list-header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #e5edf7;
  color: #334155;
  font-size: 0.74rem;
  font-weight: 800;
}

.master-list-header > span {
  align-self: end;
  min-height: 32px;
  padding: 8px 9px;
  border-right: 1px solid #cbd5e1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.master-list-header > span:last-child {
  border-right: 0;
}

.master-list .master-row {
  min-width: max-content;
  gap: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid #d7dee8;
  border-radius: 0;
  background: #ffffff;
}

.master-list .master-row:last-child {
  border-bottom: 0;
}

.master-list .master-row:not(.master-list-header):hover {
  background: #f8fbff;
}

.master-list .master-row > label,
.master-list .master-row > .master-field,
.master-list .master-row > button,
.master-list .master-row > .status-chip {
  min-height: 40px;
  padding: 4px 5px;
  border-right: 1px solid #d7dee8;
}

.master-list .master-row > label:last-child,
.master-list .master-row > .master-field:last-child,
.master-list .master-row > button:last-child,
.master-list .master-row > .status-chip:last-child {
  border-right: 0;
}

.master-form label,
.master-row label,
.master-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
}

.master-form label > span:first-child,
.master-row label > span:first-child,
.master-field > span:first-child {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.master-form input,
.master-form select,
.master-row input,
.master-row select {
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
}

.master-list .master-row input,
.master-list .master-row select {
  min-height: 30px;
  padding: 4px 6px;
  border-color: transparent;
  border-radius: 3px;
  background: transparent;
}

.master-list .master-row input:focus,
.master-list .master-row select:focus {
  border-color: var(--accent);
  background: #ffffff;
  outline: none;
}

.master-form button,
.master-row button {
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
}

.master-list .master-row button {
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 0.8rem;
}

.check-label {
  min-height: 34px;
  display: flex;
  gap: 6px;
  align-items: center;
  align-self: center;
}

.check-label input {
  width: 18px;
  min-height: 18px;
}

.inline-checks {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.inline-checks label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.inline-checks input {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

.master-list .master-row:not(.master-list-header) > label:not(.check-label),
.master-list .master-row:not(.master-list-header) > .master-field {
  grid-template-columns: minmax(0, 1fr);
}

.master-list .master-row:not(.master-list-header) > label > span:first-child,
.master-list .master-row:not(.master-list-header) > .master-field > span:first-child {
  display: none;
}

.empty,
.empty-cell,
.lead,
.muted {
  color: var(--muted);
}

.empty-cell {
  padding: 28px 12px;
  text-align: center;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.flash.success {
  background: #dcfce7;
  border-color: #bbf7d0;
  color: #166534;
}

.flash.error {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(15, 118, 110, 0.1)),
    var(--bg);
}

.auth-shell {
  width: min(960px, 100%);
}

.auth-panel {
  display: grid;
  grid-template-columns: 1fr 420px;
  min-height: 520px;
  overflow: hidden;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.16);
}

.auth-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.16), rgba(15, 118, 110, 0.12)),
    #eff6ff;
}

.auth-copy h1 {
  max-width: 520px;
  margin-bottom: 14px;
  font-size: 3rem;
  line-height: 1.05;
}

.auth-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px;
}

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

@media (max-width: 1100px) {
  .app-header,
  .dashboard-grid,
  .masters-grid,
  .chart-layout,
  .filter-form,
  .inline-form,
  .stack-form,
  .work-filter-form {
    grid-template-columns: 1fr;
  }

  .account-area,
  .main-nav {
    justify-content: flex-start;
  }

  .pie-chart {
    width: min(240px, 100%);
  }

}

@media (max-width: 640px) {
  .app-header,
  .app-main {
    padding-left: 16px;
    padding-right: 16px;
  }

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

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

  .auth-copy,
  .auth-card {
    padding: 28px 22px;
  }

  .auth-copy h1 {
    font-size: 2rem;
  }

  .touch-head,
  .time-summary,
  .running-row,
  .running-meta,
  .ocr-settings-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .start-dock {
    grid-template-columns: 1fr;
  }

  .scanner-manual {
    grid-template-columns: 1fr;
  }

  .ocr-controls,
  .ocr-result-row {
    grid-template-columns: 1fr;
  }

  .touch-card {
    min-height: 92px;
  }

  .time-row {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 6px;
    padding: 6px;
  }

  .time-quarter-grid {
    gap: 4px;
  }

  .time-hour {
    min-height: 50px;
    font-size: 1.18rem;
  }

  .time-button {
    min-height: 50px;
    padding: 6px 2px;
  }

  .time-button strong {
    font-size: 1rem;
  }

  .time-button span {
    font-size: 0.64rem;
  }
}

@media (orientation: portrait) and (max-width: 900px) {
  .app-header {
    grid-template-columns: 1fr auto;
    gap: 8px 10px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .brand-block h1 {
    display: none;
  }

  .eyebrow {
    margin-bottom: 0;
  }

  .main-nav {
    grid-column: 1 / -1;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .main-nav a {
    flex: 0 0 auto;
    padding: 7px 9px;
    font-size: 0.86rem;
    white-space: nowrap;
  }

  .account-area {
    justify-content: flex-end;
    gap: 6px;
  }

  .account-area .user-chip {
    display: none;
  }

  .account-area button {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 0.84rem;
  }

  .app-main {
    padding-top: 14px;
  }
}

@media (orientation: landscape) {
  .app-body {
    display: grid;
    grid-template-columns: 176px minmax(0, 1fr);
    align-items: start;
  }

  .app-header {
    position: sticky;
    top: 0;
    min-height: 100vh;
    grid-template-columns: 1fr;
    align-content: start;
    gap: 14px;
    padding: 16px 12px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .brand-block h1 {
    font-size: 1.15rem;
    line-height: 1.25;
  }

  .main-nav {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
  }

  .main-nav a {
    padding: 9px 10px;
  }

  .account-area {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }

  .account-area form,
  .account-area button {
    width: 100%;
  }

  .user-chip {
    justify-content: center;
    text-align: center;
  }

  .app-main {
    min-width: 0;
    padding: 18px 22px 40px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .app-header {
    gap: 8px;
    padding: 10px;
  }

  .brand-block h1 {
    display: none;
  }

  .eyebrow {
    margin-bottom: 0;
  }

  .main-nav a {
    padding: 7px 8px;
    font-size: 0.86rem;
  }

  .account-area {
    gap: 6px;
  }
}
