/* ──────────────────────────────────────────────────────────────────────────
   Sunex Shipping Track · SaaS dashboard
   White background, soft accents, rounded corners, system font.
   ────────────────────────────────────────────────────────────────────────── */

:root {
    --bg:           #f6f7fb;
    --surface:      #ffffff;
    --surface-2:    #fafbfc;
    --border:       #e5e7eb;
    --border-soft:  #eef0f4;
    --text:         #0f172a;
    --text-muted:   #6b7280;
    --text-soft:    #94a3b8;

    --primary:      #4f46e5;
    --primary-700:  #4338ca;
    --primary-50:   #eef2ff;

    --success:      #10b981;
    --success-50:   #ecfdf5;
    --warning:      #f59e0b;
    --warning-50:   #fffbeb;
    --danger:       #ef4444;
    --danger-50:    #fef2f2;

    --shadow-sm:    0 1px 2px rgba(15,23,42,0.04), 0 1px 1px rgba(15,23,42,0.03);
    --shadow:       0 1px 2px rgba(15,23,42,0.04), 0 8px 24px rgba(15,23,42,0.06);
    --shadow-lg:    0 10px 40px rgba(15,23,42,0.10);

    --radius-sm:    8px;
    --radius:       12px;
    --radius-lg:    18px;

    --font:         ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

code {
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    background: var(--border-soft);
    padding: 1px 6px;
    border-radius: 6px;
    font-size: 0.92em;
}

/* ── Boot error ─────────────────────────────────────────────────────────── */

.boot-error {
    max-width: 560px;
    margin: 80px auto;
    padding: 28px 32px;
    background: var(--surface);
    border: 1px solid var(--danger);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.boot-error h1 { margin: 0 0 8px; font-size: 20px; color: var(--danger); }
.boot-error .muted { color: var(--text-muted); font-size: 14px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
    appearance: none;
    border: 1px solid transparent;
    background: var(--surface);
    color: var(--text);
    font: 500 14px/1 var(--font);
    padding: 10px 16px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 80ms ease, box-shadow 160ms ease, background 160ms ease, color 160ms ease;
    white-space: nowrap;
}
.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.btn:disabled { cursor: not-allowed; opacity: 0.55; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 6px 16px rgba(79,70,229,0.25);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-700); border-color: var(--primary-700); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-lg {
    padding: 14px 22px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 14px;
}

.btn[data-running="1"] {
    pointer-events: none;
    background: var(--primary-700);
}
.btn[data-running="1"] .btn-emoji {
    animation: spin 0.9s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Auth page ──────────────────────────────────────────────────────────── */

.page-auth {
    background:
        radial-gradient(800px 500px at 80% -10%, rgba(79,70,229,0.10), transparent 60%),
        radial-gradient(700px 500px at -10% 110%, rgba(16,185,129,0.08), transparent 55%),
        var(--bg);
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 36px 28px;
    box-shadow: var(--shadow-lg);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    color: var(--text);
    font-weight: 600;
}
.brand-name { font-size: 15px; letter-spacing: -0.01em; }

.auth-title {
    margin: 0 0 4px;
    font-size: 26px;
    letter-spacing: -0.02em;
    font-weight: 700;
}
.auth-sub {
    margin: 0 0 24px;
    color: var(--text-muted);
    font-size: 14px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.field input {
    appearance: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.field input::placeholder { color: var(--text-soft); }
.field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}

.auth-form .btn-primary {
    margin-top: 6px;
    justify-content: center;
    padding: 12px 16px;
    font-weight: 600;
}

.auth-foot {
    margin: 24px 0 0;
    color: var(--text-soft);
    font-size: 12px;
    text-align: center;
}

.alert {
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-error {
    background: var(--danger-50);
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ── App page ───────────────────────────────────────────────────────────── */

.page-app {
    background: var(--bg);
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    letter-spacing: -0.01em;
    font-size: 15px;
}
.brand-logo {
    height: 36px;
    width: auto;
    display: block;
    object-fit: contain;
    flex-shrink: 0;
}
.brand-logo-auth {
    height: 40px;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
    color: var(--text);
}
.user-avatar {
    width: 24px; height: 24px;
    background: var(--primary-50);
    color: var(--primary-700);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.05em;
}
.user-name {
    color: var(--text);
}

/* ── Dashboard ──────────────────────────────────────────────────────────── */

.dashboard {
    max-width: 1120px;
    margin: 0 auto;
    padding: 48px 24px 64px;
}

/* ── Tab picker ─────────────────────────────────────────────────────────── */

.tab-picker {
    margin-bottom: 28px;
    max-width: 360px;
}
.tab-picker-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.tab-picker-control {
    position: relative;
}
.tab-picker-control select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 38px 11px 14px;
    font: inherit;
    color: var(--text);
    cursor: pointer;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.tab-picker-control select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}
.tab-picker-control select:disabled {
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: not-allowed;
}
.tab-picker-caret {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-muted);
    font-size: 12px;
}
.tab-picker-error {
    margin: 8px 0 0;
    color: var(--danger);
    font-size: 13px;
}

/* ── Carrier rows (compact) ─────────────────────────────────────────────── */

.cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 720px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 200ms ease, transform 200ms ease;
}
.card:hover { box-shadow: var(--shadow); }

.carrier-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
}
.row-icon {
    width: 40px; height: 40px;
    background: var(--primary-50);
    color: var(--primary-700);
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 20px;
    flex-shrink: 0;
}
.row-title {
    margin: 0;
    font-size: 16px;
    letter-spacing: -0.005em;
    font-weight: 600;
    flex: 1;
}
.carrier-row .btn { flex-shrink: 0; }

/* ── Modal ──────────────────────────────────────────────────────────────── */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    animation: fade-in 160ms ease;
}
.modal[hidden] { display: none; }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15,23,42,0.42);
    backdrop-filter: blur(2px);
}
.modal-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px 32px 24px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    transform: translateY(0);
    animation: pop-in 180ms cubic-bezier(.2,.9,.3,1.2);
}
.modal-icon {
    font-size: 40px;
    margin: 0 auto 12px;
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--success-50);
    display: grid;
    place-items: center;
    line-height: 1;
}
.modal[data-tone="error"] .modal-icon { background: var(--danger-50); }
.modal[data-tone="warn"]  .modal-icon { background: var(--warning-50); }

.modal-title {
    margin: 0 0 8px;
    font-size: 20px;
    letter-spacing: -0.01em;
    font-weight: 700;
}
.modal-body {
    margin: 0 0 22px;
    color: var(--text-muted);
    font-size: 14.5px;
    line-height: 1.55;
}
.modal-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
}
.modal-actions .btn { min-width: 120px; justify-content: center; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 760px) {
    .topbar-inner { padding: 12px 16px; }
    .user-name { display: none; }
    .dashboard { padding: 32px 16px 48px; }
    .tab-picker { max-width: 100%; }
    .carrier-row { padding: 14px 16px; gap: 12px; }
    .row-title { font-size: 15px; }
}
