*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: #f0f7f0;
    color: #2b3a2b;
}

header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #1b4a1b;
    color: #fff;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

header nav a {
    display: block;
    color: #fff;
    text-decoration: none;
    padding: 14px 4px;
    font-weight: bold;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

header nav a:first-child {
    border-top: none;
}

.back-link {
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    padding: 8px 0;
    white-space: nowrap;
}

.user-area {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.user-area .user-name {
    color: #cfe8cf;
    font-size: 0.9rem;
}

.user-area a {
    color: #fff;
    text-decoration: none;
    font-weight: bold;
}

.logout-form {
    display: inline;
    margin: 0;
    padding: 0;
}

.logout-link {
    background: none;
    border: none;
    color: #fff;
    font-weight: bold;
    font-size: 1rem;
    padding: 4px 0;
    cursor: pointer;
    text-decoration: none;
}

.logout-link:hover {
    text-decoration: underline;
}

.nav-details summary {
    list-style: none;
    cursor: pointer;
    background: #2e7d32;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 1.05rem;
    font-weight: bold;
    text-align: center;
}

.nav-details summary::-webkit-details-marker {
    display: none;
}

.nav-details nav {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: #1b4a1b;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 180px;
    padding: 6px 14px;
    z-index: 20;
}

.nav-details[open] nav {
    display: block;
}

main {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
}

h1 {
    color: #1b4a1b;
    margin-top: 8px;
    font-size: 1.4rem;
}

.list-actions {
    margin: 12px 0;
}

a.button {
    display: inline-block;
    background: #2e7d32;
    color: #fff;
    padding: 12px 18px;
    text-decoration: none;
    border-radius: 8px;
    font-size: 1.05rem;
    text-align: center;
}

a.button.secondary {
    background: #5a8f5a;
}

a.button.danger {
    background: #b3261e;
}

form p {
    margin-bottom: 12px;
}

form label {
    display: block;
    font-weight: bold;
    margin-bottom: 6px;
    color: #2b3a2b;
}

input, select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #9aaa9a;
    border-radius: 8px;
    font-size: 1.05rem;
    background: #fff;
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    min-width: 0;
}

button {
    display: inline-block;
    background: #2e7d32;
    color: #fff;
    border: none;
    padding: 12px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.05rem;
    text-align: center;
}

button.danger {
    background: #b3261e;
}

button[type="submit"] {
    width: 100%;
    padding: 14px;
    margin-top: 8px;
}

.card-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
    padding: 16px;
}

.card h3 {
    margin: 0 0 8px;
    font-size: 1.2rem;
}

.card .meta {
    color: #4a5a4a;
    font-size: 0.98rem;
    margin-bottom: 10px;
}

.card .actions a {
    display: inline-block;
    margin: 6px 10px 0 0;
}

.empty {
    color: #5a6a5a;
    font-style: italic;
    padding: 20px 0;
}

.error {
    color: #b3261e;
    font-weight: bold;
    padding: 10px 0;
}

.detail {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
    padding: 16px;
    margin-bottom: 16px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #e6eee6;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row .label {
    color: #4a5a4a;
}

.detail-row .value {
    text-align: right;
    word-break: break-word;
}

.hops-groups {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 12px 0;
}

.hops-group {
    border: 2px solid #1b4a1b;
    border-radius: 8px;
    padding: 10px 14px;
    min-width: 320px;
    align-self: flex-start;
    flex: 1 1 auto;
}

.hops-group > div[id^="id_"] {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px 8px;
}

.hops-group > div[id^="id_"] > div {
    break-inside: avoid;
    line-height: 1.9;
}

.hops-group input {
    min-width: auto;
}

.hops-group label {
    font-weight: normal;
    display: inline;
}

@media (min-width: 900px) {
    header {
        padding: 12px 24px;
    }

    header .nav-details summary {
        display: none;
    }

    header .nav-details nav {
        position: static;
        box-shadow: none;
        background: transparent;
        border-radius: 0;
        padding: 0;
        min-width: 0;
        display: flex;
        gap: 16px;
    }

    header nav a {
        display: inline;
        padding: 0;
        border-top: none;
        font-weight: normal;
    }

    main {
        padding: 28px 24px 48px;
    }

    .hops-group > div[id^="id_"] {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    button[type="submit"] {
        width: auto;
        padding: 12px 24px;
    }
}

/* ---- Пикер хмеля (поиск + теги) ---- */
.hops-picker {
    position: relative;
}

.hops-picker #hops-search {
    width: 100%;
}

.hops-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.hop-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #2e7d32;
    color: #fff;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 0.95rem;
    font-weight: normal;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.hop-chip::after {
    content: "×";
    font-size: 1.1rem;
    font-weight: bold;
    line-height: 1;
}

.hop-chip:active {
    background: #1b4a1b;
}

.hops-results {
    margin-top: 8px;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #d4e0d4;
    border-radius: 8px;
    background: #fff;
}

.hops-result {
    display: block;
    width: 100%;
    text-align: left;
    background: #fff;
    color: #2b3a2b;
    border: none;
    border-bottom: 1px solid #eef3ee;
    padding: 14px 16px;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 0;
}

.hops-result:last-child {
    border-bottom: none;
}

.hops-result:active {
    background: #e8f2e8;
}

.hops-none {
    padding: 14px 16px;
    color: #5a6a5a;
    font-style: italic;
}