/* SafeAway — hand-rolled stylesheet, no build step required. */

:root {
    --bg: #f9fbfa;
    --surface: #ffffff;
    --ink: #12211b;
    --muted: #677e73;
    --border: #d6e1db;
    --green: #1d724a;
    --green-dark: #175c3c;
    --green-tint: #dfece5;
    --green-tint-soft: #ecf4ef;
    --green-ink: #1f4734;
    --red-tint: #fbecea;
    --red-ink: #8c2f23;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 2px rgba(18, 33, 27, .04), 0 4px 12px rgba(18, 33, 27, .05);
    --shadow-modal: 0 8px 40px rgba(18, 33, 27, .18);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; }

/* ---------- Header ---------- */

.site-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 19px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }
.brand svg { color: var(--green); }

.header-sub { color: var(--muted); font-size: 14px; }

.header-spacer { flex: 1; }

.back-link {
    display: inline-flex;
    align-items: center;
    color: var(--ink);
    padding: 4px;
    border-radius: 8px;
}
.back-link:hover { background: var(--green-tint-soft); }

/* Avatar + menu */
.avatar-wrap { position: relative; }
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 0;
    background: var(--green);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.avatar-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
    min-width: 200px;
    padding: 6px;
    display: none;
    z-index: 50;
}
.avatar-menu.open { display: block; }
.avatar-menu .menu-user {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}
.avatar-menu .menu-user strong { display: block; font-size: 14px; }
.avatar-menu .menu-user span { font-size: 12px; color: var(--muted); word-break: break-all; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    font-size: 14px;
    color: var(--ink);
    background: none;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}
.menu-item:hover { background: var(--green-tint-soft); text-decoration: none; }

/* ---------- Layout ---------- */

.page { max-width: 1060px; margin: 0 auto; padding: 32px 24px 80px; }
.page-narrow { max-width: 720px; margin: 0 auto; padding: 32px 20px 80px; }

.page-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.page-top h1 { font-size: 30px; letter-spacing: -.02em; }

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 18px;
    cursor: pointer;
    transition: background .15s ease;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: var(--green-tint); color: var(--green-ink); }
.btn-secondary:hover { background: #d2e4da; }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: #fff; color: #b3251e; border-color: #ecc8c5; }
.btn-danger:hover { background: var(--red-tint); }
.btn-block { width: 100%; }
.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 0;
    color: var(--green);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
}
.btn-link:hover { background: var(--green-tint-soft); text-decoration: none; }
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 0;
    background: none;
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
}
.icon-btn:hover { background: var(--green-tint-soft); color: var(--ink); }
.icon-btn.danger:hover { background: var(--red-tint); color: var(--red-ink); }

/* ---------- Tabs ---------- */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin: 18px 0 24px;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    appearance: none;
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--ink); border-bottom-color: var(--green); font-weight: 600; }

/* ---------- Trip cards (My Trips) ---------- */

.trip-group-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--green-ink);
    margin: 20px 0 12px;
}
.trip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.trip-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    color: var(--ink);
    transition: box-shadow .15s ease, border-color .15s ease;
}
.trip-card:hover { text-decoration: none; box-shadow: var(--shadow); border-color: #c3d2ca; }
.trip-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}
.trip-card h3 { font-size: 18px; margin-bottom: 4px; }
.trip-card .trip-meta { font-size: 14px; color: var(--muted); }
.trip-card .trip-dates { font-size: 13px; color: var(--muted); }
.trip-card .trip-shared {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
    margin-top: 10px;
}
.trip-card .trip-shared.is-shared { color: var(--green); }

.chip {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    background: var(--green-tint);
    color: var(--green-ink);
}
.chip-neutral { background: #edf1ef; color: var(--muted); }
.chip-active { background: #def0e4; color: #175c3c; }

.empty-note {
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    padding: 56px 0;
}

/* ---------- Trip detail ---------- */

.trip-heading { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trip-heading h1 { font-size: 28px; letter-spacing: -.02em; }
.trip-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.section-head h2 { font-size: 18px; }

.item-list { display: flex; flex-direction: column; gap: 12px; }
.item-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
}
.item-card .item-body { flex: 1; min-width: 0; }
.item-card .item-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
}
.item-card .item-title svg { color: var(--ink); flex: none; }
.item-card .item-meta { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.item-card .item-actions { display: flex; gap: 2px; flex: none; }
.item-rows { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.item-rows .row { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; }
.item-rows .row .k { color: var(--muted); }
.item-rows .row .v { text-align: right; overflow-wrap: anywhere; }

/* ---------- Modals ---------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(18, 33, 27, .45);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 16px;
    overflow-y: auto;
    z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
    background: #fdfdfc;
    border-radius: 16px;
    box-shadow: var(--shadow-modal);
    width: 430px;
    max-width: 100%;
    padding: 24px;
    margin: auto 0;
    position: relative;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.modal-head h2 { font-size: 19px; }
.modal-sub { color: var(--muted); font-size: 14px; margin: -10px 0 16px; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* ---------- Forms ---------- */

.field { margin-bottom: 14px; }
.field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}
.field input,
.field select,
.field textarea {
    width: 100%;
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(29, 114, 74, .12);
}
.field input::placeholder, .field textarea::placeholder { color: #9fb1a8; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.field-error { color: #b3251e; font-size: 13px; margin-top: 4px; }

.current-file {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
    margin-top: 6px;
}

/* ---------- Auth ---------- */

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(18, 33, 27, .05);
    width: 390px;
    max-width: 100%;
    padding: 36px 32px;
}
.auth-card h1 { font-size: 24px; text-align: center; margin-bottom: 24px; }
.auth-brand { display: flex; justify-content: center; margin-bottom: 10px; }
.auth-foot { text-align: center; font-size: 14px; color: var(--muted); margin-top: 22px; }
.auth-foot a { font-weight: 700; color: var(--ink); }

/* ---------- Shared public view ---------- */

.shared-title { font-size: 28px; letter-spacing: -.02em; }
.shared-sub { color: var(--muted); font-size: 14px; margin: 6px 0 26px; }

.shared-section { margin-bottom: 26px; }
.shared-section > h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    margin-bottom: 12px;
}
.tint-card {
    border-radius: var(--radius-lg);
    padding: 18px;
    border: 1px solid transparent;
}
.tint-green { background: var(--green-tint-soft); border-color: #dceae1; }
.tint-red { background: var(--red-tint); border-color: #f4ddda; }
.tint-card h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    margin-bottom: 10px;
}
.contact-line { font-size: 14px; margin-top: 2px; overflow-wrap: anywhere; }
.contact-label { font-weight: 600; font-size: 14px; margin-top: 8px; }
.contact-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 7px 0;
    font-size: 14px;
}
.contact-row + .contact-row { border-top: 1px solid rgba(18, 33, 27, .05); }
.contact-row .who strong { font-size: 14px; }
.contact-row .who .rel { color: var(--muted); }
.contact-row .who .loc { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.contact-row .phone { white-space: nowrap; font-size: 14px; }

.kv-row { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; padding: 4px 0; }
.kv-row .k { color: var(--muted); }
.kv-row .v { text-align: right; overflow-wrap: anywhere; }

/* ---------- Share modal ---------- */

.share-link-box {
    background: var(--green-tint-soft);
    border-radius: var(--radius);
    padding: 14px;
}
.share-link-row { display: flex; gap: 8px; }
.share-link-row input {
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 10px;
    min-width: 0;
}
.share-note { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.share-divider { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.invite-row { display: flex; gap: 8px; }
.invite-row input { flex: 1; min-width: 0; }
.invite-ok { color: var(--green); font-size: 13px; margin-top: 8px; display: none; }

/* ---------- Admin ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    margin: 20px 0 28px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
}
.stat-card .stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat-card .stat-value { font-size: 26px; font-weight: 800; margin-top: 2px; }

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    margin-bottom: 28px;
}
table.admin { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
table.admin th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
table.admin td { padding: 11px 16px; border-bottom: 1px solid #ecf1ee; vertical-align: top; }
table.admin tr:last-child td { border-bottom: 0; }
.pager { display: flex; gap: 10px; padding: 10px 16px; font-size: 14px; }

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

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: #fff;
    font-size: 14px;
    padding: 10px 18px;
    border-radius: 999px;
    box-shadow: var(--shadow-modal);
    z-index: 200;
    animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
    .page, .page-narrow { padding: 20px 16px 64px; }
    .site-header { padding: 12px 16px; }
    .page-top h1 { font-size: 24px; }
    .trip-heading h1 { font-size: 22px; }
    .trip-grid { grid-template-columns: 1fr; }
    .modal { padding: 20px 16px; }
    .modal-overlay { padding: 12px 8px; }
    .field-row { flex-direction: column; gap: 0; }
    .item-card { flex-wrap: wrap; }
    .header-sub { display: none; }
}
