:root {
    --ios-bg: #f2f2f7;
    --ios-card: #ffffff;
    --ios-blue: #007aff;
    --ios-blue-dark: #005ecb;
    --ios-green: #34c759;
    --ios-orange: #ff9500;
    --ios-red: #ff3b30;
    --ios-text: #1c1c1e;
    --ios-muted: #6e6e73;
    --ios-border: rgba(60, 60, 67, 0.12);
    --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--ios-bg); color: var(--ios-text); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--ios-blue); text-decoration: none; }

.page-wrap { max-width: 480px; margin: 0 auto; padding: 16px 14px 40px; min-height: 100vh; display: flex; flex-direction: column; }

/* Header thương hiệu */
.top-brand { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; padding: 4px 2px; }
.brand-link { display: inline-flex; align-items: center; gap: 10px; color: var(--ios-text); font-weight: 700; font-size: 1.05rem; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; box-shadow: 0 2px 6px rgba(0, 122, 255, 0.22); }
.top-action { font-size: .88rem; font-weight: 600; color: var(--ios-blue); background: rgba(0, 122, 255, .1); padding: 6px 12px; border-radius: 999px; }
.top-action:hover { background: rgba(0, 122, 255, .18); }

/* Banner cảnh báo trình duyệt không phải Safari */
.safari-banner { display: none; background: #fff4e5; border: 1px solid #ffd599; color: #7c4a03; border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-size: .88rem; }
.safari-banner.show { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.safari-banner button { flex-shrink: 0; border: 0; background: #ff9500; color: #fff; font-weight: 600; border-radius: 999px; padding: 6px 12px; font-size: .82rem; cursor: pointer; }

/* Màn hình thông báo bắt buộc mở bằng Safari */
.safari-gate { display: none; background: #fdf2f2; border: 1.5px solid #f8b4b4; border-radius: var(--radius); padding: 22px 18px; text-align: center; margin-bottom: 14px; }
.safari-gate.show { display: block; }
.safari-gate-title { font-size: 1.32rem; font-weight: 700; color: #7f1d1d; margin: 0 0 8px; }
.safari-gate-title span { color: #e02424; }
.safari-gate-sub { font-size: .92rem; color: #9b1c1c; margin: 0 0 16px; }
.safari-gate-link { background: #fff; border: 1px solid #f3d1d1; border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.safari-gate-url { font-size: .84rem; color: var(--ios-blue); word-break: break-all; }
.safari-gate-qr { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 16px; text-align: center; }
.safari-gate-qr img { width: 184px; height: 184px; border-radius: 10px; border: 1px solid var(--ios-border); padding: 6px; background: #fff; margin-top: 10px; }
.safari-gate-skip { display: inline-block; margin-top: 12px; font-size: .8rem; color: var(--ios-muted); text-decoration: underline; cursor: pointer; background: none; border: 0; }

/* Card kiểu iOS */
.ios-card { background: var(--ios-card); border-radius: var(--radius); padding: 18px; box-shadow: 0 2px 10px rgba(0, 0, 0, .04); border: 1px solid rgba(0, 0, 0, .04); margin-bottom: 14px; }
.ios-section-title { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ios-muted); margin: 16px 6px 8px; }

/* Hero */
.hero-box { text-align: center; padding: 22px 18px; }
.hero-icon { width: 72px; height: 72px; border-radius: 18px; box-shadow: 0 8px 20px rgba(0, 122, 255, .24); margin-bottom: 12px; }
.hero-title { font-size: 1.3rem; font-weight: 700; margin: 0 0 6px; }
.hero-sub { color: var(--ios-muted); font-size: .92rem; margin: 0 0 18px; }

/* Nút bấm kiểu iOS */
.ios-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; border: 0; border-radius: 14px; padding: 13px 18px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: transform .1s, background .15s; text-align: center; }
.ios-btn:active { transform: scale(.985); }
.ios-btn-primary { background: var(--ios-blue); color: #fff; }
.ios-btn-primary:hover { background: var(--ios-blue-dark); color: #fff; }
.ios-btn-success { background: var(--ios-green); color: #fff; }
.ios-btn-success:hover { background: #28a745; color: #fff; }
.ios-btn-soft { background: rgba(0, 122, 255, .1); color: var(--ios-blue); }
.ios-btn-soft:hover { background: rgba(0, 122, 255, .16); color: var(--ios-blue); }
.ios-btn-sm { padding: 9px 14px; font-size: .9rem; border-radius: 12px; width: auto; }

/* Danh sách App */
.app-list { background: var(--ios-card); border-radius: var(--radius); overflow: hidden; border: 1px solid rgba(0, 0, 0, .04); box-shadow: 0 2px 10px rgba(0, 0, 0, .04); }
.app-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--ios-text); border-bottom: 1px solid var(--ios-border); transition: background .12s; }
.app-row:last-child { border-bottom: 0; }
.app-row:hover { background: #f8f9fc; }
.app-icon-wrap { position: relative; width: 52px; height: 52px; flex-shrink: 0; border-radius: 13px; overflow: hidden; background: #eef2ff; border: 1px solid rgba(0, 0, 0, .06); }
.app-icon-wrap.lg { width: 78px; height: 78px; border-radius: 19px; box-shadow: 0 6px 16px rgba(0, 0, 0, .1); }
.app-icon-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.app-icon-wrap .fallback { display: none; width: 100%; height: 100%; align-items: center; justify-content: center; background: linear-gradient(135deg, #0a84ff, #5856d6); color: #fff; font-weight: 800; font-size: 1.15rem; }
.app-icon-wrap.is-fallback img { display: none; }
.app-icon-wrap.is-fallback .fallback { display: flex; }
.app-info { flex: 1; min-width: 0; }
.app-name { font-weight: 600; font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-meta { color: var(--ios-muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-pill { background: rgba(0, 122, 255, .12); color: var(--ios-blue); font-weight: 700; font-size: .8rem; padding: 5px 12px; border-radius: 999px; flex-shrink: 0; }

/* Form nhập UDID */
.ios-input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid #d1d1d6; background: #f9f9fb; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; color: var(--ios-text); outline: none; transition: border-color .15s, background .15s; }
.ios-input:focus { border-color: var(--ios-blue); background: #fff; }

/* Hộp hiển thị UDID */
.udid-box { background: #f5f7ff; border: 1.5px dashed #8ab4f8; border-radius: 14px; padding: 14px; text-align: center; margin: 12px 0; }
.udid-value { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .95rem; font-weight: 700; color: #1d4ed8; word-break: break-all; letter-spacing: .02em; }

/* Trạng thái kết quả */
.status-box { border-radius: 14px; padding: 14px 16px; margin-top: 14px; }
.status-ready { background: #edfdf2; border: 1px solid #b7efc5; }
.status-warn { background: #fff8eb; border: 1px solid #ffe0a3; color: #7c4a03; }
.status-err { background: #fff1f0; border: 1px solid #ffccc7; color: #a8071a; }
.status-info { background: #eef6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* Hướng dẫn các bước */
.step-list { list-style: none; padding: 0; margin: 0; }
.step-list li { display: flex; gap: 11px; align-items: flex-start; padding: 8px 0; font-size: .92rem; }
.step-num { width: 24px; height: 24px; border-radius: 50%; background: rgba(0, 122, 255, .12); color: var(--ios-blue); font-weight: 700; font-size: .8rem; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }

/* Trang cài đặt App (Ready) kiểu OTA */
.ota-header { display: flex; gap: 16px; align-items: flex-start; }
.ota-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.ota-badge { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.ota-badge-blue { background: #e8f1ff; color: #2563eb; }
.ota-badge-gray { background: #f3f4f6; color: #4b5563; }
.ota-install-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; border: 0; border-radius: 999px; padding: 12px 20px; font-size: 1rem; font-weight: 700; background: #3b6ef6; color: #fff; box-shadow: 0 6px 14px rgba(59, 110, 246, .28); transition: background .15s, transform .1s; margin-top: 12px; }
.ota-install-btn:hover { background: #2959dc; color: #fff; }
.ota-install-btn:active { transform: scale(.985); }
.ota-meta-list { border-top: 1px solid var(--ios-border); margin-top: 16px; padding-top: 4px; }
.ota-meta-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid rgba(60, 60, 67, .07); font-size: .88rem; }
.ota-meta-row:last-child { border-bottom: 0; padding-bottom: 2px; }
.ota-meta-label { font-size: .76rem; font-weight: 600; letter-spacing: .04em; color: var(--ios-muted); text-transform: uppercase; }
.ota-meta-val { font-weight: 700; color: var(--ios-text); }

/* Hộp Copy link Safari (màu cam ấm) */
.safari-copy-card { background: #fffbf2; border: 1.5px solid #fcd9a0; border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.safari-copy-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.safari-copy-title { font-weight: 700; font-size: .92rem; color: #92400e; display: inline-flex; align-items: center; gap: 6px; }
.safari-copy-btn { display: inline-flex; align-items: center; gap: 5px; border: 1px solid #f5b963; background: #fff; color: #b45309; font-weight: 600; font-size: .82rem; padding: 6px 12px; border-radius: 999px; cursor: pointer; flex-shrink: 0; }
.safari-copy-btn:hover { background: #fef3c7; }
.safari-copy-box { background: #fff; border: 1px solid #f5c982; border-radius: 12px; padding: 11px 12px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; color: #1f2937; word-break: break-all; line-height: 1.45; }

/* QR code trên desktop */
.qr-wrap { text-align: center; padding-top: 12px; border-top: 1px solid var(--ios-border); margin-top: 16px; }
.qr-wrap img { width: 160px; height: 160px; border-radius: 12px; border: 1px solid var(--ios-border); padding: 6px; background: #fff; }

/* Footer & Toast */
.page-footer { margin-top: auto; padding-top: 20px; text-align: center; color: var(--ios-muted); font-size: .82rem; }
.toast-msg { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); background: rgba(28, 28, 30, .92); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: .88rem; font-weight: 500; opacity: 0; pointer-events: none; transition: all .22s; z-index: 999; }
.toast-msg.show { opacity: 1; transform: translateX(-50%) translateY(0); }
