/* Базовая типографика */

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    color: #2c3e2d;
    background: #f7f6f1;
    line-height: 1.5;
}

header {
    background: #4a7c4e;
    color: #fff;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
header h1 { margin: 0; font-size: 1.4em; }
header a { color: #fff; text-decoration: none; }
nav a { margin-left: 20px; }
nav a:hover { text-decoration: underline; }

main {
    padding: 20px 24px;
    max-width: 1400px;
    margin: 0 auto;
}

footer {
    text-align: center;
    padding: 14px;
    color: #888;
}

section { margin-bottom: 24px; }
h2 { color: #2c5530; margin-top: 0; }
h3 { color: #3a6b3e; margin-top: 0; }

.muted { color: #888; }

/* «Карточка» — общий контейнер */
.card {
    background: #fff;
    border: 1px solid #d5d5d0;
    border-radius: 6px;
    padding: 16px;
}

/* Двухколоночные сетки */
.top-row,
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}
.top-row > section,
.two-col > section {
    background: #fff;
    border: 1px solid #d5d5d0;
    border-radius: 6px;
    padding: 16px;
    margin: 0;
}
@media (max-width: 900px) {
    .top-row, .two-col {
        grid-template-columns: 1fr;
    }
}

/* Погода */
.weather-block pre {
    background: #eef5ef;
    padding: 12px 14px;
    border-radius: 6px;
    font-family: inherit;
    white-space: pre-wrap;
    margin: 0;
    font-size: 0.95em;
}
.warning {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 6px;
    border-left: 4px solid;
}
.warning.cold {
    background: #e0eff5;
    border-color: #3a7ca5;
}
.warning.hot {
    background: #fbe9c9;
    border-color: #d68b00;
}

/* Список задач на главной */
.task-list {
    margin: 0;
    padding-left: 20px;
}
.task-list li {
    padding: 4px 0;
}

/* Таблица «Сегодня» с кнопками действий */
.today-table {
    border: none;
    border-radius: 0;
    background: transparent;
}
.today-table td {
    border-bottom: 1px solid #ececec;
    padding: 8px 6px;
    vertical-align: middle;
}
.today-table .task-cell { width: auto; }
.today-table .actions-cell {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}
.btn-action {
    border: 1px solid #4a7c4e;
    background: #fff;
    color: #2c5530;
    margin-left: 2px;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}
.btn-action:hover { background: #e8efe5; }

.small { font-size: 0.85em; }

.overdue {
    color: #c0392b;
    font-weight: 500;
}
.today {
    color: #d68b00;
    font-weight: 500;
}

/* Таблица */
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #d5d5d0;
    border-radius: 6px;
    overflow: hidden;
}
th, td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #ececec;
    vertical-align: top;
}
th {
    background: #e8efe5;
    font-weight: 600;
}
tbody tr:hover { background: #f9fbf7; }
table small { color: #888; font-size: 0.85em; display: block; }

/* Формы */
.flower-form, .action-form, .preset-picker {
    background: #fff;
    border: 1px solid #d5d5d0;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
}

/* Сетка для трёх колонок в форме редактирования */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}
.form-grid fieldset {
    margin-bottom: 0;
}
.form-grid input[type="text"],
.form-grid input[type="number"],
.form-grid input[type="date"],
.form-grid select,
.form-grid textarea {
    max-width: 100%;
}
@media (max-width: 1100px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
    .form-grid { grid-template-columns: 1fr; }
}

fieldset {
    border: 1px solid #d5d5d0;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 14px;
}
legend { font-weight: 600; padding: 0 6px; }
label {
    display: block;
    margin-bottom: 10px;
}
label.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}
label.checkbox input { width: auto; }
input[type="text"], input[type="number"], input[type="date"], select, textarea {
    width: 100%;
    max-width: 400px;
    padding: 6px 8px;
    border: 1px solid #c5c5b8;
    border-radius: 4px;
    font: inherit;
}
textarea { font-family: inherit; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #4a7c4e;
}

/* Свёрнутая форма «отметить событие» */
details summary {
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
}
details[open] summary { margin-bottom: 12px; }
details .action-form {
    margin: 0;
    padding: 12px;
    background: #f9fbf7;
    border: 1px solid #d5d5d0;
}

/* Кнопки */
.btn {
    display: inline-block;
    padding: 7px 14px;
    background: #e8efe5;
    color: #2c5530;
    text-decoration: none;
    border: 1px solid #4a7c4e;
    border-radius: 4px;
    cursor: pointer;
    font: inherit;
}
.btn:hover { background: #d6e4d2; }
.btn-primary {
    background: #4a7c4e;
    color: #fff;
}
.btn-primary:hover { background: #3a6b3e; }
.btn-danger {
    background: #fff;
    color: #c0392b;
    border-color: #c0392b;
}
.btn-danger:hover { background: #fbe5e1; }
.btn-mini {
    background: transparent;
    border: 1px solid #aaa;
    color: #c0392b;
    width: 22px; height: 22px;
    border-radius: 3px;
    cursor: pointer;
    padding: 0;
}
form.inline { display: inline; margin: 0; }

/* Расписание */
.schedule td, .schedule th { font-size: 0.95em; }

/* Форма загрузки фото — компактная, в одну строку */
.action-form-inline {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.action-form-inline input[type="file"] { max-width: none; }

/* Галерея фото */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}
.gallery figure {
    margin: 0;
    background: #fff;
    border: 1px solid #d5d5d0;
    border-radius: 6px;
    padding: 6px;
    text-align: center;
}
.gallery img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 4px;
}
.gallery figcaption {
    margin-top: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88em;
}

/* === ДОПОЛНЕНИЯ === */

/* Шапка карточки цветка — три равные колонки, фото на 2 строки, примечания внизу */
.flower-header-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    align-items: start;
}
.flower-header-photo {
    grid-column: 3;
    grid-row: 1 / span 2;
}
.notes-inline {
    grid-column: 1 / span 2;
    grid-row: 2;
}
.flower-title h2 { margin: 0 0 6px 0; }
.flower-title p { margin: 0; }
.title-meta {
    margin-bottom: 6px;
}
.title-species {
    color: #888;
    font-size: 0.95em;
}

/* Кнопки и чекбокс в центре, столбиком */
.flower-header-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
    width: 100%;
}
.flower-header-actions .btn {
    text-align: center;
    width: 100%;
}
.checkbox-window {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    padding: 6px 0;
    border: 1px solid #d5d5d0;
    border-radius: 4px;
    background: #f9fbf7;
    cursor: pointer;
    user-select: none;
}
.checkbox-window input { margin: 0; }

/* Примечания в шапке — внизу слева, занимают 2 колонки */
.notes-inline {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    margin-top: 4px;
}
.notes-inline .muted { font-size: 0.85em; }
.notes-inline textarea {
    width: 100%;
    max-width: none;
    resize: vertical;
    background: #fff5d6;
    border: 1px solid #d6b800;
    border-radius: 4px;
    padding: 8px 12px;
    font: inherit;
    min-height: 70px;
}

/* Превью фото справа */
.flower-header-photo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.flower-header-photo img {
    width: 100%;
    max-width: 280px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #d5d5d0;
}
.flower-header-photo small { font-size: 0.85em; }
.no-photo {
    width: 100%;
    max-width: 280px;
    aspect-ratio: 1 / 1;
    border: 1px dashed #c5c5b8;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #aaa;
    font-size: 2.5em;
    background: #fafaf6;
}
.no-photo small { font-size: 0.35em; }

/* Инпуты в шапке (заголовок, подзаголовок) */
.title-input {
    font-size: 1.5em;
    font-weight: 600;
    border: 1px solid transparent;
    background: transparent;
    padding: 2px 6px;
    width: 100%;
    max-width: none;
}
.title-input:focus { background: #fff; border-color: #4a7c4e; }

.subtitle-input {
    border: 1px solid transparent;
    background: transparent;
    padding: 2px 4px;
    width: 100%;
    max-width: none;
    font-size: 0.95em;
}
.subtitle-input:focus { background: #fff; border-color: #4a7c4e; }

.inline-select {
    max-width: 220px;
    padding: 4px 8px;
}

@media (max-width: 900px) {
    .flower-header-row {
        grid-template-columns: 1fr;
    }
    .flower-header-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .flower-header-photo,
    .notes-inline {
        grid-column: auto;
        grid-row: auto;
    }
    .flower-header-photo {
        align-self: start;
    }
}

/* Шапка таблицы цветов с кнопкой очистки */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
    flex-wrap: wrap;
}
.table-header h2 { margin: 0; }

/* Горизонтальный скролл для широкой таблицы */
.table-scroll {
    overflow-x: auto;
    background: #fff;
    border: 1px solid #d5d5d0;
    border-radius: 6px;
}
.main-table {
    min-width: 1200px;
    border: none;
    border-radius: 0;
}
.main-table th, .main-table td {
    white-space: nowrap;
    font-size: 0.92em;
    padding: 6px 8px;
}

/* Опасный блок (очистка истории) */
.danger-block summary { color: #c0392b; }
.danger-block[open] {
    background: #fbe5e1;
    border-radius: 4px;
    padding: 8px;
    margin-top: 8px;
}

/* Блок "задать дату следующего раза" */
.set-next-block {
    margin-top: 12px;
    padding: 8px;
    background: #f9fbf7;
    border: 1px solid #d5d5d0;
    border-radius: 4px;
}
.set-next-block summary { padding: 4px; }

/* Inline-редактирование даты «Следующий раз» */
.next-date-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.edit-date-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    opacity: 0.4;
    font-size: 0.9em;
    transition: opacity 0.15s;
}
.edit-date-btn:hover {
    opacity: 1;
    background: #e8efe5;
}

/* Кликабельные ячейки дат в таблице на главной */
.date-cell.editable {
    cursor: pointer;
    transition: background 0.12s;
}
.date-cell.editable:hover {
    background: #e8efe5;
}

/* Форма логина */
.login-card {
    max-width: 400px;
    margin: 60px auto 0;
}
.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.login-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.login-form input {
    padding: 8px 12px;
    border: 1px solid #d5d5d0;
    border-radius: 4px;
    font: inherit;
}

/* === Своя задача (произвольное дело со своей датой) === */
.custom-task-card .action-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}
.custom-task-card .custom-task-text {
    flex: 1 1 280px;
}
.custom-task-card .custom-task-text input[type="text"] {
    width: 100%;
    max-width: none;
}
.custom-task-card .custom-task-days {
    align-self: center;
    color: #666;
}
.custom-task-cell a {
    white-space: normal;
    display: inline-block;
    max-width: 180px;
}
.custom-task-cell small {
    display: block;
    color: #666;
    font-size: 0.85em;
}
