:root {
    color-scheme: light;
    background-color: #ffffff;
    --brand: #0d9f4a;
    --brand-dark: #0b8a40;
    --bar: #177e3b;
    --ink: #000000;
    --ink-soft: #63646f;
    --line: #ececec;
    --page: #fafafa;
    --head: #f2f2f2;
    --stripe: #f4f4f4;
    --radius: 10px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    background: #ffffff;
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background: #ffffff;
}

.ios-safari {
    --safe-area-top: env(safe-area-inset-top, 0px);
}

.ios-safari .app {
    padding-top: var(--safe-area-top);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

.ios-safari::before {
    content: "";
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: var(--safe-area-top);
    z-index: 100;
    background: #ffffff;
    pointer-events: none;
}

/* ---------- Header ---------- */
.topbar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px 23.5px;
    background: var(--bar);
    color: #ffffff;
}

.topbar__back {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.topbar__back svg {
    width: 18px;
    height: 18px;
}

.topbar__title {
    flex: 1;
    margin: 0 48px 0 0;
    font-size: 16px;
    font-weight: 400;
    text-align: center;
}

/* ---------- Khối nội dung ---------- */
.sheet {
    /* position + z-index: phải nằm trên .topbar (đang position: relative) thì mới thấy bo góc. */
    position: relative;
    z-index: 1;
    flex: 1;
    margin-top: -10px;
    padding: 34px 20px calc(24px + env(safe-area-inset-bottom));
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--page);
}

/* ---------- Bảng thông tin ---------- */
.info {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: #ffffff;
    box-shadow: 0 0 0 1px var(--head);
    font-size: 13px;
    line-height: 1.18;
}

.info th,
.info td {
    padding: 13.2px 21px;
    text-align: left;
    vertical-align: top;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.info thead th {
    padding-top: 14.3px;
    padding-bottom: 14.3px;
    background: var(--head);
    color: var(--brand);
    font-weight: 400;
}

.info thead th:first-child,
.info tbody th {
    width: 45%;
}

.info tbody th {
    color: var(--ink);
    font-weight: 400;
}

.info tbody td {
    padding-right: 52px;
    color: var(--ink-soft);
}

.info tbody tr:nth-child(even) th,
.info tbody tr:nth-child(even) td {
    background: var(--stripe);
}

/* ---------- Thông báo trạng thái ---------- */
.notice {
    padding: 26px 18px;
    border-radius: var(--radius);
    background: var(--stripe);
    text-align: center;
}

.notice__icon {
    width: 42px;
    height: 42px;
}

.notice--info .notice__icon {
    color: var(--brand);
}

.notice--error .notice__icon {
    color: #d93025;
}

.notice--warning .notice__icon {
    color: #f9ab00;
}

.notice__title {
    margin: 10px 0 6px;
    font-size: 1.0625rem;
    font-weight: 600;
}

.notice__text {
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.9375rem;
}

.notice__text strong {
    color: var(--ink);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    letter-spacing: 0.04em;
}

/* ---------- Hành động ---------- */
.actions {
    margin-top: 86px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 51px;
    padding: 12px 20px;
    border: 0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 15.5px;
    font-weight: 700;
    cursor: pointer;
}

.btn--primary {
    width: 100%;
    background: var(--brand);
    color: #ffffff;
}

.btn--primary:active {
    background: var(--brand-dark);
}

.btn__icon {
    width: 19px;
    height: 19px;
    flex: none;
}

.btn--ghost {
    min-height: 48px;
    padding: 12px 18px;
    border: 1px solid var(--brand);
    background: #ffffff;
    color: var(--brand);
    font-size: 0.9375rem;
}

.manual {
    margin-top: 22px;
}

.manual__label {
    display: block;
    margin-bottom: 8px;
    color: var(--ink-soft);
    font-size: 0.875rem;
}

.manual__row {
    display: flex;
    gap: 8px;
}

.manual__input {
    flex: 1;
    min-width: 0;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfbfb;
    color: var(--ink);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 1rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.manual__input:focus {
    border-color: var(--brand);
    outline: 2px solid rgba(26, 150, 71, 0.18);
}

.manual__error {
    margin: 8px 0 0;
    color: #d93025;
    font-size: 0.875rem;
}

/* ---------- Lớp quét ---------- */
.scanner {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background: #000000;
    color: #ffffff;
}

.scanner[hidden] {
    display: none;
}

.scanner__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 12px 12px 18px;
    padding-top: calc(12px + env(safe-area-inset-top));
    background: var(--bar);
}

.scanner__title {
    font-size: 1.0625rem;
    font-weight: 600;
}

.scanner__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
}

.scanner__close svg {
    width: 24px;
    height: 24px;
}

.scanner__view {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.scanner__view video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

.scanner__hint {
    margin: 0;
    padding: 16px 20px calc(20px + env(safe-area-inset-bottom));
    color: #e6e6e6;
    font-size: 0.9375rem;
    text-align: center;
}

/* ---------- Màn hình lớn ---------- */
@media (min-width: 640px) {
    body {
        background: #eef1f0;
    }

    .app {
        max-width: 480px;
        margin: 0 auto;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    }
}
