:root {
    --brand: #0b67b2;
    --brand-dark: #064b86;
    --ink: #102236;
    --muted: #6d7b8c;
    --line: #e7edf3;
    --surface: #fff;
    --success: #168a5b;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: #edf3f7;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { overscroll-behavior: none; }
body.drawer-open { overflow: hidden; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.app-shell { min-height: 100%; background: #edf3f7; }
.app-bar {
    position: fixed;
    z-index: 20;
    top: 0;
    left: 0;
    right: 0;
    height: calc(64px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 14px 0;
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    color: #fff;
    box-shadow: 0 2px 14px rgba(3, 42, 76, .2);
}

.icon-button {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    background: rgba(255,255,255,.1);
    cursor: pointer;
}
.icon-button svg, .sheet-share svg, .map-control svg, .location-icon svg, .empty-icon svg {
    width: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.brand {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    color: #fff;
    text-decoration: none;
    font-family: Verdana, "Helvetica Neue", Helvetica, Arial, Geneva, sans-serif;
    font-size: 20px;
    font-weight: 400;
    letter-spacing: normal;
}
.brand img { max-width: 30px; max-height: 30px; filter: brightness(0) invert(1); }
.drawer-backdrop {
    position: fixed;
    z-index: 29;
    inset: 0;
    visibility: hidden;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    transition: opacity .24s ease, visibility .24s ease;
}
.navigation-drawer {
    position: fixed;
    z-index: 30;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(84vw, 320px);
    overflow-y: auto;
    color: #273442;
    background: #fff;
    box-shadow: 8px 0 28px rgba(0, 0, 0, .2);
    transform: translateX(-104%);
    transition: transform .26s ease;
}
.drawer-open .drawer-backdrop { visibility: visible; opacity: 1; }
.drawer-open .navigation-drawer { transform: translateX(0); }
.drawer-header {
    min-height: 190px;
    padding: calc(28px + env(safe-area-inset-top)) 18px 18px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    background: linear-gradient(145deg, #eaf6fd, #b9dff4);
}
.drawer-header img {
    width: 76px;
    height: 76px;
    margin-bottom: 10px;
    border-radius: 6px;
    object-fit: contain;
}
.drawer-header strong { font-size: 1rem; }
.drawer-header span { margin-top: 3px; color: #536676; font-size: .83rem; }
.drawer-links { padding: 8px 0 calc(18px + env(safe-area-inset-bottom)); }
.drawer-links a,
.drawer-links button {
    width: 100%;
    min-height: 52px;
    padding: 0 20px;
    border: 0;
    display: flex;
    align-items: center;
    gap: 20px;
    color: #273442;
    background: transparent;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.drawer-links a.active { color: var(--brand); background: #e7edf1; }
.drawer-links a:hover,
.drawer-links button:hover { background: #f0f4f7; }
.drawer-links svg {
    width: 24px;
    height: 24px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.drawer-divider { height: 1px; margin: 8px 0; background: var(--line); }
.map-wrap { position: fixed; inset: calc(64px + env(safe-area-inset-top)) 0 0; }
#map { width: 100%; height: 100%; background: #dbe8ee; }
.group-map-wrap { position: fixed; inset: calc(64px + env(safe-area-inset-top)) 0 0; }
#groupMap { width: 100%; height: 100%; background: #dbe8ee; }
.group-map-count {
    position: absolute;
    z-index: 3;
    top: 12px;
    left: 12px;
    padding: 8px 11px;
    border-radius: 10px;
    color: #405264;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 4px 14px rgba(20,48,71,.18);
    font-size: .76rem;
    font-weight: 700;
}
.group-map-wrap .map-control { top: 12px; bottom: auto; }
.selected-vessel-card {
    position: absolute;
    z-index: 4;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 12px;
    min-height: 82px;
    padding: 10px 12px;
    border-radius: 15px;
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr) 22px;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    background: rgba(255, 255, 255, .97);
    text-decoration: none;
    box-shadow: 0 7px 26px rgba(20,48,71,.28);
    backdrop-filter: blur(8px);
}
.selected-vessel-card[hidden] { display: none; }
.selected-vessel-card > img { width: 62px; height: 62px; border-radius: 11px; object-fit: cover; background: #eaf1f5; }
.selected-vessel-details { min-width: 0; }
.selected-vessel-details strong,
.selected-vessel-details span,
.selected-vessel-details small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.selected-vessel-details strong { font-size: 1rem; }
.selected-vessel-details span { margin-top: 4px; font-size: .78rem; font-weight: 650; }
.selected-vessel-details small { margin-top: 3px; color: var(--muted); font-size: .68rem; }
.selected-vessel-card > svg {
    width: 21px;
    fill: none;
    stroke: #8fa0ad;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.map-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--muted);
    background: rgba(238,244,247,.88);
    transition: opacity .2s ease, visibility .2s ease;
}
.map-loading.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #bfd2df;
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.flutter-boat-card {
    position: absolute;
    z-index: 4;
    top: 10px;
    left: 10px;
    right: 10px;
    overflow: hidden;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 0 10px rgba(80,80,80,.5);
    transition: max-height .28s ease, opacity .2s ease, transform .28s ease;
}
.flutter-boat-card.expanded { max-height: 160px; }
.flutter-boat-card.collapsed { max-height: 48px; }
.flutter-card-content {
    min-height: 108px;
    padding: 10px;
    display: grid;
    grid-template-columns: 70px minmax(0,1fr) 64px;
    gap: 12px;
    align-items: center;
    transition: transform .28s ease;
}
.flutter-boat-card.collapsed .flutter-card-content { transform: translateY(-61px); }
.flutter-photo-column { width: 70px; text-align: center; }
.flutter-photo-column img { width: 70px; height: 70px; border-radius: 6px; display: block; object-fit: cover; background: #eef3f6; }
.socket-status { margin-top: 4px; display: flex; justify-content: center; align-items: center; gap: 5px; color: #657483; font-size: .58rem; font-weight: 700; white-space: nowrap; }
.socket-status .status-dot { flex: none; }
.flutter-boat-details { min-width: 0; align-self: center; }
.flutter-boat-details h1 { margin: 0 0 2px; overflow: hidden; font-size: 1rem; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.flutter-boat-details p { margin: 0; overflow: hidden; color: #616d77; font-size: .74rem; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.flutter-boat-details .fence-title { color: #43515d; font-weight: 650; }
.flutter-boat-details .flutter-coordinates { margin-top: 1px; color: #818b94; font-size: .67rem; }
.flutter-speed-tile {
    width: 64px;
    padding: 8px 6px;
    border: 1px solid #d5dce1;
    border-radius: 10px;
    text-align: center;
    background: #fafafa;
}
.flutter-speed-tile span, .flutter-speed-tile small { display: block; font-size: .65rem; }
.flutter-speed-tile strong { display: block; margin: 2px 0; font-size: 1.25rem; line-height: 1; }
.card-toggle {
    position: absolute;
    z-index: 2;
    top: 2px;
    right: 2px;
    width: 28px;
    height: 26px;
    padding: 0;
    border: 0;
    display: grid;
    place-items: center;
    color: #8a969f;
    background: transparent;
}
.card-toggle svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s ease; }
.flutter-boat-card.collapsed .card-toggle svg { transform: rotate(180deg); }
.reef-chip { width: max-content; margin-top: 4px; padding: 3px 8px; border: 1px solid rgba(0,0,0,.16); border-radius: 14px; display: block; color: #1f2933; background: #fff; font-size: .62rem; font-weight: 800; }
.reef-chip[hidden] { display: none; }
.reef-chip.danger { color: #fff; background: #d93025; }
.reef-chip.warning { color: #fff; background: #ef8c18; }
.reef-chip.caution { color: #222; background: #ffd84d; }
.vessel-sheet {
    position: fixed;
    z-index: 10;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 244px;
    padding: 8px 18px calc(13px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -8px 32px rgba(23,51,73,.16);
}
.sheet-handle { width: 38px; height: 4px; margin: 0 auto 9px; border-radius: 4px; background: #d7dfe6; }
.vessel-summary { display: grid; grid-template-columns: 58px 1fr auto; gap: 12px; align-items: center; }
.vessel-photo { width: 58px; height: 58px; border-radius: 16px; object-fit: cover; border: 1px solid var(--line); background: #eef3f6; }
.vessel-heading { min-width: 0; }
.vessel-heading h1 { margin: 2px 0 1px; overflow: hidden; font-size: 1.22rem; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.vessel-heading p, .eyebrow { margin: 0; color: var(--muted); font-size: .74rem; }
.eyebrow { display: flex; align-items: center; gap: 6px; color: #526273; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #b8c2cb; }
.status-dot.online { background: var(--success); box-shadow: 0 0 0 4px rgba(22,138,91,.12); }
.status-dot.stale { background: #d14343; box-shadow: 0 0 0 4px rgba(209,67,67,.12); }
.sheet-share {
    height: 38px;
    padding: 0 12px;
    border: 1px solid #c8dced;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--brand);
    background: #f4f9fd;
    font-weight: 700;
}
.sheet-share svg { width: 18px; }
.stats { margin-top: 12px; padding: 10px 0; display: grid; grid-template-columns: repeat(3, 1fr); border-block: 1px solid var(--line); }
.stat { padding: 0 10px; text-align: center; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat span, .stat small { display: block; color: var(--muted); font-size: .68rem; }
.stat strong { display: inline-block; margin: 3px 2px 1px; font-size: 1.13rem; }
.location-row { padding-top: 10px; display: flex; align-items: center; gap: 12px; }
.location-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: var(--brand); background: #eef6fc; }
.location-icon svg { width: 19px; }
.location-row span, .location-row strong { display: block; }
.location-row div > span { margin-bottom: 2px; color: var(--muted); font-size: .7rem; }
.location-row strong { font-size: .86rem; }
.toast { position: fixed; z-index: 40; left: 50%; bottom: calc(260px + env(safe-area-inset-bottom)); padding: 10px 16px; border-radius: 12px; color: #fff; background: rgba(16,34,54,.92); opacity: 0; transform: translate(-50%, 10px); pointer-events: none; transition: .2s ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.empty-state { min-height: 100vh; padding: calc(104px + env(safe-area-inset-top)) 26px 40px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: linear-gradient(#f7fbfe, #eaf2f7); }
.empty-icon { width: 74px; height: 74px; border-radius: 24px; display: grid; place-items: center; color: var(--brand); background: #fff; box-shadow: 0 12px 34px rgba(27,73,108,.13); }
.empty-icon svg { width: 34px; }
.empty-state h1 { margin: 22px 0 8px; font-size: 1.45rem; }
.empty-state p { max-width: 340px; margin: 0 0 22px; color: var(--muted); line-height: 1.55; }
.primary-button { padding: 13px 20px; border-radius: 14px; color: #fff; background: var(--brand); text-decoration: none; font-weight: 700; box-shadow: 0 8px 20px rgba(11,103,178,.24); }

.boat-directory {
    min-height: 100vh;
    padding: calc(88px + env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom));
    background: #f3f7fa;
}
.directory-heading { padding: 4px 4px 14px; }
.directory-eyebrow { color: var(--brand); font-size: .72rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.directory-heading h1 { margin: 4px 0 1px; font-size: 1.65rem; letter-spacing: -.035em; }
.directory-heading p { margin: 0; color: var(--muted); font-size: .85rem; }
.boat-search {
    position: sticky;
    z-index: 8;
    top: calc(72px + env(safe-area-inset-top));
    margin-bottom: 14px;
    padding: 5px 5px 5px 13px;
    display: grid;
    grid-template-columns: 22px 1fr auto auto;
    align-items: center;
    gap: 8px;
    border: 1px solid #dde7ee;
    border-radius: 16px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 6px 20px rgba(31,62,84,.08);
    backdrop-filter: blur(10px);
}
.boat-search svg { width: 20px; fill: none; stroke: #718293; stroke-width: 2; stroke-linecap: round; }
.boat-search input { min-width: 0; height: 40px; border: 0; outline: 0; color: var(--ink); background: transparent; font: inherit; }
.boat-search > a { padding: 5px; color: var(--muted); text-decoration: none; font-size: 1.4rem; line-height: 1; }
.boat-search button { height: 38px; padding: 0 14px; border: 0; border-radius: 11px; color: #fff; background: var(--brand); font-weight: 700; }
.boat-list { display: grid; gap: 10px; }
.group-list { display: grid; gap: 10px; }
.group-card {
    min-height: 82px;
    padding: 12px 14px;
    border: 1px solid #e3ebf1;
    border-radius: 16px;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 24px;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    background: #fff;
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(29,59,81,.055);
}
.group-card:hover { border-color: #c7dce9; background: #fbfdff; }
.group-icon {
    width: 48px;
    height: 48px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    color: var(--brand);
    background: #eaf4fb;
}
.group-icon svg,
.group-chevron {
    width: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.operator-icon { color: #5367b7; background: #eef0fb; }
.group-details { min-width: 0; }
.group-details strong,
.group-details small { display: block; }
.group-details strong { overflow: hidden; font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.group-details small { margin-top: 5px; color: var(--muted); font-size: .76rem; }
.group-chevron { color: #9cabb7; }
.public-group-list { grid-template-columns: minmax(0, 1fr); }
.public-group-card {
    min-height: 70px;
    padding: 11px 12px;
    grid-template-columns: 46px minmax(0, 1fr) 42px;
    border-radius: 9px;
}
.public-group-card .group-icon {
    width: 46px;
    height: 46px;
    border-radius: 11px;
}
.public-group-action {
    width: 42px;
    height: 42px;
    border: 1px solid rgba(11, 103, 178, .2);
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--brand);
    background: #e8f3fa;
    box-shadow: 0 2px 7px rgba(29, 59, 81, .08);
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.public-group-action .group-chevron {
    width: 21px;
    height: 21px;
    color: inherit;
}
.public-group-card:hover .public-group-action {
    color: var(--brand);
    background: #dceef9;
    border-color: rgba(11, 103, 178, .25);
    box-shadow: 0 3px 9px rgba(29, 59, 81, .1);
}
.boat-card {
    position: relative;
    overflow: hidden;
    border: 1px solid #e3ebf1;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 4px 16px rgba(29,59,81,.055);
}
.boat-main-link {
    min-height: 104px;
    padding: 10px 38px 22px 10px;
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 10px;
    align-items: start;
    color: inherit;
    text-decoration: none;
}
.boat-photo { width: 72px; height: 72px; border-radius: 13px; object-fit: cover; background: #eaf1f5; }
.boat-details { min-width: 0; }
.boat-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.boat-title-row h2 { min-width: 0; margin: 1px 0 0; overflow: hidden; font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.boat-title-row time { flex: none; color: var(--muted); font-size: .66rem; }
.operator-name { margin: 3px 0 7px; overflow: hidden; color: var(--muted); font-size: .74rem; text-overflow: ellipsis; white-space: nowrap; }
.boat-status { display: flex; align-items: center; gap: 7px; font-size: .78rem; }
.list-status-icon { width: 20px; height: 20px; flex: none; object-fit: contain; image-rendering: auto; }
.chevron { position: absolute; top: 36px; right: 12px; width: 19px; fill: none; stroke: #9cabb7; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.boat-meta-row {
    min-height: 30px;
    position: absolute;
    z-index: 2;
    right: 38px;
    bottom: 4px;
    left: 92px;
    display: flex;
    align-items: center;
    gap: 7px;
}
.boat-meta-link {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    color: inherit;
    text-decoration: none;
}
.boat-meta-link span {
    padding: 3px 7px;
    overflow: hidden;
    border-radius: 7px;
    color: #5b6d7e;
    background: #f0f4f7;
    font-size: .63rem;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.boat-meta-link span:first-child { flex: none; }
.boat-call {
    min-width: 0;
    margin-left: auto;
    padding: 5px 8px;
    display: flex;
    align-items: center;
    gap: 5px;
    border-radius: 9px;
    color: var(--brand);
    background: #eef6fc;
    text-decoration: none;
    font-size: .7rem;
    font-weight: 750;
    white-space: nowrap;
}
.boat-call svg { width: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.boat-call span { overflow: hidden; text-overflow: ellipsis; }
.list-empty { padding: 52px 24px; border-radius: 18px; text-align: center; background: #fff; }
.list-empty h2 { margin: 0 0 6px; font-size: 1.1rem; }
.list-empty p { margin: 0; color: var(--muted); line-height: 1.5; }

@media (min-width: 760px) {
    .app-shell { max-width: 1180px; margin: 0 auto; box-shadow: 0 0 36px rgba(29,61,85,.12); }
    .app-bar, .map-wrap, .vessel-sheet { left: 50%; width: min(100%, 1180px); transform: translateX(-50%); }
    .app-shell.directory-shell { max-width: none; box-shadow: none; }
    .directory-shell .app-bar { left: 0; width: 100%; transform: none; }
    .vessel-sheet { max-width: 560px; right: auto; bottom: 24px; border-radius: 24px; }
    .flutter-boat-card { max-width: 520px; right: auto; width: calc(100% - 20px); }
    .boat-directory { padding-inline: 24px; }
    .boat-list, .group-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .public-group-list { grid-template-columns: minmax(0, 1fr); }
    .selected-vessel-card { right: auto; bottom: 24px; left: 24px; width: 420px; }
}

@media (min-width: 1180px) {
    .boat-list, .group-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .public-group-list { grid-template-columns: minmax(0, 1fr); }
}

@media (max-height: 650px) {
    .vessel-sheet { min-height: 220px; }
    .map-wrap { bottom: 0; }
    .stats { margin-top: 10px; padding: 9px 0; }
    .location-row { padding-top: 10px; }
}
