:root {
  --primary: #1e3a5f;
  --primary-light: #2d5a8a;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1a2e;
  --muted: #6b7280;
  --success: #16a34a;
  --warning: #ea580c;
  --danger: #dc2626;
  --info: #2563eb;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

body {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

#app {
  min-height: 100dvh;
}

.noscript {
  padding: 2rem;
  text-align: center;
}

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  background: var(--primary);
  color: #fff;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header h1 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
}

.header p {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  opacity: 0.85;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.content {
  flex: 1;
  padding: 1rem;
}

.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  display: block;
}

.login-card h1 {
  text-align: center;
  margin: 0 0 0.35rem;
  color: var(--primary);
  font-size: 1.5rem;
}

.login-card .subtitle {
  text-align: center;
  color: var(--muted);
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.field input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
}

.field input:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.9rem 1rem;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-outline {
  background: #fff;
  border: 1.5px solid currentColor;
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

.empty,
.loading {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.shipment-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.85rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.shipment-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.shipment-id {
  font-weight: 700;
  font-size: 1rem;
}

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-pending {
  background: #e0e7ff;
  color: #3730a3;
}
.badge-transit {
  background: #ffedd5;
  color: #c2410c;
}
.badge-delivered {
  background: #dcfce7;
  color: #15803d;
}
.badge-failed {
  background: #fee2e2;
  color: #b91c1c;
}

.meta {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.meta strong {
  color: var(--text);
}

.meta-icon {
  flex-shrink: 0;
  width: 1.1rem;
  text-align: center;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.btn-transit {
  color: var(--warning);
  border-color: var(--warning);
}
.btn-delivered {
  color: var(--success);
  border-color: var(--success);
}
.btn-failed {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-outline:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.install-banner {
  background: #dbeafe;
  color: #1e40af;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.install-banner button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.toast {
  position: fixed;
  bottom: calc(1rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 100;
  animation: fadein 0.2s ease;
}

@keyframes fadein {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
}

.screen-tabs {
  padding-bottom: calc(3.5rem + var(--safe-bottom));
}

.content-tabs {
  padding-bottom: 0.5rem;
}

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid #e5e7eb;
  padding-bottom: var(--safe-bottom);
  z-index: 20;
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.75rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tab-active {
  color: var(--primary);
  box-shadow: inset 0 -2px 0 var(--primary);
}

.validate-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0 0.25rem;
  padding: 0.65rem 0.75rem;
  background: #f0fdf4;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #15803d;
  cursor: pointer;
}

.validate-row input {
  width: 1.1rem;
  height: 1.1rem;
}

.btn-inline {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  width: auto;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
}

.item-list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.empty-inline {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}

.header-admin .health-pill {
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.health-ok {
  background: #dcfce7;
  color: #15803d;
}

.health-off {
  background: #fee2e2;
  color: #b91c1c;
}

.company-name {
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 0.25rem;
}

.refresh-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

.section-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 1.25rem 0 0.65rem;
}

.stats {
  display: grid;
  gap: 0.65rem;
}

.stats-grid {
  grid-template-columns: repeat(2, 1fr);
}

.stat-card {
  background: var(--card);
  border-radius: 12px;
  padding: 0.85rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.alert-card {
  background: var(--card);
  border-radius: 12px;
  padding: 0.85rem;
  margin-bottom: 0.65rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.alert-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.alert-store {
  font-size: 0.75rem;
  color: var(--muted);
}

.alert-msg {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.badge-critical {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-warning {
  background: #ffedd5;
  color: #c2410c;
}

.btn-ack {
  color: var(--primary);
  border-color: var(--primary);
  width: 100%;
}

.list-block {
  background: var(--card);
  border-radius: 12px;
  padding: 0.5rem 0.85rem;
}

.delivery-row {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.85rem;
}

.delivery-row:last-child {
  border-bottom: none;
}

.muted {
  color: var(--muted);
  font-size: 0.8rem;
}

.hint {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
  margin: 0.25rem 0 0.75rem;
}

.hint code {
  font-size: 0.75rem;
  word-break: break-all;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  margin-left: 0.35rem;
}

.offline-panel {
  padding: 1rem 0;
}

.offline-panel .btn {
  margin-top: 1rem;
}

.notif-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.75rem 1rem 0;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a5f;
  font-size: 0.82rem;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  white-space: nowrap;
}
