:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #152033;
  --muted: #667085;
  --line: #d9e2ee;
  --primary: #1167d8;
  --success: #0f9f6e;
  --warning: #d97706;
  --danger: #d92d20;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
select,
input {
  font: inherit;
}

.worker-app {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 18px;
  display: grid;
  gap: 16px;
}

.worker-header {
  background: #0f172a;
  color: white;
  border-radius: 8px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.worker-header p,
.worker-header h1 {
  margin: 0;
}

.worker-header p {
  color: #cbd5e1;
}

.worker-header a {
  color: white;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
}

.identity-panel,
.tasks-section,
.auto-assign-note {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.identity-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

select,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
  color: var(--text);
}

input[readonly] {
  background: #f8fafc;
  color: #475467;
}

.hidden {
  display: none !important;
}

.worker-content {
  display: grid;
  gap: 16px;
}

.login-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  display: grid;
  gap: 16px;
}

.login-panel p,
.login-panel h1 {
  margin: 0;
}

.login-panel p {
  color: var(--muted);
}

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

.login-form button,
.worker-header button {
  border: 0;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
}

.worker-header button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.login-message {
  min-height: 24px;
  color: var(--danger);
  font-weight: 700;
}

.worker-identity {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

.worker-identity strong {
  color: var(--text);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.gps-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #e8fff6;
  color: #075f45;
  border-radius: 8px;
  padding: 12px;
  min-width: 220px;
}

.gps-card.tracking {
  background: #e7f0ff;
  color: #175cd3;
}

.gps-card p {
  margin: 2px 0 0;
}

.gps-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(15, 159, 110, 0.12);
}

.gps-dot.off {
  background: #98a2b3;
  box-shadow: 0 0 0 5px rgba(152, 162, 179, 0.14);
}

.tracking-toggle {
  border: 0;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
  min-height: 46px;
}

.tracking-toggle.active {
  background: var(--danger);
}

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

.summary-grid article {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 7px;
}

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

.summary-grid strong {
  font-size: 30px;
}

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

.section-head h2,
.auto-assign-note h2,
.auto-assign-note p {
  margin: 0;
}

.workflow-hint {
  color: var(--muted);
  line-height: 1.7;
}

.section-head button,
.task-card button {
  border: 0;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 700;
}

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

.task-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.task-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.task-top h3,
.task-card p {
  margin: 0;
}

.task-card p {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.new {
  color: #175cd3;
  background: #e7f0ff;
}

.badge.progress {
  color: #b45309;
  background: #fff7e6;
}

.badge.done {
  color: #047857;
  background: #e8fff6;
}

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

.task-waiting-note {
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
  color: var(--muted);
}

.start-task-btn {
  border: 0;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  padding: 10px 12px;
}

.install-form input:disabled,
.install-form button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.install-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
}

.install-form button {
  border: 0;
  background: var(--success);
  color: white;
  border-radius: 8px;
  padding: 11px 12px;
  cursor: pointer;
  font-weight: 700;
}

.install-form .location-row,
.install-form .scan-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.install-form .save-install {
  grid-column: 1 / -1;
}

.location-btn,
.scan-btn {
  white-space: nowrap;
}

.install-form small {
  color: var(--muted);
  line-height: 1.6;
}

.scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(0, 0, 0, 0.82);
}

.scanner-panel {
  position: relative;
  width: min(100%, 480px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: #101827;
  color: white;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.45);
}

.scanner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.scanner-close,
.scanner-manual-save {
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--primary);
  color: white;
}

.scanner-video {
  display: block;
  width: 100%;
  min-height: 300px;
  max-height: 62vh;
  object-fit: cover;
  background: #05070d;
}

.scanner-frame {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 38%;
  height: 96px;
  border: 3px solid #18c786;
  border-radius: 12px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.scanner-message {
  margin: 0;
  padding: 12px;
  color: #c8d3e4;
  text-align: center;
}

.scanner-manual {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 0 12px 12px;
}

.scanner-manual-input {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.task-actions a {
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  padding: 10px 12px;
}

.whatsapp-link {
  background: #e8fff6;
  border-color: #a7f3d0 !important;
  color: #075f45 !important;
  font-weight: 700;
}

.empty {
  color: var(--muted);
  background: #f8fafc;
  border-radius: 8px;
  padding: 18px;
  text-align: center;
}

.auto-assign-note {
  background: #eef5ff;
}

.auto-assign-note p {
  color: #1e3a5f;
  margin-top: 8px;
  line-height: 1.8;
}

@media (max-width: 720px) {
  .worker-header,
  .identity-panel,
  .section-head,
  .task-top {
    align-items: stretch;
    flex-direction: column;
  }

  .identity-panel,
  .summary-grid,
  .install-form {
    grid-template-columns: 1fr;
  }
}
