:root {
  --deep: #0c4a6e;
  --tide: #0284c7;
  --sky: #38bdf8;
  --ice: #f0f9ff;
  --foam: #e0f2fe;
  --ink: #0f172a;
  --slate: #475569;
  --muted: #64748b;
  --line: #e2e8f0;
  --ok: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --card: #ffffff;
  --radius: 16px;
  --nav-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #ecfeff 0%, #f8fafc 40%, #f1f5f9 100%);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--tide); text-decoration: none; }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }

/* Top bar */
.app-top {
  position: sticky; top: 0; z-index: 40;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem;
  background: rgba(12, 74, 110, 0.96);
  color: #fff;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(12, 74, 110, 0.25);
}
.app-top .brand { display: flex; align-items: center; gap: .65rem; font-weight: 700; }
.app-top .logo-word { color: #fff; font-weight: 800; letter-spacing: -.02em; font-size: 1.05rem; }
.app-top .logo-word span { color: #67e8f9; }
.app-top .mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: #0369a1; display: grid; place-items: center;
  font-size: .72rem; font-weight: 800; letter-spacing: .02em;
}
.app-top .actions { display: flex; gap: .5rem; align-items: center; }
.icon-btn {
  border: 0; background: rgba(255,255,255,.12); color: #fff;
  width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
  position: relative;
}
.icon-btn .badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px; border-radius: 999px;
  background: #f97316; color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; padding: 0 4px;
}

/* Layout */
.app-shell {
  max-width: 520px;
  margin: 0 auto;
  min-height: calc(100vh - var(--nav-h));
  padding: 1rem 1rem calc(5.5rem + var(--safe-b));
}
@media (min-width: 900px) {
  .app-shell { max-width: 980px; padding-bottom: 2rem; }
  .desktop-grid { display: grid; grid-template-columns: 220px 1fr; gap: 1.25rem; align-items: start; }
  .desktop-side {
    position: sticky; top: calc(var(--nav-h) + 1rem);
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: .75rem; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  }
  .desktop-side a {
    display: block; padding: .7rem .85rem; border-radius: 12px; color: var(--ink); font-weight: 600; font-size: .92rem;
  }
  .desktop-side a.active, .desktop-side a:hover { background: var(--ice); color: var(--deep); }
  .bottom-nav { display: none !important; }
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
  margin-bottom: .85rem;
  overflow-x: hidden;
  max-width: 100%;
}
.card h2, .card h3 { margin: 0 0 .35rem; color: var(--deep); }
.muted { color: var(--muted); font-size: .9rem; line-height: 1.5; }
.eyebrow {
  font-size: .72rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--tide); margin-bottom: .35rem;
}

/* Stats */
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; margin-bottom: 1rem;
}
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: .85rem .7rem; text-align: center;
}
.stat strong { display: block; font-size: 1.45rem; color: var(--deep); line-height: 1.1; }
.stat span { font-size: .75rem; color: var(--muted); font-weight: 600; }

/* Forms */
label { display: block; font-size: .85rem; font-weight: 700; color: var(--deep); margin-bottom: .35rem; }
input, select, textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 12px;
  padding: .75rem .85rem; background: #fff; margin-bottom: .85rem;
}
select { overflow: hidden; text-overflow: ellipsis; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(2, 132, 199, 0.35); border-color: var(--tide);
}
textarea { min-height: 96px; resize: vertical; }
.check {
  display: flex; gap: .65rem; align-items: flex-start;
  font-size: .9rem; font-weight: 600; margin: .4rem 0 1rem; color: var(--slate);
}
.check input { width: auto; margin: .2rem 0 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 0; border-radius: 999px; padding: .8rem 1.2rem; font-weight: 700;
  cursor: pointer; text-align: center;
}
.btn-primary { background: linear-gradient(135deg, #0284c7, #0c4a6e); color: #fff; width: 100%; }
.btn-secondary { background: var(--foam); color: var(--deep); width: 100%; border: 1px solid #bae6fd; }
.btn-ghost { background: transparent; color: var(--tide); width: auto; padding: .5rem .75rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: grid; gap: .65rem; }
@media (min-width: 480px) {
  .btn-row.two { grid-template-columns: 1fr 1fr; }
}

/* Lists */
.list-item {
  display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start;
  padding: .9rem 0; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
.list-item h4 { margin: 0 0 .2rem; font-size: 1rem; color: var(--ink); }
.list-item .meta { font-size: .8rem; color: var(--muted); }
.pill {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: .2rem .55rem; font-size: .72rem; font-weight: 700; white-space: nowrap;
}
.pill-ok { background: #d1fae5; color: #065f46; }
.pill-prog { background: #e0f2fe; color: #075985; }
.pill-wait { background: #fef3c7; color: #92400e; }
.pill-bad { background: #fee2e2; color: #991b1b; }

/* Timeline */
.timeline { border-left: 3px solid var(--foam); margin: 1rem 0 0 0.5rem; padding-left: 1rem; }
.timeline .step { position: relative; padding: 0 0 1rem; }
.timeline .step::before {
  content: ""; position: absolute; left: -1.28rem; top: .25rem;
  width: 10px; height: 10px; border-radius: 50%; background: var(--tide);
  box-shadow: 0 0 0 3px var(--foam);
}
.timeline .step.done::before { background: var(--ok); }
.timeline .step strong { display: block; font-size: .92rem; }
.timeline .step span { font-size: .8rem; color: var(--muted); }

/* Auth screens */
.auth-wrap {
  min-height: calc(100vh - var(--nav-h));
  display: grid; place-items: center; padding: 1.25rem;
}
.auth-card { width: min(420px, 100%); }
.auth-card .logo-lg {
  width: 64px; height: 64px; border-radius: 18px; background: var(--deep);
  color: #fff; display: grid; place-items: center; font-weight: 800; margin: 0 auto 1rem;
}
.auth-card h1 { text-align: center; font-size: 1.45rem; margin: 0 0 .35rem; color: var(--deep); }
.auth-card .lead { text-align: center; margin: 0 0 1.25rem; }
.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: .35rem;
  background: var(--ice); padding: .3rem; border-radius: 12px; margin-bottom: 1rem;
}
.tabs button {
  border: 0; background: transparent; border-radius: 10px; padding: .6rem;
  font-weight: 700; color: var(--muted); cursor: pointer;
}
.tabs button.active { background: #fff; color: var(--deep); box-shadow: 0 2px 8px rgba(15,23,42,.06); }

.error-box {
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
  border-radius: 12px; padding: .75rem .9rem; margin-bottom: .85rem; font-size: .9rem;
}
.success-box {
  background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0;
  border-radius: 12px; padding: .75rem .9rem; margin-bottom: .85rem; font-size: .9rem;
}

/* Bottom nav (mobile) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255,255,255,.96);
  border-top: 1px solid var(--line);
  padding: .35rem .25rem calc(.35rem + var(--safe-b));
  backdrop-filter: blur(12px);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  padding: .4rem .2rem; color: var(--muted); font-size: .68rem; font-weight: 700;
}
.bottom-nav a.active { color: var(--deep); }
.bottom-nav svg { width: 22px; height: 22px; }

/* COA detail */
.coa-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .65rem .85rem;
}
.coa-grid div strong { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.coa-grid div span { font-size: .92rem; font-weight: 600; color: var(--ink); }

.install-banner {
  background: linear-gradient(135deg, #0c4a6e, #0369a1);
  color: #fff; border-radius: var(--radius); padding: 1rem;
  margin-bottom: 1rem; display: flex; gap: .85rem; align-items: center; justify-content: space-between;
}
.install-banner p { margin: 0; font-size: .9rem; line-height: 1.45; }
.install-banner .btn { width: auto; background: #fff; color: var(--deep); padding: .6rem 1rem; font-size: .85rem; }

.empty {
  text-align: center; padding: 2rem 1rem; color: var(--muted);
}
.empty strong { display: block; color: var(--deep); margin-bottom: .35rem; font-size: 1.05rem; }
