/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f0f4f8;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a202c;
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,.10);
    padding: 48px 40px;
    width: 100%;
    max-width: 500px;
}

/* ── Logo / header ─────────────────────────────────────────────────────────── */
.brand {
    text-align: center;
    margin-bottom: 32px;
}
.brand h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1a56db;
}
.brand p {
    font-size: .9rem;
    color: #6b7280;
    margin-top: 4px;
}

/* ── Login button ──────────────────────────────────────────────────────────── */
.btn-microsoft {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 20px;
    background: #fff;
    border: 2px solid #dadce0;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    color: #3c4043;
    cursor: pointer;
    text-decoration: none;
    transition: box-shadow .2s, border-color .2s;
}
.btn-microsoft:hover {
    border-color: #1a56db;
    box-shadow: 0 2px 8px rgba(26,86,219,.15);
}
.btn-microsoft svg { flex-shrink: 0; }

/* ── Form elements ─────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 22px;
}
.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 7px;
}
.req {
    color: #e02424;
    margin-left: 3px;
    font-weight: 700;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: .97rem;
    color: #111827;
    background: #f9fafb;
    transition: border-color .2s, box-shadow .2s;
    appearance: none;
}
.form-group textarea {
    resize: vertical;
    min-height: 90px;
    line-height: 1.5;
    box-sizing: border-box;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #1a56db;
    box-shadow: 0 0 0 3px rgba(26,86,219,.12);
    background: #fff;
}

/* Amount prefix */
.amount-wrap {
    position: relative;
}
.amount-wrap .prefix {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    color: #6b7280;
    pointer-events: none;
}
.amount-wrap input {
    padding-left: 48px;
}

/* Hide number input spin buttons */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* ── Payee other input ─────────────────────────────────────────────────── */
.payee-other-wrap {
    position: relative;
    margin-top: 8px;
}
.payee-other-input {
    width: 100%;
    transition: background .2s, border-color .2s, box-shadow .2s, color .2s;
}
.payee-other-input:disabled {
    background: repeating-linear-gradient(
        -45deg,
        #f3f4f6,
        #f3f4f6 6px,
        #e9eaec 6px,
        #e9eaec 12px
    );
    border-color: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
}
.payee-other-input:not(:disabled) {
    background: #fff;
    border-color: #1a56db;
    box-shadow: 0 0 0 3px rgba(26,86,219,.15);
    color: #111827;
}


/* ── File drop zone ────────────────────────────────────────────────────────── */
.drop-zone {
    border: 2px dashed #d1d5db;
    border-radius: 10px;
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    background: #f9fafb;
    position: relative;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: #1a56db;
    background: #eff6ff;
}
.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}
.drop-zone .dz-icon { font-size: 2rem; margin-bottom: 8px; }
.drop-zone .dz-label { font-size: .9rem; color: #6b7280; }
.drop-zone .dz-label strong { color: #1a56db; }
.drop-zone .dz-filename {
    margin-top: 10px;
    font-size: .85rem;
    font-weight: 600;
    color: #111827;
    word-break: break-all;
    overflow-wrap: break-word;
}

/* ── Submit button ─────────────────────────────────────────────────────────── */
.btn-submit {
    display: block;
    width: 100%;
    padding: 14px;
    background: #1a56db;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s, transform .1s;
    margin-top: 8px;
}
.btn-submit:hover  { background: #1648c0; }
.btn-submit:active { transform: scale(.98); }
.btn-submit:disabled { background: #93a5d6; cursor: not-allowed; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
    padding: 13px 16px;
    border-radius: 8px;
    font-size: .9rem;
    margin-bottom: 22px;
    word-break: break-word;
    overflow-wrap: break-word;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }

/* ── User bar ──────────────────────────────────────────────────────────────── */
.user-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    padding-bottom: 18px;
    border-bottom: 1px solid #e5e7eb;
    font-size: .85rem;
}
.user-bar .email { color: #374151; font-weight: 600; }
.user-bar .logout { color: #ef4444; text-decoration: none; font-weight: 600; }
.user-bar .logout:hover { text-decoration: underline; }

/* ── User Guide button ─────────────────────────────────────────────────────── */
.guide-btn {
    background: none;
    border: 1.5px solid #1a56db;
    color: #1a56db;
    border-radius: 6px;
    padding: 3px 10px;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, color .2s;
}
.guide-btn:hover { background: #1a56db; color: #fff; }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 1rem;
}
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    padding: 0 4px;
}
.modal-close:hover { color: #374151; }
.modal-body {
    padding: 22px;
    overflow-y: auto;
    font-size: .88rem;
    line-height: 1.65;
    color: #374151;
}
.guide-intro { margin-bottom: 16px; }
.guide-section {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 10px;
}
.guide-section strong { display: block; margin-bottom: 4px; }
.guide-section p { margin: 0; }
.guide-tag {
    display: inline-block;
    background: #1a56db;
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 4px;
    margin-bottom: 5px;
}
.guide-divider { border: none; border-top: 1px solid #e5e7eb; margin: 16px 0; }
.guide-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.guide-table tr { border-bottom: 1px solid #f3f4f6; }
.guide-table td { padding: 8px 6px; vertical-align: top; }
.guide-table td:first-child { width: 110px; font-weight: 600; color: #111827; white-space: nowrap; }
.guide-note { font-size: .82rem; color: #6b7280; }
.guide-tips {
    padding-left: 18px;
    margin: 0;
    font-size: .85rem;
    line-height: 1.7;
}
.guide-tips li { margin-bottom: 8px; }
.guide-tips a { color: #1a56db; }

/* ── Language toggle ───────────────────────────────────────────────────────── */
.lang-toggle {
    display: flex;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
}
.lang-btn {
    background: none;
    border: none;
    padding: 3px 10px;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    color: #6b7280;
    transition: background .15s, color .15s;
}
.lang-btn.active { background: #1a56db; color: #fff; }
.lang-btn:not(.active):hover { background: #f3f4f6; }

/* ── Testing mode badge ────────────────────────────────────────────────────── */
.test-badge {
    display: inline-block;
    background: #f59e0b;
    color: #fff;
    font-size: .55rem;
    font-weight: 800;
    letter-spacing: .06em;
    padding: 2px 7px;
    border-radius: 4px;
    vertical-align: middle;
    position: relative;
    top: -3px;
}

/* ── Supplier history bar ──────────────────────────────────────────────────── */
.notes-history-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    padding: 5px 10px;
    background: #eff6ff;
    border-radius: 6px;
    border: 1px solid #bfdbfe;
}
.hist-nav-btn {
    background: #1a56db;
    color: #fff;
    border: none;
    border-radius: 4px;
    width: 26px;
    height: 26px;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background .15s;
}
.hist-nav-btn:hover:not(:disabled) { background: #1648c0; }
.hist-nav-btn:disabled { background: #d1d5db; cursor: default; }
.hist-counter {
    font-size: .8rem;
    color: #1a56db;
    font-weight: 600;
    min-width: 36px;
    text-align: center;
}
.hist-label {
    font-size: .8rem;
    color: #6b7280;
    flex: 1;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 560px) {
    .card { padding: 32px 18px; }
}

/* ── Topbar layout (authenticated pages) ──────────────────────────────────── */
body.topbar-page {
    display: block;
    align-items: unset;
    justify-content: unset;
    background: #f0f4f8;
    padding: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 52px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-brand {
    font-size: 1rem;
    font-weight: 700;
    color: #1a56db;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}
.topbar-brand:hover { color: #1648c0; }

.topbar nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-email {
    font-size: .82rem;
    color: #6b7280;
    font-weight: 500;
    margin-right: 4px;
}

/* Feedback bug button in topbar */
.btn-feedback {
    background: transparent;
    border: 1.5px solid #d1d5db;
    color: #6b7280;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: border-color .15s, color .15s;
}
.btn-feedback:hover    { border-color: #1a56db; color: #1a56db; }
.btn-feedback:disabled { opacity: .5; cursor: wait; pointer-events: none; }

/* Logout button style in topbar */
.logout-btn { border-color: #fca5a5 !important; color: #dc2626 !important; }
.logout-btn:hover { background: #fef2f2 !important; }

/* Form card: add top margin since topbar is above it */
body.topbar-page .card {
    margin: 32px auto;
    max-width: 500px;
}

/* ── Feedback modal ────────────────────────────────────────────────────────── */
.fb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1100;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.fb-overlay.visible { display: flex; }
.fb-box {
    background: #fff;
    border-radius: 10px;
    width: clamp(320px, calc(100vw - 32px), 560px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.fb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.fb-title { font-size: 1rem; font-weight: 600; }
.fb-body  { padding: 18px 20px 20px; overflow-y: auto; flex: 1; }
.field { margin-bottom: 1rem; }
.field-label { font-size: .82rem; font-weight: 600; color: #374151; margin-bottom: .3rem; }
.fb-type-row { display: flex; gap: .5rem; }
.fb-type-btn {
    flex: 1;
    padding: .55rem .75rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: transparent;
    font-size: .88rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    transition: border-color .15s, background .15s, color .15s;
}
.fb-type-btn.selected             { border-color: #1a56db; background: #eff6ff; color: #1a56db; }
.fb-type-btn:hover:not(.selected) { border-color: #9ca3af; color: #111827; }
.fb-ss-wrap {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    min-height: 56px;
    max-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f6f7f9;
    cursor: zoom-in;
}
.fb-ss-wrap img { max-width: 100%; max-height: 180px; display: block; }
.fb-ss-ph { color: #6b7280; font-size: .85rem; padding: 1.2rem; text-align: center; }
.input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: .9rem;
    font-family: inherit;
    color: #111827;
    background: #f9fafb;
    transition: border-color .2s, box-shadow .2s;
    resize: vertical;
}
.input:focus { outline: none; border-color: #1a56db; box-shadow: 0 0 0 3px rgba(26,86,219,.12); background: #fff; }
.error-box { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; border-radius: 6px; padding: 9px 12px; font-size: .85rem; }
.form-actions { display: flex; gap: .5rem; }
.btn { padding: 7px 16px; border-radius: 7px; font-size: .88rem; font-weight: 600; cursor: pointer; font-family: inherit; transition: background .15s, border-color .15s; }
.btn.primary { background: #1a56db; color: #fff; border: none; }
.btn.primary:hover:not(:disabled) { background: #1648c0; }
.btn.primary:disabled { background: #93a5d6; cursor: not-allowed; }
.btn.ghost { background: #fff; color: #374151; border: 1.5px solid #d1d5db; }
.btn.ghost:hover { background: #f3f4f6; }
.guide-close-btn {
    background: none;
    border: none;
    font-size: 22px;
    color: #6b7280;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
}
.guide-close-btn:hover { color: #111827; }
