:root {
  color-scheme: light;
  --bg: #f7f9fb;
  --border: #d9e2e7;
  --danger: #b42318;
  --danger-dark: #7a271a;
  --ink: #17212b;
  --muted: #5e6b76;
  --primary: #166534;
  --primary-dark: #14532d;
  --surface: #ffffff;
  --warning: #b7791f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  min-height: 44px;
}

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

.login-layout {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.login-panel,
.work-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(23, 33, 43, 0.08);
  width: min(100%, 760px);
}

.login-panel {
  padding: 24px;
}

.brand-row {
  align-items: center;
  display: grid;
  justify-items: center;
  margin-bottom: 20px;
}

.brand-logo {
  display: block;
  height: auto;
  width: min(210px, 70%);
}

.login-install-button {
  margin-bottom: 20px;
  width: 100%;
}

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

h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

h3 {
  font-size: 16px;
}

.form-stack {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 6px;
}

label span,
legend,
.eyebrow,
.metric span,
small,
.muted {
  color: var(--muted);
  font-size: 13px;
}

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

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.segmented-field {
  display: grid;
  gap: 8px;
}

.segmented-option {
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
}

.segmented-option input {
  min-height: auto;
  width: auto;
}

.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) 20px 16px;
  position: sticky;
  top: 0;
  z-index: 3;
}

.topbar-actions,
.section-header {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.connection-pill {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  min-height: 36px;
  padding: 8px 10px;
}

.connection-pill.online {
  background: #dcfce7;
  color: var(--primary);
}

.connection-pill.offline {
  background: #fef3c7;
  color: var(--warning);
}

.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 20px;
}

.tabs button {
  background: transparent;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  min-width: 96px;
  padding: 10px 12px;
}

.tabs button.active {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}

.content {
  display: grid;
  gap: 16px;
  margin: 0 auto;
  padding: 20px;
  width: min(100%, 860px);
}

.work-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.compact-panel {
  box-shadow: none;
}

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

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 18px;
}

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

.metric.narrow {
  max-width: 320px;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.ghost-danger-button {
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  padding: 10px 14px;
}

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

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

.secondary-button {
  background: #e7f3ec;
  color: var(--primary);
}

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

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

.ghost-button,
.ghost-danger-button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
}

.ghost-danger-button,
.plain-danger {
  color: var(--danger);
}

.plain-danger {
  background: transparent;
  font-weight: 700;
}

.full-width {
  width: 100%;
}

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

.status-message,
.loading-bar {
  border-radius: 8px;
  padding: 12px 14px;
}

.inline-status,
.install-banner,
.inline-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.install-banner {
  background: #eef6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 12px 14px;
}

.install-banner p,
.version-footer {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}

.compact-actions {
  flex-shrink: 0;
}

.inline-actions label {
  flex: 1;
}

.status-message.info,
.loading-bar {
  background: #e8eef2;
}

.status-message.success {
  background: #dcfce7;
  color: #14532d;
}

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

.status-message.error {
  background: #fee2e2;
  color: #991b1b;
}

.status-pill {
  border-radius: 999px;
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  padding: 6px 10px;
}

.status-pill.pending {
  background: #fef3c7;
  color: var(--warning);
}

.status-pill.approved {
  background: #dcfce7;
  color: var(--primary);
}

.status-pill.in_progress {
  background: #fee2e2;
  color: var(--danger);
}

.catalog-results,
.draft-list,
.history-list {
  display: grid;
  gap: 10px;
}

.activity-summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.activity-summary article {
  background: #fbfcfd;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 12px;
}

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

.activity-timeline {
  display: grid;
  gap: 0;
}

.diagnostics-grid {
  display: grid;
  gap: 10px;
}

.diagnostic-row {
  align-items: center;
  background: #fbfcfd;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto;
  padding: 12px;
}

.diagnostic-row div {
  display: grid;
  gap: 4px;
}

.timeline-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 18px minmax(0, 1fr);
}

.timeline-rail {
  display: flex;
  justify-content: center;
  position: relative;
}

.timeline-rail::before {
  background: var(--border);
  bottom: 0;
  content: '';
  position: absolute;
  top: 0;
  width: 2px;
}

.timeline-rail span {
  background: var(--primary);
  border: 3px solid var(--surface);
  border-radius: 999px;
  height: 14px;
  margin-top: 14px;
  position: relative;
  width: 14px;
  z-index: 1;
}

.timeline-content {
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 4px;
  padding: 10px 0 12px;
}

.timeline-content p {
  margin: 0;
}

.list-row,
.order-card {
  background: #fbfcfd;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

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

.list-row div:first-child {
  display: grid;
  gap: 4px;
}

.quantity-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.quantity-controls button {
  border-radius: 8px;
  min-height: 36px;
  padding: 6px 10px;
}

.history-hours {
  text-align: end;
}

.struck {
  text-decoration: line-through;
}

.camera-overlay,
.choice-overlay {
  align-items: center;
  background: rgba(23, 33, 43, 0.72);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 20;
}

.camera-panel,
.choice-panel {
  background: var(--surface);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  max-width: 460px;
  padding: 16px;
  width: min(100%, 460px);
}

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

.choice-card {
  background: #f8fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  min-height: 108px;
  padding: 16px;
  text-align: center;
}

.choice-card:hover {
  border-color: var(--primary);
}

.camera-preview {
  aspect-ratio: 3 / 4;
  background: #000;
  border-radius: 8px;
  object-fit: cover;
  width: 100%;
}

[dir='rtl'] .history-hours {
  text-align: start;
}

@media (max-width: 700px) {
  .topbar,
  .section-header,
  .list-row {
    align-items: stretch;
    flex-direction: column;
  }

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

  .topbar-actions button,
  .section-header button {
    width: 100%;
  }

  .connection-pill,
  .inline-status,
  .install-banner,
  .inline-actions,
  .diagnostic-row {
    align-items: stretch;
    flex-direction: column;
  }

  .diagnostic-row {
    grid-template-columns: 1fr;
  }

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

  .activity-summary {
    grid-template-columns: 1fr;
  }

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

  .content,
  .login-layout {
    padding: 14px;
  }
}
