:root {
    color-scheme: light;
    --navy: #14213d;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --surface: #ffffff;
    --background: #f3f6fb;
    --text: #172033;
    --muted: #64748b;
    --border: #dbe3ef;
    --danger: #b42318;
    --success: #067647;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body { margin: 0; min-height: 100%; color: var(--text); background: var(--background); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, textarea { font: inherit; }
a { color: var(--blue); }
.app-header { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .6rem; min-height: 48px; padding: .35rem max(1rem, env(safe-area-inset-left)); color: white; background: var(--navy); box-shadow: 0 2px 12px #0f172a33; }
.brand { grid-column: 1; grid-row: 1; color: white; font-size: 1rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.app-header nav { grid-column: 2; grid-row: 1; justify-self: stretch; display: flex; align-items: center; justify-content: space-around; gap: .85rem; overflow-x: auto; }
.app-header nav a, .link-button { color: white; font-size: .9rem; text-decoration: none; white-space: nowrap; }
.app-header form { margin: 0; }
.app-header .nav-active { display: inline-flex; align-items: center; min-height: 34px; padding: .35rem .7rem; border: 1px solid #93c5fd; border-radius: 8px; font-weight: 750; background: var(--blue); }
.app-header .nav-active:hover { background: var(--blue-dark); }
.app-header .link-button { min-height: 32px; }
.link-button { padding: 0; border: 0; background: transparent; cursor: pointer; }
.user-menu { position: relative; grid-column: 3; grid-row: 1; justify-self: end; min-width: 0; max-width: 280px; }
.user-menu summary { display: flex; align-items: center; gap: .4rem; min-height: 34px; padding: .35rem .3rem; font-size: .85rem; cursor: pointer; list-style: none; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; border-radius: 6px; }
.user-identifier { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-panel { position: absolute; top: 100%; right: 0; min-width: 140px; padding-top: .4rem; }
.user-menu-actions { padding: .3rem; border: 1px solid var(--border); border-radius: 10px; background: white; box-shadow: 0 8px 24px #0f172a26; }
.user-menu-link, .user-sign-out { display: block; width: 100%; min-height: 46px; padding: .7rem 1rem; border-radius: 10px; color: var(--text); background: white; font-size: 1rem; font-weight: 750; text-align: left; text-decoration: none; }
.user-menu-link:hover, .user-menu-link:focus-visible, .user-sign-out:hover, .user-sign-out:focus-visible { background: #f3f4f6; }
.user-menu-link[aria-current="page"] { color: white; background: var(--blue); }
.page-shell { width: min(760px, 100%); margin: 0 auto; padding: 1rem max(1rem, env(safe-area-inset-right)) calc(2rem + env(safe-area-inset-bottom)); }
.card { padding: clamp(1rem, 4vw, 2rem); border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: 0 10px 30px #0f172a0d; }
.auth-card { max-width: 460px; margin: 6vh auto; }
h1 { margin: 0 0 .5rem; font-size: clamp(1.65rem, 6vw, 2.25rem); line-height: 1.15; }
h2 { margin: 1.2rem 0 .75rem; font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.stack { display: grid; gap: .8rem; margin-top: 1.25rem; }
label { display: block; margin-bottom: .3rem; color: #334155; font-size: .88rem; font-weight: 700; }
input, textarea { width: 100%; min-height: 48px; padding: .72rem .8rem; border: 1px solid #b7c3d4; border-radius: 10px; color: var(--text); background: white; }
textarea { min-height: 160px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus { border-color: var(--blue); outline: 3px solid #2563eb22; }
button, .button-link { min-height: 46px; padding: .7rem 1rem; border: 0; border-radius: 10px; font-weight: 750; cursor: pointer; text-align: center; text-decoration: none; }
.primary { color: white; background: var(--blue); }
.primary:hover { background: var(--blue-dark); }
.secondary { color: #1e293b; border: 1px solid #b7c3d4; background: white; }
.compose-card .secondary, .review-card .secondary { background: #f3f4f6; }
.compose-card .secondary:hover, .review-card .secondary:hover { background: #e5e7eb; }
.compact { min-height: 36px; padding: .45rem .7rem; font-size: .86rem; }
.danger { color: white; background: var(--danger); }
.validation { color: var(--danger); font-size: .88rem; }
.validation ul { margin: .5rem 0; padding-left: 1.25rem; }
.code-input { text-align: center; font-size: 1.8rem; font-weight: 800; letter-spacing: .35em; }
.profile-company { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.input-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; padding: .3rem; border-radius: 12px; background: #edf2f8; }
.input-tab { min-height: 42px; color: #475569; background: transparent; }
.input-tab.active { color: var(--navy); background: white; box-shadow: 0 2px 8px #0f172a1a; }
.input-panel { padding-top: .4rem; }
.hidden { display: none !important; }
.file-input { padding: .55rem; }
.record-controls { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.record-help { margin-top: .8rem; padding: 1rem; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc; }
.record-help p { margin: 0; font-weight: 700; }
.record-help ol { padding-left: 1.2rem; }
.record-help li + li { margin-top: .5rem; }
#record-preview { width: 100%; margin-top: .8rem; }
.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.status-badge { padding: .35rem .6rem; border-radius: 999px; color: #475569; background: #eef2f7; font-size: .8rem; font-weight: 800; }
.status-sent { color: var(--success); background: #ecfdf3; }
.status-failed { color: var(--danger); background: #fef3f2; }
.success { margin: 1rem 0; padding: .8rem 1rem; border-radius: 10px; color: var(--success); background: #ecfdf3; }
.job-group { margin: .7rem 0; padding: 1rem; border: 1px solid var(--border); border-radius: 14px; }
.job-group legend { padding: 0 .4rem; color: var(--navy); font-weight: 850; }
.job-group > [data-remove-group] { display: block; margin: 0 0 .6rem auto; }
.origin-grid { display: grid; grid-template-columns: 1fr 82px; gap: .7rem; }
.destination-row { display: grid; grid-template-columns: 75px 1fr 1fr auto; gap: .55rem; margin-bottom: .7rem; padding: .8rem; border-radius: 12px; background: #f8fafc; }
.destination-row > button { align-self: end; min-height: 48px; }
.destination-remarks { grid-column: 1 / -1; }
.destination-remarks textarea { min-height: 80px; }
.action-bar { position: sticky; bottom: calc(.5rem + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; padding: .7rem; border: 1px solid var(--border); border-radius: 14px; background: #ffffffee; backdrop-filter: blur(10px); box-shadow: 0 8px 30px #0f172a1f; }
.action-bar-single { grid-template-columns: 1fr; }
.job-share-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .6rem; }
.job-share-actions > button { min-width: 0; padding-inline: .5rem; }
.share-button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.share-icon { width: 18px; height: 18px; }
.app-icon { width: 24px; height: 24px; }
.whatsapp-share .app-icon { color: #128c4a; }
.telegram-share .app-icon { color: #229ed9; }
.sent-job-group { margin: 1.5rem 0; }
.sent-job-group h2 { overflow-wrap: anywhere; }
.sent-jobs-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: .9rem; }
.sent-jobs-table th, .sent-jobs-table td { padding: .65rem .4rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.sent-jobs-table th { color: #334155; background: #f8fafc; }
.sent-jobs-table th:nth-child(1) { width: 32%; }
.sent-jobs-table th:nth-child(2) { width: 22%; }
.sent-jobs-table td:last-child { white-space: pre-wrap; }
.history-list, .history-page { display: grid; gap: 1rem; }
.history-list { margin-top: 1rem; }
.history-item { padding: 1rem; border: 1px solid var(--border); border-radius: 14px; }
.history-item .sent-jobs-table { table-layout: auto; }
.history-item .sent-jobs-table th:first-child { white-space: nowrap; overflow-wrap: normal; }
.history-item .sent-jobs-table th:nth-child(2), .history-item .sent-jobs-table td:nth-child(2) { white-space: nowrap; overflow-wrap: normal; }
.history-loader { padding-top: .75rem; text-align: center; }
.history-loader[hidden] { display: none; }
.copy-source { position: fixed; left: -10000px; width: 1px; height: 1px; opacity: 0; }

@media (max-width: 560px) {
    .app-header { grid-template-columns: auto minmax(0, 1fr); gap: .55rem; min-height: 64px; padding: .8rem max(1rem, env(safe-area-inset-left)); }
    .app-header .brand { font-size: 1.1rem; }
    .app-header .link-button { min-height: 46px; }
    .app-header nav { grid-column: 1 / -1; grid-row: 2; width: 100%; }
    .user-menu { grid-column: 2; max-width: 100%; }
    .page-shell { padding-top: .75rem; }
    .card { border-radius: 14px; }
    .destination-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
