/*
 * Active Pilot view -mobile-first stylesheet.
 * Phone is the lower bound (360px), tablet the design target, desktop a
 * centred max-width column. All touch targets >=56px; primary >=72px.
 * Modern slate/indigo palette with layered surfaces and soft gradients.
 * Sunlight-readable: high contrast on white text over saturated primaries,
 * cool low-glare cards. Numpad keys >=72px tall.
 *
 * Two-screen architecture: Start Day (unified gate) and Flying Day
 * (three concurrent sections: Before / Status / After).
 */

:root {
    --ap-bg-base:     #eef1f7;
    --ap-bg-grad:     linear-gradient(180deg, #f6f8fc 0%, #eef1f7 60%, #e8ecf3 100%);
    --ap-bg-card:     linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
    --ap-bg-card-flat:#ffffff;
    --ap-bg-key:      linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
    --ap-bg-key-pressed: linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 100%);
    --ap-bg-rail:     linear-gradient(180deg, #e6eaf3 0%, #dfe4ee 100%);
    --ap-text:        #0f172a;
    --ap-text-muted:  #64748b;
    --ap-border:      #e2e8f0;
    --ap-border-strong: #cbd5e1;
    --ap-primary:           linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    --ap-primary-pressed:   linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
    --ap-primary-accent:    #6366f1;
    --ap-primary-accent-strong: #4f46e5;
    --ap-primary-soft:      linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    --ap-primary-text:      #ffffff;
    --ap-success:           linear-gradient(135deg, #059669 0%, #10b981 100%);
    --ap-success-accent:    #10b981;
    --ap-success-soft:      linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    --ap-success-soft-bg:   #d1fae5;
    --ap-warn:        #d97706;
    --ap-warn-soft:   #fef3c7;
    --ap-danger:      #dc2626;
    --ap-touch-min:   56px;
    --ap-touch-pri:   72px;
    --ap-key-min:     72px;
    --ap-radius:      14px;
    --ap-radius-sm:   10px;
    --ap-gap:         12px;
    --ap-pad-x:       16px;
    --ap-shadow-sm:   0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);
    --ap-shadow-md:   0 4px 14px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
    --ap-shadow-lg:   0 12px 28px rgba(15, 23, 42, 0.10), 0 4px 10px rgba(15, 23, 42, 0.06);
    --ap-shadow-primary: 0 6px 18px rgba(79, 70, 229, 0.32), 0 1px 3px rgba(79, 70, 229, 0.18);
    --ap-shadow-primary-soft: 0 3px 10px rgba(79, 70, 229, 0.18);
    --ap-shadow-success: 0 6px 18px rgba(16, 185, 129, 0.28), 0 1px 3px rgba(16, 185, 129, 0.16);
    --ap-shadow-inset-key: inset 0 -1px 0 rgba(15, 23, 42, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.6);
    --ap-font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --ap-mono:        ui-monospace, "SF Mono", "Menlo", "Roboto Mono", Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--ap-bg-base);
    color: var(--ap-text);
    font-family: var(--ap-font);
    font-size: 18px;
    line-height: 1.4;
    overscroll-behavior-y: contain;
}

body.ap-body {
    min-height: 100dvh;
    min-height: 100vh;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    background: var(--ap-bg-grad) fixed;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button {
    border: 0;
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

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

/* ---------- App scaffold ---------- */

.ap-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    overflow: hidden;
}

.ap-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 4px 8px;
    padding: 8px var(--ap-pad-x);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: saturate(140%) blur(12px);
    -webkit-backdrop-filter: saturate(140%) blur(12px);
    border-bottom: 1px solid var(--ap-border);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.ap-topbar-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: var(--ap-radius-sm);
    border: 1px solid var(--ap-border-strong);
    background: var(--ap-bg-card);
    color: var(--ap-text);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    justify-self: start;
}
.ap-topbar-back:active { background: var(--ap-bg-key-pressed); }

.ap-topbar-title {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.15;
    min-width: 0;
    text-align: center;
}
.ap-topbar-reg {
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 0.02em;
}
.ap-topbar-day {
    font-size: 15px;
    color: var(--ap-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.ap-topbar-net { font-size: 16px; text-align: right; color: var(--ap-text-muted); min-width: 44px; }
.ap-topbar-net[data-state="offline"] {
    color: var(--ap-warn);
    font-weight: 600;
}
.ap-topbar-net[data-state="syncing"] { color: var(--ap-primary-accent); }
.ap-topbar-net[data-state="online"]  { color: var(--ap-success-accent); }

.ap-main {
    flex: 1;
    overflow-y: auto;
    padding: 10px var(--ap-pad-x) 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: var(--page-max-width, 1600px);
    margin: 0 auto;
    width: 100%;
}

.ap-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 80px 0;
    color: var(--ap-text-muted);
}
.ap-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--ap-border);
    border-top-color: var(--ap-primary-accent);
    border-radius: 50%;
    animation: apSpin 700ms linear infinite;
}
@keyframes apSpin { to { transform: rotate(360deg); } }

/* ---------- Buttons ---------- */

.ap-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: var(--ap-touch-pri);
    padding: 0 18px;
    border-radius: var(--ap-radius);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.01em;
    background: var(--ap-bg-card);
    color: var(--ap-text);
    border: 1px solid var(--ap-border-strong);
    box-shadow: var(--ap-shadow-sm);
    transition: background 160ms ease, transform 90ms ease, box-shadow 160ms ease;
}
.ap-btn:active { transform: scale(0.98); }
.ap-btn[disabled] { opacity: 0.5; pointer-events: none; box-shadow: none; }

.ap-btn--primary {
    background: var(--ap-primary);
    color: var(--ap-primary-text);
    border-color: transparent;
    box-shadow: var(--ap-shadow-primary);
}
.ap-btn--primary:active { background: var(--ap-primary-pressed); box-shadow: var(--ap-shadow-primary-soft); }
.ap-btn--secondary {
    background: var(--ap-bg-card);
    border-color: var(--ap-border-strong);
    color: var(--ap-text);
}
.ap-btn--complete {
    background: var(--ap-success);
    color: #fff;
    border-color: transparent;
    box-shadow: var(--ap-shadow-success);
}
.ap-btn--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--ap-text-muted);
    min-height: 40px;
    font-weight: 500;
    box-shadow: none;
}

/* ---------- Section / Card ---------- */

.ap-section {
    background: var(--ap-bg-card);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius);
    box-shadow: var(--ap-shadow-md);
    padding: 18px var(--ap-pad-x);
    position: relative;
}
.ap-section::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
            mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
    opacity: 0.6;
}
.ap-section + .ap-section { margin-top: 4px; }

.ap-section-head {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
}
.ap-section-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}
.ap-section-sub {
    font-size: 17px;
    color: var(--ap-text-muted);
    margin: 0;
}

.ap-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--ap-success-soft);
    color: var(--ap-success-accent);
    font-size: 15px;
    font-weight: 600;
    border: 1px solid rgba(16, 185, 129, 0.18);
}
.ap-chip--neutral {
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
    color: var(--ap-text-muted);
    border-color: var(--ap-border);
}

/* ---------- Empty / Picker ---------- */

.ap-empty, .ap-picker {
    max-width: 540px;
    margin: 0 auto;
    padding: 48px 20px;
    text-align: center;
}
.ap-picker-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 15px;
    font-weight: 500;
    color: var(--ap-text-muted);
    text-decoration: none;
    margin-bottom: 16px;
}
.ap-picker-back:active { opacity: 0.7; }
.ap-empty h1, .ap-picker-head h1 { font-size: 24px; margin: 0 0 8px; letter-spacing: -0.01em; }
.ap-picker-head p { color: var(--ap-text-muted); margin: 0 0 24px; }
.ap-picker-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ap-picker-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 12px 16px;
    min-height: var(--ap-touch-min);
    background: var(--ap-bg-card);
    border: 1px solid var(--ap-border-strong);
    border-radius: var(--ap-radius);
    box-shadow: var(--ap-shadow-sm);
    text-align: left;
    transition: box-shadow 160ms ease, transform 120ms ease;
}
.ap-picker-card:hover  { box-shadow: var(--ap-shadow-md); }
.ap-picker-card:active { transform: scale(0.99); background: var(--ap-bg-key-pressed); }
.ap-picker-reg { font-size: 24px; font-weight: 700; letter-spacing: 0.02em; }
.ap-picker-type { font-size: 17px; color: var(--ap-text-muted); }
.ap-picker-card--active {
    border-color: var(--ap-primary-accent-strong, #6366f1);
    background: var(--ap-primary-soft, #eef2ff);
}

/* ---------- Change Pilot bar (shared accounts) ---------- */

.ap-change-row {
    display: flex;
    gap: 8px;
    margin: 4px 0;
}
.ap-change-row > .ap-change-pilot-bar {
    flex: 1;
    min-width: 0;
    margin: 0;
}
.ap-change-pilot-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 14px;
    margin: 2px 0;
    background: var(--ap-primary-soft, #eef2ff);
    border: 1px solid rgba(99, 102, 241, 0.18);
    border-radius: var(--ap-radius-sm, 8px);
}
.ap-change-pilot-label {
    font-size: 18px;
    font-weight: 600;
    color: var(--ap-text);
}
.ap-change-pilot-btn {
    min-height: 40px;
    padding: 0 16px;
    border-radius: var(--ap-radius-sm, 8px);
    background: var(--ap-bg-card, #fff);
    border: 1px solid var(--ap-border-strong, #d1d5db);
    font-size: 16px;
    font-weight: 600;
    color: var(--ap-primary-accent-strong, #6366f1);
    box-shadow: var(--ap-shadow-sm);
    cursor: pointer;
    transition: background 120ms ease;
}
.ap-change-pilot-btn:active { background: var(--ap-bg-key-pressed, #e5e7eb); }

/* ---------- Numpad ---------- */

.ap-numpad {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ap-numpad-label {
    font-size: 17px;
    color: var(--ap-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.ap-numpad-display {
    font-family: var(--ap-mono);
    font-size: 56px;
    line-height: 1;
    font-weight: 700;
    text-align: center;
    padding: 22px 16px;
    background: linear-gradient(135deg, #ffffff 0%, #eef2ff 100%);
    border: 1px solid var(--ap-border-strong);
    border-radius: var(--ap-radius);
    min-height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.02em;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: var(--ap-shadow-sm), inset 0 1px 0 rgba(255,255,255,0.8);
    transition: background 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
}
.ap-numpad-display[data-empty="true"] {
    color: var(--ap-text-muted);
    font-weight: 500;
    background: linear-gradient(135deg, #ffffff 0%, #f3f5fb 100%);
}
.ap-numpad-display[data-state="typing"] {
    border-color: var(--ap-primary-accent);
    box-shadow: var(--ap-shadow-primary-soft), inset 0 1px 0 rgba(255,255,255,0.8);
}
.ap-numpad-display[data-state="saved"] {
    border-color: var(--ap-success-accent);
    background: var(--ap-success-soft);
    color: #064e3b;
}
.ap-numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.ap-numpad-key {
    min-height: var(--ap-key-min);
    height: 14vw;
    max-height: 96px;
    font-size: 28px;
    font-weight: 600;
    background: var(--ap-bg-key);
    border: 1px solid var(--ap-border-strong);
    border-radius: var(--ap-radius);
    color: var(--ap-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--ap-shadow-inset-key), var(--ap-shadow-sm);
    transition: background 120ms ease, transform 80ms ease;
}
.ap-numpad-key:active {
    background: var(--ap-bg-key-pressed);
    transform: scale(0.97);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}
.ap-numpad-key[data-key="back"] { font-size: 22px; color: var(--ap-text-muted); }
.ap-numpad-actions {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    margin-top: 4px;
}
/* Code sign-in confirm: Back and OK share the row equally. */
.ap-code-sign-in .ap-numpad-actions { grid-template-columns: 1fr 1fr; }
.ap-numpad-undo {
    min-height: var(--ap-touch-pri);
    padding: 0 18px;
    background: var(--ap-bg-card);
    border: 1px solid var(--ap-border-strong);
    border-radius: var(--ap-radius);
    font-size: 20px;
    font-weight: 600;
    color: var(--ap-text-muted);
    box-shadow: var(--ap-shadow-sm);
}
.ap-numpad-undo[disabled] { opacity: 0.4; pointer-events: none; box-shadow: none; }

/* Compact numpad -used inside overlays to avoid scrolling */
.ap-numpad--compact { gap: 5px; }
.ap-numpad--compact .ap-numpad-label { font-size: 14px; margin-bottom: 0; }
.ap-numpad--compact .ap-numpad-display {
    font-size: 32px;
    min-height: 44px;
    padding: 6px 10px;
}
.ap-numpad--compact .ap-numpad-grid { gap: 4px; }
.ap-numpad--compact .ap-numpad-key {
    min-height: 40px;
    height: 8vw;
    max-height: 46px;
    font-size: 20px;
    border-radius: var(--ap-radius-sm);
}
.ap-numpad--compact .ap-numpad-actions { margin-top: 2px; }
.ap-numpad--compact .ap-numpad-undo { min-height: 40px; font-size: 16px; }
.ap-numpad--compact .ap-btn { min-height: 44px; }

/* ---------- Profile (dot multi-select) ---------- */

.ap-dot-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.ap-dot-check {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    min-height: var(--ap-touch-pri);
    background: var(--ap-bg-card);
    border: 1px solid var(--ap-border-strong);
    border-radius: var(--ap-radius);
    font-size: 20px;
    font-weight: 600;
    box-shadow: var(--ap-shadow-sm);
    transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 90ms ease;
}
.ap-dot-check:active { transform: scale(0.99); }
.ap-dot-check[data-checked="true"] {
    border-color: var(--ap-primary-accent);
    background: var(--ap-primary-soft);
    box-shadow: var(--ap-shadow-primary-soft);
    color: #1e1b4b;
}
.ap-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--ap-border-strong);
    background: var(--ap-bg-card);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.04);
}
.ap-dot-check[data-checked="true"] .ap-dot {
    background: var(--ap-primary);
    border-color: transparent;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35);
}
.ap-dot-check[data-checked="true"] .ap-dot::after {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
}

/* ---------- Hold (YES / NO) ---------- */

.ap-yesno {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.ap-yesno-btn {
    min-height: 96px;
    border-radius: var(--ap-radius);
    border: 1px solid var(--ap-border-strong);
    background: var(--ap-bg-card);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--ap-text);
    box-shadow: var(--ap-shadow-sm);
    transition: background 160ms ease, color 160ms ease, transform 90ms ease, box-shadow 160ms ease;
}
.ap-yesno-btn:active { transform: scale(0.99); }
.ap-yesno-btn[data-selected="true"] {
    background: var(--ap-primary);
    color: var(--ap-primary-text);
    border-color: transparent;
    box-shadow: var(--ap-shadow-primary);
}

/* ---------- Signature pad ---------- */

.ap-sig-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ap-sig-canvas {
    width: 100%;
    aspect-ratio: 2 / 1;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px dashed var(--ap-border-strong);
    border-radius: var(--ap-radius);
    touch-action: none;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}
.ap-sig-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Bottom sticky action bar ---------- */

.ap-actions {
    position: sticky;
    bottom: 0;
    padding: 12px var(--ap-pad-x) calc(12px + env(safe-area-inset-bottom));
    margin: 0 calc(-1 * var(--ap-pad-x));
    background: linear-gradient(180deg, rgba(238, 241, 247, 0) 0%, rgba(238, 241, 247, 0.92) 32%, var(--ap-bg-base) 100%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 5;
}

.ap-actions-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ap-main--compact .ap-actions {
    padding: 6px var(--ap-pad-x) calc(6px + env(safe-area-inset-bottom));
    margin-top: 12px;
}

/* --- Animated plane divider between flight buttons and End Day --- */
.ap-plane-divider {
    position: relative;
    height: 48px;
    margin: 20px 0 8px;
    overflow: hidden;
}
.ap-plane-trail {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(99, 102, 241, 0.08) 20%,
        rgba(99, 102, 241, 0.18) 50%,
        rgba(99, 102, 241, 0.08) 80%,
        transparent 100%
    );
    transform: translateY(-50%);
}
.ap-plane-trail::before {
    content: '';
    position: absolute;
    inset: -1px 0;
    height: 4px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(99, 102, 241, 0.35) 40%,
        rgba(99, 102, 241, 0.35) 60%,
        transparent 100%
    );
    filter: blur(4px);
    animation: apTrailPulse 3s ease-in-out infinite;
}
@keyframes apTrailPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}
.ap-plane-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    color: var(--ap-primary-accent-strong);
    filter: drop-shadow(0 2px 8px rgba(79, 70, 229, 0.40))
            drop-shadow(0 0 14px rgba(99, 102, 241, 0.25));
    animation: apPlaneFloat 8s ease-in-out infinite;
}
.ap-plane-icon svg { width: 100%; height: 100%; display: block; }
@keyframes apPlaneFloat {
    0%   { left: -10%; opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { left: 105%; opacity: 0; }
}
/* Shimmering highlight on the plane body */
.ap-plane-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 60% 40%,
        rgba(255, 255, 255, 0.6) 0%,
        transparent 60%
    );
    animation: apPlaneShimmer 8s ease-in-out infinite;
    pointer-events: none;
}
@keyframes apPlaneShimmer {
    0%, 100% { opacity: 0; }
    40%  { opacity: 1; }
    60%  { opacity: 1; }
    80%  { opacity: 0; }
}

/* ---------- Next-flight slide-up confirmation ---------- */

.ap-strip {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 20;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    border-radius: var(--ap-radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: var(--ap-shadow-lg);
    transform: translateY(120%);
    transition: transform 180ms ease;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.ap-strip[data-open="true"] { transform: translateY(0); }
.ap-strip-msg { font-size: 16px; font-weight: 500; }
.ap-strip-actions { display: flex; gap: 8px; }
.ap-strip-btn {
    min-height: 44px;
    padding: 0 16px;
    border-radius: 10px;
    background: var(--ap-primary);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    border: 0;
    box-shadow: var(--ap-shadow-primary-soft);
}
.ap-strip-btn--ghost {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.24);
    box-shadow: none;
}

/* ---------- Toast ---------- */

.ap-toast {
    position: fixed;
    left: 50%;
    bottom: calc(96px + env(safe-area-inset-bottom));
    transform: translate(-50%, 16px);
    z-index: 30;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--ap-success);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: transform 180ms ease, opacity 180ms ease;
    box-shadow: var(--ap-shadow-success);
    max-width: calc(100% - 32px);
    border: 1px solid rgba(255,255,255,0.18);
}
.ap-toast[data-visible="true"] { opacity: 1; transform: translate(-50%, 0); }
.ap-toast[data-tone="warn"]  { background: linear-gradient(135deg, #b45309 0%, #d97706 100%); box-shadow: 0 6px 18px rgba(217, 119, 6, 0.32); }
.ap-toast[data-tone="error"] { background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%); box-shadow: 0 6px 18px rgba(220, 38, 38, 0.32); }

/* ---------- Summary ---------- */

.ap-summary-row {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 12px 0;
    border-top: 1px solid var(--ap-border);
}
.ap-summary-row:first-child { border-top: 0; }
.ap-summary-idx {
    font-weight: 700;
    font-size: 18px;
    color: var(--ap-text-muted);
}
.ap-summary-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 16px;
}
.ap-summary-field { display: inline-flex; gap: 4px; }
.ap-summary-field b { font-weight: 700; }
.ap-summary-warn {
    background: var(--ap-warn-soft);
    color: var(--ap-warn);
    border: 1px solid #fcd34d;
    border-radius: var(--ap-radius);
    padding: 12px 14px;
    font-weight: 600;
    margin-bottom: 12px;
    box-shadow: var(--ap-shadow-sm);
}

/* =============================================
 * NEW: Start Day screen
 * ============================================= */

.ap-greeting {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}
.ap-greeting-sub {
    font-size: 18px;
    color: var(--ap-text-muted);
    margin: 2px 0 10px;
}
.ap-aircraft-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 8px 0 4px;
    padding: 14px 18px;
    border-radius: var(--ap-radius);
    background: var(--ap-bg-card);
    border: 2px solid var(--ap-primary);
    text-decoration: none;
    color: inherit;
    transition: background 120ms ease;
}
.ap-aircraft-bar:active { background: #eef2ff; }
.ap-aircraft-bar-reg {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--ap-primary);
}
.ap-aircraft-bar-change {
    font-size: 13px;
    color: var(--ap-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* --- Optional actions row (compact 3-button row) --- */

.ap-opt-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 4px;
}
.ap-opt-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 56px;
    padding: 10px 6px;
    background: var(--ap-bg-card);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius-sm);
    box-shadow: var(--ap-shadow-sm);
    font-size: 24px;
    font-weight: 600;
    color: var(--ap-text-muted);
    text-align: center;
    transition: background 160ms ease, border-color 160ms ease;
}
.ap-opt-btn:active { background: var(--ap-bg-key-pressed); }
.ap-opt-btn[data-has-value="true"] {
    border-color: var(--ap-success-accent);
    color: #064e3b;
}
.ap-opt-btn-icon {
    font-size: 18px;
    line-height: 1;
}

/* --- Required section --- */

.ap-startday-section {
    background: var(--ap-bg-card);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius);
    box-shadow: var(--ap-shadow-md);
    padding: 14px var(--ap-pad-x);
    position: relative;
}
.ap-startday-section::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
            mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
    opacity: 0.6;
}

.ap-startday-label {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ap-text-muted);
    margin-bottom: 8px;
}

/* ---------- Field row (collapsible) ---------- */

.ap-field-row {
    border-bottom: 1px solid var(--ap-border);
    padding: 8px 0;
}
.ap-field-row:last-child { border-bottom: 0; }

.ap-field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}
.ap-field-header-label {
    font-size: 20px;
    font-weight: 600;
}
.ap-field-header-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--ap-success-accent);
    display: flex;
    align-items: center;
    gap: 6px;
}
.ap-field-header-value[data-empty="true"] {
    color: var(--ap-text-muted);
    font-weight: 400;
}
.ap-field-header-btn {
    min-height: 44px;
    padding: 0 16px;
    border-radius: var(--ap-radius-sm);
    background: var(--ap-primary-soft);
    color: var(--ap-primary-accent-strong);
    font-size: 18px;
    font-weight: 600;
    border: 1px solid rgba(99, 102, 241, 0.18);
}

.ap-field-expand {
    display: none;
    padding-top: 10px;
}
.ap-field-expand[data-open="true"] {
    display: block;
}

/* A-check signed state */
.ap-field-row[data-signed="true"] .ap-field-header {
    cursor: default;
}
.ap-field-signed-tick {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--ap-success);
    color: #fff;
    box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3);
}

/* Highlight required fields when missing */
.ap-field-row[data-highlight="true"] {
    background: #fef3c7;
    border-radius: var(--ap-radius-sm);
    margin: 0 -8px;
    padding: 8px 8px;
    border-color: #fcd34d;
}

/* ---------- Notes textarea ---------- */

.ap-notes-textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid var(--ap-border-strong);
    border-radius: var(--ap-radius-sm);
    font-size: 18px;
    line-height: 1.4;
    resize: vertical;
    background: var(--ap-bg-card-flat);
}
.ap-notes-textarea:focus {
    outline: none;
    border-color: var(--ap-primary-accent);
    box-shadow: var(--ap-shadow-primary-soft);
}

/* ---------- Inline overlay for optional panels (oil, notes) ---------- */

.ap-overlay-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}
.ap-overlay-panel {
    background: #fff;
    border-radius: var(--ap-radius) var(--ap-radius) 0 0;
    box-shadow: var(--ap-shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 95dvh;
    max-height: 95vh;
    overflow-y: auto;
    padding: 12px var(--ap-pad-x) calc(12px + env(safe-area-inset-bottom));
    animation: apSlideUp 200ms ease-out;
}
@keyframes apSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
.ap-overlay-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 8px;
}
.ap-overlay-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 8px;
}

/* --- Hobbs Start confirm screen --- */
.ap-hobbs-confirm {
    text-align: center;
    padding: 16px 0 8px;
}
.ap-hobbs-confirm-value {
    font-family: var(--ap-mono);
    font-size: 48px;
    font-weight: 700;
    color: var(--ap-text);
    padding: 24px 0;
}
.ap-hobbs-confirm-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}
.ap-btn--hobbs-confirm {
    flex: 1;
    min-height: var(--ap-touch-pri);
    font-size: 20px;
    font-weight: 700;
    background: var(--ap-success);
    color: #fff;
    border-color: transparent;
    box-shadow: var(--ap-shadow-success);
}
.ap-btn--hobbs-confirm:active { background: linear-gradient(135deg, #047857 0%, #059669 100%); }
.ap-btn--hobbs-change {
    flex: 1;
    min-height: var(--ap-touch-pri);
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 18px rgba(217, 119, 6, 0.28), 0 1px 3px rgba(217, 119, 6, 0.16);
}
.ap-btn--hobbs-change:active { background: linear-gradient(135deg, #b45309 0%, #d97706 100%); }

/* --- Hobbs Start missing-data warning --- */
.ap-hobbs-warning {
    background: var(--ap-warn-soft);
    border: 1px solid var(--ap-warn);
    border-radius: var(--ap-radius-sm);
    padding: 14px 16px;
    margin-bottom: 12px;
    text-align: center;
}
.ap-hobbs-warning-icon {
    font-size: 36px;
    line-height: 1;
    margin-bottom: 6px;
}
.ap-hobbs-warning-text {
    font-size: 15px;
    line-height: 1.4;
    color: var(--ap-text);
}

/* =============================================
 * NEW: Flying Day screen
 * ============================================= */

/* --- Flight badge bar --- */

.ap-badge-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--ap-bg-card);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius);
    box-shadow: var(--ap-shadow-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.ap-badge-bar::-webkit-scrollbar { display: none; }

.ap-badge-bar-label {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ap-text-muted);
    flex-shrink: 0;
}

.ap-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px 3px 8px;
    min-height: 28px;
    background: var(--ap-bg-card);
    border: 1px solid var(--ap-border-strong);
    border-radius: 999px;
    color: var(--ap-text);
    font-size: 16px;
    font-weight: 700;
    box-shadow: var(--ap-shadow-sm);
    flex-shrink: 0;
    transition: transform 90ms ease, box-shadow 160ms ease, background 160ms ease;
    cursor: pointer;
}
.ap-badge:active { transform: scale(0.96); }

.ap-badge[data-active="true"] {
    background: var(--ap-primary);
    color: var(--ap-primary-text);
    border-color: transparent;
    box-shadow: var(--ap-shadow-primary);
}

.ap-badge[data-completed="true"]:not([data-active="true"]) {
    background: var(--ap-success-soft);
    border-color: rgba(16, 185, 129, 0.32);
    color: #064e3b;
}

.ap-badge-tick {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--ap-success);
    color: #fff;
    box-shadow: 0 1px 2px rgba(16, 185, 129, 0.35);
}

/* --- Three-column flying grid --- */

.ap-flying-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ap-flying-before,
.ap-flying-status,
.ap-flying-after {
    background: var(--ap-bg-card);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius);
    box-shadow: var(--ap-shadow-md);
    padding: 14px var(--ap-pad-x);
    position: relative;
}

.ap-flying-before::before,
.ap-flying-status::before,
.ap-flying-after::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
            mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
    opacity: 0.6;
}

.ap-column-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ap-text-muted);
    margin: 0 0 8px;
}

/* --- Airborne fade --- */

.ap-section--faded {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(0.5);
    transition: opacity 400ms ease, filter 400ms ease;
}

/* --- Status section content --- */

.ap-status-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Aeroplane icon in status */
.ap-status-plane {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ap-status-plane svg {
    width: 40px;
    height: 40px;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.12));
    transition: stroke 300ms ease;
}
/* Plane icon colour per status */
.ap-status-inner[data-status="on_ground_off"] .ap-status-plane svg { stroke: var(--ap-border-strong); }
.ap-status-inner[data-status="on_ground"] .ap-status-plane svg     { stroke: #16a34a; }
.ap-status-inner[data-status="engine_on"] .ap-status-plane svg     { stroke: #d97706; }
.ap-status-inner[data-status="airborne"] .ap-status-plane svg      { stroke: #3b82f6; }

/* --- Status pill --- */

.ap-status-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--ap-radius);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
}

.ap-status-pill[data-status="on_ground_off"] {
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
    color: var(--ap-text-muted);
    border: 1px solid var(--ap-border);
}

.ap-status-pill[data-status="on_ground"] {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #15803d;
    border: 1px solid rgba(22, 163, 74, 0.24);
}

.ap-status-pill[data-status="engine_on"] {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border: 1px solid rgba(217, 119, 6, 0.24);
}

.ap-status-pill[data-status="airborne"] {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e3a5f;
    border: 1px solid rgba(59, 130, 246, 0.24);
}

.ap-status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ap-status-pill[data-status="on_ground_off"] .ap-status-dot {
    background: var(--ap-border-strong);
}

.ap-status-pill[data-status="on_ground"] .ap-status-dot {
    background: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
}

.ap-status-pill[data-status="engine_on"] .ap-status-dot {
    background: #d97706;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.2);
    animation: apPulseOrange 1.5s ease-in-out infinite;
}

.ap-status-pill[data-status="airborne"] .ap-status-dot {
    background: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    animation: apPulse 1.5s ease-in-out infinite;
}

@keyframes apPulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
    50%      { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.08); }
}

@keyframes apPulseOrange {
    0%, 100% { box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.2); }
    50%      { box-shadow: 0 0 0 8px rgba(217, 119, 6, 0.08); }
}

.ap-status-detail {
    font-size: 16px;
    font-weight: 500;
    color: var(--ap-text-muted);
    text-align: center;
    margin-top: 4px;
}

/* --- Start Day info bar and large button --- */

.ap-startday-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    padding: 4px 0;
}
.ap-startday-info-reg { font-size: 20px; font-weight: 800; letter-spacing: 0.04em; }
.ap-startday-info-date { font-size: 17px; color: var(--ap-text-muted); }
.ap-startday-info-greeting { font-size: 18px; font-weight: 600; }
.ap-startday-info-change {
    font-size: 16px; color: var(--ap-primary-accent);
    text-decoration: underline; text-underline-offset: 2px; margin-left: auto;
}
.ap-startday-big-btn { margin-top: 8px; min-height: 80px; font-size: 38px; }

/* --- Flight screen three square buttons --- */

.ap-flight-btn-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ap-flight-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: var(--ap-radius); font-weight: 700;
    font-size: 24px; letter-spacing: 0.02em;
    border: none; color: #fff; box-shadow: var(--ap-shadow-md);
    transition: transform 90ms ease, box-shadow 160ms ease; padding: 10px 8px; gap: 2px;
}
.ap-flight-btn:active { transform: scale(0.96); }
.ap-flight-btn-label { line-height: 1.15; font-size: 20px; text-transform: uppercase; letter-spacing: 0.04em; }
.ap-flight-btn-value { font-size: 22px; font-weight: 800; margin-top: 1px; font-family: var(--ap-mono); }
.ap-flight-btn--temp {
    background: #f97316;
    box-shadow: 0 6px 18px rgba(234, 88, 12, 0.28), 0 1px 3px rgba(234, 88, 12, 0.16);
}
.ap-flight-btn--fuel {
    background: #f7ecbf;
    color: #4a3c00;
    box-shadow: 0 6px 18px rgba(212, 180, 60, 0.22), 0 1px 3px rgba(212, 180, 60, 0.14);
}
.ap-flight-btn--fuel .ap-flight-btn-label { color: #6b5a10; }
.ap-flight-btn--fuel .ap-flight-btn-value { color: #4a3c00; }

/* --- Quick-start hint --- */
.ap-hint {
    background: var(--ap-primary-soft);
    border: 1px solid rgba(99, 102, 241, 0.18);
    border-radius: var(--ap-radius-sm);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ap-hint-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ap-text);
}
.ap-hint-dismiss {
    align-self: flex-end;
    font-size: 14px;
    font-weight: 600;
    color: var(--ap-primary-accent-strong);
    padding: 4px 14px;
    border-radius: 6px;
    border: 1px solid rgba(99, 102, 241, 0.25);
}
.ap-hint-dismiss:active { background: rgba(99, 102, 241, 0.10); }

/* Held inert for the moment between first paint and the first poll, while the
   row for the current lift is still being created. */
.ap-flight-btn:disabled {
    opacity: 0.45;
    pointer-events: none;
}

/* --- Delayed sensor data notice --- */
/* Read-only status line. Deliberately has no control on it: the pilot is
   busy, so this informs and never asks. */
.ap-sensor-stale {
    background: rgba(212, 180, 60, 0.14);
    border: 1px solid rgba(212, 180, 60, 0.40);
    border-radius: var(--ap-radius-sm);
    padding: 10px 14px;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.45;
    font-weight: 600;
    color: #4a3c00;
}

/* --- Topbar status display for flight screen --- */

.ap-topbar-status-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; vertical-align: middle; margin-right: 3px;
}
.ap-topbar-status-icon svg { width: 16px; height: 16px; transition: stroke 300ms ease; }
.ap-topbar-status-icon[data-status="on_ground_off"] svg { stroke: var(--ap-border-strong); }
.ap-topbar-status-icon[data-status="on_ground"] svg { stroke: #16a34a; }
.ap-topbar-status-icon[data-status="engine_on"] svg { stroke: #d97706; }
.ap-topbar-status-icon[data-status="airborne"] svg { stroke: #3b82f6; }
.ap-topbar-change-pilot {
    font-size: 14px; font-weight: 600; color: var(--ap-primary-accent);
    background: transparent; border: none; padding: 4px 0;
    text-decoration: underline; text-underline-offset: 2px;
}

/* --- Small Add Hold action --- */

.ap-hold-action {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ap-bg-card);
    border: 1px solid var(--ap-border-strong);
    border-radius: var(--ap-radius-sm);
    min-height: 36px;
    font-size: 15px;
    font-weight: 600;
    box-shadow: var(--ap-shadow-sm);
    width: 100%;
}

/* --- Big centered status for flying screen --- */

.ap-status-inner--big {
    padding: 2px 0;
    gap: 2px;
}
.ap-status-inner--big .ap-status-plane {
    width: 28px;
    height: 28px;
}
.ap-status-inner--big .ap-status-plane svg {
    width: 24px;
    height: 24px;
}
.ap-status-inner--big .ap-status-pill {
    font-size: 20px;
    padding: 6px 16px;
}
.ap-status-inner--big .ap-status-dot {
    width: 12px;
    height: 12px;
}
.ap-status-inner--big .ap-status-detail {
    font-size: 14px;
    margin-top: 0;
}

/* --- Compact main for flight screen --- */

.ap-main--compact { padding-top: 6px; padding-bottom: 0; gap: 4px; }

.ap-endday-btn { font-size: 28px; min-height: 56px; }

/* --- End-day inline panel --- */

.ap-endday-panel {
    background: var(--ap-bg-card);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius);
    box-shadow: var(--ap-shadow-md);
    padding: 18px var(--ap-pad-x);
    margin-top: 8px;
}
.ap-endday-panel .ap-field-row:first-child { padding-top: 0; }

/* =============================================
 * Obs/defect modal styles (subset of styles.css
 * + settingsStyle.css for this isolated view)
 * ============================================= */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
}
.modal-backdrop.od-open {
    display: flex;
}
.modal-panel {
    background: #fff;
    border-radius: var(--ap-radius);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    width: 560px;
    max-width: 100%;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
    animation: apModalSlideIn 0.2s ease-out;
}
@keyframes apModalSlideIn {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.modal-title {
    margin: 0 0 14px 0;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: var(--ap-primary-accent-strong);
}
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 14px;
}
.modal-label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 16px;
    color: var(--ap-text);
}
#od-modal-backdrop .modal-label { margin-top: 16px; }
#od-modal-backdrop .modal-panel > .modal-label:first-of-type { margin-top: 4px; }
.modal-label + .modal-label { margin-top: 12px; }
.modal-input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--ap-border-strong);
    border-radius: var(--ap-radius-sm);
    font-size: 16px;
    box-sizing: border-box;
    font-family: inherit;
}
.modal-input:focus {
    outline: none;
    border-color: var(--ap-primary-accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
textarea.modal-input { resize: vertical; }
.text-muted { color: #6b7280; font-weight: 400; }
.od-type-row {
    display: flex;
    gap: 18px;
    margin: 4px 0 8px;
}

/* .btn base for modal buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    font-size: 16px;
    font-family: inherit;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--ap-radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    line-height: 1.5;
    white-space: nowrap;
    transition: box-shadow 0.18s ease;
}
.btn-primary {
    background: var(--ap-primary);
    color: var(--ap-primary-text);
    border-color: transparent;
}
.btn-secondary {
    background: var(--ap-bg-card-flat);
    color: var(--ap-text);
    border-color: var(--ap-border-strong);
}

/* Radio dot filter (obs/defect type) */
.users-dot-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    color: var(--ap-text-muted);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.users-dot-filter input { display: none; }
.users-dot-filter .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ap-border-strong);
    transition: background 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}
.users-dot-filter input:checked ~ .dot {
    background: var(--ap-primary-accent);
    box-shadow: 0 0 6px 2px rgba(99, 102, 241, 0.4);
}

/* File pick */
.file-pick-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.file-pick {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border: 1.5px dashed var(--ap-border-strong);
    border-radius: var(--ap-radius-sm);
    background: var(--ap-bg-card-flat);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    flex: 1;
    min-width: 0;
}
.file-pick:hover { border-color: var(--ap-primary-accent); }
.file-pick-icon { font-size: 16px; line-height: 1; opacity: 0.5; flex-shrink: 0; }
.file-pick-label {
    font-size: 15px;
    color: var(--ap-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-pick-input-hidden {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}
.add-defect-attachments-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.add-defect-attachments-list li {
    background: #f9fafb;
    border: 1px solid var(--ap-border);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    color: var(--ap-text-muted);
}

/* =============================================
 * Responsive
 * ============================================= */

/* --- Tablet (>= 600px) --- */

@media (min-width: 600px) {
    .ap-main { padding: 14px 24px 14px; }
    .ap-main--compact { padding-top: 6px; padding-bottom: 0; }
    .ap-numpad-display { font-size: 64px; min-height: 112px; }
    .ap-numpad-grid { gap: 12px; }
    .ap-numpad-key { font-size: 32px; height: 88px; max-height: 96px; }
    .ap-dot-grid { grid-template-columns: repeat(3, 1fr); }
    .ap-section { padding: 24px; }
    .ap-startday-section { padding: 24px; }
    .ap-greeting { font-size: 32px; }
}

/* --- Desktop (>= 1024px) --- */

@media (min-width: 1024px) {
    .ap-main { padding: 20px 32px 20px; }
    .ap-section { padding: 28px; }
    .ap-startday-section { padding: 28px; }
}

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0ms !important;
    }
}

/* @mention suggestions. mentions.js appends the list to <body>, so it must sit
   above the Notes overlay and the observation/defect modal (9999). */
.mention-dropdown {
    position: absolute;
    z-index: 10001;
    background: var(--ap-bg-card-flat);
    border: 1px solid var(--ap-border-strong);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
    max-height: 280px;
    overflow-y: auto;
}
.mention-dropdown-item {
    min-height: var(--ap-touch-min);
    padding: 8px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    color: var(--ap-text);
    font-size: 16px;
    cursor: pointer;
}
.mention-dropdown-email {
    font-size: 13px;
    color: var(--ap-text-muted);
}
.mention-dropdown-item:hover,
.mention-dropdown-item--active {
    background: var(--ap-primary-soft);
}
