/*
 * Ukurasa wa kuingia (auth.php): muundo wa pande mbili kwa rangi za benki.
 * Kushoto: paneli ya navy yenye nembo, kazi za mfumo na mchoro mwembamba wa kifedha. Kulia: fomu safi.
 * Simu: nembo na kichwa juu, fomu chini yake. Kifaa kikiwa kwenye hali ya giza, fomu inakuwa giza pia.
 * Inachukua nafasi ya motion-login.css kwenye ukurasa huu. Maombi ya kuingia hayajaguswa.
 */
:root {
    --navy: #101b33;
    --slate: #263b5b;
    --emerald: #10b981;
    --emerald-ink: #047857;
    --ink: #101b33;
    --text: #172033;
    --text-2: #4b5669;
    --muted: #748094;
    --line: #e7ecf2;
    --line-strong: #d6dde7;
    --bg: #f5f7fa;
    --surface: #ffffff;
    --field: #ffffff;
    --primary: #101b33;
    --primary-2: #263b5b;
    --primary-soft: #eef2f7;
    --link: #047857;
    --ring: rgba(16, 185, 129, .18);
    --accent: #10b981;
    --accent-soft: #e8f8f1;
    --danger: #ef4444;
    --warn: #f59e0b;
    --ls-ease: cubic-bezier(.22, 1, .36, 1);
    --shadow-card: 0 1px 2px rgba(16, 27, 51, .04), 0 16px 40px -12px rgba(16, 27, 51, .12);
}

body {
    grid-template-columns: minmax(0, 1fr) minmax(460px, 1fr);
    background: var(--bg);
    color: var(--text);
    font-family: "DM Sans", system-ui, sans-serif;
}
.portal-header { display: none !important; }

/* ================= Paneli ya chapa ================= */
.brand-panel {
    isolation: isolate;
    padding: 40px clamp(32px, 5vw, 80px) 32px;
    color: #fff;
    background: linear-gradient(165deg, #101b33 0%, #14223f 60%, #182a4a 100%);
}
.brand-panel::before { display: none; }
.ls-art { position: absolute; right: 0; bottom: 0; z-index: -1; width: min(100%, 640px); height: auto; aspect-ratio: 1; color: #8fa6c8; pointer-events: none; }
.ls-line { stroke-dasharray: 900; stroke-dashoffset: 900; animation: ls-draw 2.2s .3s var(--ls-ease) forwards; }
@keyframes ls-draw { to { stroke-dashoffset: 0; } }

.brand img { width: 44px; height: 44px; border-radius: 12px; }
.brand-name { font-size: 17px; letter-spacing: .2px; }
.brand-tag { color: #93a3bf; letter-spacing: 1.2px; }

.brand-copy { max-width: 470px; padding: 32px 0; }
.brand-copy h1 { margin-bottom: 16px; font: 800 clamp(32px, 3.2vw, 46px)/1.12 "Manrope", sans-serif; letter-spacing: -1.4px; }
.brand-copy > p { max-width: 420px; margin-bottom: 34px; color: #b4c0d6; font-size: 15.5px; line-height: 1.7; }
.ls-points { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.ls-points li { display: flex; align-items: center; gap: 14px; color: #e6ebf4; font-size: 14.5px; font-weight: 600; }
.ls-points span { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border: 1px solid rgba(16, 185, 129, .25); border-radius: 11px; color: var(--emerald); background: rgba(16, 185, 129, .10); font-size: 15px; }
.brand-footer { gap: 8px 22px; color: #8393ae; font-size: 11.5px; }
.brand-footer i { margin-right: 6px; color: var(--emerald); }

/* ================= Upande wa fomu ================= */
.form-panel { position: relative; padding: 24px clamp(24px, 4vw, 56px) 20px; background: var(--bg); }
.topbar-link { margin: 0; color: var(--muted); }
.topbar-link a { color: var(--link); }
.form-center { padding: 20px 0; }

.auth-card {
    width: min(100%, 440px);
    padding: 36px 36px 30px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
    animation: ls-card-in .5s var(--ls-ease) both;
}
.auth-card.wide { width: min(100%, 680px); }
@keyframes ls-card-in { from { opacity: 0; transform: translateY(10px); } }

.kicker { margin-bottom: 12px; color: var(--emerald-ink); font-size: 10.5px; letter-spacing: .9px; }
#login-view .kicker { display: none; }
.auth-card h2 { margin-bottom: 6px; color: var(--text); font-size: clamp(25px, 2.4vw, 28px); letter-spacing: -.6px; }
.intro { margin-bottom: 22px; color: var(--muted); font-size: 14px; line-height: 1.6; }

/* Nafasi (Msimamizi Mkuu / Tawi) */
.segmented { margin-bottom: 20px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.segmented label { min-height: 40px; padding: 0 6px; border-radius: 9px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.segmented label:hover { color: var(--text); }
.segmented input:checked + label { color: var(--text); background: var(--surface); box-shadow: 0 1px 2px rgba(16, 27, 51, .08), 0 2px 8px rgba(16, 27, 51, .06); }
.segmented input:checked + label i { color: var(--emerald); }
.segmented label i { font-size: 12.5px; }

/* Visanduku */
label { margin-bottom: 7px; color: var(--text); font-size: 12.5px; font-weight: 700; }
.ls-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ls-label-row .text-link { font-size: 12px; }
.field { margin-bottom: 16px; }
input, select {
    height: 48px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    color: var(--text);
    background-color: var(--field);
    font: 500 14.5px "DM Sans", sans-serif;
    transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover { border-color: #c3ccd9; }
input:focus, select:focus { border-color: var(--emerald); box-shadow: 0 0 0 4px var(--ring); }
input::placeholder { color: #a3adbd; }
.input-wrap > i.lead { left: 16px; color: #9aa5b6; transition: color .15s; }
.input-wrap:focus-within > i.lead { color: var(--emerald); }
.input-wrap > i.lead ~ input, .input-wrap > i.lead ~ select { padding-left: 44px; }
.reveal { color: var(--muted); }
.reveal:hover { color: var(--text); background: var(--primary-soft); }
input:-webkit-autofill { -webkit-box-shadow: 0 0 0 40px var(--field) inset; -webkit-text-fill-color: var(--text); }

/* Nikumbuke */
.ls-remember { display: inline-flex; align-items: center; gap: 10px; margin: 0 0 18px; color: var(--text-2); font-size: 13px; font-weight: 600; cursor: pointer; user-select: none; }
.ls-remember input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ls-box { position: relative; width: 18px; height: 18px; flex: 0 0 18px; border: 1.5px solid var(--line-strong); border-radius: 5px; background: var(--field); transition: background .15s, border-color .15s; }
.ls-box::after { position: absolute; top: 2px; left: 5px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) scale(0); transition: transform .15s; content: ""; }
.ls-remember input:checked + .ls-box { border-color: var(--emerald); background: var(--emerald); }
.ls-remember input:checked + .ls-box::after { transform: rotate(45deg) scale(1); }
.ls-remember input:focus-visible + .ls-box { box-shadow: 0 0 0 4px var(--ring); }

/* Kitufe */
.primary-button {
    position: relative;
    min-height: 50px;
    margin-top: 4px;
    border-radius: 10px;
    background: var(--primary);
    box-shadow: 0 1px 2px rgba(16, 27, 51, .2), 0 8px 20px -8px rgba(16, 27, 51, .5);
    font-size: 15px;
    transition: background .15s, transform .15s, box-shadow .15s;
}
.primary-button:hover:not(:disabled) { background: var(--primary-2); transform: translateY(-1px); box-shadow: 0 1px 2px rgba(16, 27, 51, .2), 0 12px 24px -8px rgba(16, 27, 51, .55); }
.primary-button:focus-visible { outline: 0; box-shadow: 0 0 0 4px var(--ring); }
.primary-button i { color: var(--emerald); transition: transform .2s var(--ls-ease); }
.primary-button:hover:not(:disabled) i { transform: translateX(3px); }
.primary-button:disabled { opacity: .6; }
/* Inapakia: maandishi yanafichwa na duara linazunguka */
.primary-button.is-busy { color: transparent !important; opacity: 1; }
.primary-button.is-busy i { visibility: hidden; }
.primary-button.is-busy::after { position: absolute; top: 50%; left: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border: 2.5px solid rgba(255, 255, 255, .3); border-top-color: #fff; border-radius: 50%; animation: ls-spin .7s linear infinite; content: ""; }
@keyframes ls-spin { to { transform: rotate(360deg); } }

.switch-link { margin-top: 20px; color: var(--muted); }
.switch-link a, .text-link, .text-button { color: var(--link); }
.sysadmin-link { margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.sysadmin-link button { color: var(--text-2); }
.security-note { color: var(--muted); }
.ghost-button { border-color: var(--line); color: var(--text-2); background: var(--surface); }

/* Ujumbe (makosa na mafanikio) */
.message { border-radius: 10px; border-left-width: 3px; }
.message.error, .message.diagnostic { border-color: #fecaca; border-left-color: var(--danger); color: #991b1b; background: #fef2f2; }
.message.success { border-color: #bbf7d0; border-left-color: var(--emerald); color: #065f46; background: #ecfdf5; }

/* Hatua za usajili */
.stepper li.active .num { border-color: var(--navy); background: var(--navy); box-shadow: 0 0 0 4px var(--primary-soft); }
.stepper li.done .num { border-color: var(--emerald); background: var(--emerald); }
.role-card:has(input:checked) { border-color: var(--emerald); box-shadow: 0 0 0 4px var(--ring); }
.role-card:has(input:checked) .role-check { border-color: var(--emerald); background: var(--emerald); }
.role-card[data-role] .role-icon, .role-chip[data-role] .role-icon, .invite-summary .role-icon { color: var(--navy); background: var(--primary-soft); }
.role-card[data-role="branch_admin"] .role-icon, .role-chip[data-role="branch_admin"] .role-icon { color: var(--emerald-ink); background: var(--accent-soft); }
.code-panel { border-color: var(--line); background: var(--bg); }
.sent-to { color: var(--navy); }
.code-icon { color: var(--emerald-ink); background: var(--accent-soft); }

.form-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px; margin: 0; color: var(--muted); font-size: 11.5px; }
.designer-credit { padding: 5px 11px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); }
.designer-credit a { color: var(--link); font-weight: 700; text-decoration: none; }

.auth-card.ls-shake { animation: ls-shake .4s ease both; }
@keyframes ls-shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.ls-in { animation: ls-rise .4s var(--ls-ease) both; animation-delay: calc(var(--i, 0) * 35ms); }
@keyframes ls-rise { from { opacity: 0; transform: translateY(6px); } }

/* Dropdown (select-search.js) */
.mk-ss-pop { border: 1px solid var(--line) !important; border-radius: 12px !important; background: var(--surface) !important; color: var(--text) !important; box-shadow: 0 20px 44px -16px rgba(16, 27, 51, .3) !important; }
.mk-ss-list { padding: 6px !important; }
.mk-ss-list li { padding: 10px 12px !important; border-radius: 8px !important; }
.mk-ss-list li.mk-ss-active, .mk-ss-list li:not(.mk-ss-group):not(.mk-ss-empty):not([aria-disabled=true]):hover { background: var(--primary-soft) !important; }
.mk-ss-list li[aria-selected=true] { color: var(--emerald-ink) !important; }

/* ================= Laptop fupi ================= */
@media (max-height: 780px) and (min-width: 901px) {
    .auth-card { padding: 28px 32px 24px; }
    #login-view .intro { display: none; }
    #login-view h2 { margin-bottom: 18px; }
    .form-center { padding: 8px 0; }
    .form-panel { padding-top: 16px; padding-bottom: 14px; }
    .brand-copy > p { margin-bottom: 24px; }
}

/* ================= Simu na tablet ================= */
@media (max-width: 900px) {
    body { display: block; background: var(--bg); }
    .brand-panel { position: relative; height: auto; display: block; overflow: hidden; padding: 22px 20px 64px; }
    .ls-art { width: 340px; opacity: .45; }
    .brand-copy { padding: 22px 0 0; }
    .brand-copy > p, .ls-points, .brand-footer { display: none; }
    .brand-copy h1 { margin: 0; font-size: clamp(25px, 6.2vw, 34px); letter-spacing: -1px; }
    .form-panel { min-height: 0; margin-top: -40px; padding: 0 16px 20px; background: transparent; }
    .topbar { display: none; }
    .form-center { padding: 0 0 18px; }
    .auth-card { width: min(100%, 520px); padding: 26px 20px 22px; }
    .form-footer { padding-bottom: 6px; }
}
@media (max-width: 1100px) and (min-width: 901px), (max-width: 420px) {
    .segmented label { gap: 6px; font-size: 12px; }
    .segmented label i { display: none; }
}

/* ================= Hali ya giza (kufuata kifaa) ================= */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --text: #e8edf5;
        --text-2: #b6c0d0;
        --muted: #8592a8;
        --line: #22304a;
        --line-strong: #2e3e5c;
        --bg: #0b1324;
        --surface: #111c33;
        --field: #0d172b;
        --primary: #10b981;
        --primary-2: #0ea472;
        --primary-soft: rgba(255, 255, 255, .05);
        --link: #34d399;
        --shadow-card: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 30px 60px -24px rgba(0, 0, 0, .7);
    }
    .primary-button { color: #06281d; box-shadow: 0 8px 20px -8px rgba(16, 185, 129, .45); }
    .primary-button i { color: #06281d; }
    .primary-button.is-busy::after { border-color: rgba(6, 40, 29, .25); border-top-color: #06281d; }
    .segmented input:checked + label { background: var(--line); }
    input::placeholder { color: #5f6c84; }
    .input-wrap > i.lead { color: #67748c; }
    .message { border-color: var(--line); color: #c9d4e6; background: var(--field); }
    .message.error, .message.diagnostic { border-color: rgba(239, 68, 68, .3); border-left-color: var(--danger); color: #fecaca; background: rgba(239, 68, 68, .08); }
    .diagnostic-action, .diagnostic details { color: #fca5a5; }
    .message.success { border-color: rgba(16, 185, 129, .3); border-left-color: var(--emerald); color: #a7f3d0; background: rgba(16, 185, 129, .08); }
    .code-panel { background: var(--field); }
    .sent-to { color: #e8edf5; }
    .dev-code { color: #fde68a; background: rgba(245, 158, 11, .12); }
    .role-card, .role-chip, .invite-summary { border-color: var(--line); background: var(--field); box-shadow: none; }
    .role-card.is-taken { background: var(--field); }
    .role-points li { color: var(--text-2); }
    .role-status { color: #6ee7b7; background: rgba(16, 185, 129, .12); }
    .role-status.loading, .role-status.neutral { color: var(--muted); background: rgba(255, 255, 255, .05); }
    .role-card.is-taken .role-status { color: #fcd34d; background: rgba(245, 158, 11, .12); }
    .role-card[data-role] .role-icon, .role-chip[data-role] .role-icon, .invite-summary .role-icon { color: #c9d4e6; background: var(--line); }
    .role-card[data-role="branch_admin"] .role-icon, .role-chip[data-role="branch_admin"] .role-icon, .code-icon { color: #6ee7b7; background: rgba(16, 185, 129, .12); }
    .role-banner { border-color: var(--line); color: #c9d4e6; background: var(--field); }
    .stepper .num { border-color: var(--line-strong); background: var(--field); }
    .stepper li.active .num { border-color: var(--emerald); background: var(--emerald); }
    .strength span, .timeline li:not(:last-child)::after, .timeline .t-dot.next { background: var(--line); }
    .timeline .t-dot.now, .done-icon.pending { color: #fcd34d; background: rgba(245, 158, 11, .14); box-shadow: 0 0 0 6px rgba(245, 158, 11, .05); }
    .done-icon.bad { color: #fca5a5; background: rgba(239, 68, 68, .14); box-shadow: 0 0 0 6px rgba(239, 68, 68, .05); }
    .text-button:disabled { color: #4f5b72; }
    select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238592a8' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); }
    select option { color: var(--text); background: var(--surface); }
    .mk-ss-list li[aria-selected=true] { color: #6ee7b7 !important; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-card, .ls-in, .ls-line { animation: none !important; }
    .ls-line { stroke-dashoffset: 0; }
}

/* ================= login-v4: kadi moja katikati, bila paneli ya kushoto ================= */
body { display: block; grid-template-columns: none; min-height: 100vh; min-height: 100dvh; }
.brand-panel, .topbar { display: none !important; }
.form-panel {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 32px 20px 20px;
    background:
        radial-gradient(900px 420px at 50% -120px, rgba(16, 27, 51, .10), transparent 70%),
        radial-gradient(520px 260px at 50% 0, rgba(16, 185, 129, .08), transparent 70%),
        var(--bg);
}
.form-center { flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px 0 24px; }
.ls-top-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 22px; color: var(--navy); font: 800 17px/1.2 "Manrope", "DM Sans", sans-serif; letter-spacing: -.2px; }
.ls-top-brand img { width: 56px; height: 56px; padding: 6px; border: 1px solid var(--line); border-radius: 16px; background: #fff; object-fit: contain; box-shadow: 0 1px 2px rgba(16, 27, 51, .05), 0 10px 24px -12px rgba(16, 27, 51, .25); }
.auth-card { width: min(100%, 420px); padding: 32px 32px 26px; border-radius: 20px; }
.auth-card.wide { width: min(100%, 640px); }
#login-view h2 { text-align: center; font-size: 24px; }
#login-view .intro { text-align: center; margin-bottom: 22px; }
.segmented label { font-size: 12.5px; }
.ls-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.ls-chip-wrap { display: inline-flex; }
.ls-chip-wrap.is-hidden { display: none !important; }
.ls-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-2);
    font: 600 12.5px "DM Sans", sans-serif;
    text-decoration: none;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
.ls-chip i { color: var(--muted); font-size: 11.5px; }
.ls-chip:hover { border-color: var(--emerald); color: var(--text); background: var(--accent-soft); text-decoration: none; }
.ls-chip:hover i { color: var(--emerald); }
.ls-chip:focus-visible { outline: 0; box-shadow: 0 0 0 4px var(--ring); }
.form-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin: 0; color: var(--muted); font-size: 12px; text-align: center; }
@media (max-width: 520px) {
    .form-panel { padding: 20px 14px 16px; }
    .ls-top-brand { margin-bottom: 16px; }
    .ls-top-brand img { width: 48px; height: 48px; }
    .auth-card { padding: 24px 20px 20px; border-radius: 16px; }
}
@media (prefers-color-scheme: dark) {
    .form-panel { background: radial-gradient(900px 420px at 50% -120px, rgba(16, 185, 129, .08), transparent 70%), var(--bg); }
    .ls-top-brand { color: var(--text); }
    .ls-top-brand img { border-color: var(--line); }
    .ls-chip { background: var(--surface); }
}

/* ================= login-v5: mwendo mtulivu ================= */
.form-panel { position: relative; overflow: hidden; isolation: isolate; }
.form-panel::before,
.form-panel::after {
    content: "";
    position: absolute;
    z-index: -1;
    width: 520px;
    height: 520px;
    border-radius: 50%;
    filter: blur(70px);
    opacity: .5;
    pointer-events: none;
}
.form-panel::before { top: -180px; left: calc(50% - 520px); background: rgba(16, 185, 129, .28); animation: ls-drift-a 18s ease-in-out infinite alternate; }
.form-panel::after { bottom: -220px; right: calc(50% - 560px); background: rgba(38, 59, 91, .22); animation: ls-drift-b 22s ease-in-out infinite alternate; }
@keyframes ls-drift-a { to { transform: translate(140px, 90px) scale(1.15); } }
@keyframes ls-drift-b { to { transform: translate(-160px, -80px) scale(1.1); } }
.ls-top-brand { animation: ls-brand-in .7s var(--ls-ease) both; }
.ls-top-brand img { animation: ls-logo-in .8s var(--ls-ease) both, ls-float 6s ease-in-out 1s infinite; }
@keyframes ls-brand-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes ls-logo-in { from { opacity: 0; transform: scale(.7) rotate(-8deg); } }
@keyframes ls-float { 50% { transform: translateY(-4px); } }
.auth-card { animation: ls-card-in .7s .15s var(--ls-ease) both; }
.form-footer { animation: ls-brand-in .6s .6s var(--ls-ease) both; }
.primary-button { overflow: hidden; }
.primary-button::before {
    content: "";
    position: absolute;
    top: 0;
    left: -60%;
    width: 40%;
    height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .22), transparent);
    transform: skewX(-20deg);
    pointer-events: none;
}
.primary-button:hover:not(:disabled)::before { animation: ls-shine .8s ease; }
@keyframes ls-shine { to { left: 130%; } }
.segmented label { transition: color .2s, background .25s var(--ls-ease), box-shadow .25s; }
.input-wrap input:focus, .input-wrap select:focus { transform: translateY(-1px); }
.ls-chip { transition: border-color .15s, color .15s, background .15s, transform .2s var(--ls-ease); }
.ls-chip:hover { transform: translateY(-2px); }
@media (prefers-color-scheme: dark) {
    .form-panel::before { background: rgba(16, 185, 129, .18); }
    .form-panel::after { background: rgba(56, 120, 200, .16); }
}
@media (prefers-reduced-motion: reduce) {
    .form-panel::before, .form-panel::after, .ls-top-brand, .ls-top-brand img, .form-footer, .primary-button::before { animation: none !important; }
    .input-wrap input:focus, .input-wrap select:focus, .ls-chip:hover { transform: none; }
}
