/* nhapve: phone-first, centred column on a desktop. */
:root {
    --brand: #0a7fd1;
    --brand-dark: #075f9e;
    --ink: #1c2733;
    --muted: #66727f;
    --line: #d9e1ea;
    --bg: #f2f5f9;
    --card: #fff;
    --ok: #1f8a4c;
    --err: #c62828;
    --warn: #b26a00;
    --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 42px; padding: 0 16px;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: #fff; color: var(--ink); cursor: pointer; text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-block { width: 100%; }
.btn-lg { min-height: 50px; font-size: 17px; }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn-danger { color: var(--err); border-color: #efc4c4; }
.btn-link { border: 0; background: none; color: var(--brand); }
.btn-ghost { background: #f7f9fc; }
.icon-btn { border: 0; background: none; font-size: 24px; width: 40px; height: 40px; cursor: pointer; color: inherit; }

/* ---- Forms ---- */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.field small { font-weight: 400; }
.field input, .field select {
    width: 100%; height: 44px; padding: 0 12px;
    border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
    outline: none;
}
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(10,127,209,.15); }
.field input:disabled, .field select:disabled, .field input[readonly] { background: #eef2f6; }
.field input.big { font-size: 22px; font-weight: 700; letter-spacing: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 18px; height: 18px; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 64px; }
.pw-toggle { position: absolute; right: 4px; top: 4px; height: 36px; border: 0; background: none; color: var(--brand); cursor: pointer; padding: 0 10px; }
.hint { font-size: 13px; color: var(--brand-dark); margin-top: -6px; min-height: 0; }
.hint:empty { display: none; }
.msg { font-size: 14px; }
.msg:empty { display: none; }
.msg.error { color: var(--err); background: #fdecec; padding: 8px 10px; border-radius: 8px; }
.msg.ok { color: var(--ok); background: #e8f6ee; padding: 8px 10px; border-radius: 8px; }
.fine { font-size: 12px; color: var(--muted); text-align: center; margin: 0; }

.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 10px 0; cursor: pointer; }
.seg input:checked + span { background: var(--brand); color: #fff; font-weight: 600; }
.seg input:disabled + span { cursor: default; opacity: .7; }
.seg label + label span { border-left: 1px solid var(--line); }

/* ---- Login / password pages ---- */
body.auth { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 24px 14px; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0 20px 22px; box-shadow: 0 6px 24px rgba(20,40,70,.07); }
.auth-head { text-align: center; margin: 0 -20px 18px; padding: 16px 20px 14px; border-bottom: 1px solid var(--line); background: linear-gradient(#eef5ff, #fff); border-radius: 14px 14px 0 0; }
.auth-head .company { font-family: "Times New Roman", serif; font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.auth-logo { width: 84px; height: 84px; margin: 14px auto 4px; display: block; }
.auth-head h1 { font-size: 19px; margin: 6px 0 0; color: var(--brand-dark); }
.auth-head .sub { margin: 6px 0 0; color: var(--muted); }
.notice { background: #fff6e5; border: 1px solid #f3d9a4; color: #6b4a00; padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; }
.rules { list-style: none; margin: -4px 0 0; padding: 0; font-size: 13px; color: var(--muted); display: grid; gap: 2px; }
.rules li::before { content: "○"; display: inline-block; width: 18px; color: #b0b9c4; }
.rules li.ok { color: var(--ok); }
.rules li.ok::before { content: "✓"; color: var(--ok); }

/* ---- App ---- */
body.app { max-width: 520px; margin: 0 auto; min-height: 100vh; background: var(--bg); padding-bottom: 20px; }
@media (min-width: 560px) { body.app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 12px; background: var(--brand); color: #fff; }
.topbar-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title img { width: 34px; height: 34px; background: #fff; border-radius: 50%; padding: 2px; }
.topbar .t1 { font-weight: 700; font-size: 16px; }
.topbar .t2 { font-size: 13px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 44px; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.15); min-width: 170px; overflow: hidden; }
.menu-pop a, .menu-pop button { display: block; width: 100%; text-align: left; padding: 12px 14px; border: 0; background: none; color: inherit; text-decoration: none; cursor: pointer; }
.menu-pop a + button { border-top: 1px solid var(--line); }
.tabs { position: sticky; top: 50px; z-index: 15; display: grid; grid-template-columns: 1fr 1fr; background: #fff; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: none; padding: 12px 0; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 12px; line-height: 20px; }
.badge:empty { display: none; }
.panel { padding: 12px; }

.edit-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff6e5; border: 1px solid #f3d9a4; border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.edit-banner small { color: var(--warn); }

.camera { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.camera-view { position: relative; aspect-ratio: 4 / 3; background: #111; border-radius: 8px; overflow: hidden; }
.camera-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-off { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #1b2430; }
.camera-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; margin-top: 8px; }
.btn-capture { background: #10263b; color: #fff; border-color: #10263b; font-weight: 600; min-height: 48px; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.photos:empty { display: none; }
.photo { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #ddd; cursor: pointer; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo.uploading img { opacity: .5; }
.photo.error { outline: 2px solid var(--err); }
.photo-state { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; text-align: center; padding: 2px; }
.photo.error .photo-state { background: var(--err); }
.photo-del { position: absolute; top: 3px; right: 3px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 18px; line-height: 26px; padding: 0; cursor: pointer; }
.form-actions { padding: 4px 0; }

.filters { margin-bottom: 8px; }
.list-summary { font-size: 14px; color: var(--muted); margin: 4px 2px 10px; }
.rows { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.card-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.card-num { font-size: 24px; font-weight: 700; letter-spacing: 2px; margin: 2px 0; }
.card-num .tag { font-size: 12px; letter-spacing: 0; background: #e6f1fb; color: var(--brand-dark); border-radius: 6px; padding: 2px 6px; margin-right: 6px; vertical-align: middle; }
.card-num .sym { font-size: 14px; letter-spacing: 0; color: var(--brand-dark); }
.card-meta { font-size: 13px; color: var(--muted); }
.card-photos { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; }
.card-photos img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; background: #ddd; cursor: pointer; flex: none; }
.card-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.card-lock { font-size: 12px; color: var(--warn); margin-top: 8px; }
.status { font-size: 12px; font-weight: 600; border-radius: 10px; padding: 1px 8px; white-space: nowrap; }
.st-new { background: #eef2f6; color: #4a5866; }
.st-sale { background: #e8f6ee; color: var(--ok); }
.st-stop { background: #fdecec; color: var(--err); }

.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; padding: 10px; }
.lightbox img { max-width: 100%; max-height: 100%; }
.toast { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 60; max-width: 92%; padding: 10px 16px; border-radius: 10px; color: #fff; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.ok { background: var(--ok); }
.toast.error { background: var(--err); }
