/* VIA Employee Portal - mobile-first (tech phones) */
:root {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #f0f4ff;
  --bg2: #e8eefc;
  --card: #ffffff;
  --line: #c7d2fe;
  --accent: #4f46e5;
  --accent2: #6366f1;
  --text: #1e1b4b;
  --muted: #64748b;
  --label: #4338ca;
  --chip: #eef2ff;
  --ok-bg: #ecfdf5;
  --ok-bd: #34d399;
  --ok-tx: #065f46;
  --err-bg: #fef2f2;
  --err-bd: #f87171;
  --err-tx: #991b1b;
  --touch: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-x: max(12px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
}
*, *::before, *::after { box-sizing: border-box; }
html {
  width: 100%;
  max-width: 100%;
  -webkit-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  font-size: 16px;
  background:
    radial-gradient(900px 480px at 10% -10%, #ddd6fe 0%, transparent 55%),
    radial-gradient(700px 400px at 100% 0%, #bfdbfe 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  overflow-x: hidden;
  -webkit-tap-highlight-color: rgba(79, 70, 229, 0.12);
}
.wrap {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: calc(12px + var(--safe-t)) var(--safe-x) calc(28px + var(--safe-b));
  box-sizing: border-box;
}
/* Only constrain width on larger screens / tablets */
@media (min-width: 600px) {
  .wrap { max-width: 560px; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  min-width: 0;
}
.brand img.logo {
  height: 40px;
  width: auto;
  max-width: 120px;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 2px solid #c7d2fe;
  background: #eef2ff;
  flex-shrink: 0;
}
.avatar-fallback {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  border: 2px solid #c7d2fe;
  flex-shrink: 0;
}
.topbar .avatar, .topbar .avatar-fallback { width: 42px; height: 42px; }
.brand-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: #312e81;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 55vw;
}
.brand-sub {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.25;
}

h1 {
  font-size: 1.2rem;
  color: #312e81;
  margin: 0 0 10px;
  font-weight: 700;
  line-height: 1.25;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-top: 12px;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.07);
}
.hidden { display: none !important; }

label {
  display: block;
  font-size: 0.72rem;
  color: var(--label);
  margin: 12px 0 5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
}

/* 16px+ inputs = no iOS zoom on focus */
input, select, textarea {
  width: 100%;
  max-width: 100%;
  min-height: var(--touch);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--text);
  font-size: 16px;
  line-height: 1.3;
  appearance: none;
  -webkit-appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, #6366f1 50%),
    linear-gradient(135deg, #6366f1 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent2);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}
textarea {
  min-height: 88px;
  resize: vertical;
}

button.primary {
  margin-top: 14px;
  width: 100%;
  min-height: var(--touch);
  padding: 14px 16px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.22);
  touch-action: manipulation;
}
button.primary:active { transform: scale(0.98); }
button.primary:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }
button.ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: #4338ca;
  border-radius: 12px;
  min-height: 40px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  touch-action: manipulation;
  flex-shrink: 0;
}
button.ghost:active { background: var(--chip); }

.links { margin-top: 14px; font-size: 0.95rem; }
.links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  display: inline-block;
  padding: 8px 0;
  min-height: 40px;
}
.msg {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  display: none;
  line-height: 1.35;
}
.msg.show { display: block; }
.msg.ok { background: var(--ok-bg); border: 1px solid var(--ok-bd); color: var(--ok-tx); }
.msg.err { background: var(--err-bg); border: 1px solid var(--err-bd); color: var(--err-tx); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 calc(-1 * var(--safe-x)) 0;
  padding: 8px var(--safe-x);
  background: rgba(240, 244, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(199, 210, 254, 0.6);
}
.who {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 48vw;
}

/* Horizontal scroll tabs — easier than wrapping on narrow phones */
.tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
  overscroll-behavior-x: contain;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  min-width: max(72px, 18vw);
  min-height: 42px;
  background: #fff;
  border: 1px solid var(--line);
  color: #4338ca;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
  touch-action: manipulation;
  white-space: nowrap;
}
.tab.active {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.22);
}

.statgrid, .metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.stat {
  background: linear-gradient(180deg, #fafbff 0%, #eef2ff 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  min-width: 0;
}
.stat .k {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  font-weight: 700;
}
.stat .v {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 4px;
  color: #312e81;
  word-break: break-word;
}
.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.row > div { flex: 1 1 100px; min-width: 0; }

.days {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.days label.day {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 42px;
  min-width: calc(25% - 8px);
  flex: 1 1 calc(25% - 8px);
  padding: 8px 6px;
  cursor: pointer;
  font-weight: 600;
  touch-action: manipulation;
  user-select: none;
}
.days label.day input {
  width: auto;
  min-height: 0;
  margin: 0;
  accent-color: var(--accent);
}
.days label.day.on {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #fff;
}
.meta-line {
  font-size: 0.86rem;
  color: var(--muted);
  margin: 0 0 12px;
  line-height: 1.4;
}

/* Performance snapshot */
.snap-banner {
  border-radius: 14px;
  padding: 14px 12px;
  text-align: center;
  color: #fff;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.3;
}
.snap-banner.good { background: linear-gradient(135deg, #059669, #10b981); }
.snap-banner.bad { background: linear-gradient(135deg, #dc2626, #ef4444); }
.snap-banner .sub {
  font-weight: 500;
  font-size: 0.8rem;
  opacity: 0.95;
  margin-top: 6px;
  line-height: 1.35;
}
.snap-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.snap-info .cell {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  min-width: 0;
}
.snap-info .cell .k {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.snap-info .cell .v {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
  margin-top: 2px;
  word-break: break-word;
}
.section-h {
  font-size: 0.8rem;
  font-weight: 800;
  color: #1f538d;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid #1f538d;
  display: inline-block;
  padding-bottom: 4px;
  margin: 14px 0 8px;
}
.mcard {
  border-radius: 12px;
  border: 1px solid #d1d5db;
  padding: 12px;
  background: #fff;
  min-width: 0;
}
.mcard.on { background: #eafaf1; border-color: #a9dfbf; }
.mcard.below { background: #fdecea; border-color: #f5b7b1; }
.mcard.na, .mcard.info { background: #f8fafc; border-color: #e2e8f0; }
.mcard .ttl { font-weight: 800; color: #1e293b; font-size: 0.9rem; line-height: 1.2; }
.mcard .sub { font-size: 0.7rem; color: #94a3b8; margin: 2px 0 6px; line-height: 1.25; }
.mcard .val {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.15;
  word-break: break-word;
}
.mcard.on .val { color: #27ae60; }
.mcard.below .val { color: #c0392b; }
.mcard .bar {
  height: 8px;
  background: #e8e8e8;
  border-radius: 6px;
  overflow: hidden;
  margin: 8px 0;
}
.mcard .bar > i {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: #27ae60;
}
.mcard.below .bar > i { background: #e74c3c; }
.mcard .pill {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #fff;
  background: #27ae60;
  padding: 4px 8px;
  border-radius: 20px;
  line-height: 1.2;
}
.mcard.below .pill { background: #e74c3c; }
.mcard.na .pill { background: #94a3b8; }
.mcard .tgt {
  font-size: 0.68rem;
  color: #95a5a6;
  margin-left: 4px;
  display: inline-block;
  margin-top: 4px;
}
.tier-line {
  font-size: 0.98rem;
  font-weight: 800;
  margin: 4px 0 8px;
  line-height: 1.3;
}

/* Links — big tap targets */
.link-cat { margin-bottom: 16px; }
.link-cat h2 {
  font-size: 0.88rem;
  color: #1f538d;
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.link-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 8px;
}
.link-item a {
  color: #4f46e5;
  font-weight: 700;
  text-decoration: none;
  font-size: 1rem;
  display: block;
  padding: 4px 0;
  min-height: 40px;
  line-height: 1.35;
  word-break: break-word;
}
.link-item .body {
  white-space: pre-wrap;
  font-size: 0.9rem;
  color: #475569;
  margin-top: 6px;
  line-height: 1.45;
}
.admin-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.admin-row button {
  font-size: 0.85rem;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  color: #4338ca;
  touch-action: manipulation;
}
.admin-row button.danger { color: #b91c1c; border-color: #fecaca; }
.admin-form label { margin-top: 8px; }
.admin-form textarea {
  width: 100%;
  min-height: 88px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 12px;
  font-family: inherit;
  font-size: 16px;
  background: #f8fafc;
}

/* Very narrow phones */
@media (max-width: 380px) {
  .statgrid, .metric-grid { gap: 6px; }
  .mcard .val { font-size: 1.2rem; }
  .brand-text { font-size: 0.95rem; max-width: 48vw; }
  .days label.day {
    min-width: calc(33.33% - 8px);
    flex: 1 1 calc(33.33% - 8px);
  }
}

/* Landscape phones / small tablets: slightly roomier */
@media (min-width: 480px) {
  .wrap { padding-top: calc(16px + var(--safe-t)); }
  .card { padding: 18px; }
  .brand img.logo { height: 48px; }
  .stat .v { font-size: 1.25rem; }
  .mcard .val { font-size: 1.45rem; }
}

/* Larger phones / desktop */
@media (min-width: 640px) {
  .wrap { padding: 24px 16px 48px; max-width: 560px; }
  .tabs { flex-wrap: wrap; overflow: visible; }
  .tab { flex: 1; min-width: 80px; }
  .topbar {
    position: static;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    backdrop-filter: none;
  }
}
