/* ═══════════════════════════════════════════════════════════
   MAGO LOGBOOK — Mobile-First App CSS
   Optimised for iPhone 17 Pro in direct sunlight.
   Design: maritime-premium, Apple clarity, high contrast.
   ═══════════════════════════════════════════════════════════ */

/* ─── Custom properties ──────────────────────────────────── */
:root {
    /* MB brand palette */
    --c-navy:       #10263A;
    --c-navy-mid:   #1B3A4B;
    --c-navy-light: #2C5F7C;
    --c-slate:      #2E4A61;   /* was #617082 — lifted for sunlight contrast */
    --c-muted:      #4D6679;   /* was #8B9DAD — nav inactive text */
    --c-fog:        #6A8799;   /* was #B8CDD6 — placeholder text */

    /* MB accent — signature orange */
    --c-accent:     #FF6A1A;
    --c-accent-dark:#E05510;

    /* Backgrounds — MB exact */
    --c-bg:         #C8D5E0;   /* was #E8ECF2 — darker so white cards pop in sunlight */
    --c-surface:    #FFFFFF;
    --c-surface-2:  #E4EAF2;   /* was #F0F3F7 */
    --c-border:     rgba(16,38,58,0.22);  /* was 0.12 — stronger borders */

    /* Text — MB exact */
    --c-text-1:     #09131D;
    --c-text-2:     #1A2D3F;   /* was #243140 — slightly darker */
    --c-text-3:     #2E4A61;   /* was #617082 — matches new slate */

    /* Semantic */
    --c-green:      #1A7F4B;
    --c-green-bg:   #D4EDDA;
    --c-yellow:     #856404;
    --c-yellow-bg:  #FFF3CD;
    --c-red:        #C0392B;
    --c-red-bg:     #F8D7DA;
    --c-sos:        #C0392B;

    /* Sizing — generous for one-hand touch */
    --tap-min:      52px;
    --radius-sm:    8px;
    --radius-md:    12px;
    --radius-lg:    18px;
    --radius-pill:  100px;

    /* Shadows — slightly stronger for outdoor readability */
    --shadow-sm:    0 1px 4px rgba(16,38,58,.14);
    --shadow-md:    0 4px 16px rgba(16,38,58,.20);
    --shadow-lg:    0 8px 32px rgba(16,38,58,.28);

    /* Nav height — must match JS offsets */
    --nav-h:        72px;
    --header-h:     60px;
}

/* ─── Reset & base (scoped to app) ──────────────────────── */
.mago-app *, .mago-app *::before, .mago-app *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ─── Hide WP chrome when logbook is open ────────────────── */
.has-mago-app .site-header,
.has-mago-app .mobile-cta-bar,
.has-mago-app .scroll-progress,
.has-mago-app .skip-link,
.has-mago-app .back-to-home,
.has-mago-app .site-footer { display: none !important; }

.has-mago-app body,
.has-mago-app #main-content { overflow: hidden; }

/* ─── App container — full-screen overlay ────────────────── */
.mago-app {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 640px;
    height: 100svh;
    height: 100dvh;
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--c-text-1);
    background: var(--c-bg);
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

/* Account for WP admin bar when logged in */
.admin-bar .mago-app {
    top: 46px;
    height: calc(100svh - 46px);
    height: calc(100dvh - 46px);
}
@media screen and (min-width: 601px) {
    .admin-bar .mago-app { top: 32px; height: calc(100svh - 32px); height: calc(100dvh - 32px); }
}

/* ─── Header — white, maritime brand ────────────────────── */
.mago-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    min-height: var(--header-h);
    background: var(--c-navy);
    z-index: 100;
    flex-shrink: 0;
    border-bottom: 2px solid var(--c-accent);
}

.mago-header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
}

.mago-header-brand-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.mago-header-boat-svg {
    width: 38px;
    height: 24px;
    color: var(--c-accent);
    flex-shrink: 0;
}

.mago-wordmark {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: #fff;
    line-height: 1;
}

.mago-header-sub {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: rgba(255,255,255,.55);
    text-transform: uppercase;
    line-height: 1;
}

/* ─── Active trip strip ──────────────────────────────────── */
.mago-active-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--c-navy);
    color: rgba(255,255,255,.9);
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0;
}

.mago-active-strip[hidden] { display: none; }

.mago-active-open-btn {
    margin-left: auto;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.2);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    cursor: pointer;
}

/* SOS button — always visible, large, red */
.mago-sos-btn {
    min-width: var(--tap-min);
    min-height: var(--tap-min);
    padding: 0 18px;
    background: var(--c-sos);
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    font-family: inherit;
    letter-spacing: 0.1em;
    border: 2px solid rgba(255,255,255,.25);
    border-radius: var(--radius-pill);
    cursor: pointer;
    box-shadow: 0 0 0 3px rgba(192,57,43,.4), var(--shadow-sm);
    transition: transform .1s, box-shadow .1s;
    flex-shrink: 0;
}
.mago-sos-btn:active { transform: scale(.95); }

/* Active trip bar */
.mago-active-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    background: rgba(255,255,255,.08);
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: 13px;
    color: rgba(255,255,255,.85);
    font-weight: 500;
}

.mago-active-pulse {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #2ECC71;
    box-shadow: 0 0 0 3px rgba(46,204,113,.3);
    animation: pulse 1.5s infinite;
    flex-shrink: 0;
}
@keyframes pulse {
    0%,100% { box-shadow: 0 0 0 3px rgba(46,204,113,.3); }
    50%      { box-shadow: 0 0 0 6px rgba(46,204,113,.1); }
}

.mago-active-timer {
    margin-left: auto;
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #fff;
}

/* ─── Main content ───────────────────────────────────────── */
.mago-main {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 0 24px;
    overscroll-behavior: contain;
}

/* ─── Screens ────────────────────────────────────────────── */
.mago-screen { }

/* Ensure hidden screens stay invisible regardless of theme CSS */
.mago-screen[hidden] { display: none !important; }

/* Non-dashboard screens get standard 16px padding */
#screen-trip,
#screen-checklists,
#screen-inventory,
#screen-archive,
#screen-maintenance,
#screen-documents,
#screen-emergency,
#screen-more { padding: 16px 16px 24px; }

/* ─── Bottom tab navigation ──────────────────────────────── */
.mago-tab-nav {
    flex-shrink: 0;
    height: var(--nav-h);
    background: var(--c-surface);
    border-top: 1.5px solid var(--c-border);
    display: flex;
    align-items: stretch;
    box-shadow: 0 -2px 12px rgba(13,34,51,.14);
    padding-bottom: env(safe-area-inset-bottom, 0);
    position: relative;
    z-index: 10;
}

.mago-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--c-muted);
    font-family: inherit;
    font-size: 10px;
    font-weight: 500;
    transition: color .15s;
    min-height: var(--tap-min);
    padding: 6px 4px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    pointer-events: auto;
    position: relative;
    -webkit-user-select: none;
    user-select: none;
}

.mago-nav-btn.active {
    color: var(--c-navy);
}

.mago-nav-btn.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    background: var(--c-navy);
    border-radius: 0 0 3px 3px;
}

.mago-nav-icon {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ─── Stats row ──────────────────────────────────────────── */
.mago-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.mago-stat-card {
    background: var(--c-surface);
    border-radius: var(--radius-md);
    padding: 14px 8px;
    text-align: center;
    border: 1px solid var(--c-border);
    box-shadow: var(--shadow-sm);
}

.mago-stat-card-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--c-navy-mid);
    line-height: 1;
}

.mago-stat-card-unit {
    font-size: 12px;
    font-weight: 500;
    color: var(--c-slate);
}

.mago-stat-card-label {
    font-size: 10px;
    color: var(--c-text-3);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-top: 4px;
}

/* ─── Section title ──────────────────────────────────────── */
.mago-section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--c-text-3);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin: 20px 0 10px;
}

/* ─── Cards / surfaces ───────────────────────────────────── */
.mago-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.mago-card + .mago-card { margin-top: 10px; }

.mago-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mago-card-body {
    padding: 0 16px 16px;
    border-top: 1px solid var(--c-border);
}

/* ─── Alert list ─────────────────────────────────────────── */
.mago-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
}

.mago-alert-warn { background: var(--c-yellow-bg); color: var(--c-yellow); border: 1px solid #f0c040; }
.mago-alert-danger { background: var(--c-red-bg); color: var(--c-red); border: 1px solid #e57373; }

/* ─── Buttons ────────────────────────────────────────────── */
.mago-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--tap-min);
    padding: 0 24px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform .1s, box-shadow .1s, opacity .15s;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}

.mago-btn:active { transform: scale(.97); }

.mago-btn-primary {
    background: var(--c-navy);
    color: #fff;
    box-shadow: 0 3px 10px rgba(16,38,58,.3);
}
.mago-btn-primary:hover { background: var(--c-navy-mid); }

.mago-btn-danger {
    background: var(--c-red);
    color: #fff;
    box-shadow: 0 3px 10px rgba(192,57,43,.35);
}

.mago-btn-ghost {
    background: var(--c-surface-2);
    color: var(--c-text-2);
    border: 1px solid var(--c-border);
}

.mago-btn-full { width: 100%; }

.mago-btn-xl {
    min-height: 60px;
    font-size: 17px;
    border-radius: var(--radius-lg);
}

.mago-btn-sm {
    min-height: 40px;
    font-size: 13px;
    padding: 0 16px;
}

/* ─── Forms ──────────────────────────────────────────────── */
.mago-form { display: flex; flex-direction: column; gap: 14px; }

.mago-form-row {
    display: flex;
    gap: 12px;
}
.mago-form-row .mago-form-field { flex: 1; }

.mago-form-field { display: flex; flex-direction: column; gap: 6px; }

.mago-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--c-slate);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.mago-label-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--c-text-2);
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
}

.mago-input,
.mago-select,
.mago-textarea {
    width: 100%;
    min-height: var(--tap-min);
    padding: 12px 14px;
    background: var(--c-surface);
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 16px;   /* 16px prevents iOS zoom on focus */
    color: var(--c-text-1);
    appearance: none;
    -webkit-appearance: none;
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}

.mago-input:focus,
.mago-select:focus,
.mago-textarea:focus {
    border-color: var(--c-navy-mid);
    box-shadow: 0 0 0 3px rgba(44,95,124,.15);
}

.mago-input::placeholder,
.mago-textarea::placeholder { color: var(--c-fog); }

/* Force consistent text colour on native date/time/number inputs (iOS shows light blue) */
.mago-input[type="date"],
.mago-input[type="time"],
.mago-input[type="number"] { color: var(--c-text-1); }

.mago-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237A9AAD' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

.mago-textarea {
    min-height: 80px;
    resize: vertical;
}

/* Chip row — for weather, status, etc. */
.mago-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}

.mago-chip {
    min-height: 44px;
    padding: 8px 16px;
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius-pill);
    background: var(--c-surface);
    color: var(--c-text-2);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    -webkit-tap-highlight-color: transparent;
}

.mago-chip.active,
.mago-chip:hover {
    background: var(--c-navy-mid);
    border-color: var(--c-navy-mid);
    color: #fff;
}

.mago-chip-green.active { background: var(--c-green); border-color: var(--c-green); color: #fff; }
.mago-chip-yellow.active { background: #d4a000; border-color: #d4a000; color: #fff; }
.mago-chip-red.active { background: var(--c-red); border-color: var(--c-red); color: #fff; }

/* ─── Crew slots ─────────────────────────────────────────── */
.mago-crew-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.mago-crew-slot .mago-input { flex: 1; }

.mago-crew-slot .mago-select {
    flex: 0 0 130px;
}

.mago-crew-remove {
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: none;
    color: var(--c-red);
    font-size: 20px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ─── Trip cards ─────────────────────────────────────────── */
.mago-trip-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
}

.mago-trip-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mago-trip-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--c-navy-mid), var(--c-navy-light));
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mago-trip-meta { flex: 1; min-width: 0; }

.mago-trip-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--c-text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mago-trip-sub {
    font-size: 13px;
    color: var(--c-text-3);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mago-trip-chevron {
    color: var(--c-muted);
    transition: transform .2s;
    flex-shrink: 0;
}

.mago-trip-card.expanded .mago-trip-chevron { transform: rotate(180deg); }

.mago-trip-card-body {
    padding: 14px 16px;
    border-top: 1px solid var(--c-border);
    background: var(--c-surface-2);
    display: none;
}

.mago-trip-card.expanded .mago-trip-card-body { display: block; }

.mago-trip-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    font-size: 14px;
}

.mago-trip-detail-grid dt { color: var(--c-text-3); font-size: 12px; }
.mago-trip-detail-grid dd { font-weight: 600; color: var(--c-text-1); }

.mago-trip-note-block {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.5;
}

.mago-note-general { background: var(--c-surface); border-left: 3px solid var(--c-slate); }
.mago-note-incident { background: #FDF6F0; border-left: 3px solid var(--c-red); color: #7A2C1A; }
.mago-note-lesson { background: #F0F8F4; border-left: 3px solid var(--c-green); color: #1A5435; }

.mago-trip-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    justify-content: flex-end;
}

/* ─── One-tap log ────────────────────────────────────────── */
.mago-onetap-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 8px;
}

.mago-onetap-btn {
    min-height: 90px;
    background: var(--c-surface);
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    color: var(--c-text-2);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform .1s, box-shadow .1s, background .15s;
    -webkit-tap-highlight-color: transparent;
    text-align: center;
    line-height: 1.3;
}

.mago-onetap-btn:active {
    transform: scale(.95);
    background: var(--c-surface-2);
}

.mago-onetap-icon {
    font-size: 26px;
    line-height: 1;
}

.mago-onetap-note {
    border-style: dashed;
    color: var(--c-slate);
}

/* ─── Event log ──────────────────────────────────────────── */
.mago-event-log {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mago-event-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.mago-event-time {
    font-size: 12px;
    font-weight: 700;
    color: var(--c-slate);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding-top: 1px;
}

.mago-event-label { font-weight: 600; color: var(--c-text-1); }
.mago-event-note { font-weight: 400; color: var(--c-text-2); margin-top: 2px; }

/* ─── Checklists ─────────────────────────────────────────── */
.mago-checklist-tabs,
.mago-cat-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    margin-bottom: 12px;
}

.mago-checklist-tabs::-webkit-scrollbar,
.mago-cat-tabs::-webkit-scrollbar { display: none; }

.mago-tab {
    min-height: 40px;
    padding: 0 16px;
    background: var(--c-surface);
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--c-text-2);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .15s, border-color .15s, color .15s;
}

.mago-tab.active {
    background: var(--c-navy-mid);
    border-color: var(--c-navy-mid);
    color: #fff;
}

/* Progress bar */
.mago-checklist-progress-bar {
    height: 6px;
    background: var(--c-border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.mago-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--c-navy-mid), var(--c-navy-light));
    border-radius: 3px;
    transition: width .3s ease;
}

.mago-progress-label {
    font-size: 12px;
    color: var(--c-text-3);
    font-weight: 600;
    margin-bottom: 14px;
}

/* Checklist items */
.mago-checklist-item {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 56px;
    padding: 12px 0;
    border-bottom: 1px solid var(--c-border);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mago-checklist-item:last-child { border-bottom: none; }

/* Custom large checkbox */
.mago-checkbox {
    width: 32px;
    height: 32px;
    border: 2px solid var(--c-border);
    border-radius: 8px;
    background: var(--c-surface);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, border-color .15s;
}

.mago-checklist-item.checked .mago-checkbox {
    background: var(--c-navy-mid);
    border-color: var(--c-navy-mid);
}

.mago-checkbox-check {
    opacity: 0;
    transition: opacity .1s;
}
.mago-checklist-item.checked .mago-checkbox-check { opacity: 1; }

.mago-checklist-label {
    font-size: 16px;
    font-weight: 500;
    color: var(--c-text-1);
    flex: 1;
    line-height: 1.4;
}

.mago-checklist-item.checked .mago-checklist-label {
    color: var(--c-text-3);
    text-decoration: line-through;
}

/* All complete state */
.mago-checklist-complete {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 0;
    gap: 8px;
    color: var(--c-green);
}

.mago-checklist-complete-icon { font-size: 48px; }
.mago-checklist-complete-text { font-size: 18px; font-weight: 700; }

/* ─── Inventory ──────────────────────────────────────────── */
.mago-readiness-banner {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.mago-readiness-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 700;
}

.mago-readiness-pill-green { background: var(--c-green-bg); color: var(--c-green); }
.mago-readiness-pill-yellow { background: var(--c-yellow-bg); color: var(--c-yellow); }
.mago-readiness-pill-red { background: var(--c-red-bg); color: var(--c-red); }

.mago-inventory-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s;
}

.mago-inventory-item:active { box-shadow: none; }

.mago-status-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}

.mago-dot-ok     { background: #27AE60; }
.mago-dot-check  { background: #F39C12; }
.mago-dot-replace { background: var(--c-red); }

.mago-inventory-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--c-text-1);
    flex: 1;
}

.mago-inventory-qty {
    font-size: 14px;
    font-weight: 700;
    color: var(--c-text-2);
    background: var(--c-surface-2);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    padding: 2px 8px;
}

.mago-inventory-warn {
    font-size: 12px;
    color: var(--c-red);
    font-weight: 600;
    flex-shrink: 0;
}

/* ─── Maintenance list ───────────────────────────────────── */
.mago-maintenance-item {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
}

.mago-maintenance-item.due { border-left: 4px solid #F39C12; }
.mago-maintenance-item.overdue { border-left: 4px solid var(--c-red); }

.mago-maintenance-title { font-size: 16px; font-weight: 700; color: var(--c-text-1); }
.mago-maintenance-meta { font-size: 13px; color: var(--c-text-3); margin-top: 4px; }
.mago-maintenance-due-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 700;
    background: var(--c-yellow-bg);
    color: var(--c-yellow);
}

/* ─── Document list ──────────────────────────────────────── */
.mago-document-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
}

.mago-document-icon { font-size: 24px; flex-shrink: 0; }
.mago-document-title { font-size: 16px; font-weight: 600; color: var(--c-text-1); }
.mago-document-meta { font-size: 13px; color: var(--c-text-3); margin-top: 2px; }
.mago-document-link { margin-left: auto; flex-shrink: 0; font-size: 13px; color: var(--c-navy-mid); font-weight: 600; }

/* ─── Emergency screen ───────────────────────────────────── */
.mago-emergency-header {
    background: var(--c-red);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(192,57,43,.35);
}

.mago-emergency-title {
    font-size: 26px;
    font-weight: 800;
    color: #fff;
    letter-spacing: .04em;
}

.mago-emergency-sub {
    font-size: 13px;
    color: rgba(255,255,255,.8);
    margin-top: 4px;
}

.mago-emergency-calls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.mago-call-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 72px;
    padding: 14px 20px;
    background: var(--c-surface);
    border: 2px solid var(--c-border);
    border-radius: var(--radius-md);
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: transform .1s, box-shadow .1s;
    -webkit-tap-highlight-color: transparent;
}

.mago-call-btn:active { transform: scale(.97); }

.mago-call-btn-primary { border-color: var(--c-red); background: #FEF5F5; }

.mago-call-icon { font-size: 28px; flex-shrink: 0; }
.mago-call-label { font-size: 13px; color: var(--c-text-3); font-weight: 500; }
.mago-call-number {
    font-size: 22px;
    font-weight: 800;
    color: var(--c-text-1);
    font-variant-numeric: tabular-nums;
    letter-spacing: .02em;
}
.mago-call-btn-primary .mago-call-number { color: var(--c-red); }
.mago-call-arrow { margin-left: auto; font-size: 20px; color: var(--c-slate); }

.mago-emergency-position {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
}

.mago-emergency-pos-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--c-text-3);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 8px;
}

.mago-emergency-pos-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--c-text-1);
    font-variant-numeric: tabular-nums;
    margin-bottom: 12px;
}

.mago-pos-placeholder { font-size: 14px; color: var(--c-text-3); font-weight: 500; }

.mago-emergency-boat {
    background: var(--c-surface-2);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    font-size: 14px;
    color: var(--c-text-2);
}

.mago-emergency-boat-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--c-text-3);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 10px;
}

/* ─── More screen grid ───────────────────────────────────── */
.mago-more-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 8px;
}

.mago-more-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 110px;
    background: var(--c-surface);
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius-lg);
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    color: var(--c-text-1);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform .1s, box-shadow .1s;
    -webkit-tap-highlight-color: transparent;
}

.mago-more-tile:active { transform: scale(.97); box-shadow: none; }

.mago-more-icon { font-size: 34px; }

.mago-more-emergency {
    border-color: #e57373;
    background: #FEF5F5;
    color: var(--c-red);
}

/* ─── Back row ───────────────────────────────────────────── */
.mago-back-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.mago-back-btn {
    min-height: 44px;
    padding: 0 14px;
    background: none;
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--c-text-2);
    cursor: pointer;
    white-space: nowrap;
}

.mago-screen-heading {
    font-size: 18px;
    font-weight: 800;
    color: var(--c-text-1);
}

/* ─── Filter row ─────────────────────────────────────────── */
.mago-filter-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.mago-filter-input {
    flex: 1;
    min-height: 44px;
    font-size: 15px;
}

/* ─── Active trip header ─────────────────────────────────── */
.mago-active-trip-header {
    background: linear-gradient(135deg, var(--c-navy-mid), var(--c-navy-light));
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 4px;
    color: #fff;
}

.mago-active-destination {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -.01em;
}

.mago-active-meta {
    font-size: 13px;
    color: rgba(255,255,255,.7);
    margin-top: 6px;
}

/* ─── Modals / bottom sheets ─────────────────────────────── */
.mago-modal[hidden] { display: none; }
.mago-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.mago-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(13,34,51,.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.mago-modal-sheet {
    position: relative;
    background: var(--c-surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 12px 20px 32px;
    max-height: 92svh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-lg);
    animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(60px); opacity:0; } to { transform: none; opacity:1; } }

.mago-modal-handle {
    width: 40px;
    height: 5px;
    background: var(--c-border);
    border-radius: var(--radius-pill);
    margin: 0 auto 16px;
}

.mago-modal-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--c-text-1);
    margin-bottom: 16px;
}

/* ─── Toast notifications ────────────────────────────────── */
.mago-toast-container {
    position: fixed;
    bottom: calc(var(--nav-h) + 12px);
    left: 50%;
    transform: translateX(-50%);
    width: min(90vw, 380px);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
}

.mago-toast {
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    box-shadow: var(--shadow-md);
    animation: toastIn .2s ease;
    pointer-events: all;
}
@keyframes toastIn { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: none; } }

.mago-toast-success { background: #1A7F4B; }
.mago-toast-error   { background: var(--c-red); }
.mago-toast-info    { background: var(--c-navy-mid); }

/* ─── Login required state ───────────────────────────────── */
.mago-login-required {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    min-height: 300px;
    padding: 40px 20px;
    text-align: center;
    font-family: 'DM Sans', sans-serif;
    color: var(--c-text-2);
}

/* ─── Utility ────────────────────────────────────────────── */
.mago-text-danger { color: var(--c-red); }
.mago-text-muted  { color: var(--c-text-3); }
.mago-text-center { text-align: center; }
.mago-mt-8        { margin-top: 8px; }
.mago-mt-16       { margin-top: 16px; }

.mago-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 20px;
    color: var(--c-text-3);
    font-size: 14px;
    text-align: center;
    gap: 8px;
}
.mago-empty-state-icon { font-size: 44px; margin-bottom: 4px; }
.mago-empty-state-title { font-size: 16px; font-weight: 700; color: var(--c-text-2); }

/* ─── Responsive: larger screens ────────────────────────────
   On desktop the app shows as a centred phone-like column.    */
@media (min-width: 680px) {
    .mago-app {
        border-left: 1px solid var(--c-border);
        border-right: 1px solid var(--c-border);
        min-height: 100vh;
    }

    .mago-stats-row { grid-template-columns: repeat(4, 1fr); }
}

/* ─── Reduced motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD — New design components
   ═══════════════════════════════════════════════════════════ */

/* Screen title (used in non-dashboard screens) */
.mago-screen-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--c-text-1);
    padding: 16px 16px 4px;
    letter-spacing: -0.02em;
}

/* ─── Hero card ──────────────────────────────────────────── */
.mago-hero {
    margin: 12px 12px 0;
    border-radius: 20px;
    background: linear-gradient(150deg, var(--c-navy) 0%, #1B5472 50%, #2C7A9E 100%);
    background-size: cover;
    background-position: center;
    color: #fff;
    padding: 28px 20px 22px;
    min-height: 190px;
    display: flex;
    align-items: flex-end;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.mago-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(160deg, rgba(13,34,51,.75) 0%, rgba(13,34,51,.25) 100%);
    border-radius: inherit;
    pointer-events: none;
}

.mago-hero-watermark {
    position: absolute;
    right: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 180px;
    height: auto;
    color: rgba(255,255,255,.07);
    pointer-events: none;
    z-index: 0;
}

.mago-hero-content { position: relative; z-index: 1; width: 100%; }

.mago-hero-greeting {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--c-accent);
    margin-bottom: 4px;
}

.mago-hero-title {
    font-size: 32px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 6px;
}

.mago-hero-meta {
    font-size: 12px;
    color: rgba(255,255,255,.6);
    margin-bottom: 14px;
}

.mago-hero-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,.9);
}

.mago-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ECC71;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(46,204,113,.35);
}

.mago-status-dot--yellow { background: #F0C040; box-shadow: 0 0 0 2px rgba(240,192,64,.35); }
.mago-status-dot--red    { background: #E74C3C; box-shadow: 0 0 0 2px rgba(231,76,60,.35); }

/* ─── Quick action grid ──────────────────────────────────── */
.mago-quick-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    padding: 12px 12px 0;
}

.mago-quick-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 14px;
    padding: 12px 4px 10px;
    font-size: 10px;
    font-weight: 600;
    color: var(--c-text-2);
    cursor: pointer;
    text-align: center;
    line-height: 1.3;
    transition: transform .1s, box-shadow .1s;
    -webkit-tap-highlight-color: transparent;
}

.mago-quick-tile:active { transform: scale(.94); }

.mago-quick-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--c-navy);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mago-quick-icon-wrap--red { background: var(--c-red); }

/* ─── Dashboard cards ────────────────────────────────────── */
.mago-card {
    background: var(--c-surface);
    border-radius: 16px;
    padding: 16px;
    margin: 10px 12px 0;
    box-shadow: 0 2px 8px rgba(16,38,58,.07);
    border: 1px solid var(--c-border);
}

.mago-card--last { margin-bottom: 24px; }

.mago-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.mago-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--c-text-1);
}

.mago-card-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 20px;
}

.mago-card-badge--green { background: var(--c-green-bg); color: var(--c-green); }
.mago-card-badge--yellow { background: var(--c-yellow-bg); color: var(--c-yellow); }
.mago-card-badge--red { background: var(--c-red-bg); color: var(--c-red); }

.mago-card-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--c-navy-light);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

/* ─── Active trip summary card ───────────────────────────── */
.mago-active-card-strip {
    background: var(--c-navy);
    border-radius: 16px;
    padding: 14px 16px;
    margin: 10px 12px 0;
    color: #fff;
}

.mago-active-card-strip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.mago-active-card-title {
    font-size: 14px;
    font-weight: 700;
    color: rgba(255,255,255,.75);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.mago-btn-pill {
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.25);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 20px;
    cursor: pointer;
}

.mago-active-card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.mago-active-card-item-label {
    font-size: 11px;
    color: rgba(255,255,255,.55);
    margin-bottom: 3px;
}

.mago-active-card-item-value {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.mago-active-card-item-sub {
    font-size: 11px;
    color: rgba(255,255,255,.55);
    margin-top: 1px;
}

/* ─── One-tap dashboard row ──────────────────────────────── */
.mago-onetap-dash {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

.mago-onetap-dash-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    border: none;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    margin: 0 auto;
    cursor: pointer;
    font-size: 9px;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    transition: transform .1s;
    justify-content: center;
}

.mago-onetap-dash-btn:active { transform: scale(.9); }
.mago-onetap-dash-btn span { display: none; }

.mago-onetap-dash-btn--green { background: #27AE60; }
.mago-onetap-dash-btn--red   { background: var(--c-red); }
.mago-onetap-dash-btn--navy  { background: var(--c-navy); }
.mago-onetap-dash-btn--teal  { background: #16A085; }
.mago-onetap-dash-btn--sand  { background: #BEA06E; }

/* ─── Safety check grid ──────────────────────────────────── */
.mago-safety-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.mago-safety-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}

.mago-safety-check {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mago-safety-check--ok { background: var(--c-green-bg); color: var(--c-green); }
.mago-safety-check--check { background: var(--c-yellow-bg); color: var(--c-yellow); }
.mago-safety-check--replace { background: var(--c-red-bg); color: var(--c-red); }

.mago-safety-label { font-size: 11px; font-weight: 600; color: var(--c-text-2); }
.mago-safety-status { font-size: 10px; color: var(--c-text-3); }

/* ─── Inventory status row ───────────────────────────────── */
.mago-inv-status-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.mago-inv-status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
}

.mago-inv-status-icon {
    font-size: 22px;
    line-height: 1;
}

.mago-inv-status-label { font-size: 11px; font-weight: 600; color: var(--c-text-2); }

.mago-inv-status-badge {
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 3px;
}

.mago-inv-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mago-inv-status-dot--ok    { background: var(--c-green); }
.mago-inv-status-dot--check { background: #F0C040; }
.mago-inv-status-dot--replace { background: var(--c-red); }
