/* Layout and components. Font sizes in rem (follow phone text size), spacing in px. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg-2); min-height: 100vh;
  background-image: radial-gradient(1200px 600px at 110% -10%, rgba(37, 99, 235, 0.13), transparent 60%),
    radial-gradient(900px 500px at -20% 30%, rgba(11, 37, 69, 0.10), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed; line-height: 1.35; overflow-wrap: break-word;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: 0.8125rem; }
.tiny { font-size: 0.72rem; }
.b { font-weight: 650; }
.right { text-align: right; }
.nowrap { white-space: nowrap; overflow-wrap: normal; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row.top { align-items: flex-start; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.between.wrap, .linefoot { flex-wrap: wrap; justify-content: space-between; row-gap: 8px; }
.tabbar a > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.mt { margin-top: 12px; } .mt2 { margin-top: 20px; } .mb { margin-bottom: 12px; }
.hide { display: none !important; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20; color: #fff;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 12px; box-shadow: 0 4px 18px rgba(11, 37, 69, 0.25);
}
.topbar .row { min-height: 40px; }
.topbar h1 { font-size: 1.125rem; font-weight: 650; }
.topbar .sub { font-size: 0.78rem; opacity: 0.8; }
.iconbtn {
  border: 0; background: rgba(255, 255, 255, 0.12); color: inherit; width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; position: relative; flex: 0 0 auto; cursor: pointer;
}
.iconbtn.plain { background: transparent; }
.iconbtn .dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--red); color: #fff; font-size: 0.62rem; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.logo { font-weight: 900; letter-spacing: 0.08em; font-size: 1.5rem; line-height: 1; font-style: italic; }
.logo small { display: block; font-size: 0.42rem; letter-spacing: 0.32em; font-style: normal; font-weight: 600; opacity: 0.85; margin-top: 3px; }
.content { padding: 14px 14px calc(env(safe-area-inset-bottom, 0px) + 92px); max-width: 1240px; margin: 0 auto; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around;
  background: var(--glass-strong); backdrop-filter: blur(20px) saturate(170%); -webkit-backdrop-filter: blur(20px) saturate(170%);
  border-top: 1px solid var(--line); padding: 6px 4px calc(env(safe-area-inset-bottom, 0px) + 6px);
}
.tabbar a { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: clamp(10px, 0.68rem, 12.5px); white-space: nowrap; padding: 4px 2px; border-radius: 10px; text-align: center; line-height: 1.15; }
.tabbar a.on { color: var(--navy); font-weight: 650; }
:root[data-theme="dark"] .tabbar a.on { color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tabbar a.on { color: #fff; } }
.side { display: none; }
@media (min-width: 960px) {
  .shell.wide { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
  .shell.wide .side {
    display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 12px;
    background: linear-gradient(180deg, var(--navy) 0%, #0a1d38 100%); color: #dbe6f5;
  }
  .side a { color: #c6d3e6; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; font-size: 0.9rem; }
  .side a.on, .side a:hover { background: rgba(255, 255, 255, 0.10); color: #fff; }
  .side .group { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.55; margin: 14px 12px 4px; }
  .shell.wide .tabbar { display: none; }
  .shell.wide .content { padding-bottom: 40px; }
  .shell.wide .topbar .menu-only { display: none; }
}

/* ---------- cards ---------- */
.card {
  background: var(--glass); backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--glass-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; min-width: 0;
}
.card.pad0 { padding: 0; overflow: hidden; }
.card h3 { font-size: 1rem; font-weight: 650; }
.card .h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card.hero { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-3) 100%); color: #fff; border: 0; }
.card.hero .muted { color: rgba(255, 255, 255, 0.75); }
.card.promo { background: linear-gradient(135deg, #fff1ee, #ffe2df); border-color: #ffd0cb; color: #6b1d1d; }
:root[data-theme="dark"] .card.promo { background: linear-gradient(135deg, #3a1a1d, #2a1416); border-color: #5a2a2e; color: #ffd6d2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .card.promo { background: linear-gradient(135deg, #3a1a1d, #2a1416); border-color: #5a2a2e; color: #ffd6d2; } }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .v { font-size: 1.3rem; font-weight: 750; letter-spacing: -0.01em; }
.stat .l { font-size: 0.75rem; color: var(--muted); }
.card.hero .stat .l { color: rgba(255, 255, 255, 0.75); }
.tap { cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.tap:active { transform: scale(0.985); }

/* ---------- tiles (home) ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 8px; padding: 14px 6px; text-align: center; color: var(--ink); font-size: 0.78rem; font-weight: 600; line-height: 1.2; }
.tile .ic { width: 46px; height: 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.c-blue { background: var(--blue-bg); color: var(--blue); } .c-green { background: var(--green-bg); color: var(--green); }
.c-red { background: var(--red-bg); color: var(--red); } .c-orange { background: var(--orange-bg); color: var(--orange); }
.c-purple { background: var(--purple-bg); color: var(--purple); } .c-grey { background: var(--grey-bg); color: var(--ink-2); }

/* ---------- chips ---------- */
.chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 650; white-space: nowrap; line-height: 1.3; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.chip.green { background: var(--green-bg); color: var(--green); } .chip.red { background: var(--red-bg); color: var(--red); }
.chip.orange { background: var(--orange-bg); color: var(--orange); } .chip.blue { background: var(--blue-bg); color: var(--blue); }
.chip.purple { background: var(--purple-bg); color: var(--purple); } .chip.grey { background: var(--grey-bg); color: var(--ink-2); }
.chip.x { cursor: pointer; padding-right: 6px; }
.pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill { border: 1px solid var(--line); background: var(--glass); padding: 7px 12px; border-radius: 999px; font-size: 0.8rem; white-space: nowrap; cursor: pointer; color: var(--ink-2); }
.pill.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.seg { display: flex; background: var(--grey-bg); padding: 4px; border-radius: 12px; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 0 auto; white-space: nowrap; border: 0; background: transparent; padding: 8px 6px; border-radius: 9px; font-size: 0.8rem; color: var(--ink-2); cursor: pointer; min-width: 0; line-height: 1.2; }
.seg button.on { background: var(--glass-strong); color: var(--ink); font-weight: 650; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08); }

/* ---------- buttons & inputs ---------- */
.btn {
  border: 0; border-radius: 12px; padding: 11px 16px; min-height: 44px; font-weight: 650; font-size: 0.92rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--navy); color: #fff; text-align: center; line-height: 1.2;
}
.btn.block { width: 100%; }
.btn.green { background: var(--green); } .btn.red { background: var(--red); } .btn.blue { background: var(--blue); } .btn.orange { background: var(--orange); }
.btn.ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--line); }
:root[data-theme="dark"] .btn.ghost { color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.ghost { color: var(--ink); } }
.btn.sm { min-height: 36px; padding: 7px 12px; font-size: 0.8rem; border-radius: 10px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns > .btn { flex: 1 1 140px; }
label.f, div.f { display: flex; flex-direction: column; gap: 5px; font-size: 0.78rem; color: var(--muted); font-weight: 600; min-width: 0; }
.in, select.in, textarea.in {
  width: 100%; border: 1.5px solid var(--line); background: var(--glass-strong); border-radius: 12px; padding: 10px 12px; min-height: 44px;
  font-size: 0.95rem; color: var(--ink); outline: none; font-weight: 500;
}
.in:focus { border-color: var(--blue); }
textarea.in { min-height: 84px; resize: vertical; }
.search { position: relative; }
.search .in { padding-left: 38px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--navy); flex: 0 0 auto; }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--glass-strong); flex: 0 0 auto; }
.stepper button { width: 36px; height: 38px; border: 0; background: transparent; font-size: 1.1rem; cursor: pointer; color: var(--ink); }
.stepper input { width: calc(5ch + 18px); font-variant-numeric: tabular-nums; border: 0; text-align: center; background: transparent; font-weight: 650; height: 38px; outline: none; }
.radio { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1.5px solid var(--line); border-radius: 14px; cursor: pointer; background: var(--glass-strong); }
.radio.on { border-color: var(--blue); background: var(--blue-bg); }
.radio.off { opacity: 0.55; }
.upload { border: 1.5px dashed var(--line); border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 4px; min-height: 84px; color: var(--blue); font-size: 0.8rem; cursor: pointer; position: relative; padding: 8px; text-align: center; }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img, .thumbs .file { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: var(--grey-bg); display: flex; align-items: center; justify-content: center; font-size: 0.7rem; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.li { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); min-width: 0; }
.li:last-child { border-bottom: 0; }
.li .t { font-weight: 650; font-size: 0.92rem; }
.li .s { font-size: 0.78rem; color: var(--muted); }
.avatar { width: 40px; height: 40px; border-radius: 12px; background: var(--blue-bg); color: var(--blue); display: flex; align-items: center; justify-content: center; font-weight: 750; font-size: 0.85rem; flex: 0 0 auto; }
details.group { border-bottom: 1px solid var(--line); }
details.group > summary { list-style: none; cursor: pointer; padding: 10px 14px; display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 0.85rem; background: var(--grey-bg); }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary .caret { transition: transform 0.15s; }
details.group[open] > summary .caret { transform: rotate(90deg); }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.tbl th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap; user-select: none; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: rgba(37, 99, 235, 0.04); }
.tablewrap { overflow-x: auto; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 0.9rem; }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 8px 12px; font-size: 0.88rem; }
.kv > :nth-child(odd) { color: var(--muted); }
.kv > :nth-child(even) { font-weight: 600; text-align: right; }
.sum { display: flex; justify-content: space-between; gap: 10px; font-size: 0.9rem; padding: 4px 0; }
.sum.total { font-size: 1.05rem; font-weight: 750; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }

/* ---------- filters ---------- */
.filters { display: flex; flex-direction: column; gap: 10px; }
.fbar { display: flex; gap: 8px; align-items: center; }
.fbar .search { flex: 1 1 auto; min-width: 0; }
.datebox { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.count { font-size: 0.78rem; color: var(--muted); }

/* ---------- timeline / progress ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline .step { position: relative; padding-bottom: 16px; }
.timeline .step::before { content: ""; position: absolute; left: -19px; top: 18px; bottom: -2px; width: 2px; background: var(--line); }
.timeline .step:last-child::before { display: none; }
.timeline .dot { position: absolute; left: -26px; top: 0; width: 16px; height: 16px; border-radius: 50%; background: var(--grey-bg); border: 2px solid var(--muted); }
.timeline .step.done .dot { background: var(--green); border-color: var(--green); }
.timeline .step.now .dot { background: var(--orange); border-color: var(--orange); }
.track { display: flex; justify-content: space-between; gap: 2px; }
.track .s { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: clamp(9.5px, 0.66rem, 11.5px); padding: 0 1px; text-align: center; color: var(--muted); position: relative; min-width: 0; line-height: 1.15; }
.track .s::before { content: ""; position: absolute; top: 9px; left: -50%; width: 100%; height: 2px; background: var(--line); z-index: 0; }
.track .s:first-child::before { display: none; }
.track .s.done::before { background: var(--green); }
.track .s i { width: 20px; height: 20px; border-radius: 50%; background: var(--grey-bg); border: 2px solid var(--line); z-index: 1; display: flex; align-items: center; justify-content: center; color: #fff; }
.track .s.done i { background: var(--green); border-color: var(--green); }
.track .s.done { color: var(--ink); font-weight: 600; }
.bar { height: 8px; background: var(--grey-bg); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #34c77b); border-radius: 99px; }
.bar.orange > i { background: linear-gradient(90deg, var(--orange), #f5b54a); }
.bar.red > i { background: linear-gradient(90deg, var(--red), #ef7b7b); }
.bar.blue > i { background: linear-gradient(90deg, var(--blue), #6f9cff); }
.ring { position: relative; width: 112px; height: 112px; flex: 0 0 auto; }
.ring svg { transform: rotate(-90deg); }
.ring .c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 14px; }
.ring .c b { font-size: 0.95rem; } .ring .c span { font-size: 0.66rem; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 14px; }
.bars .b { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; min-width: 0; }
.bars .b i { width: 100%; max-width: 26px; background: linear-gradient(180deg, var(--navy-3), var(--navy)); border-radius: 6px 6px 3px 3px; min-height: 2px; }
.bars .b span { font-size: 0.62rem; color: var(--muted); }

/* ---------- sheet / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5, 15, 30, 0.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade 0.15s ease; }
.sheet { background: var(--glass-strong); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 18px); animation: up 0.2s ease; }
.sheet h2 { font-size: 1.1rem; margin-bottom: 12px; }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 22px; } }
.toast { position: fixed; left: 16px; right: 16px; margin: 0 auto; width: fit-content; max-width: min(520px, calc(100% - 32px)); top: calc(env(safe-area-inset-top, 0px) + 70px); z-index: 60; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 0.9rem; font-weight: 600; line-height: 1.35; text-align: center; box-shadow: 0 10px 30px rgba(5, 15, 30, 0.28); border: 1px solid rgba(255, 255, 255, 0.14); animation: drop 0.2s ease; }
@keyframes drop { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.err { background: var(--red); }
@keyframes up { from { transform: translate(var(--tx, 0), 24px); opacity: 0; } to { transform: translate(var(--tx, 0), 0); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.spin { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--navy-3); border-radius: 50%; animation: rot 0.8s linear infinite; margin: 30px auto; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 24px 18px calc(env(safe-area-inset-bottom) + 24px);
  background: radial-gradient(800px 500px at 20% 0%, rgba(80, 110, 160, 0.35), transparent 60%), linear-gradient(160deg, #0a1322 0%, #10233f 55%, #060c16 100%); color: #fff; }
.login .logo { font-size: 3rem; text-align: center; }
.login .logo small { font-size: 0.7rem; margin-top: 6px; }
.login .box { width: 100%; max-width: 380px; margin-top: 28px; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-radius: 22px; padding: 20px; }
.login .in { background: rgba(255, 255, 255, 0.95); color: #0f1b2d; border-color: transparent; }
.login label.f { color: rgba(255, 255, 255, 0.8); }
.login .btn { background: #fff; color: var(--navy); }
.prod { width: 64px; height: 64px; border-radius: 14px; flex: 0 0 auto; display: flex; align-items: flex-end; justify-content: center; overflow: hidden;
  background: linear-gradient(160deg, #1b1f27, #3b4352); position: relative; }
.prod::before { content: ""; position: absolute; top: 8px; left: 14px; right: 14px; bottom: 8px; border-radius: 6px 6px 8px 8px; background: linear-gradient(90deg, #d9dde3, #fff 45%, #c8ccd3); }
.prod::after { content: attr(data-t); position: absolute; top: 24px; left: 14px; right: 14px; height: 18px; background: #0b2545; color: #fff; font-size: 0.5rem; font-weight: 800; letter-spacing: 0.08em; display: flex; align-items: center; justify-content: center; font-style: italic; }
.prod.light { background: linear-gradient(160deg, #e7ebf1, #cfd6df); }
img.prodimg { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; flex: 0 0 auto; }
.row.wrap > .chip { white-space: normal; overflow: visible; }
/* phone keyboard open: hide the tab bar so it does not ride up and cover boxes */
body.typing .tabbar { display: none; }
body.typing .content { padding-bottom: 24px; }

/* search picker drop-down: solid glass so text behind never shows through */
.drop { background: #fff; box-shadow: 0 12px 32px rgba(5, 15, 30, 0.22); }
:root[data-theme="dark"] .drop { background: #17283f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .drop { background: #17283f; } }
.nowrap { white-space: nowrap; }
