* { box-sizing: border-box; }

:root {
    --bg: #f4f2ec;
    --card: #ffffff;
    --text: #1f261f;
    --muted: #687264;
    --line: #ded8cc;
    --green: #1f7a3f;
    --red: #b42318;
    --orange: #b76e00;
    --blue: #315a7d;
    --shadow: 0 12px 30px rgba(31, 38, 31, 0.10);
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.app {
    width: min(920px, 100%);
    margin: 0 auto;
    padding: 18px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.app.wide { width: min(1180px, 100%); }

.hero {
    background: linear-gradient(135deg, #25351f, #587047);
    color: white;
    border-radius: 24px;
    padding: 28px 22px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}

.eyebrow {
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: 12px;
    opacity: .85;
}

h1, h2, h3 { margin: 0; }
h1 { font-size: clamp(28px, 8vw, 46px); line-height: 1.05; }
h2 { font-size: 22px; margin-bottom: 16px; }
h3 { font-size: 17px; margin-bottom: 8px; }

.subtitle { margin: 12px 0 0; opacity: .9; max-width: 760px; }

.nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 16px;
}

.nav a {
    text-decoration: none;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 800;
    white-space: nowrap;
}

.nav a.active {
    background: #25351f;
    color: white;
    border-color: #25351f;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 18px;
}

.notice {
    border-radius: 16px;
    padding: 14px 16px;
    margin: 0 0 16px;
    font-weight: 700;
}

.notice.success { background: #e8f7ec; color: var(--green); }
.notice.error { background: #fdecec; color: var(--red); }
.notice.warningbox { background: #fff4df; color: #765000; }

.form { display: grid; gap: 16px; }

label, fieldset {
    display: grid;
    gap: 8px;
    font-weight: 700;
}

fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 700; margin-bottom: 8px; }

input, select, textarea, button {
    width: 100%;
    font: inherit;
    border-radius: 16px;
}

input, select, textarea {
    border: 1px solid #cfc8bb;
    padding: 14px 13px;
    background: white;
    color: var(--text);
}

textarea { resize: vertical; }

.status-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.status-option {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #cfc8bb;
    border-radius: 16px;
    padding: 12px;
    background: #faf9f6;
    font-weight: 700;
}

.status-option input {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
}

.hint {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

button, .small-button {
    border: 0;
    background: #25351f;
    color: white;
    padding: 16px 18px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(37, 53, 31, .22);
    text-decoration: none;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

button:active { transform: translateY(1px); }

button.secondary {
    background: #ffffff;
    color: var(--text);
    border: 1px solid var(--line);
    box-shadow: none;
}

button.danger { background: #7d1f1f; }

.small-button {
    width: auto;
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 14px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.history-header {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.filter { min-width: 210px; }
.timeline { display: grid; gap: 12px; }

.entry {
    border: 1px solid var(--line);
    border-left: 8px solid #9a9a9a;
    border-radius: 18px;
    padding: 14px;
    background: #fff;
}

.entry.ok { border-left-color: var(--green); }
.entry.not_ok { border-left-color: var(--red); }
.entry.repaired { border-left-color: var(--orange); }
.entry.warning { border-left-color: var(--blue); }

.entry-top {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
}

.entry-top strong { display: block; font-size: 17px; }
.entry-top span { color: var(--muted); font-size: 14px; }

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 13px !important;
    font-weight: 800;
    color: white !important;
    white-space: nowrap;
}

.badge.ok { background: var(--green); }
.badge.not_ok { background: var(--red); }
.badge.repaired { background: var(--orange); }
.badge.warning { background: var(--blue); }

.entry p { margin: 10px 0; line-height: 1.45; }

.photo-link { display: block; margin-top: 12px; }
.photo-link img {
    width: 100%;
    max-height: 360px;
    object-fit: cover;
    border-radius: 16px;
    border: 1px solid var(--line);
}

.empty { color: var(--muted); }

.map-toolbar, .coordinate-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.coordinate-box {
    background: #f8f6ef;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
}

.coordinate-box p {
    margin: 0 0 12px;
    color: var(--muted);
    line-height: 1.45;
}

.draw-map, .overview-map {
    width: 100%;
    min-height: 68vh;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #ddd;
    touch-action: none;
}

.map-card { padding: 10px; }

.helpbox {
    background: #f8f6ef;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    line-height: 1.5;
    color: var(--text);
}

.field-list { display: grid; gap: 10px; }

.field-item {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px;
    background: #fff;
    display: grid;
    gap: 4px;
}

.field-item span, .field-item small { color: var(--muted); }

.leaflet-popup-content {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    min-width: 230px;
}

.popup-actions {
    display: grid;
    gap: 6px;
    margin-top: 10px;
}

.popup-actions a {
    display: block;
    background: #25351f;
    color: white !important;
    text-align: center;
    padding: 8px 10px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 800;
}

@media (min-width: 720px) {
    .status-grid { grid-template-columns: repeat(2, 1fr); }
    .map-toolbar { grid-template-columns: repeat(3, 1fr); }
    .coordinate-grid { grid-template-columns: 1fr 1fr 1fr 1fr; }
}


.login-app {
    width: min(520px, 100%);
}

.login-hint {
    margin-top: 14px;
    line-height: 1.45;
}

.userbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 10px 12px;
    margin: -6px 0 16px;
    color: var(--muted);
    flex-wrap: wrap;
}

.userbar a {
    color: #7d1f1f;
    font-weight: 800;
    text-decoration: none;
}

.field-item-actions{grid-template-columns:1fr;align-items:center}.field-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}.field-actions a{display:inline-flex;align-items:center;justify-content:center;border-radius:999px;background:#25351f;color:#fff;text-decoration:none;font-weight:800;padding:10px 13px}.compact-button{width:auto;border-radius:999px;padding:10px 13px;box-shadow:none}.secondary-link{background:#ffffff;color:var(--text);border:1px solid var(--line);box-shadow:none}.deleted-field{opacity:.72;background:#faf9f6}@media (min-width:720px){.field-item-actions{grid-template-columns:1fr auto}.field-actions{margin-top:0}}


.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.checkbox-option {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #cfc8bb;
    border-radius: 16px;
    padding: 12px;
    background: #faf9f6;
    font-weight: 700;
}

.checkbox-option input {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
}

@media (min-width: 720px) {
    .checkbox-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
