@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --navy: #0F1B2D;
    --navy-mid: #1A2D47;
    --navy-light: #243B57;
    --accent: #3DD68C;
    --accent-dim: #2BAD72;
    --amber: #F5A623;
    --slate: #64748B;
    --slate-light: #94A3B8;
    --surface: #F8FAFC;
    --border: #E2E8F0;
    --white: #FFFFFF;
    --text: #0F172A;
    --text-muted: #64748B;
    --page-bg: #F1F5F9;
    --blue: #3B82F6;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15,27,45,.06);
    --shadow-md: 0 4px 12px rgba(15,27,45,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--page-bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    font-weight: 400;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { font-family: 'DM Sans', sans-serif; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
h1 { font-size: 24px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 18px 0 10px; }

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

/* ====== Topbar ====== */
.topbar {
    background: var(--navy);
    color: var(--white);
    height: 56px;
    border-radius: var(--radius-lg);
    margin: 12px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 12px;
    z-index: 100;
    box-shadow: var(--shadow-md);
}
.topbar .brand {
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: 19px;
    letter-spacing: -.01em;
    color: var(--white);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 9px;
}
.topbar .brand:hover { text-decoration: none; }
.topbar .brand .accent { color: var(--accent); }
.topbar .brand-icon { width: 32px; height: 32px; display: block; flex-shrink: 0; }
.topbar .meta { color: rgba(255,255,255,.85); font-size: 13px; display: flex; align-items: center; gap: 10px; }
.topbar .meta a { color: rgba(255,255,255,.85); font-weight: 500; }
.topbar .meta a:hover { color: var(--white); text-decoration: none; }

.cong-pill {
    background: var(--navy-mid);
    color: var(--white);
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.admin-pill {
    background: rgba(61, 214, 140, .18);
    color: var(--accent);
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--navy);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
}
.avatar.admin { background: var(--amber); color: var(--navy); }

/* ====== Container ====== */
.container { max-width: 1100px; margin: 0 auto; padding: 4px 16px 32px; }
.container.narrow { max-width: 480px; }

/* ====== Cards / panels ====== */
.card-block {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.panel-header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    margin-bottom: 14px;
}
.panel-header h2 { margin: 0; }
.section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin: 0 0 10px;
    font-weight: 500;
}

/* ====== Stat row ====== */
.stat-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.stat {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px 14px 20px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.stat::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--slate);
}
.stat.green::before { background: var(--accent); }
.stat.amber::before { background: var(--amber); }
.stat.blue::before  { background: var(--blue); }
.stat.slate::before { background: var(--slate); }
.stat .num {
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: 28px;
    line-height: 1.1;
    color: var(--text);
}
.stat .label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 500;
    margin-top: 4px;
}
@media (max-width: 700px) {
    .stat-row { grid-template-columns: repeat(2, 1fr); }
}

/* ====== Forms ====== */
label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    font-weight: 500;
    margin: 12px 0 6px;
}
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--navy-light);
    box-shadow: 0 0 0 3px rgba(36,59,87,.12);
    background: var(--white);
}

/* ====== Buttons ====== */
.btn {
    display: inline-block;
    padding: 10px 18px;
    background: var(--navy);
    color: var(--white);
    border: 1px solid var(--navy);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    font-family: inherit;
    transition: background .15s, border-color .15s, transform .05s;
    line-height: 1.3;
}
.btn:hover { background: var(--navy-mid); border-color: var(--navy-mid); text-decoration: none; color: var(--white); }
.btn:active { transform: translateY(1px); }
.btn.btn-block { display: block; width: 100%; padding: 12px 18px; border-radius: var(--radius-md); }
.btn.btn-secondary {
    background: var(--white);
    color: var(--navy);
    border: 1px solid var(--border);
}
.btn.btn-secondary:hover {
    background: var(--surface);
    border-color: var(--slate-light);
    color: var(--navy);
}
.btn.btn-ghost { background: transparent; color: var(--navy); border-color: transparent; }
.btn.btn-ghost:hover { background: var(--surface); color: var(--navy); }
.btn.btn-danger { background: #DC2626; border-color: #DC2626; color: var(--white); }
.btn.btn-danger:hover { background: #B91C1C; border-color: #B91C1C; color: var(--white); }
.btn.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--navy); }
.btn.btn-accent:hover { background: var(--accent-dim); border-color: var(--accent-dim); color: var(--navy); }
.btn.btn-amber { background: var(--amber); border-color: var(--amber); color: var(--navy); }
.btn.btn-amber:hover { background: #DC940F; border-color: #DC940F; color: var(--navy); }
.btn.btn-blue { background: var(--blue); border-color: var(--blue); color: var(--white); }
.btn.btn-blue:hover { background: #2563EB; border-color: #2563EB; color: var(--white); }
.btn.btn-small { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ====== Layout helpers ====== */
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
.right { text-align: right; }
.muted { color: var(--text-muted); font-size: 13px; }

/* ====== Tabs ====== */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs .tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
    font-size: 14px;
}
.tabs .tab.active { color: var(--navy); border-bottom-color: var(--accent); }

/* ====== Alerts ====== */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 14px; }
.alert.error { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.alert.success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.alert.info { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ====== Status badges (dot + pill) ====== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
    line-height: 1.2;
    white-space: nowrap;
}
.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: currentColor;
    opacity: .9;
}
.badge.available  { background: #DCFCE7; color: #166534; }
.badge.checked_out { background: #FEF3C7; color: #92400E; }
.badge.worked     { background: #EFF6FF; color: #1E40AF; }

/* ====== Card list with thumbnails ====== */
.card-list { list-style: none; padding: 0; margin: 0; }
.card-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    border-radius: 10px;
    transition: box-shadow .15s, background .15s;
}
.card-list li:first-child { border-top: 0; }
.card-list li:hover { background: var(--surface); box-shadow: var(--shadow-sm); }
.card-list .name { font-weight: 500; }
.card-list .name a { color: var(--text); }

.card-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
}
.card-row .thumb {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
}
.card-row .thumb svg { display: block; width: 100%; height: 100%; }
.card-row .body { flex: 1; min-width: 0; }
.card-row .body .name a { color: var(--text); font-weight: 500; }
.card-row .body .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-row .body .worked-tag { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.card-row .body .worked-tag.never { color: var(--amber); font-weight: 600; }
.card-row .body .held-tag { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.card-row .body .held-tag.mine { color: var(--accent-dim); font-weight: 600; }

/* ====== Member board actions ====== */
.board-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}
.board-actions form { margin: 0; }

/* ====== Member login + access code ====== */
.member-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.member-auth-card { max-width: 420px; width: 100%; margin: 0; }
.access-code-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.access-code-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.access-code {
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--navy);
}

/* ====== Map ====== */
.map {
    width: 100%;
    height: 60vh;
    min-height: 320px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
}
.map.tall { height: 70vh; }
.map-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.map-help { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }

/* ====== Status toggle ====== */
.status-toggle { display: flex; gap: 8px; flex-wrap: wrap; }
.status-toggle .btn { flex: 1; min-width: 130px; border-radius: var(--radius-md); padding: 12px; }

/* ====== QR ====== */
.qr-wrap { display: flex; flex-direction: column; align-items: center; padding: 12px; background: var(--white); }
.qr-wrap canvas, .qr-wrap img { display: block; }

/* ====== Pin list ====== */
.pin-list { list-style: none; padding: 0; margin: 0; }
.pin-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
    font-size: 14px;
}
.pin-list li:first-child { border-top: 0; }

/* ====== Leaflet tooltip ====== */
.leaflet-tooltip.card-label {
    background: rgba(255,255,255,.92);
    border: 1px solid rgba(15,27,45,.1);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,.08);
    white-space: nowrap;
}
.leaflet-tooltip.card-label::before { display: none; }

/* ====== Auth two-column ====== */
.auth-shell {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
}
.auth-side {
    background: var(--navy);
    color: var(--white);
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.auth-side .brand {
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: 36px;
    margin-bottom: 14px;
    color: var(--white);
}
.auth-side .brand .accent { color: var(--accent); }
.auth-side .tagline {
    font-size: 16px;
    color: rgba(255,255,255,.78);
    margin: 0 0 30px;
    max-width: 380px;
    line-height: 1.55;
}
.auth-side .features {
    list-style: none;
    padding: 0;
    margin: 0;
    color: rgba(255,255,255,.88);
    font-size: 14px;
}
.auth-side .features li {
    padding: 7px 0 7px 22px;
    position: relative;
}
.auth-side .features li::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--accent);
    position: absolute;
    left: 0;
    top: 14px;
}
.auth-main {
    background: var(--white);
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.auth-main-inner {
    max-width: 380px;
    width: 100%;
    margin: 0 auto;
}
.auth-main .wordmark { display: block; height: 40px; width: auto; margin: 0 0 24px; }
.auth-main h1 { font-size: 22px; margin: 0 0 4px; }
.auth-main p.lede { color: var(--text-muted); margin: 0 0 18px; }
@media (max-width: 800px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-side { display: none; }
}

/* ====== Admin orgs table ====== */
.orgs-table { width: 100%; border-collapse: collapse; }
.orgs-table th, .orgs-table td { padding: 11px 14px; text-align: left; vertical-align: middle; font-size: 14px; }
.orgs-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 500;
    background: var(--white);
}
.orgs-table tbody tr:nth-child(even) { background: var(--surface); }
.orgs-table tbody tr:hover { background: #EFF6FF; }
.orgs-table tbody tr.disabled td { opacity: .55; }
.orgs-table .row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.orgs-table .org-email { color: var(--text-muted); font-size: 12px; }

/* ====== Mobile ====== */
@media (max-width: 540px) {
    .container { padding: 4px 12px 24px; }
    .topbar { margin: 8px; padding: 0 14px; height: 52px; }
    .topbar .brand { font-size: 17px; gap: 7px; }
    .topbar .brand-icon { width: 28px; height: 28px; }
    .card-block { padding: 16px; }
    /* Trim the squished header: the avatar already shows the congregation
       initials (amber when admin), so drop the redundant name/role pills. */
    .topbar .cong-pill,
    .topbar .admin-pill { display: none; }
    .topbar .meta { gap: 8px; }
}

/* ====== Print ====== */
@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .topbar { display: none; }
}
