/* =========================================================================
   The Importer 168 – Worker portal (labour.importer168.com)
   Mobile-first; the layout is a single phone-width column on every screen.
   ========================================================================= */
:root {
    --navy: #2b3a67;
    --navy-2: #1f2a4d;
    --ink: #1e2742;
    --ink-2: #4b5675;
    --ink-3: #7b86a3;
    --line: rgba(43, 58, 103, .12);
    --card: rgba(255, 255, 255, .78);
    --card-solid: #fff;
    --ok: #16a34a;
    --ok-bg: #22c55e;
    --warn: #d97706;
    --danger: #dc2626;
    --accent-a: #f97316;
    --accent-b: #2f6df6;
    --radius: 18px;
    --shadow: 0 10px 30px rgba(43, 58, 103, .12), 0 1px 2px rgba(43, 58, 103, .08);
    --nav-h: 66px;
    --font: "Noto Sans Thai", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    color: var(--ink);
    min-height: 100dvh;
    background: #d6e4fb;
    background-image:
        radial-gradient(120% 90% at 0% 0%, #cfe6ff 0%, rgba(207, 230, 255, 0) 60%),
        radial-gradient(100% 80% at 100% 100%, #f7d2f3 0%, rgba(247, 210, 243, 0) 60%),
        linear-gradient(160deg, #cfe3fb 0%, #dadcff 50%, #f3d6f5 100%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--navy); }
img { max-width: 100%; }
.ico { width: 1.2em; height: 1.2em; flex: none; vertical-align: -0.25em; }

/* ---------------------------------------------------------------- background art */
.bg-art { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; color: var(--navy); }
.art { position: absolute; opacity: .10; }
.art-passport { width: 190px; height: 250px; top: -40px; left: -70px; transform: rotate(-22deg); opacity: .14; }
.art-plane { width: 160px; height: 160px; top: 110px; right: -30px; transform: rotate(-12deg); }
.art-plane-2 { width: 230px; height: 230px; bottom: -60px; right: -40px; transform: rotate(8deg); opacity: .12; }
.art-route { width: 240px; height: 240px; bottom: 40px; left: -90px; }
@media (min-width: 720px) {
    .art-passport { left: calc(50% - 400px); }
    .art-plane { right: calc(50% - 360px); }
    .art-plane-2 { right: calc(50% - 420px); }
    .art-route { left: calc(50% - 420px); }
}

/* ---------------------------------------------------------------- shell */
.phone {
    position: relative; z-index: 1;
    max-width: 440px; margin: 0 auto; min-height: 100dvh;
    display: flex; flex-direction: column;
}
.screen { flex: 1; padding: 14px 16px calc(var(--nav-h) + 24px); }
.screen-login { padding: 24px 22px 32px; justify-content: center; display: flex; flex-direction: column; }
.is-login .screen { padding-bottom: 32px; }

/* ---------------------------------------------------------------- top bar */
.topbar {
    position: sticky; top: 0; z-index: 5;
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px 10px;
    padding-top: calc(12px + env(safe-area-inset-top));
    background: linear-gradient(to bottom, rgba(214, 228, 251, .95), rgba(214, 228, 251, .75));
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; flex: 1; }
.brand img { width: 38px; height: 38px; border-radius: 10px; background: #fff; padding: 3px; box-shadow: var(--shadow); }
.brand b { display: block; font-size: .95rem; line-height: 1.2; color: var(--navy); }
.brand small { display: block; font-size: .75rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px; }
.bell { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--navy); background: rgba(255, 255, 255, .6); text-decoration: none; }
.bell .ico { width: 22px; height: 22px; }
.bell .dot { position: absolute; top: 3px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center; }

/* ---------------------------------------------------------------- cards */
.card {
    background: var(--card);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    margin-bottom: 14px;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.card-head > div { min-width: 0; flex: 1; }
.card-head b { display: block; font-size: 1.12rem; line-height: 1.15; color: var(--ink); }
.card-head small { display: block; font-size: .9rem; color: var(--ink-2); }
.card-head .big { display: block; font-size: 1.25rem; font-weight: 600; letter-spacing: .02em; color: var(--ink); font-family: "Inter", var(--font); }
.card-head .head-right { color: var(--navy); width: 22px; height: 22px; align-self: flex-start; }
.card-icon {
    width: 50px; height: 50px; border-radius: 13px; flex: none;
    display: grid; place-items: center; background: #fff; box-shadow: 0 2px 10px rgba(43, 58, 103, .12);
}
.card-icon .ico { width: 28px; height: 28px; }
.tone-navy { color: var(--navy); }
.tone-warn { color: var(--warn); }
.tone-ok { color: var(--ok); }
.tone-danger { color: var(--danger); }
.tone-muted { color: var(--ink-3); }

/* identity card (screen 2) */
.card-identity { padding-top: 22px; }
.identity-icon { width: 76px; height: 76px; margin: -4px auto 12px; border-radius: 18px; border: 2.5px solid var(--navy); display: grid; place-items: center; color: var(--navy); background: rgba(255, 255, 255, .5); }
.identity-icon .ico { width: 44px; height: 44px; stroke-width: 1.6; }
.identity-icon.tone-warn { border-color: var(--warn); color: var(--warn); }
.field { margin-bottom: 10px; }
.field .label { font-size: .95rem; color: var(--ink-2); margin-bottom: 3px; }
.field .value {
    background: #fff; border-radius: 10px; padding: 10px 12px; font-weight: 500;
    box-shadow: inset 0 0 0 1px var(--line);
}
.field .value-name { font-size: 1.08rem; font-weight: 600; display: flex; align-items: center; gap: 8px; font-family: "Inter", var(--font); }
.field-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field-inline .label { margin: 0; }
.label .th, .label.th { font-weight: 600; color: var(--ink); }
.value-name.center { justify-content: center; font-size: 1.2rem; font-weight: 700; font-family: "Inter", var(--font); }
.status-th { font-weight: 500; }

.pill { display: inline-block; padding: 4px 14px; border-radius: 8px; color: #fff; font-weight: 600; font-size: .95rem; line-height: 1.3; }
.pill-ok { background: var(--ok-bg); }
.pill-danger { background: var(--danger); }

/* document cards (screen 3/4) */
.row-label { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 1.02rem; margin: 6px 0; }
.row-label small { display: block; font-size: .95rem; color: var(--ink-2); font-weight: 500; }
.row-label .val { font-size: 1.12rem; font-weight: 600; font-family: "Inter", var(--font); }
.remain-block { margin-top: 8px; }
.remain-label { display: block; color: var(--ink-2); font-size: .98rem; }

.remaining { display: inline-flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-weight: 700; }
.remaining .num { font-family: "Inter", var(--font); font-weight: 800; letter-spacing: -.01em; }
.remaining-lg .num { font-size: 2.1rem; line-height: 1.1; }
.remaining-lg .unit { font-size: 1.25rem; }
.remaining-sm .num { font-size: 1.15rem; }
.remaining-sm .unit { font-size: .95rem; }
.remaining .sub { width: 100%; font-size: .78rem; font-weight: 600; opacity: .9; }
.remaining.tone-ok { color: var(--ok); }
.remaining.tone-warn { color: var(--warn); }
.remaining.tone-danger { color: var(--danger); }
.remaining.tone-muted { color: var(--ink-3); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 4px 0 0; align-items: baseline; }
.kv dt { font-weight: 500; color: var(--ink); font-size: .98rem; line-height: 1.2; }
.kv dt small { display: block; font-size: .9rem; color: var(--ink-2); font-weight: 400; }
.kv dd { margin: 0; text-align: right; font-size: 1.08rem; font-weight: 600; font-family: "Inter", var(--font); word-break: break-word; }
.kv dd .muted { font-weight: 400; font-size: .85rem; }

.two-col { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.two-col .label { font-size: .98rem; color: var(--ink-2); }
.two-col .val-lg { font-size: 1.15rem; font-weight: 600; font-family: "Inter", var(--font); }
.text-end { text-align: right; }

.status-pair { display: flex; gap: 14px; margin: 6px 0 2px; }
.status-pair .opt { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: .98rem; line-height: 1.15; }
.status-pair .opt .ico { width: 30px; height: 30px; stroke-width: 1.8; }
.status-pair .opt small { display: block; font-size: .85rem; }
.status-pair .opt.on-ok { color: var(--ok); font-weight: 600; }
.status-pair .opt.on-danger { color: var(--danger); font-weight: 600; }
.addr { font-size: .98rem; }
.addr.en { color: var(--ink-2); font-size: .92rem; }

.card-download .btn { margin-top: 2px; }
.btn .count { background: rgba(255, 255, 255, .3); border-radius: 999px; padding: 0 9px; font-size: .85rem; margin-left: 6px; }

/* alerts */
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); align-items: center; }
.alert-list li:first-child { border-top: 0; }
.alert-list .name { font-weight: 600; }
.alert-list .name small { display: block; font-weight: 400; color: var(--ink-2); }
.alert-list .when { text-align: right; font-weight: 600; font-size: .92rem; }
.alert-list .when small { display: block; font-weight: 400; color: var(--ink-2); }
.alert-list .level-warning .when { color: var(--warn); }
.alert-list .level-critical .when, .alert-list .level-expired .when { color: var(--danger); }

/* documents list */
.doc-list { list-style: none; margin: 6px 0 0; padding: 0; }
.doc-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.doc-list li:first-child { border-top: 0; }
.doc-no { width: 22px; color: var(--ink-3); font-size: .85rem; text-align: center; flex: none; }
.doc-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; background: #fff; }
.doc-icon .ico { width: 22px; height: 22px; }
.doc-icon.is-pdf { color: var(--danger); }
.doc-icon.is-img { color: var(--accent-b); }
.doc-meta { flex: 1; min-width: 0; }
.doc-meta b { display: block; font-size: 1rem; line-height: 1.2; }
.doc-meta small { display: block; color: var(--ink-2); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; padding: 24px 0 10px; color: var(--ink-2); }
.empty .ico { width: 48px; height: 48px; color: var(--ink-3); }

/* ---------------------------------------------------------------- buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 18px; border-radius: 14px; border: 0; cursor: pointer;
    font: inherit; font-weight: 600; font-size: 1rem; text-decoration: none;
    transition: transform .08s, filter .15s, box-shadow .15s;
}
.btn:active { transform: scale(.98); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; border-radius: 10px; font-size: .9rem; }
.btn-primary { background: var(--navy); color: #fff; box-shadow: 0 8px 20px rgba(43, 58, 103, .28); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-accent { background: linear-gradient(90deg, var(--accent-a) 0%, var(--accent-b) 100%); color: #fff; box-shadow: 0 8px 20px rgba(47, 109, 246, .28); }
.btn-accent:hover { filter: brightness(1.06); }
.btn-outline { background: rgba(255, 255, 255, .7); color: var(--danger); border: 1.5px solid rgba(220, 38, 38, .35); }
.btn[disabled], .btn.is-loading { opacity: .7; pointer-events: none; }

/* ---------------------------------------------------------------- login */
.login-hero { text-align: center; margin: 6vh 0 22px; }
.login-badge { width: 92px; height: 92px; margin: 0 auto 10px; border-radius: 22px; border: 3px solid var(--navy); color: var(--navy); display: grid; place-items: center; background: rgba(255, 255, 255, .45); }
.login-badge .ico { width: 56px; height: 56px; stroke-width: 1.5; }
.login-hero h1 { margin: 0; font-size: 2.6rem; font-weight: 800; color: var(--navy); letter-spacing: -.01em; font-family: "Inter", var(--font); }
.login-sub { margin: 4px 0 0; color: var(--ink-2); font-size: .95rem; line-height: 1.4; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.pill-input {
    display: flex; align-items: center; gap: 10px;
    background: #fff; border-radius: 16px; padding: 0 14px; height: 56px;
    box-shadow: 0 8px 22px rgba(43, 58, 103, .14); border: 1.5px solid transparent;
    color: var(--navy);
}
.pill-input:focus-within { border-color: var(--navy); }
.pill-input.is-invalid { border-color: var(--danger); }
.pill-input .ico { width: 22px; height: 22px; }
.pill-input input {
    flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
    font: inherit; font-size: 1.05rem; color: var(--ink); height: 100%;
}
.pill-input input::placeholder { color: #8e97b3; }
.pill-input .eye { border: 0; background: none; padding: 6px; margin-right: -6px; color: var(--navy); cursor: pointer; display: grid; place-items: center; }
.pill-input .eye .icon-eye { display: none; }
.pill-input .eye.is-on .icon-eye { display: block; }
.pill-input .eye.is-on .icon-eye-off { display: none; }
.form-error { display: flex; gap: 8px; align-items: flex-start; background: rgba(220, 38, 38, .1); color: #991b1b; border-radius: 12px; padding: 10px 12px; font-size: .92rem; }
.form-error .ico { margin-top: 2px; }
.login-hint { color: var(--ink); font-size: 1rem; line-height: 1.7; padding: 4px 4px 0; }
.login-hint .en { color: var(--ink-2); font-size: .9rem; }
.login-foot { text-align: center; color: var(--ink-3); font-size: .78rem; margin: 26px 0 0; }

/* ---------------------------------------------------------------- bottom nav */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    max-width: 440px; margin: 0 auto;
    display: grid; grid-template-columns: repeat(3, 1fr);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -8px 24px rgba(43, 58, 103, .08);
}
.bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 9px 4px 7px; text-decoration: none; color: var(--ink-3); font-size: .8rem; line-height: 1.1; text-align: center;
}
.bottom-nav a small { font-size: .68rem; color: inherit; opacity: .8; }
.bottom-nav a .ico { width: 24px; height: 24px; }
.bottom-nav a.active { color: var(--navy); font-weight: 600; }
.bottom-nav a.active .ico { stroke-width: 2.4; }

/* ---------------------------------------------------------------- flash */
.flash { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; margin-bottom: 12px; font-size: .92rem; background: #fff; box-shadow: var(--shadow); }
.flash .ico { margin-top: 2px; }
.flash-ok { color: #166534; background: #ecfdf5; }
.flash-danger { color: #991b1b; background: #fef2f2; }
.flash-info { color: var(--navy-2); background: #eef2ff; }

/* ---------------------------------------------------------------- misc */
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.center { text-align: center; }
.mt { margin-top: 12px; }
.mt-sm { margin-top: 6px; }
.updated { text-align: center; color: var(--ink-3); font-size: .78rem; margin: 4px 0 0; }
.logout-form { margin-top: 6px; }
h2 { color: var(--navy); margin: 8px 0 4px; }
.card.center { padding: 28px 20px; }

/* skeleton shimmer while navigating */
.is-navigating .card { position: relative; }
.page-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: linear-gradient(90deg, var(--accent-a), var(--accent-b)); z-index: 50; transition: width .3s ease; opacity: 0; }
.page-progress.on { opacity: 1; width: 80%; }
.page-progress.done { width: 100%; opacity: 0; transition: width .2s, opacity .4s .2s; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .bg-art, .bottom-nav, .topbar { display: none; } .card { break-inside: avoid; } }
