:root {
  --n: #1b2f4e; --n2: #2c4a75; --nl: #e9eef6; --gold: #c9a227; --goldl: #fbf3d9; --bg: #f5f3ee; --card: #fff; --ink: #1c2433; --mut: #6b7280; --line: #e6e2d8;
  --red: #c0392b; --redl: #fdecea; --amber: #b9770e; --green: #1e8449; --greenl: #e8f6ee; --wa: #25d366;
  --r: 14px; --sh: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(27,47,78,.07);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.3; }
h2 { font-size: 1.3rem; } h3 { font-size: 1.02rem; }
small, .small { font-size: .8em; }
.muted { color: var(--mut); } .red { color: var(--red) !important; } .green { color: var(--green); }
.loading { font-size: 3rem; text-align: center; padding: 30vh 0; }

/* layout */
#side { display: none; }
#body { padding-bottom: 88px; }
#top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; background: var(--n); color: #fff; }
#top:empty { display: none; }
.shopname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topsearch { background: rgba(255,255,255,.12); border: 0; color: #fff; border-radius: 999px; padding: 7px 12px; cursor: pointer; white-space: nowrap; flex: none; }
#main { padding: 14px; max-width: 1200px; margin: 0 auto; overflow-x: clip; }
#bottom { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; align-items: flex-end; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#bottom:empty { display: none; }
#bottom a { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 9px; font-size: .72rem; color: var(--mut); }
#bottom a i { font-style: normal; font-size: 1.3rem; filter: grayscale(1); opacity: .7; }
#bottom a.on { color: var(--n); font-weight: 700; } #bottom a.on i { filter: none; opacity: 1; }
#bottom a em { position: absolute; top: 6px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--red); }
#fab { width: 60px; height: 60px; flex: none; margin: -22px 4px 8px; border-radius: 50%; border: 4px solid var(--bg); background: var(--gold); color: var(--n); font-size: 2rem; font-weight: 700; line-height: 1; cursor: pointer; box-shadow: 0 4px 14px rgba(201,162,39,.5); }
body.bare #body { padding-bottom: 0; }
@media (min-width: 900px) {
  #app { display: grid; grid-template-columns: 230px 1fr; }
  body.bare #app { display: block; }
  #side { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; background: var(--n); color: #dfe6f1; padding: 14px 10px; overflow-y: auto; }
  #side:empty { display: none; }
  #side .brand { font-size: 1.15rem; padding: 6px 10px 14px; color: #fff; }
  .side-add { margin: 0 0 12px; min-height: 48px !important; font-size: 1rem !important; }
  #side a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; }
  #side a i { font-style: normal; width: 22px; text-align: center; }
  #side a em { margin-inline-start: auto; background: var(--red); color: #fff; font-style: normal; font-size: .72rem; font-weight: 800; border-radius: 999px; padding: 1px 7px; }
  #side a:hover { background: rgba(255,255,255,.08); }
  #side a.on { background: #fff; color: var(--n); font-weight: 700; }
  #side .lock { margin-top: auto; opacity: .85; }
  #bottom { display: none !important; }
  #body { padding-bottom: 0; }
  #top { background: transparent; color: var(--ink); border-bottom: 1px solid var(--line); position: static; padding: 12px 26px; }
  .topsearch { background: #fff; color: var(--mut); border: 1.5px solid var(--line); min-width: 260px; text-align: start; }
  #main { padding: 22px 26px; }
}

/* basics */
.card { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: var(--sh); margin-bottom: 14px; }
.card.soft { background: var(--nl); box-shadow: none; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; } .card-h h3 { margin: 0; }
.row { display: flex; align-items: flex-end; } .row.wrap { flex-wrap: wrap; } .gap { gap: 10px; } .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); } .grid2 > .card { margin: 0; }
@media (min-width: 760px) { .grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .grid2 .wide { grid-column: 1 / -1; } }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.pagehead h2 { margin: 2px 0; } .pagehead > div { min-width: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--n); border-color: var(--n); color: #fff; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--n); font-weight: 800; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger.ghost { background: #fff; color: var(--red); border-color: #f2c4be; }
.btn.ghost { background: transparent; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #073b1c; }
.btn.big { min-height: 54px; font-size: 1.05rem; width: 100%; }
.btn.sm { min-height: 36px; padding: 5px 12px; font-size: .88rem; border-radius: 10px; }
.linkbtn { background: none; border: 0; color: var(--n2); text-decoration: underline; cursor: pointer; padding: 6px; font-weight: 600; }

.f { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; flex: 1; min-width: 0; }
.f > span { font-size: .82rem; color: var(--mut); font-weight: 700; }
input, select, textarea { width: 100%; min-height: 46px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 11px; background: #fff; outline: none; }
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { border-color: var(--n2); box-shadow: 0 0 0 3px rgba(44,74,117,.15); }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0 12px; cursor: pointer; }
.check input { width: 20px; min-height: 20px; height: 20px; accent-color: var(--n); flex: none; }
.hint { font-size: .82rem; color: var(--mut); margin: -2px 0 12px; }
.search { margin-bottom: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chips button { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; white-space: nowrap; cursor: pointer; font-weight: 600; font-size: .9rem; }
.chips button.on { background: var(--n); border-color: var(--n); color: #fff; }
.li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 4px; border: 0; border-bottom: 1px solid var(--line); width: 100%; background: none; text-align: start; }
.li:last-child { border-bottom: 0; } .li.link { cursor: pointer; } .li.link:hover { background: #faf9f5; } .li.big { padding: 15px 6px; }
.li > span, .li > a { min-width: 0; } .li small { display: inline; }
.li .amt { text-align: end; white-space: nowrap; font-weight: 700; } .li .amt small { display: block; }
.empty { text-align: center; color: var(--mut); padding: 22px 10px; } .empty.big { font-size: 1.15rem; padding: 60px 10px; } .empty .btn { margin-top: 10px; }
.pill { display: inline-block; font-size: .74rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--nl); color: var(--n2); white-space: nowrap; }
.pill.red { background: var(--redl); color: var(--red); } .pill.green { background: var(--greenl); color: var(--green); } .pill.amber { background: var(--goldl); color: var(--amber); } .pill.grey { background: #eee; color: #777; }
.alert { display: block; padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 600; }

/* today */
.hello { margin: 2px 0 12px; } .hello h1 { font-size: 1.35rem; margin: 0; }
.uptodate { background: var(--greenl); color: var(--green); font-weight: 700; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.card.attn { border: 2px solid #f5b7b1; background: #fffafa; }
.weekstrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 14px; }
.wday { background: #fff; border-radius: 12px; padding: 8px 2px; text-align: center; box-shadow: var(--sh); display: flex; flex-direction: column; align-items: center; gap: 1px; }
.wday small { font-size: .68rem; color: var(--mut); } .wday b { font-size: 1.1rem; }
.wday em { font-style: normal; font-size: .72rem; font-weight: 800; background: var(--gold); color: var(--n); border-radius: 999px; min-width: 20px; padding: 0 5px; }
.wday em.zero { background: transparent; color: #ccc; }
.wday.on { background: var(--n); color: #fff; } .wday.on small { color: #c9d4e6; }
.cgroup { font-size: .8rem; font-weight: 800; color: var(--n2); margin: 12px 0 2px; text-transform: uppercase; letter-spacing: .02em; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } .stats.three { grid-template-columns: repeat(3, 1fr); } }
.stat { background: #fff; border-radius: var(--r); padding: 12px 14px; box-shadow: var(--sh); display: flex; flex-direction: column; gap: 2px; border-inline-start: 4px solid var(--n2); min-width: 0; }
.stat span { font-size: .78rem; color: var(--mut); font-weight: 700; } .stat b { font-size: 1.2rem; } .stat small { color: var(--mut); }
.stat.warn { border-color: var(--gold); } .stat.good { border-color: var(--green); }
.links { display: flex; flex-wrap: wrap; gap: 8px; } .links .btn { white-space: normal; text-align: center; flex: 1 1 200px; }

/* hearing row */
.hrow { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.hrow:last-child { border-bottom: 0; }
.hmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hmain b { line-height: 1.25; } .hmain small { color: var(--mut); overflow: hidden; text-overflow: ellipsis; }
.hmain .pill { align-self: flex-start; margin-top: 3px; }
.hcourt { font-size: .74rem; font-weight: 800; color: var(--n2); text-transform: uppercase; letter-spacing: .02em; }
.btn.upd { background: var(--gold); border-color: var(--gold); color: var(--n); font-weight: 800; flex: none; }
.hrow.done { opacity: .75; } .hdone { color: var(--green); font-weight: 700; font-size: .85rem; flex: none; max-width: 40%; text-align: end; }

/* sheet */
#sheet-wrap { position: fixed; inset: 0; z-index: 50; }
#sheet-bg { position: absolute; inset: 0; background: rgba(15,23,40,.5); opacity: 0; transition: opacity .18s; }
#sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; background: #fff; border-radius: 20px 20px 0 0; padding: 20px 16px calc(18px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .2s ease-out; }
#sheet-wrap.open #sheet-bg { opacity: 1; } #sheet-wrap.open #sheet { transform: none; }
@media (min-width: 700px) {
  #sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 560px; border-radius: 20px; transform: translate(-50%, -45%); opacity: 0; transition: .18s; }
  #sheet-wrap.open #sheet { transform: translate(-50%, -50%); opacity: 1; } #sheet.small { width: 420px; }
}
.sheet-x { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: #f0ede6; cursor: pointer; }
#sheet h3 { padding-right: 40px; }
.uhead { margin-bottom: 10px; } .uhead h3 { margin: 2px 0; }
#u-nextbox.dim { opacity: .35; pointer-events: none; }
.nextlbl { font-weight: 700; color: var(--n2); font-size: .9rem; align-self: center; }
#u-date { margin-bottom: 10px; }
.notebox { position: relative; } .notebox textarea { padding-right: 52px; }
.mic { position: absolute; right: 6px; top: 6px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--nl); cursor: pointer; font-size: 1.1rem; }
.mic.on { background: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.addgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.addbtn { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: start; padding: 16px 14px; border-radius: 16px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; min-height: 120px; }
.addbtn i { font-style: normal; font-size: 1.8rem; } .addbtn small { color: var(--mut); }
.addbtn:hover { border-color: var(--n2); } .addbtn:first-child { background: var(--goldl); border-color: #ecd68a; }
.plist { max-height: 55vh; overflow-y: auto; }

/* case page */
.nextbox { border-radius: 16px; padding: 16px; background: var(--nl); margin-bottom: 12px; display: flex; flex-direction: column; gap: 2px; }
.nextbox > span { color: var(--mut); font-weight: 700; font-size: .85rem; } .nextbox > b { font-size: 1.45rem; color: var(--n); } .nextbox > small { color: var(--mut); margin-bottom: 8px; }
.nextbox .btn { margin-top: 8px; }
.nextbox.late { background: var(--redl); } .nextbox.late > b { color: var(--red); }
.nextbox.today { background: var(--goldl); } .nextbox.closed { background: #eee; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.info { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 10px 0 0; }
.info dt { color: var(--mut); font-size: .85rem; } .info dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.feebar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.feebar div { display: flex; flex-direction: column; } .feebar small { color: var(--mut); }
.progress { height: 8px; background: #eee; border-radius: 99px; overflow: hidden; margin-bottom: 8px; } .progress i { display: block; height: 100%; background: var(--green); }
.timeline { position: relative; }
.tl { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); } .tl:last-child { border-bottom: 0; }
.tl-d { flex: none; width: 54px; text-align: center; background: var(--nl); border-radius: 10px; padding: 6px 2px; align-self: flex-start; display: flex; flex-direction: column; }
.tl-d small { color: var(--mut); font-size: .7rem; }
.tl-b { min-width: 0; } .tl-b p { margin: 4px 0; overflow-wrap: anywhere; }

/* calendar */
.cal-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; } .cal-h b { font-size: 1.1rem; }
.cal-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.dow { text-align: center; font-size: .72rem; color: var(--mut); font-weight: 700; padding: 4px 0; }
.cd { aspect-ratio: 1 / .9; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: #faf9f5; position: relative; }
.cd b { font-size: .95rem; } .cd.sun b { color: var(--red); }
.cd em { font-style: normal; font-size: .68rem; font-weight: 800; background: var(--gold); color: var(--n); border-radius: 99px; min-width: 18px; text-align: center; padding: 0 4px; }
.cd em.late { background: var(--red); color: #fff; }
.cd.tdy { box-shadow: inset 0 0 0 2px var(--gold); } .cd.sel { background: var(--n); } .cd.sel b { color: #fff; }
.filt { align-items: center; margin-bottom: 8px; } .filt .chips { flex: 1 1 100%; margin: 0; } .filt select { flex: 1 1 100%; min-height: 42px; }
@media (min-width: 760px) { .filt .chips { flex: 1; } .filt select { flex: 0 0 220px; } }

/* setup / login */
.setup { max-width: 440px; margin: 6vh auto; padding: 26px 22px; text-align: center; }
.setup .f { text-align: start; } .setup h1 { color: var(--n); } .setup .btn { margin-top: 6px; width: 100%; }
.logo { font-size: 3.2rem; }
.people { display: grid; gap: 10px; }
.person { padding: 16px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.pindots { display: flex; justify-content: center; gap: 12px; margin: 14px 0; }
.pindots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--n); } .pindots i.on { background: var(--n); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 280px; margin: 0 auto 10px; }
.pinpad button { height: 62px; border-radius: 16px; border: 1.5px solid var(--line); background: #fff; font-size: 1.5rem; font-weight: 700; cursor: pointer; }

/* prototype */
.proto-badge { background: var(--gold); color: var(--n); border: 0; border-radius: 999px; padding: 3px 10px; font-weight: 800; font-size: .72rem; margin-right: 8px; cursor: pointer; vertical-align: middle; }
.proto-note { background: var(--goldl); color: #7a5b00; border: 1px solid #ecd68a; border-radius: 12px; padding: 10px; margin: 0 0 14px; font-weight: 600; font-size: .9rem; }
.alert.proto { width: 100%; text-align: start; background: var(--goldl); color: #7a5b00; border: 1px dashed #d9b84a; cursor: pointer; font-size: .9rem; }
.lock-sheet { text-align: center; } .lock-sheet h3 { padding: 0 !important; } .lock-ic { font-size: 2.6rem; }
.lock-list { text-align: start; } .lock-list ul { list-style: none; padding: 0; margin: 8px 0 0; } .lock-list li { padding: 4px 0; }
.lock-contact { font-weight: 700; color: var(--n); } .lock-sheet .btn { width: 100%; margin-top: 8px; }

/* toast / print */
#toast { position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 90vw; text-align: center; font-weight: 600; }
#toast.show { opacity: 1; transform: translate(-50%, 0); } #toast.err { background: var(--red); }
#print-area { display: none; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; color: #000; } body { background: #fff; }
  .pdiary { position: relative; font-size: 11px; }
  .p-h { display: flex; justify-content: space-between; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 8px; font-size: 14px; }
  .pdiary table { width: 100%; border-collapse: collapse; } .pdiary th, .pdiary td { border: 1px solid #555; padding: 5px; text-align: left; vertical-align: top; }
  .pdiary td.blank { width: 22%; } .pdiary th { background: #eee; }
  .p-demo { position: fixed; top: 40%; left: 25%; font-size: 120px; font-weight: 900; color: rgba(0,0,0,.08); transform: rotate(-20deg); }
  .p-demo-foot { text-align: center; font-weight: 800; margin-top: 10px; }
}
@media (max-width: 520px) { .topsearch span { display: none; } .topsearch { padding: 7px 11px; } }
.li > a { flex: 1; } .li > a b { overflow-wrap: anywhere; } .li > .row { flex: none; align-items: center; }
.li > a small { display: block; }
