:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --border: #e5e7eb;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
    --bg: #111827;
    --surface: #1f2937;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --border: #374151;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.nav-brand a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.nav-links a {
    margin-left: 1.25rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}

.nav-links a:hover { color: var(--primary); }

.container {
    flex: 1;
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1rem;
    width: 100%;
}

.footer {
    text-align: center;
    padding: 1rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

h1 { margin-top: 0; }

.actions {
    margin: 1rem 0;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-block;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.15s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-small { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-seen { background: var(--success); color: #fff; }
.btn-unseen { background: var(--border); color: var(--text); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: var(--shadow);
}

.location-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.form-box {
    max-width: 420px;
    margin: 3rem auto;
    background: var(--surface);
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.form-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    max-width: 700px;
}

.field { margin-bottom: 1rem; }
.field label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.field-wide {
    grid-column: 1 / -1;
}

.input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
}

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

.error {
    color: var(--danger);
    font-size: 0.85rem;
}

.flash-messages { margin-bottom: 1rem; }
.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
}
.alert-success { background: #dcfce7; color: #166534; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e40af; }
.alert-warning { background: #fef3c7; color: #92400e; }

[data-theme="dark"] .alert-success { background: #14532d; color: #bbf7d0; }
[data-theme="dark"] .alert-danger { background: #7f1d1d; color: #fecaca; }
[data-theme="dark"] .alert-info { background: #1e3a8a; color: #bfdbfe; }
[data-theme="dark"] .alert-warning { background: #78350f; color: #fde68a; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    box-shadow: var(--shadow);
    border-radius: 0.5rem;
    overflow: hidden;
}
.data-table th, .data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    background: var(--bg);
    font-weight: 600;
}
.data-table .empty { text-align: center; color: var(--muted); }

.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
}
.search-input { min-width: 350px; }

.inline-form { display: inline; }

.detail-card { max-width: 700px; }
.detail-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}
.detail-table th {
    width: 160px;
    text-align: left;
    padding: 0.5rem;
    vertical-align: top;
    color: var(--muted);
}
.detail-table td { padding: 0.5rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.big {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.coords, .uuid {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0.25rem 0;
}

#gps-status { margin-left: 0.5rem; color: var(--muted); font-size: 0.9rem; }

@media (max-width: 640px) {
    .field-row { grid-template-columns: 1fr; }
    .search-input { min-width: auto; }
    .nav-links a { margin-left: 0.75rem; font-size: 0.9rem; }
}
