/* ============================================================
   Realtor OS Builder — trang học viên coaching (DuongEdu)
   Nhận diện: xanh ngọc #2DBDB6, cam nhấn #F5A623 (giống CRM DuongEdu)
   ============================================================ */
:root {
  --brand: #2DBDB6;
  --brand-dark: #1FA39C;
  --brand-darker: #157F79;
  --brand-050: #EAF9F8;
  --brand-100: #D3F1EF;
  --accent: #F5A623;
  --accent-soft: #FEF4E2;
  --accent-ink: #B45309;
  --canvas: #F3F6F7;
  --surface: #FFFFFF;
  --surface-2: #F8FAFB;
  --ink: #131B24;
  --ink-2: #56636F;
  --ink-3: #93A0AC;
  --line: #E7ECEE;
  --line-soft: #F0F4F5;
  --danger: #DC2626;
  --danger-soft: #FDECEC;
  --success: #16A34A;
  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow: 0 2px 10px rgba(19, 27, 36, .05), 0 1px 3px rgba(19, 27, 36, .04);
  --shadow-md: 0 8px 24px rgba(19, 27, 36, .09);
  --font: 'Montserrat', 'Segoe UI', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--canvas); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button, a, .stu-tabs, .nav-item { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--ink); }
a { color: var(--brand-darker); text-decoration: none; }
::selection { background: var(--brand-100); }

/* ---------- chung ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.btn { border: none; border-radius: 10px; padding: 11px 16px; font-size: 14.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn { transition: transform .1s ease; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(45, 189, 182, .35); }
.btn-primary:active { background: var(--brand-dark); }
.btn-secondary { background: var(--surface); color: var(--ink-2); border: 1.5px solid var(--line); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; min-height: 48px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.field input, .field select, .field textarea { padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3.5px rgba(45, 189, 182, .18); }
.muted { color: var(--ink-3); font-size: 13px; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 11px; white-space: nowrap; }
.pill-on { background: var(--brand-050); color: var(--brand-darker); }
.pill-watch { background: var(--accent-soft); color: var(--accent-ink); }
.pill-alert { background: var(--danger); color: #fff; }
.pill-mute { background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line); }
.pill-new { background: #F3E8FF; color: #7C3AED; }
.bar { height: 7px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.bar > div { height: 100%; border-radius: 999px; }
.bar-ok > div { background: var(--brand); }
.bar-mid > div { background: var(--accent); }
.bar-low > div { background: var(--danger); }
.section-title { font-size: 15.5px; font-weight: 700; margin-bottom: 10px; }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: #1D2733; color: #fff; padding: 11px 20px; border-radius: 11px; font-size: 13.5px; font-weight: 600; z-index: 99; box-shadow: var(--shadow-md); max-width: 90vw; }
.toast.err { background: var(--danger); }

/* ---------- đăng nhập ---------- */
.login-screen { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(160deg, #EAF9F8 0%, #F3F6F7 55%); }
.login-box { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 30px 26px; }
.login-logo { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.login-logo .mark { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, var(--brand-darker), var(--brand)); color: #fff; font-weight: 800; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.login-logo .word { font-size: 19px; font-weight: 800; }
.login-logo .word span { color: var(--brand); }
.login-sub { color: var(--ink-2); font-size: 13px; margin-bottom: 20px; }

/* ---------- khung học viên (mobile-first, tab đáy) ---------- */
.stu-shell { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.stu-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: calc(14px + env(safe-area-inset-top)) 18px 12px; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 5; }
.avatar { border-radius: 999px; background: var(--brand-100); color: var(--brand-darker); font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stu-head .avatar { width: 42px; height: 42px; font-size: 15px; }
.stu-head .who { display: flex; flex-direction: column; }
.stu-head .who b { font-size: 17px; }
.stu-head .who .muted { font-size: 12.5px; }
.stu-body { flex: 1; padding: 14px 14px calc(84px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; animation: viewIn .18s ease; }
@keyframes viewIn { from { opacity: .35; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.stu-tabs { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); display: flex; padding: 6px 6px calc(10px + env(safe-area-inset-bottom)); z-index: 10; }
.stu-tabs button { flex: 1; background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 0; font-size: 11.5px; font-weight: 600; color: var(--ink-3); border-radius: 10px; transition: transform .1s ease; }
.stu-tabs button:active { transform: scale(.9); }
.stu-tabs button.active { color: var(--brand-darker); font-weight: 700; }
.stu-tabs svg { width: 22px; height: 22px; }
@media (min-width: 561px) { .stu-tabs { max-width: 560px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }

/* thẻ tiến độ hero */
.hero { background: linear-gradient(135deg, var(--brand-darker), var(--brand)); border-radius: var(--radius-lg); padding: 18px; color: #fff; box-shadow: var(--shadow-md); display: flex; flex-direction: column; gap: 10px; }
.hero .tag { margin-left: auto; font-size: 11.5px; background: rgba(255,255,255,.18); border-radius: 999px; padding: 2px 10px; font-weight: 600; }
.hero .big { font-size: 37px; font-weight: 800; line-height: 1; }
.hero .bar { background: rgba(255,255,255,.25); height: 8px; }
.hero .bar > div { background: #fff; }

/* KPI hàng */
.kpi-row { display: flex; flex-direction: column; gap: 5px; }
.kpi-row .top { display: flex; align-items: baseline; gap: 8px; font-size: 13.5px; }
.kpi-row .top .val { margin-left: auto; font-weight: 800; font-size: 16.5px; }
.kpi-row .top .val span { color: var(--ink-3); font-weight: 600; font-size: 13px; }

/* checklist */
.check-item { display: flex; align-items: center; gap: 11px; min-height: 46px; border: none; background: none; width: 100%; text-align: left; font-size: 15px; padding: 2px 0; color: var(--ink); border-radius: 9px; }
.check-item:active { background: var(--surface-2); }
.check-item .box { width: 22px; height: 22px; border-radius: 7px; border: 2px solid #D5DDE0; flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: background .12s ease, border-color .12s ease; }
.check-item.done .box { background: var(--brand); border-color: var(--brand); }
.check-item.done .txt { color: var(--ink-3); }
.stage-card { border-radius: var(--radius); }
.stage-card.current { border: 1.5px solid var(--brand); box-shadow: var(--shadow-md); border-radius: var(--radius-lg); }
.stage-head { display: flex; align-items: center; gap: 12px; width: 100%; background: none; border: none; padding: 0; text-align: left; }
.stage-head .num { width: 30px; height: 30px; border-radius: 999px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; background: var(--surface-2); border: 2px solid var(--line); color: var(--ink-3); }
.stage-head.done .num { background: var(--brand); border-color: var(--brand); color: #fff; }
.stage-head.current .num { background: var(--brand-050); border-color: var(--brand); color: var(--brand-darker); }
.stage-head .t { font-size: 15px; font-weight: 700; }
.stage-head .cnt { margin-left: auto; font-size: 13px; font-weight: 700; }

/* lời dặn coach */
.note-card { background: var(--accent-soft); border-radius: var(--radius); padding: 13px 15px; }
.note-card .from { font-size: 12.5px; font-weight: 700; color: var(--accent-ink); margin-bottom: 3px; }

/* ---------- khung coach (sidebar desktop / tab đáy mobile) ---------- */
.shell { display: flex; min-height: 100dvh; }
.sidebar { width: 240px; background: var(--surface); border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100dvh; }
.sidebar .logo { display: flex; align-items: center; gap: 10px; padding: 0 10px 16px; }
.sidebar .logo .mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--brand-darker), var(--brand)); color: #fff; font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.sidebar .logo .word { font-size: 16px; font-weight: 800; }
.sidebar .logo .word span { color: var(--brand); }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 11px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); background: none; border: none; width: 100%; text-align: left; }
.nav-item.active { background: var(--brand-050); color: var(--brand-darker); font-weight: 700; }
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.sidebar .foot { margin-top: auto; border-top: 1px solid var(--line-soft); padding: 12px 10px 0; display: flex; align-items: center; gap: 10px; }
.sidebar .foot .avatar { width: 34px; height: 34px; font-size: 12.5px; }
.main { flex: 1; padding: 24px 26px 40px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 21px; font-weight: 800; }
.page-head .sub { color: var(--ink-2); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 13px; margin-bottom: 16px; }
.tile { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 15px 17px; }
.tile .k { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.tile .v { font-size: 25px; font-weight: 800; margin: 1px 0; }
.tile .s { font-size: 11.5px; color: var(--ink-2); }

/* bảng học viên */
.table-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; min-width: 760px; }
table.list th { text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); padding: 13px 14px; border-bottom: 1px solid var(--line); }
table.list td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); font-size: 13px; vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }
table.list tr.row-alert { background: var(--danger-soft); }
.who-cell { display: flex; align-items: center; gap: 10px; }
.who-cell .avatar { width: 34px; height: 34px; font-size: 12px; }
.who-cell b { font-size: 13.5px; display: block; }
.progress-cell { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.progress-cell .bar { flex: 1; }
.progress-cell b { font-size: 12.5px; width: 36px; }

/* modal — trên điện thoại trồi từ đáy lên như app */
.modal-wrap { position: fixed; inset: 0; background: rgba(19, 27, 36, .45); display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 50; animation: dimIn .15s ease; }
@keyframes dimIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); width: 100%; max-width: 460px; max-height: 88dvh; overflow-y: auto; padding: 22px; animation: modalIn .2s ease; }
@keyframes modalIn { from { opacity: .4; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@media (max-width: 560px) {
  .modal-wrap { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 20px 20px 0 0; padding: 22px 18px calc(20px + env(safe-area-inset-bottom)); animation: sheetIn .22s ease; }
  @keyframes sheetIn { from { transform: translateY(45%); } to { transform: none; } }
}
.modal h3 { font-size: 16px; font-weight: 800; margin-bottom: 14px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 9px; margin-top: 6px; }

/* chi tiết học viên phía coach */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

/* Trên điện thoại: chữ trong ô nhập ≥16px để iPhone không tự phóng to màn hình khi gõ */
@media (max-width: 560px) {
  .field input, .field select, .field textarea { font-size: 16px; }
}

/* mobile cho coach */
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px 12px calc(10px + env(safe-area-inset-top)) ; border-right: none; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .sidebar .logo { padding: 0 8px 0 0; }
  .sidebar .foot { margin: 0 0 0 auto; border: none; padding: 0; }
  .nav-item { width: auto; white-space: nowrap; padding: 9px 11px; }
  .nav-item .lbl { display: none; }
  .main { padding: 16px 14px 40px; }
}
