:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --rail: #e2e8f0;
  --ink: #0f1d2e;
  --ink-2: #4a5b70;
  --border: #cbd5e1;
  --cobalt: #0b57d0;
  --cobalt-soft: #e8f0fe;
  --urgent: #c5221f;
  --urgent-soft: #fce8e6;
  --amber: #b06000;
  --amber-soft: #fef7e0;
  --ok: #137333;
  --ok-soft: #e6f4ea;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Mono', Consolas, 'Courier New', monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

.mono-code,
.mono-input {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.app-root {
  min-height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
}

/* Auth Screen */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 20px;
  box-shadow: 0 4px 18px rgba(15, 29, 46, 0.08);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rail);
}

.auth-logo {
  border-radius: 10px;
  flex-shrink: 0;
}

.auth-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.auth-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}

.panel-heading {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
}

.panel-note {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--ink-2);
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.text-input,
.search-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  outline: none;
}

.text-input:focus,
.search-input:focus {
  border-color: var(--cobalt);
  box-shadow: 0 0 0 3px rgba(11, 87, 208, 0.14);
}

.passkey-cta-wrap {
  margin-bottom: 14px;
}

.btn-passkey {
  width: 100%;
}

.divider-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 4px;
  color: var(--ink-2);
  font-size: 13px;
}

.divider-line::before,
.divider-line::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rail);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.12s ease, opacity 0.12s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-compact {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-full {
  width: 100%;
  min-height: 48px;
  font-size: 15px;
}

.btn-primary {
  background: var(--cobalt);
  color: #ffffff;
}

.btn-primary:active:not(:disabled) {
  background: #0842a0;
}

.btn-secondary {
  background: var(--cobalt-soft);
  color: var(--cobalt);
  border-color: #bfd4fa;
}

.btn-ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}

.btn-danger {
  background: var(--urgent-soft);
  color: var(--urgent);
  border-color: #f4c7c3;
}

.inline-alert {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  background: var(--urgent-soft);
  color: var(--urgent);
  border: 1px solid #f5c2be;
}

.inline-alert.is-success {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #b7dfc2;
}

/* Workspace Header */
.workspace-screen {
  min-height: 100dvh;
  padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px));
}

.top-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--ok-soft);
  color: var(--ok);
}

.sync-pill.is-busy {
  background: var(--amber-soft);
  color: var(--amber);
}

.sync-pill.is-error {
  background: var(--urgent-soft);
  color: var(--urgent);
}

.dept-rail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--rail);
  border-radius: 10px;
  margin-bottom: 8px;
}

.dept-tab {
  min-height: 40px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.dept-tab .mono-code {
  font-size: 12px;
  opacity: 0.85;
}

.dept-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 29, 46, 0.12);
}

.sync-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.sync-meta {
  font-size: 12px;
  color: var(--ink-2);
}

.filter-controls {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.chip-row {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 6px;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  min-height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chip.is-active {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

/* Main Feed & Repair Job-Tag Cards */
.main-feed {
  padding: 10px 12px 16px;
}

.feed-status {
  padding: 16px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
  color: var(--ink-2);
  font-size: 14px;
  margin-bottom: 10px;
}

.task-list,
.audit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--cobalt);
  border-radius: 11px;
  padding: 12px 13px;
  box-shadow: 0 1px 2px rgba(15, 29, 46, 0.04);
}

.task-card.spine-urgent {
  border-left-color: var(--urgent);
}

.task-card.spine-amber {
  border-left-color: var(--amber);
}

.task-card.spine-ok {
  border-left-color: var(--ok);
}

.task-card.is-queued {
  opacity: 0.92;
  border-left-color: var(--cobalt);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.card-codes {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.doc-code {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.item-code {
  font-size: 13px;
  font-weight: 600;
  color: var(--cobalt);
  background: var(--cobalt-soft);
  padding: 1px 6px;
  border-radius: 5px;
}

.status-badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--rail);
  color: var(--ink);
}

.status-badge.is-pendding {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-badge.is-inprocess {
  background: var(--cobalt-soft);
  color: var(--cobalt);
}

.status-badge.is-onhold {
  background: var(--urgent-soft);
  color: var(--urgent);
}

.card-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 8px;
}

.reject-banner {
  margin-bottom: 8px;
  padding: 6px 9px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  background: var(--urgent-soft);
  color: var(--urgent);
  border: 1px solid #f4c7c3;
}

.card-device {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 3px;
}

.card-fault {
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 6px;
}

.card-extra {
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.customer-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid var(--rail);
  border-radius: 8px;
  margin-bottom: 8px;
}

.customer-text {
  font-size: 13px;
  color: var(--ink);
  min-width: 160px;
  flex: 1;
}

.customer-address {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 2px;
}

.phone-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 7px;
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid #b7dfc2;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.assignee-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 13px;
  padding-top: 4px;
  margin-bottom: 10px;
}

.assignee-name {
  font-weight: 700;
  color: var(--ink);
}

.assignee-unassigned {
  font-weight: 700;
  color: var(--amber);
}

.assignee-state {
  font-size: 12px;
  color: var(--ink-2);
}

.assignee-queued {
  font-size: 13px;
  font-weight: 700;
  color: var(--cobalt);
}

.worksheet-panel {
  margin-bottom: 10px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
}

.worksheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-weight: 700;
}

.worksheet-line {
  padding: 6px 0;
  border-top: 1px dashed var(--border);
}

.worksheet-line:first-of-type {
  border-top: none;
  padding-top: 2px;
}

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

.card-actions .btn {
  flex: 1;
  min-height: 44px;
  padding: 0 10px;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 720px;
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-tab {
  min-height: 58px;
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}

.bottom-tab.is-active {
  color: var(--cobalt);
  box-shadow: inset 0 3px 0 var(--cobalt);
}

.tab-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--rail);
  color: var(--ink);
}

.bottom-tab.is-active .tab-badge {
  background: var(--cobalt-soft);
  color: var(--cobalt);
}

/* Slide-Up Bottom Sheets */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 29, 46, 0.45);
  z-index: 40;
}

.bottom-sheet {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 720px;
  max-height: 88dvh;
  z-index: 50;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 28px rgba(15, 29, 46, 0.22);
  display: flex;
  flex-direction: column;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--rail);
}

.sheet-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.sheet-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}

.sheet-body {
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sheet-footer {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--rail);
  background: var(--surface);
}

.ticket-mini-card {
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
}

.custom-tech-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tech-group-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  margin: 4px 0 6px;
}

.tech-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tech-option {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}

.tech-option.is-selected {
  border-color: var(--cobalt);
  background: var(--cobalt-soft);
}

.tech-option-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tech-option-dept {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

/* Security Drawer */
.sec-section {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rail);
}

.sec-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.sec-heading {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
}

.inline-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

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

.passkey-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-size: 13px;
}

.sec-danger-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Audit Card */
.audit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--ok);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.audit-card.is-fail {
  border-left-color: var(--urgent);
}

.audit-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  margin-bottom: 4px;
}

.audit-time {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}

/* Toast */
.toast-banner {
  position: fixed;
  left: 50%;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100% - 24px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(15, 29, 46, 0.25);
}

.toast-banner.is-error {
  background: var(--urgent);
}
