/* Tông màu lấy từ giao diện license của VFT (UI/keyuser.ui, UI/keyadmin.ui) */
:root {
  --bg: #f0f7ff; --card: #ffffff; --text: #1e293b; --muted: #64748b; --faint: #94a3b8;
  --line: #bfdbfe; --line-soft: #e2e8f0; --chip: #dbeafe; --chip-text: #1e3a8a;
  --primary: #1d4ed8; --primary-hover: #1e40af; --primary-text: #ffffff; --heading: #1e3a8a;
  --head-from: #1e3a8a; --head-to: #1d4ed8;
  --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7; --err: #dc2626; --err-bg: #fee2e2;
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1324; --card: #111c33; --text: #e2e8f0; --muted: #94a3b8; --faint: #64748b;
    --line: #1e3a8a; --line-soft: #1e293b; --chip: #172554; --chip-text: #bfdbfe;
    --primary: #3b82f6; --primary-hover: #60a5fa; --primary-text: #ffffff; --heading: #93c5fd;
    --head-from: #172554; --head-to: #1e3a8a;
    --ok: #4ade80; --ok-bg: #052e16; --warn: #fbbf24; --warn-bg: #3a2a05; --err: #f87171; --err-bg: #3b0a0a;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

/* Thanh tiêu đề */
.appbar {
  background: linear-gradient(135deg, var(--head-from), var(--head-to)); color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 16px 18px;
}
.appbar .brand { display: flex; align-items: center; gap: 10px; }
.appbar img { width: 34px; height: 34px; border-radius: 8px; box-shadow: 0 0 0 1px rgba(255,255,255,.25); }
.appbar h1 { font-size: 17px; margin: 0; font-weight: 700; flex: 1; }
.appbar .lock { font-size: 12px; background: rgba(255,255,255,.16); border: 0; color: #fff; border-radius: 12px; padding: 5px 11px; font-weight: 500; }
.appbar .hello { margin-top: 14px; font-size: 20px; font-weight: 700; }
.appbar .sub { font-size: 13px; opacity: .85; margin-top: 2px; }
.stats { display: flex; gap: 10px; margin-top: 14px; }
.stat { flex: 1; background: rgba(255,255,255,.14); border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-size: 20px; line-height: 1.2; }
.stat span { font-size: 12px; opacity: .85; }

main { padding: 12px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 12px 0; }
.card h2 { font-size: 15px; margin: 0 0 10px; color: var(--heading); display: flex; align-items: center; gap: 8px; }
.card h2 .count { background: var(--primary); color: var(--primary-text); border-radius: 10px; padding: 0 8px; font-size: 12px; }
.card h2 .grow { flex: 1; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--heading); margin: 18px 0 6px; }

label.field { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=date], input[type=time], select, textarea {
  width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 16px; font-family: inherit;
}
textarea { min-height: 96px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13px; word-break: break-all; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.row > * { flex: 1 1 auto; }
button {
  padding: 11px 14px; border-radius: 8px; border: 1px solid var(--primary);
  background: var(--primary); color: var(--primary-text); font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer;
}
button:active { background: var(--primary-hover); }
button.ghost { background: var(--chip); color: var(--chip-text); border-color: var(--line); }
button.danger { background: transparent; color: var(--err); border-color: var(--err); }
button.small { padding: 6px 10px; font-size: 13px; flex: 0 0 auto; }
button.link { background: none; border: 0; color: var(--primary); padding: 4px 0; font-size: 13px; }
button:disabled { opacity: .5; }

.status { font-size: 14px; margin-top: 10px; white-space: pre-wrap; }
.status:empty { display: none; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .err { color: var(--err); }
.hint { font-size: 13px; color: var(--muted); }
.hidden { display: none !important; }

/* Danh sách yêu cầu */
ul.list { list-style: none; margin: 0; padding: 0; }
ul.list > li { padding: 12px 0; border-top: 1px solid var(--line-soft); }
ul.list > li:first-child { border-top: 0; padding-top: 0; }
ul.list > li:last-child { padding-bottom: 0; }
.who { font-weight: 600; word-break: break-word; }
.meta { font-size: 13px; color: var(--muted); word-break: break-word; }
.req { display: flex; gap: 12px; align-items: center; }
.req .body { flex: 1; min-width: 0; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--chip); color: var(--chip-text);
          display: flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }
.compact li { padding: 8px 0; }
.compact .line { display: flex; gap: 8px; align-items: baseline; }
.compact .line .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.compact .line time { font-size: 12px; color: var(--faint); flex: 0 0 auto; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--chip); color: var(--chip-text); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.empty { text-align: center; padding: 14px 0 6px; color: var(--muted); font-size: 14px; }

/* Form cấp license */
.check { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: 0 0 auto; accent-color: var(--primary); }
.check small { display: block; color: var(--muted); font-size: 12px; }
.check.disabled { opacity: .5; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chips button { flex: 0 0 auto; padding: 5px 11px; font-size: 13px; background: var(--chip); color: var(--chip-text); border-color: var(--line); font-weight: 500; border-radius: 14px; }
.note { font-size: 13px; padding: 10px 12px; border-radius: 8px; background: var(--chip); color: var(--text); margin-top: 8px; word-break: break-word; }
.note .who { color: var(--heading); }
.keybox { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; background: var(--bg);
          border: 1px dashed var(--line); border-radius: 8px; padding: 10px; max-height: 160px; overflow: auto; user-select: all; }
.setting { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.setting:first-of-type { border-top: 0; }
.setting .grow { flex: 1; min-width: 0; }
.setting .val { font-size: 13px; color: var(--muted); word-break: break-all; }

/* Bảng duyệt yêu cầu: phủ toàn màn hình */
.sheet { position: fixed; inset: 0; background: var(--bg); overflow-y: auto; z-index: 30; }
.sheet .appbar { padding-bottom: 14px; position: sticky; top: 0; z-index: 1; }
.sheet .appbar .brand button { background: rgba(255,255,255,.18); border-color: transparent; color: #fff; }
.sheet main { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* Thanh tab dưới cùng */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
nav.tabs button {
  flex: 1; background: none; border: 0; border-radius: 0; color: var(--faint); font-weight: 500; font-size: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; position: relative;
}
nav.tabs button .ic { font-size: 21px; line-height: 1; filter: grayscale(1); opacity: .7; }
nav.tabs button.active { color: var(--primary); }
nav.tabs button.active .ic { filter: none; opacity: 1; }
nav.tabs button.active::before { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary); }
nav.tabs .dot { position: absolute; top: 8px; left: calc(50% + 8px); min-width: 17px; height: 17px; border-radius: 9px;
                background: var(--err); color: #fff; font-size: 11px; line-height: 17px; padding: 0 4px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); z-index: 40;
         background: var(--heading); color: #fff; border-radius: 10px; padding: 12px 14px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
@media (prefers-color-scheme: dark) { .toast { background: #1e3a8a; } }

/* Kích hoạt / mở khoá */
.login { min-height: 100vh; display: flex; flex-direction: column; }
.login .appbar { padding-bottom: 40px; }
.login main { margin-top: -28px; padding-bottom: 24px; width: 100%; }
.links { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* Popup nhỏ */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .55);
            display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 420px;
         max-height: calc(100vh - 32px); overflow-y: auto; padding: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal h2 { font-size: 17px; margin: 0 0 4px; color: var(--heading); }
.modal .hint { margin: 0 0 6px; }
.modal .warnbox { font-size: 13px; padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); margin-top: 10px; }
.modal .keybox { margin-top: 10px; font-size: 14px; }
.meter { height: 4px; border-radius: 2px; background: var(--line-soft); margin-top: 6px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--err); transition: width .2s, background .2s; }

/* Quản lý admin */
.role { font-size: 11px; padding: 1px 7px; border-radius: 9px; background: var(--chip); color: var(--chip-text); margin-left: 6px; vertical-align: 1px; }
.role.owner { background: var(--primary); color: var(--primary-text); }
.admin-actions { display: flex; gap: 8px; margin-top: 8px; }
.admin-actions button { flex: 0 0 auto; }
