* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #0f151c; font-family: Roboto, "Segoe UI", Arial, sans-serif; color: #17212b; }
body { display: flex; justify-content: center; user-select: none; -webkit-user-select: none; }
#device { width: 100%; max-width: 520px; height: 100%; display: flex; flex-direction: column; background: #e9edf1; }

#statusbar { display: flex; align-items: center; justify-content: space-between; height: 28px; padding: 0 12px;
  background: #1d2733; color: #c9d3dd; font-size: 13px; font-variant-numeric: tabular-nums; }
#sb-device { opacity: .75; }
.sb-right { display: flex; align-items: center; gap: 8px; }
#sb-link { width: 8px; height: 8px; border-radius: 50%; background: #c0392b; }
#sb-link.on { background: #4cb86b; }
.batt { width: 22px; height: 11px; border: 1.5px solid #c9d3dd; border-radius: 2px; position: relative; padding: 1px; }
.batt:after { content: ""; position: absolute; right: -4px; top: 2px; width: 2px; height: 4px; background: #c9d3dd; }
.batt i { display: block; height: 100%; width: 78%; background: #c9d3dd; }

#titlebar { background: #2b3a4a; color: #fff; padding: 12px 16px; font-size: 19px; font-weight: 600; letter-spacing: .3px;
  border-bottom: 3px solid #3f8fd2; }
#screen { flex: 1; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
#softkeys { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #d5dce3; border-top: 1px solid #c2cbd4; }
#softkeys:empty { display: none; }
#softkeys button { flex: 1; }

button { font: inherit; border: 0; border-radius: 8px; padding: 14px 10px; font-size: 17px; font-weight: 600; cursor: pointer;
  background: #fff; color: #1d2733; box-shadow: 0 1px 0 #b5c0ca, 0 1px 3px rgba(0,0,0,.08); }
button:active { transform: translateY(1px); background: #f1f4f7; }
button.primary { background: #2f7fc1; color: #fff; box-shadow: 0 1px 0 #1f5d90; }
button.primary:active { background: #286fa9; }
button:disabled { opacity: .45; }

.menu { display: flex; flex-direction: column; gap: 12px; }
.menu button { text-align: left; padding: 18px 16px; font-size: 19px; display: flex; align-items: center; gap: 14px; }
.menu .n { display: inline-flex; width: 30px; height: 30px; border-radius: 6px; background: #2b3a4a; color: #fff;
  align-items: center; justify-content: center; font-size: 16px; flex: none; }
.menu small { display: block; font-weight: 400; font-size: 13px; color: #5c6b79; margin-top: 2px; }

.prompt { font-size: 18px; font-weight: 600; margin: 4px 0 12px; }
.hint { color: #5c6b79; font-size: 14px; margin: 8px 0 0; }
.entry { width: 100%; font-size: 28px; padding: 14px; border: 2px solid #9fb0bf; border-radius: 8px; background: #fff;
  font-family: "Roboto Mono", Consolas, monospace; letter-spacing: 1px; user-select: text; -webkit-user-select: text; }
.entry:focus { outline: none; border-color: #2f7fc1; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.keypad button { font-size: 24px; padding: 14px 0; }

.list { display: flex; flex-direction: column; gap: 10px; }
.list button { text-align: left; padding: 16px; }
.list small { display: block; font-weight: 400; color: #5c6b79; font-size: 13px; margin-top: 3px; }

.panel { background: #fff; border-radius: 10px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.center { text-align: center; }

.cart { width: 92px; height: 140px; margin: 10px auto 18px; border-radius: 8px; background: linear-gradient(#f6f8fa, #d9e0e6);
  border: 2px solid #8796a5; position: relative; animation: slide 1.6s ease-in-out infinite; }
.cart:before { content: ""; position: absolute; left: 14px; right: 14px; top: 18px; height: 46px; border-radius: 4px; background: #c8a45a; opacity: .7; }
.cart:after { content: ""; position: absolute; left: 36px; bottom: 16px; width: 20px; height: 20px; border-radius: 50%; border: 3px solid #8796a5; }
@keyframes slide { 0%,100% { transform: translateY(0); } 50% { transform: translateY(14px); } }

.bar { height: 22px; border-radius: 11px; background: #cfd8e0; overflow: hidden; margin: 18px 0 10px; }
.bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(45deg, #2f7fc1 0 12px, #3a8ed4 12px 24px); transition: width .25s linear; }
.big { font-size: 26px; font-weight: 700; }
.mono { font-family: "Roboto Mono", Consolas, monospace; font-variant-numeric: tabular-nums; }
.warn { color: #8a5a00; font-weight: 600; }

.hdr { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 14px; margin-bottom: 12px; }
.hdr b { color: #5c6b79; font-weight: 500; }
table.res { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
table.res td { padding: 10px 8px; border-bottom: 1px solid #e3e8ed; vertical-align: middle; }
table.res tr:last-child td { border-bottom: 0; }
.r-name { font-weight: 600; font-size: 17px; }
.r-val { text-align: right; font-size: 22px; font-weight: 700; white-space: nowrap; }
.r-flag { width: 22px; text-align: center; font-size: 18px; font-weight: 700; color: #b03a2e; }
.r-unit { color: #5c6b79; font-size: 13px; white-space: nowrap; }
.r-ref { color: #8592a0; font-size: 12px; display: block; font-weight: 400; }
tr.crit td { background: #fde8e6; }
tr.crit .r-val { color: #b03a2e; }
.crit-tag { display: inline-block; font-size: 10px; font-weight: 700; color: #fff; background: #b03a2e; border-radius: 3px; padding: 1px 4px; margin-left: 4px; vertical-align: middle; }
.legend { font-size: 12px; color: #5c6b79; margin-top: 10px; line-height: 1.5; }

.err { border-left: 6px solid #b03a2e; }
.err h2 { margin: 0 0 6px; color: #b03a2e; font-size: 20px; }

.hist { display: flex; flex-direction: column; gap: 8px; }
.hist button { text-align: left; font-weight: 400; font-size: 15px; padding: 12px 14px; }
.hist b { font-weight: 600; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: #d9e6f2; color: #1f5d90; margin-left: 6px; }
.tag.e { background: #fde8e6; color: #b03a2e; }

#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #1d2733; color: #fff; padding: 10px 16px;
  border-radius: 8px; font-size: 15px; opacity: 0; transition: opacity .25s; pointer-events: none; max-width: 90%; }
#toast.show { opacity: .95; }
