﻿/* =========================================================
   OTS Mobile - mobile-first stylesheet
   Brand colour follows the desktop login (#b91c1c).
   ========================================================= */
:root {
    --brand: #b91c1c;
    --brand-dark: #8f1515;
    --brand-soft: #fdecec;
    --bg: #f3f4f6;
    --surface: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --ok: #15803d;
    --ok-soft: #e8f6ed;
    --err: #b91c1c;
    --err-soft: #fdecec;
    --radius: 12px;
    --tap: 48px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.4;
}

a { color: var(--brand); }

/* ---------- Header ---------- */
.m-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--brand);
    color: #fff;
    padding: 10px 16px 8px;
    padding-top: calc(10px + env(safe-area-inset-top));
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.m-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.m-brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 16px; letter-spacing: .2px;
           white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-logout { color: #fff; text-decoration: none; font-size: 14px; border: 1px solid rgba(255,255,255,.6);
            padding: 6px 12px; border-radius: 999px; flex-shrink: 0; }
.m-header-sub { font-size: 13px; opacity: .9; margin-top: 2px; }
.m-dot { margin: 0 6px; }

/* ---------- Layout ---------- */
.m-main { padding: 16px; padding-bottom: calc(110px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
.m-title { font-size: 20px; font-weight: 700; margin: 4px 0 12px; }

.m-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
}
.m-card-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase;
                letter-spacing: .5px; margin: 0 0 10px; }

/* ---------- Form controls ---------- */
.m-field { margin-bottom: 14px; }
.m-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.m-hint { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
.m-hint.err { color: var(--err); font-weight: 600; }

.m-input, .m-select {
    width: 100%;
    min-height: var(--tap);
    font-size: 17px;              /* >=16px prevents iOS zoom */
    padding: 10px 12px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
.m-select {
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    padding-right: 34px;
}
.m-input:focus, .m-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.m-input.invalid { border-color: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.m-input[readonly] { background: #f9fafb; color: var(--muted); }
.m-input-big { font-size: 24px; letter-spacing: 3px; text-align: center; font-weight: 700; }
.m-input::placeholder { color: #9ca3af; }
.m-input-big::placeholder { font-size: 17px; letter-spacing: 0; font-weight: 500; }

.m-row { display: flex; gap: 10px; }
.m-row > * { flex: 1; min-width: 0; }

/* ---------- Buttons ---------- */
.m-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%;
    min-height: var(--tap);
    padding: 12px 16px;
    font-size: 16px; font-weight: 700;
    border: 0; border-radius: 10px;
    background: var(--brand); color: #fff;
    text-decoration: none; cursor: pointer;
}
.m-btn:active { background: var(--brand-dark); }
.m-btn[disabled], .m-btn.disabled { background: #d1d5db; color: #6b7280; cursor: not-allowed; }
.m-btn-outline { background: #fff; color: var(--brand); border: 1.5px solid var(--brand); }
.m-btn-outline:active { background: var(--brand-soft); }
.m-btn-ghost { background: transparent; color: var(--muted); }

/* ---------- Messages ---------- */
.m-msg { padding: 12px 14px; border-radius: 10px; font-size: 15px; margin-bottom: 12px; display: block; }
.m-msg:empty { display: none; }
.m-msg-err { background: var(--err-soft); color: var(--err); }

/* ---------- Key/Value grid ---------- */
.m-kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.m-kv > div { min-width: 0; }
.m-kv .k { font-size: 12px; color: var(--muted); }
.m-kv .v { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.m-kv .full { grid-column: 1 / -1; }

.m-route { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.m-route .arrow { color: var(--muted); }

.m-chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
          background: var(--brand-soft); color: var(--brand); }
.m-chip-muted { background: #eef0f3; color: var(--muted); }

/* ---------- Balance table ---------- */
.m-bal { width: 100%; border-collapse: collapse; font-size: 14px; margin: 4px 0 14px; }
.m-bal th, .m-bal td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line); }
.m-bal th:first-child, .m-bal td:first-child { text-align: left; color: var(--muted); font-weight: 600; }
.m-bal th { font-size: 12px; color: var(--muted); font-weight: 600; }
.m-bal tr.rem td { font-weight: 800; color: var(--ok); border-bottom: 0; }

/* ---------- Added CN list ---------- */
.m-list-empty { text-align: center; color: var(--muted); padding: 18px 8px; font-size: 14px; }
.m-item { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.m-item:last-child { border-bottom: 0; }
.m-item-body { flex: 1; min-width: 0; }
.m-item-cn { font-weight: 800; font-size: 16px; }
.m-item-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-item-qty { font-size: 14px; margin-top: 2px; }
.m-item-del { border: 0; background: var(--err-soft); color: var(--err); font-weight: 700; border-radius: 8px;
              min-width: 44px; min-height: 40px; font-size: 14px; cursor: pointer; }

.m-totals { display: flex; justify-content: space-between; font-weight: 700; padding-top: 10px; border-top: 2px solid var(--line); margin-top: 4px; }

/* ---------- Sticky action bar ---------- */
.m-actionbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 8px rgba(0,0,0,.06);
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
.m-actionbar-inner { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; }
.m-actionbar .m-btn-outline { flex: 0 0 34%; }

/* ---------- Home tiles ---------- */
.m-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.m-tile { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 14px;
          text-decoration: none; color: var(--text); min-height: 110px; display: flex; flex-direction: column; justify-content: space-between; }
.m-tile-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--brand-soft); color: var(--brand);
               display: flex; align-items: center; justify-content: center; font-weight: 800; }
.m-tile-name { font-weight: 700; font-size: 15px; margin-top: 10px; }

/* ---------- Login ---------- */
.m-login-wrap { min-height: 100vh; display: flex; flex-direction: column; }
.m-login-head { background: var(--brand); color: #fff; padding: 36px 20px 56px; padding-top: calc(36px + env(safe-area-inset-top)); text-align: center; }
.m-login-head h1 { margin: 0; font-size: 24px; }
.m-login-head p { margin: 6px 0 0; opacity: .9; font-size: 14px; }
.m-login-card { margin: -36px 16px 24px; max-width: 440px; align-self: center; width: calc(100% - 32px); }
.m-captcha { display: flex; align-items: center; gap: 10px; }
.m-captcha img { height: 48px; width: auto; border-radius: 8px; border: 1px solid var(--line); }
.m-captcha .m-icon-btn { width: 48px; height: 48px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; padding: 10px; }

/* ---------- Success ---------- */
.m-success { text-align: center; padding: 28px 16px; }
.m-success-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-soft); color: var(--ok);
                  display: inline-flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 800; }
.m-success h2 { margin: 14px 0 4px; font-size: 20px; }
.m-success .dino { font-size: 28px; font-weight: 800; letter-spacing: 1px; margin: 6px 0 18px; }

/* ---------- Loader / toast ---------- */
.m-loader { position: fixed; inset: 0; background: rgba(255,255,255,.6); z-index: 50; display: flex; align-items: center; justify-content: center; }
.m-spinner { width: 42px; height: 42px; border: 4px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: mspin .8s linear infinite; }
@keyframes mspin { to { transform: rotate(360deg); } }

.m-toast { position: fixed; left: 16px; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 60;
           max-width: 608px; margin: 0 auto; padding: 12px 14px; border-radius: 10px; font-size: 15px; font-weight: 600;
           color: #fff; background: #111827; box-shadow: 0 6px 18px rgba(0,0,0,.2);
           opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s; pointer-events: none; }
.m-toast.show { opacity: 1; transform: translateY(0); }
.m-toast.err { background: var(--err); }
.m-toast.ok { background: var(--ok); }

.hidden { display: none !important; }
