/* Dotin Academy – student ID form (mobile-first) */
:root {
    --blue: #2D7FF9;
    --blue-d: #1F66D1;
    --blue-l: #EAF2FF;
    --red: #F5413D;
    --yellow: #FFC20E;
    --teal: #1CC8C8;
    --ink: #17191c;
    --ink-2: #5b6170;
    --line: #dfe3ea;
    --bg: #f5f7fb;
    --card: #ffffff;
    --err: #d93025;
    --ok: #18a058;
    --radius: 14px;
    --bar-h: 76px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

.app {
    max-width: 560px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--card);
    display: flex;
    flex-direction: column;
}
@media (min-width: 600px) {
    body { padding: 24px 0; }
    .app { min-height: calc(100dvh - 48px); border-radius: 24px; box-shadow: 0 10px 40px rgba(20, 30, 60, .08); overflow: hidden; }
}

/* Header */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 18px 12px;
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid #eef1f5;
}
.brand { height: 34px; width: auto; display: block; }
.progress { display: flex; gap: 6px; }
.progress .dot { width: 22px; height: 6px; border-radius: 6px; background: var(--line); transition: background .25s, width .25s; }
.progress .dot.on { background: var(--blue); }
.progress .dot.cur { width: 34px; }

/* Screens */
.screen {
    flex: 1;
    padding: 22px 18px calc(var(--bar-h) + var(--safe-b) + 28px);
    animation: in .25s ease;
}
.screen.center {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; gap: 6px; padding-bottom: 60px;
}
@keyframes in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1 { font-family: "Montserrat", -apple-system, sans-serif; font-weight: 700; font-size: 24px; line-height: 1.2; margin: 4px 0 6px; letter-spacing: -.01em; }
.eyebrow { margin: 0; color: var(--blue); font-weight: 700; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.muted { color: var(--ink-2); margin: 0 0 18px; font-size: 15px; }
.center-text { text-align: center; }

/* Branch cards */
.branch-list { display: grid; gap: 12px; }
.branch {
    display: flex; align-items: center; gap: 14px;
    width: 100%; text-align: left;
    padding: 16px; border-radius: var(--radius);
    background: var(--card); border: 2px solid var(--line);
    font: inherit; color: inherit; cursor: pointer;
    transition: border-color .15s, background .15s, transform .1s;
}
.branch:active { transform: scale(.99); }
.branch .pin {
    flex: none; width: 44px; height: 44px; border-radius: 12px;
    display: grid; place-items: center;
    font-family: "Montserrat", sans-serif; font-weight: 700; font-size: 20px; color: #fff;
    background: var(--c, var(--blue));
}
.branch .txt b { display: block; font-size: 17px; }
.branch .txt small { color: var(--ink-2); font-size: 13px; }
.branch .tick {
    margin-left: auto; flex: none; width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid var(--line); display: grid; place-items: center; color: #fff; font-size: 14px;
}
.branch.on { border-color: var(--blue); background: #f6f9ff; }
.branch.on .tick { background: var(--blue); border-color: var(--blue); }
.branch.on .tick::after { content: "✓"; }

/* Form fields */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field > span em { font-style: normal; font-weight: 400; color: var(--ink-2); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 340px) { .row { grid-template-columns: 1fr; } }

input[type=text], input[type=tel], input[type=date], select, textarea {
    width: 100%;
    font: inherit; font-size: 16px; /* 16px stops iOS zooming in */
    color: var(--ink);
    background: #fff;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    padding: 13px 14px;
    min-height: 50px;
    outline: none;
    -webkit-appearance: none; appearance: none;
    transition: border-color .15s, box-shadow .15s;
}
textarea { resize: none; min-height: 76px; }
input[type=date] { display: block; text-align: left; }
input[type=date]::-webkit-date-and-time-value { text-align: left; }
select {
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235b6170' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(45, 127, 249, .15); }
.field.bad input, .field.bad select, .field.bad textarea, .field.bad .phone { border-color: var(--err); }
::placeholder { color: #a3a9b6; }

.phone {
    display: flex; align-items: center;
    border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.phone:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(45, 127, 249, .15); }
.phone b { padding: 0 4px 0 14px; color: var(--ink-2); font-weight: 600; }
.phone input { border: 0; box-shadow: none !important; padding-left: 6px; }

.error { color: var(--err); font-size: 13px; margin: 4px 0 0; min-height: 0; display: block; }
.error:empty { display: none; }
.hint { color: #9aa1ae; font-size: 12px; float: right; margin-top: 4px; }

/* Photo */
.photo-box {
    width: 220px; height: 220px; margin: 6px auto 20px;
    border-radius: 50%; overflow: hidden;
    border: 4px solid var(--yellow);
    box-shadow: 0 0 0 6px #fff, 0 0 0 8px var(--line);
    background: #f1f4f9; display: grid; place-items: center;
}
.photo-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: #9aa1ae; font-size: 14px; }
.photo-actions { display: grid; gap: 12px; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 52px; padding: 0 20px;
    font: inherit; font-weight: 700; font-size: 16px;
    border-radius: 14px; border: 0; cursor: pointer;
    transition: transform .1s, background .15s, opacity .15s;
    text-decoration: none; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-d); }
.btn-outline { background: #fff; color: var(--blue); border: 2px solid var(--blue); width: 100%; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost.light, .muted.light { color: #e8ebf0; }

/* Sticky bottom bar – always visible */
.bottombar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex; gap: 10px;
    max-width: 560px; margin: 0 auto;
    padding: 12px 16px calc(12px + var(--safe-b));
    background: rgba(255, 255, 255, .97);
    border-top: 1px solid #eef1f5;
    box-shadow: 0 -6px 24px rgba(20, 30, 60, .06);
}
.bottombar .btn-ghost { flex: 0 0 auto; min-width: 88px; }
.bottombar .btn-primary { flex: 1; }
@media (min-width: 600px) { .bottombar { bottom: 24px; border-radius: 0 0 24px 24px; } }

/* Review */
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: #eef1f6; padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.tab { font: inherit; font-weight: 600; border: 0; background: transparent; padding: 10px; border-radius: 9px; color: var(--ink-2); cursor: pointer; }
.tab.on { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.card-frame { display: flex; justify-content: center; margin-bottom: 18px; }
.card-frame canvas {
    width: min(78vw, 300px); height: auto; display: block;
    border-radius: 16px; background: #fff;
    box-shadow: 0 10px 30px rgba(20, 30, 60, .14), 0 0 0 1px #e8ecf2;
}
.confirm { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 12px; background: var(--blue-l); font-size: 14px; cursor: pointer; }
.confirm input { width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--blue); }

/* Big icons / states */
.big-icon { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-size: 38px; background: var(--blue-l); margin-bottom: 8px; }
.big-icon.ok { background: #e6f6ee; color: var(--ok); font-weight: 800; }
#screenDone .btn { margin-top: 18px; max-width: 320px; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--blue-l); border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Crop sheet (full screen) */
.crop-sheet { position: fixed; inset: 0; z-index: 50; background: #0f1115; display: flex; flex-direction: column; }
.crop-head, .crop-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px; color: #fff;
}
.crop-foot { padding: 10px 12px calc(14px + var(--safe-b)); font-size: 13px; }
.crop-head .btn { min-height: 44px; padding: 0 16px; font-size: 15px; }
.crop-area { flex: 1; min-height: 0; }
.crop-area img { display: block; max-width: 100%; }
/* round guide inside cropper */
.crop-sheet .cropper-view-box, .crop-sheet .cropper-face { border-radius: 50%; }
.crop-sheet .cropper-view-box { outline: 2px solid var(--yellow); outline-offset: -2px; }

/* Toast */
.toast {
    position: fixed; left: 50%; bottom: calc(var(--bar-h) + var(--safe-b) + 16px); z-index: 60;
    transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    background: #1d2433; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px;
    max-width: calc(100% - 32px); width: max-content; text-align: center;
    transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--err); }
