:root {
    --bg: #f4fbf6;
    --card: #ffffff;
    --accent: #216b31;
    --accent-strong: #174f25;
    --muted: #667085;
    --text: #0f1720;
    --danger: #b42318;
    --border: #dfeadf;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 24px;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, "Segoe UI", Arial, sans-serif;
}

.container {
    max-width: 1180px;
    margin: 0 auto;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 18px;
}

.title-banner {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 20px;
    font-weight: 700;
}

.subtitle {
    margin: 8px 0;
    color: var(--muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-actions a {
    color: var(--accent-strong);
    font-weight: 600;
    text-decoration: none;
}

.header-actions a:hover {
    text-decoration: underline;
}

.card {
    margin: 14px 0;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    box-shadow: 0 6px 18px rgba(34, 60, 80, 0.05);
}

h2 {
    margin: 0 0 14px;
    color: var(--text);
    font-size: 20px;
}

h3 {
    color: var(--accent-strong);
    font-size: 17px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.section-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

.production-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

button,
input[type="submit"] {
    padding: 10px 14px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}

button:hover,
input[type="submit"]:hover {
    filter: brightness(0.95);
}

button:disabled,
input[type="submit"]:disabled {
    cursor: wait;
    opacity: 0.65;
}

.secondary {
    background: #7a8288;
}

.language-toggle {
    min-width: 82px;
}

.delete-selected {
    border: 1px solid #f0c2bd;
    background: #fff;
    color: var(--danger);
}

.edit-calculation {
    padding: 7px 12px;
    font-size: 14px;
    white-space: nowrap;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    overflow: auto;
    padding: 32px 16px;
    background: rgba(15, 23, 32, 0.52);
}

.modal-content {
    position: relative;
    width: min(560px, 100%);
    margin: 0 auto;
    padding: 26px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 45px rgba(15, 23, 32, 0.2);
}

.modal-content h2 {
    margin: 0 36px 20px 0;
    color: var(--accent-strong);
}

.close-modal {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: #fff;
    color: var(--muted);
    font-size: 24px;
    line-height: 1;
}

.modal-content form > div,
.modal-content form > p {
    margin: 0 0 14px;
}

.modal-content label {
    display: block;
    margin-bottom: 7px;
    color: var(--text);
    font-weight: 600;
}

.modal-content select,
.modal-content input[type="number"],
.modal-content input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    font: inherit;
}

.modal-content select:focus,
.modal-content input:focus {
    border-color: var(--accent);
    outline: 2px solid rgba(43, 138, 62, 0.14);
}

.modal-content form > button[type="submit"] {
    width: 100%;
    margin-top: 8px;
}

.history-section h2,
.results-card > h2 {
    color: var(--accent-strong);
}

.results-section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.results-section-head h2 {
    margin-bottom: 0;
    color: var(--accent-strong);
}

.download-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.download-report-button {
    border: 1px solid #b8d8be;
    background: #fff;
    color: var(--accent-strong);
    font-size: 14px;
}

.download-report-button:hover {
    background: #eef8f0;
}

.history-section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.history-section-head h2 {
    margin-bottom: 5px;
}

.history-section-head p {
    margin: 0;
    color: var(--muted);
}

.calculation-card-list {
    display: grid;
    gap: 14px;
    margin-top: 16px;
}

.calculation-card {
    padding: 16px;
    border: 1px solid #cfe2d1;
    border-radius: 10px;
    background: #fbfefb;
}

.calculation-card-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 14px;
}

.card-selector {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.calculation-card-title h3 {
    margin: 0;
    color: var(--text);
    font-size: 18px;
}

.calculation-card-title p {
    margin: 4px 0 0;
    color: var(--muted);
}

.calculation-card-title p strong {
    color: var(--accent-strong);
    font-size: 20px;
}

.calculation-details {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.calculation-detail {
    min-width: 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: #f1faf3;
}

.calculation-detail span,
.calculation-detail strong {
    display: block;
}

.calculation-detail span {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
}

.calculation-detail strong {
    overflow-wrap: anywhere;
    font-size: 14px;
}

.table-wrap {
    width: 100%;
    margin: 14px 0;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
}

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    background: #fff;
}

#animal-history table {
    min-width: 1500px;
}

th {
    padding: 11px 10px;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 650;
    text-align: left;
    vertical-align: bottom;
}

td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:nth-child(even) td {
    background: #f6fbf7;
}

.session-calculation-selector {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.results-card > p {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f6fbf7;
    color: var(--muted);
}

.results-card > p strong,
#total-emission {
    color: var(--accent-strong);
    font-size: 20px;
    font-weight: 750;
}

.recommendations {
    margin: 28px 0 0;
    padding: 20px;
    border: 1px solid #c9e3d2;
    border-radius: 10px;
    background: #eef7f1;
}

.recommendations h2 {
    color: var(--accent-strong);
}

.recommendations-intro {
    max-width: 900px;
    color: #3f5146;
    line-height: 1.55;
}

.recommendations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.recommendation {
    padding: 16px 18px;
    border-left: 5px solid var(--accent);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(44, 62, 80, 0.08);
}

.recommendation h3 {
    margin: 0 0 8px;
    color: var(--accent-strong);
}

.recommendation p {
    margin: 0;
    line-height: 1.55;
}

.recommendation--environment {
    border-left-color: #8e6c22;
    background: #fffaf0;
}

.recommendation--positive {
    border-left-color: var(--accent);
}

.hidden {
    display: none !important;
}

@media (max-width: 800px) {
    body {
        padding: 12px;
    }

    .app-header,
    .section-head,
    .history-section-head,
    .results-section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .header-actions {
        justify-content: flex-start;
    }

    .production-actions {
        justify-content: flex-start;
    }

    .production-actions button {
        flex: 1 1 230px;
    }

    .download-actions,
    .download-report-button {
        width: 100%;
    }

    .download-report-button {
        min-height: 44px;
    }

    .card {
        padding: 16px;
    }

    .calculation-card-head {
        grid-template-columns: 1fr auto;
    }

    .card-selector {
        grid-column: 1 / -1;
    }

    .calculation-details {
        grid-template-columns: 1fr;
    }

    .modal {
        padding: 12px;
    }

    .modal-content {
        padding: 22px 16px 18px;
    }
}
