/* AGRYENA Kontaktanfrage – responsive, brand-matched styling.
   Brand: accent green #69b500, label colour #212D3A.
   Typeface: PT Sans (SIL OFL, self-hosted) – matches the original site. */

/* PT Sans – self-hosted (copied from the original agryena.com stylesheet). */
@font-face {
    font-family: "PT Sans";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/pt-sans-v17-latin-ext_latin_cyrillic-ext_cyrillic-regular.woff2") format("woff2");
}
@font-face {
    font-family: "PT Sans";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/pt-sans-v17-latin-ext_latin_cyrillic-ext_cyrillic-italic.woff2") format("woff2");
}
@font-face {
    font-family: "PT Sans";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/pt-sans-v17-latin-ext_latin_cyrillic-ext_cyrillic-700.woff2") format("woff2");
}
@font-face {
    font-family: "PT Sans";
    font-style: italic;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/pt-sans-v17-latin-ext_latin_cyrillic-ext_cyrillic-700italic.woff2") format("woff2");
}

:root {
    --brand: #69b500;
    --brand-dark: #5aa000;
    --label: #212D3A;
    --text: #33475B;
    --help: #516383;
    --border: #cbd6e2;
    --border-focus: #69b500;
    --error: #c0392b;
    --bg: #ffffff;
    --card: #ffffff;
    --field-bg: #eef3f7;
    --radius: 6px;
    --input-radius: 16px;
    --maxw: 760px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "PT Sans", "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 1rem;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { color: var(--brand-dark); }

/* --- Header / nav --- */
.site-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.site-header__logo img { height: 40px; width: auto; display: block; }

.site-nav { display: flex; gap: 18px; align-items: center; }
.site-nav a { color: var(--label); text-decoration: none; font-size: 15px; }
.site-nav a.is-active { color: var(--brand-dark); font-weight: bold; }
.site-nav__logout { color: var(--help); }

.site-main { flex: 1 0 auto; padding: 24px 16px 48px; }

.site-footer {
    flex-shrink: 0;
    text-align: center;
    padding: 16px;
    color: var(--help);
    font-size: 12px;
    border-top: 1px solid var(--border);
    background: var(--card);
}

/* --- Form layout --- */
.form-wrap, .admin-wrap, .login-card { max-width: var(--maxw); margin: 0 auto; }

.form-intro { color: var(--label); font-size: 24px; margin: 0 0 20px; }

.hs-form { background: transparent; }

.form-section {
    border: none;
    border-top: 2px solid var(--brand);
    margin: 0 0 28px;
    padding: 0;
}
.form-section legend { padding: 0; width: 100%; }
.form-section legend h2 {
    color: var(--label);
    font-size: 19px;
    margin: 14px 0 16px;
}

.field { margin: 0 0 18px; }
.field > label {
    display: block;
    color: var(--label);
    font-size: 13px;
    font-weight: bold;
    margin: 0 0 6px;
}
.req { color: var(--error); }

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="password"],
input[type="file"],
select,
textarea {
    width: 100%;
    font: inherit;
    color: var(--text);
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--input-radius);
    background: var(--field-bg);
}
textarea { resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(105, 181, 0, 0.18);
}

.has-error input,
.has-error select,
.has-error textarea { border-color: var(--error); }

/* Radio groups */
.radio-group { display: flex; flex-direction: column; gap: 8px; }
.radio-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 15px;
    color: var(--text);
    cursor: pointer;
}
.radio-option input { margin-top: 3px; }

/* Submit button */
.btn-submit {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 12px 28px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    margin: 8px auto 0;
}
.hs-form .btn-submit { display: block; }
.btn-submit:hover { background: var(--brand-dark); }
.btn-submit--sm { padding: 9px 18px; width: 100%; }

/* Submit + test-data filler share one row. */
.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}
.hs-form .form-actions .btn-submit { display: inline-block; margin: 0; }

.btn-testdata {
    display: inline-block;
    background: #fff;
    color: var(--brand-dark);
    border: 1px solid var(--brand);
    border-radius: var(--radius);
    padding: 12px 22px;
    font: inherit;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}
.btn-testdata:hover { background: #f1f8e8; }

.btn-submit:disabled,
.btn-submit[aria-disabled="true"] { opacity: 0.6; cursor: default; }

/* Submit upload progress bar (shown by submit-progress.js during upload) */
.submit-progress { margin: 14px 0 0; }
.submit-progress__track {
    height: 10px;
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
}
.submit-progress__fill {
    height: 100%;
    width: 0;
    background: var(--brand);
    border-radius: inherit;
    transition: width 0.2s ease;
}
/* Upload finished, server still working: animated stripes over the full bar. */
.submit-progress.is-processing .submit-progress__fill {
    background-image: linear-gradient(45deg,
        rgba(255, 255, 255, 0.28) 25%, transparent 25%,
        transparent 50%, rgba(255, 255, 255, 0.28) 50%,
        rgba(255, 255, 255, 0.28) 75%, transparent 75%, transparent);
    background-size: 16px 16px;
    animation: submit-progress-stripes 0.8s linear infinite;
}
@keyframes submit-progress-stripes {
    from { background-position: 0 0; }
    to { background-position: 16px 0; }
}
.submit-progress__label {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--help);
}
@media (prefers-reduced-motion: reduce) {
    .submit-progress.is-processing .submit-progress__fill { animation: none; }
    .submit-progress__fill { transition: none; }
}

/* --- Image marker (roof-area marking on uploads) --- */
.image-marker { margin: 10px 0 0; }
.image-marker__toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px;
}
.image-marker__hint { font-size: 13px; color: var(--help); margin-right: auto; }
.btn-mini.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }

.image-marker__stage {
    position: relative; display: inline-block; max-width: 100%;
    border-radius: var(--radius); overflow: hidden;
}
.image-marker__img { display: block; max-width: 100%; max-height: 380px; }
.image-marker__svg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    cursor: crosshair; touch-action: none;
}

/* Shared overlay shapes (editor, Auswertung, PDF use the same classes).
   Magenta + white halo stays visible on red brick, dark roofs, foliage,
   sky and concrete alike. */
.marker-halo { fill: none; stroke: #fff; stroke-opacity: 0.85; stroke-width: 1.35; }
.marker-halo--draft { fill: none; stroke: #fff; stroke-opacity: 0.85; stroke-width: 1.35; stroke-dasharray: 2 1.5; }
.marker-shape { fill: rgba(255, 45, 155, 0.22); stroke: #e6007e; stroke-width: 0.53; }
.marker-shape--draft { fill: rgba(255, 45, 155, 0.12); stroke: #e6007e; stroke-dasharray: 2 1.5; }
.marker-line { fill: none; stroke: #e6007e; stroke-width: 0.53; stroke-dasharray: 2 1.5; }
.marker-vertex { fill: #e6007e; }
/* Enlarged "tap to close" target for the first polygon vertex. */
.marker-vertex--first { fill: #fff; stroke: #e6007e; stroke-width: 0.53; }

/* Image + overlay wrapper used on the Auswertung page. */
.marker-figure { position: relative; display: inline-block; max-width: 100%; }
.marker-figure img { display: block; max-width: 100%; }
.marker-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.marker-figure--admin { margin-top: 8px; max-width: 320px; }
.marker-figure--admin img { border: 1px solid var(--border); border-radius: var(--radius); }

/* Messages */
.form-error {
    background: #fdecea;
    border: 1px solid var(--error);
    color: var(--error);
    padding: 10px 14px;
    border-radius: var(--radius);
    margin: 0 0 18px;
    font-size: 14px;
}

/* --- Login --- */
.page-login .site-main { display: flex; align-items: center; justify-content: center; }
.login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 100%;
    max-width: 360px;
}
.login-card h1 { color: var(--label); font-size: 22px; margin: 0 0 18px; }
.login-card .btn-submit { width: 100%; }

/* --- Admin --- */
.admin-wrap h1 { color: var(--label); font-size: 24px; }
.admin-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.admin-head h1 { margin: 0; }
.clear-form { margin: 0; }
.btn-clear {
    font: inherit;
    font-size: 14px;
    font-weight: bold;
    color: var(--error);
    background: #fff;
    border: 1px solid var(--error);
    border-radius: var(--radius);
    padding: 9px 18px;
    cursor: pointer;
}
.btn-clear:hover { background: var(--error); color: #fff; }
.admin-hint { color: var(--help); font-size: 14px; }
.admin-hint code, .empty { font-size: 13px; }

.sub-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin: 0 0 18px;
}
.sub-card__head h2 { color: var(--label); font-size: 18px; margin: 0 0 4px; }
.sub-meta { color: var(--help); font-size: 12px; }

.sub-grid { display: grid; grid-template-columns: 1fr 240px; gap: 18px; margin-top: 12px; }
/* Let grid tracks shrink below content width so the JSON box can scroll
   horizontally instead of stretching the layout. */
.sub-grid > * { min-width: 0; }
.sub-data__bar { display: flex; align-items: center; justify-content: space-between; }
.sub-data h3, .sub-controls h3 { font-size: 14px; color: var(--label); margin: 12px 0 8px; }

pre.json {
    background: #0f1d2b;
    color: #cfe8b0;
    padding: 12px;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.45;
    margin: 0;
}

.email-text {
    white-space: pre-line;
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text);
}

.btn-mini {
    font: inherit;
    font-size: 12px;
    color: var(--label);
    background: #eef3f7;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
}

.uploads { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.uploads li { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.uploads__field { color: var(--help); margin-right: 6px; }
.uploads__size { color: var(--help); }

.sub-controls { background: #f7fafc; border-left: 1px solid var(--border); padding-left: 16px; }
.pdf-form .field { margin-bottom: 12px; }
.pdf-form .field span { display: block; font-size: 13px; font-weight: bold; color: var(--label); margin-bottom: 4px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; margin: 0 0 12px; }
.output-note { color: var(--help); font-size: 12px; }

/* --- CRM ----------------------------------------------------------------- */

/* Intentional gray for default/placeholder hint text (e.g. CRM note fields). */
input::placeholder, textarea::placeholder { color: var(--help); opacity: 1; }

/* Date/time pickers share the standard field look. */
input[type="date"], input[type="datetime-local"] {
    width: 100%;
    font: inherit;
    color: var(--text);
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--input-radius);
    background: var(--field-bg);
}

.serial { color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.muted { color: var(--help); }
/* Explicit tap-to-call links: keep the surrounding text's look, stay dialable. */
.tel { color: inherit; text-decoration: none; }

/* Overview table. */
.crm-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.crm-table th {
    text-align: left; font-size: 12px; color: var(--help);
    border-bottom: 2px solid var(--border); padding: 6px 10px;
}
.crm-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.crm-table th.num, .crm-table td.num { text-align: right; }
.crm-table a { color: var(--brand-dark); text-decoration: none; }

/* Sortable column headers. */
.crm-sort {
    background: none; border: 1px solid transparent; margin: 0;
    padding: 1px 8px; border-radius: 999px;
    font: inherit; color: inherit; cursor: pointer;
    display: inline-flex; align-items: center; gap: 4px;
}
.crm-sort:hover { color: var(--brand-dark); }
.crm-sort:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* Active sort column: filled like an active filter chip (brand bg, white text),
   with an up/down triangle for the direction. */
.crm-table th[aria-sort] .crm-sort {
    background: var(--brand); color: #fff; border-color: var(--brand);
}
.crm-table th[aria-sort="ascending"] .crm-sort::after { content: "▲"; font-size: 9px; }
.crm-table th[aria-sort="descending"] .crm-sort::after { content: "▼"; font-size: 9px; }

/* Tag chips. */
.crm-tag {
    display: inline-block; font-size: 12px; margin: 0 4px 2px 0;
    padding: 1px 8px; border-radius: 999px;
    /* Subtle, stable per-tag colour from --tag-h (see tag_hue). */
    background: hsl(var(--tag-h, 210), 60%, 95%);
    color: hsl(var(--tag-h, 210), 42%, 37%);
    border: 1px solid hsl(var(--tag-h, 210), 45%, 84%);
}

/* Tag filter bar (overview). */
.crm-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0 14px; }
.crm-filter__label { font-size: 12px; font-weight: bold; color: var(--label); margin-right: 4px; }
.crm-tag--btn { cursor: pointer; text-decoration: none; }
.crm-tag--btn:hover { border-color: var(--brand); }
.crm-tag--btn.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.crm-filter__clear { font-size: 12px; color: var(--help); text-decoration: underline; margin-left: 4px; }

/* Tag chip editor (detail meta form). */
.crm-chips__list { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.crm-chip {
    display: inline-flex; align-items: center; gap: 2px; font-size: 12px;
    padding: 1px 4px 1px 8px; border-radius: 999px;
    background: hsl(var(--tag-h, 210), 60%, 95%);
    color: hsl(var(--tag-h, 210), 42%, 37%);
    border: 1px solid hsl(var(--tag-h, 210), 45%, 84%);
}
.crm-chip__x {
    border: 0; background: transparent; cursor: pointer; color: inherit; opacity: 0.7;
    font-size: 12px; line-height: 1; padding: 2px 4px; border-radius: 999px;
}
.crm-chip__x:hover { color: var(--error); opacity: 1; }
.crm-chips__input { width: 100%; }
.is-js-hidden { display: none !important; }

/* Autocomplete dropdown for the tag input. */
.crm-chips__combo { position: relative; }
.crm-chips__suggest {
    list-style: none; margin: 2px 0 0; padding: 4px;
    position: absolute; left: 0; right: 0; top: 100%; z-index: 10;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(15, 29, 43, 0.12); max-height: 220px; overflow-y: auto;
}
.crm-chips__opt {
    padding: 4px 8px; border-radius: 4px; font-size: 13px; cursor: pointer;
    color: hsl(var(--tag-h, 210), 42%, 30%);
}
.crm-chips__opt:hover,
.crm-chips__opt.is-active { background: hsl(var(--tag-h, 210), 60%, 93%); }

/* Detail page. */
.crm-back { font-size: 13px; margin: 0 0 4px; }
.crm-back a { color: var(--help); text-decoration: none; }
.crm-detail .serial { font-size: inherit; }

.crm-meta {
    background: #f7fafc; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; margin: 12px 0 20px;
}
.crm-meta__grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px; margin-bottom: 12px;
}
.crm-meta__tags { grid-column: 1 / -1; }
.crm-meta .field { margin: 0; }
.crm-meta .field span { display: block; font-size: 12px; font-weight: bold; color: var(--label); margin-bottom: 4px; }

/* [+] add controls. */
.crm-add { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin: 0 0 20px; }
.crm-add__label { font-weight: bold; color: var(--brand-dark); align-self: center; }
.crm-add__item { position: relative; }
.crm-add__item > summary {
    list-style: none; display: inline-block; user-select: none;
}
.crm-add__item > summary::-webkit-details-marker { display: none; }
.crm-add__item[open] > summary { background: var(--brand); color: #fff; border-color: var(--brand); }
.crm-form {
    position: absolute; z-index: 5; margin-top: 8px; width: 320px; max-width: 90vw;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(15, 29, 43, 0.12); padding: 14px 16px;
}
.crm-form .field { margin: 0 0 10px; }
.crm-form .field span { display: block; font-size: 12px; font-weight: bold; color: var(--label); margin-bottom: 4px; }

/* Timeline. */
.crm-timeline__title { color: var(--label); font-size: 18px; border-bottom: 2px solid var(--brand); padding-bottom: 6px; }
.crm-timeline { list-style: none; padding: 0; margin: 0; }
.crm-item {
    border: 1px solid var(--border); border-left: 3px solid var(--border);
    border-radius: var(--radius); padding: 10px 14px; margin: 0 0 12px; background: var(--card);
}
.crm-item--mail    { border-left-color: var(--help); }
.crm-item--call    { border-left-color: #2b5fb8; }
.crm-item--meeting { border-left-color: #8a6100; }
.crm-item--note    { border-left-color: var(--brand); }
.crm-item--email   { border-left-color: #6b3fa0; }
.crm-item__head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.crm-item__kind { font-weight: bold; color: var(--label); font-size: 14px; }
.crm-item__when { color: var(--help); font-size: 12px; }
.crm-item__del { margin-left: auto; }
.crm-item__del button { color: var(--error); }
.crm-item__facts { display: flex; flex-wrap: wrap; gap: 12px; color: var(--help); font-size: 13px; margin-bottom: 4px; }
.crm-item__notes { white-space: pre-line; font-size: 13px; line-height: 1.55; color: var(--text); }

/* --- Mailing / campaigns --- */
.banner {
    border-radius: var(--radius); padding: 10px 14px; margin: 0 0 16px;
    font-size: 14px; font-weight: bold; border: 1px solid var(--border);
}
.banner--ok   { background: #e3f4d1; color: #4b7a00; border-color: #c2e08f; }
.banner--warn { background: #fff3d6; color: #8a6100; border-color: #f0dca0; }

.camp-filter {
    background: #f7fafc; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; margin: 0 0 18px;
}
.camp-filter .field { margin: 0 0 10px; }
.camp-filter .field span { display: block; font-size: 12px; font-weight: bold; color: var(--label); margin-bottom: 4px; }
.camp-filter__tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.camp-filter__label { font-size: 12px; font-weight: bold; color: var(--label); margin-right: 4px; }
.camp-filter__actions { display: flex; align-items: center; gap: 10px; }

/* Tag chip that carries a checkbox (filter selection). */
.camp-tagcheck { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; }
.camp-tagcheck input { margin: 0; }
.camp-tagcheck.is-active { box-shadow: 0 0 0 2px var(--brand) inset; }

.camp-table th.camp-check, .camp-table td.camp-check { width: 1%; text-align: center; }
.camp-table td.camp-check input, .camp-table th.camp-check input { margin: 0; }

.camp-well {
    margin: 16px 0 24px; padding: 14px 16px;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(15, 29, 43, 0.08);
}
.camp-well .field { margin: 0 0 12px; }
.camp-well .field span { display: block; font-size: 12px; font-weight: bold; color: var(--label); margin-bottom: 4px; }
.camp-well textarea, .camp-well input[type="text"] { width: 100%; }

/* --- Responsive --- */
@media (max-width: 640px) {
    .site-main { padding: 16px 12px 36px; }
    .form-intro { font-size: 20px; }
    .sub-grid { grid-template-columns: 1fr; }
    .sub-controls { border-left: none; border-top: 1px solid var(--border); padding-left: 0; padding-top: 12px; }
    .site-header { padding: 12px 14px; }
    .site-header__logo img { height: 32px; }
    .crm-meta__grid { grid-template-columns: 1fr; }
    .crm-form { position: static; width: 100%; box-shadow: none; }
}
