/* ===== Portal — โรงพยาบาลเชียงใหม่ ฮอสพิทอล ===== */
.portal-body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(980px 520px at -12% -22%, #c9dcf6 0%, transparent 58%),
        radial-gradient(760px 420px at 112% -8%, #f4d5dd 0%, transparent 50%),
        radial-gradient(720px 400px at 78% 118%, #d5e6f8 0%, transparent 55%),
        linear-gradient(180deg, #eef3fa 0%, #e6eef8 100%);
}

.portal-top {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px 28px;
    background: rgba(255, 255, 255, .9);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(23, 70, 155, .08);
    box-shadow: 0 10px 28px rgba(23, 70, 155, .06);
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.portal-brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(23, 70, 155, .1);
    box-shadow: 0 6px 16px rgba(23, 70, 155, .1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.portal-brand img,
.portal-brand-mark img {
    width: 34px;
    height: auto;
    display: block;
}

.portal-kicker {
    font-size: 12px;
    font-weight: 650;
    color: var(--ink-faint);
    letter-spacing: .01em;
}

.portal-title {
    font-size: 17px;
    font-weight: 750;
    letter-spacing: -.02em;
    line-height: 1.3;
    color: var(--primary);
}

.portal-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.portal-user-name { font-weight: 700; line-height: 1.2; font-size: 13.5px; }
.portal-user-role { font-size: 12px; color: var(--ink-faint); }

.portal-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 650;
}

.portal-logout:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-tint);
}

.portal-main {
    width: min(1180px, calc(100% - 40px));
    margin: 32px auto 28px;
    flex: 1;
}

.portal-main-wide {
    width: min(980px, calc(100% - 40px));
}

.portal-intro {
    margin: 0 0 22px;
}

.portal-intro-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.portal-kicker-page {
    margin: 0 0 4px;
    font-size: 12px;
    font-weight: 750;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--primary);
}

.portal-intro h1 {
    margin: 0 0 6px;
    font-size: 30px;
    font-weight: 750;
    letter-spacing: -.04em;
    color: var(--ink);
}

.portal-intro p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 14.5px;
    line-height: 1.55;
    word-break: keep-all;
}

.portal-me {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 8px 10px;
    background: #fff;
    border: 1px solid rgba(23, 70, 155, .08);
    border-radius: 999px;
    box-shadow: 0 10px 24px rgba(23, 70, 155, .08);
}

.portal-me .avatar {
    width: 42px;
    height: 42px;
    font-size: 15px;
    border-radius: 50%;
    flex-shrink: 0;
}

.portal-me-text { min-width: 0; padding-right: 4px; }

.portal-profile-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 16px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 6px 14px rgba(23, 70, 155, .28);
}

.portal-profile-btn:hover {
    background: var(--primary-hover);
    color: #fff;
}

.portal-profile-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.portal-lead {
    margin: 0 0 22px;
    color: var(--ink-soft);
    font-size: 14.5px;
}

.portal-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.portal-card {
    --app: var(--primary);
    --app-tint: var(--primary-tint);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-height: 248px;
    padding: 22px 22px 18px;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--app-tint) 72%, #fff) 0%, #fff 42%);
    border: 1px solid rgba(23, 70, 155, .08);
    border-radius: 24px;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 12px 32px rgba(23, 70, 155, .08);
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.portal-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    background: var(--app);
}

.portal-card:hover,
.portal-card:focus-visible {
    transform: translateY(-5px);
    box-shadow: 0 22px 44px color-mix(in srgb, var(--app) 22%, rgba(23, 70, 155, .08));
    border-color: color-mix(in srgb, var(--app) 38%, #fff);
    color: inherit;
    outline: none;
}

.portal-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 4px 0 6px;
}

.portal-card-ico {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    background: #fff;
    color: var(--app);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 18px color-mix(in srgb, var(--app) 18%, transparent);
    border: 1px solid color-mix(in srgb, var(--app) 14%, #fff);
}

.portal-card-ico svg { width: 26px; height: 26px; display: block; }

.portal-card-name {
    font-size: 17.5px;
    font-weight: 750;
    letter-spacing: -.03em;
    line-height: 1.3;
    color: var(--ink);
    white-space: nowrap;
}

.portal-card-desc {
    color: var(--ink-soft);
    font-size: 13.5px;
    line-height: 1.55;
    min-height: 2.9em;
    flex: 1;
    word-break: keep-all;
}

.portal-card-foot {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 4px;
}

.portal-card-go {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 44px;
    border-radius: 999px;
    background: var(--app);
    color: #fff;
    font-weight: 700;
    font-size: 14.5px;
    box-shadow: 0 10px 20px color-mix(in srgb, var(--app) 34%, transparent);
    transition: transform .16s ease, filter .16s ease;
}

.portal-card-go svg {
    width: 16px;
    height: 16px;
    transition: transform .16s ease;
}

.portal-card:hover .portal-card-go {
    filter: brightness(1.06);
}

.portal-card:hover .portal-card-go svg {
    transform: translateX(3px);
}

.portal-card-hint {
    font-size: 12px;
    color: var(--ink-faint);
    line-height: 1.45;
    width: 100%;
}

.portal-foot {
    margin: auto 0 0;
    padding: 18px 20px 28px;
    text-align: center;
    font-size: 12.5px;
    color: var(--ink-faint);
}

.profile-layout {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 20px;
    align-items: stretch;
}

.profile-layout > .card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.id-card {
    text-align: center;
    padding: 32px 22px 22px;
    flex: 1;
    background: linear-gradient(180deg, #E8EEF7 0%, #fff 42%);
}
.id-avatar {
    width: 148px; height: 148px; border-radius: 50%; margin: 0 auto;
    background: linear-gradient(140deg, #2A62BE, #17469B); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 52px; font-weight: 700;
    box-shadow: 0 10px 24px rgba(23,70,155,.28);
    position: relative;
    overflow: hidden;
}
.id-avatar.has-photo { font-size: 0; }
.id-avatar.has-photo img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.id-avatar-wrap { position: relative; display: inline-block; margin-bottom: 16px; cursor: pointer; }
.id-avatar-wrap input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.id-avatar-edit {
    position: absolute; right: 6px; bottom: 6px;
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 10px rgba(23,70,155,.3);
    pointer-events: none;
}
.id-avatar-edit svg { width: 16px; height: 16px; }
.id-name { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.id-pos { font-size: 13.5px; color: var(--ink-soft); margin-top: 4px; }
.id-photo-actions { margin-top: 10px; }
.id-photo-actions .btn { font-size: 12.5px; }

.profile-layout .summary-row {
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
}
.profile-layout .summary-key { width: 64px; flex: 0 0 64px; }
.profile-layout .summary-val {
    text-align: left;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: keep-all;
}
.profile-layout .summary-row.is-serve .summary-val {
    font-size: 12.5px;
    letter-spacing: -.01em;
}

.portal-tg-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.portal-tg-card {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 650;
    background: var(--surface-soft, #f5f8fc);
}
.portal-tg-card:hover { border-color: var(--primary); color: var(--primary); }

/* Login */
.pl-login {
    min-height: 100vh;
    margin: 0;
    display: grid;
    place-items: center;
    padding: 28px 18px;
    background:
        radial-gradient(900px 460px at 0% -10%, #c9dbf5 0%, transparent 58%),
        radial-gradient(760px 420px at 100% 0%, #f6d6dc 0%, transparent 55%),
        #e8eef7;
}

.pl-login-shell {
    width: min(980px, 100%);
    display: grid;
    grid-template-columns: 1fr 1.05fr;
    background: #fff;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 28px 80px rgba(23, 70, 155, .16);
}
.pl-login-shell.shake { animation: shake .35s ease; }

.pl-login-brand {
    padding: 44px 40px;
    color: #fff;
    background:
        radial-gradient(520px 280px at 110% -10%, rgba(255,255,255,.16), transparent 60%),
        linear-gradient(165deg, #2156B3 0%, #17469B 55%, #113A83 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
}

.pl-login-logo {
    width: 88px;
    height: 88px;
    border-radius: 22px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 22px rgba(0, 0, 0, .16);
}

.pl-login-logo img {
    width: 68px;
    height: auto;
    display: block;
}

.pl-login-brand h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 750;
    letter-spacing: -.03em;
    line-height: 1.3;
}

.pl-login-brand p {
    margin: 0;
    font-size: 14.5px;
    line-height: 1.6;
    color: rgba(255,255,255,.86);
}

.pl-login-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.pl-login-pills span {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.2);
    font-size: 12.5px;
    font-weight: 650;
}

.pl-login-panel {
    padding: 42px 40px;
}

.pl-login-panel .auth-kicker {
    margin: 0 0 6px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: .04em;
}

.pl-login-panel .auth-title { margin: 0 0 6px; }
.pl-login-panel .auth-sub { margin: 0 0 22px; }

@media (max-width: 1080px) {
    .portal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    .profile-layout { grid-template-columns: 1fr; }
    .portal-tg-grid { grid-template-columns: 1fr; }
    .portal-grid { grid-template-columns: 1fr; }
    .portal-card { min-height: 0; }
    .pl-login-shell { grid-template-columns: 1fr; }
    .pl-login-brand { padding: 28px 24px; }
    .pl-login-panel { padding: 28px 24px; }
}

@media (max-width: 700px) {
    .portal-top { padding: 12px 16px; }
    .portal-title { font-size: 15.5px; }
    .portal-intro h1 { font-size: 24px; }
    .portal-me { width: 100%; }
    .portal-main { margin-top: 22px; width: min(1180px, calc(100% - 28px)); }
    .portal-brand-mark { width: 42px; height: 42px; border-radius: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .portal-card,
    .portal-card-go,
    .portal-card-go svg {
        transition: none;
    }
    .portal-card:hover { transform: none; }
}
