/* Fonts are stored in this app (Inter and Poppins, SIL Open Font License) so they also work offline. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/poppins-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/poppins-latin-600-normal.woff2") format("woff2");
}

:root {
  --navy: #011842;
  --navy-2: #0B2A5C;
  --blue: #0B6FB8;
  --blue-dark: #084E86;
  --sky: #51C2FE;
  --bg: #F3F7FB;
  --card: #FFFFFF;
  --line: #DDE6F0;
  --field: #C5D2E3;
  --text: #011842;
  --muted: #4A5B78;
  --ok-bg: #DDF3E8;
  --ok: #0E5A3A;
  --warn-bg: #FDEFCF;
  --warn: #6F4300;
  --bad-bg: #FBE0E0;
  --bad: #8A1C1C;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-head: "Poppins", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.01em; font-family: var(--font-head); font-weight: 600; }

a { color: var(--blue); }

/* ---------- shared form pieces ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted); }

form { display: flex; flex-direction: column; gap: 14px; }

input[type="text"], input[type="tel"], input[type="password"] {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--field);
  border-radius: 10px;
}

input::placeholder { color: #55657F; opacity: 1; }

input:focus-visible, button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(11, 111, 184, 0.45);
  outline-offset: 2px;
}

.pinwrap { position: relative; }
.pinwrap input { padding-right: 76px; }
.pinwrap .toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
}

.btn {
  min-height: 48px;
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--field); }
.btn.secondary:hover { background: #F3F7FB; }
.btn[disabled] { opacity: 0.6; cursor: default; }

.message {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  background: var(--bad-bg);
  color: var(--bad);
}
.message:empty { display: none; }
.message.info { background: #DCEFFD; color: #0A4F85; }
.message.warn { background: var(--warn-bg); color: var(--warn); }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chip { padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #E7ECF3; color: #3E4D68; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 20px; }
.card.pad { padding: 20px; }
.card h2 { font-size: 17px; }
.card .sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .k { color: var(--muted); }

/* ---------- sign-in and setup screens ---------- */

.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px 16px;
}

.brand { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.brand img { width: clamp(96px, 28vw, 128px); height: auto; border-radius: 50%; }
.brand h1 { font-size: clamp(20px, 5vw, 24px); }

.panel {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px 22px;
}
.panel h2 { font-size: 18px; margin-bottom: 4px; }
.panel .lead { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

.foot { font-size: 12px; color: var(--muted); text-align: center; margin: 0; }

/* ---------- app shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 12px;
  background: var(--navy);
  color: #C9D6EA;
}

.side-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.side-brand img { width: 48px; height: 48px; border-radius: 50%; flex: 0 0 auto; }
.side-brand .t1 { display: block; font-family: var(--font-head); font-weight: 600; font-size: 17px; color: #fff; line-height: 1.2; }
.side-brand .t2 { display: block; font-size: 12px; color: #A9BCDC; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label {
  padding: 0 12px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8CA3C9;
}

.navlink {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  color: #C9D6EA;
  text-decoration: none;
  font-weight: 500;
}
.navlink:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.navlink.active { background: var(--navy-2); color: #fff; font-weight: 600; }
.navlink svg { flex: 0 0 auto; }
.lbl-short { display: none; }

.side-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--navy-2);
}
.side-user .nm { display: block; color: #fff; font-weight: 600; line-height: 1.25; }
.side-user .rl { display: block; font-size: 12px; color: #A9BCDC; }
.side-user .txt { min-width: 0; }
.side-user .nm, .side-user .rl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sky);
  color: var(--navy);
  font-weight: 600;
  font-size: 14px;
}

.main-col { min-width: 0; display: flex; flex-direction: column; }

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.top-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-logo { display: none; width: 34px; height: 34px; border-radius: 50%; }
.top h1 { font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-right { position: relative; display: flex; align-items: center; gap: 12px; }

.net { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--ok-bg); color: var(--ok); white-space: nowrap; }
.net::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.net.off { background: var(--warn-bg); color: var(--warn); }

.userbtn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 6px 0 4px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.userbtn:hover { background: #F3F7FB; }

.pop {
  position: absolute;
  top: 54px;
  right: 0;
  width: 270px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(1, 24, 66, 0.16);
}
.pop[hidden] { display: none; }
.pop .who { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.pop .who strong { display: block; }
.pop .who span { display: block; font-size: 13px; color: var(--muted); }
.pop button, .pop a {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.pop button:hover, .pop a:hover { background: #F3F7FB; }

.view { width: 100%; max-width: 1200px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; outline: none; }

.empty { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 48px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .ic { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #DCEFFD; color: #0A4F85; margin-bottom: 8px; }
.empty h2 { font-size: 18px; }
.empty p { margin: 0; max-width: 420px; color: var(--muted); }

.tabs { display: none; }
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(1, 24, 66, 0.55); }
.scrim[hidden] { display: none; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  background: #fff;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sheet[hidden] { display: none; }
.sheet .grab { align-self: center; width: 44px; height: 5px; border-radius: 3px; background: var(--field); margin-bottom: 8px; }
.sheet .sheet-link {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 0 8px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.sheet .sheet-link.active { background: #DCEFFD; color: #0A4F85; font-weight: 600; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 80;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font-weight: 500;
}

.profile-actions { display: flex; flex-wrap: wrap; gap: 12px; padding: 16px 0 12px; }
.profile-actions[hidden], .pop button[hidden] { display: none; }

.row > span:last-child { text-align: right; }

.notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  background: #DCEFFD;
  color: #0A4F85;
}

.update-bar {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 24px);
  padding: 8px 8px 8px 16px;
  border-radius: 12px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 10px 30px rgba(1, 24, 66, 0.3);
}
.update-bar button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--sky);
  color: var(--navy);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* Tablet: slim icon sidebar with short labels */
@media (max-width: 1023px) {
  .shell { grid-template-columns: 84px minmax(0, 1fr); }
  .side { padding: 14px 6px; gap: 18px; align-items: stretch; }
  .side-brand { justify-content: center; padding: 0; }
  .side-brand .txt { display: none; }
  .side-brand img { width: 44px; height: 44px; }
  .nav-label { display: none; }
  .side-nav { gap: 2px; }
  .navlink { flex-direction: column; justify-content: center; gap: 3px; min-height: 58px; padding: 6px 2px; text-align: center; font-size: 11px; line-height: 1.2; }
  .lbl-full { display: none; }
  .lbl-short { display: block; }
  .side-user { justify-content: center; padding: 8px 0; background: transparent; }
  .side-user .txt { display: none; }
  .top { padding: 0 20px; }
  .view { padding: 20px; }
}

/* Phone: bottom tabs */
@media (max-width: 639px) {
  .shell { display: block; }
  .side { display: none; }
  .top { padding: 0 16px; min-height: 60px; }
  .top-logo { display: block; }
  .top h1 { font-size: 18px; }
  .net .net-text { display: none; }
  .net { padding: 0; width: 30px; justify-content: center; }
  .net::before { margin: 0; }
  .userbtn .uname { display: none; }
  .view { padding: 16px 16px calc(92px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    align-items: stretch;
    padding: 0 4px env(safe-area-inset-bottom);
    background: #fff;
    border-top: 1px solid var(--line);
  }
  .tab {
    flex: 1 1 0;
    min-width: 0;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0 2px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
  }
  .tab.active { color: var(--blue); font-weight: 600; }
  .pop { position: fixed; top: 64px; right: 12px; left: auto; width: min(270px, calc(100vw - 24px)); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
}
