/* ===== 绿植管家 全局样式（奶油色系手作风）===== */

:root {
    --bg: #F7F3EA;
    --bg-card: #FFFDF6;
    --ink: #3D3A32;
    --ink-soft: #7A7466;
    --line: #E9E2D2;
    --green: #5A9367;
    --green-deep: #3F7D4E;
    --green-soft: #E4F0E2;
    --terra: #C97B5A;
    --blue: #6A9BD1;
    --red: #C96A5A;
    --amber: #D9A441;
    --radius: 16px;
    --shadow: 0 2px 10px rgba(90, 80, 60, .08);
    --shadow-hover: 0 6px 20px rgba(90, 80, 60, .14);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.6;
}

h1 { font-size: 22px; margin: 8px 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
a { color: var(--green-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

#app { min-height: 100vh; }

/* ---- 布局 ---- */

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 28px;
    background: rgba(255, 253, 246, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 18px;
    color: var(--ink);
}

.brand:hover { text-decoration: none; }
.brand-emoji { font-size: 22px; }

.topnav {
    display: flex;
    gap: 4px;
    flex: 1;
}

.nav-link {
    padding: 6px 14px;
    border-radius: 999px;
    color: var(--ink-soft);
    font-weight: 500;
}

.nav-link:hover { text-decoration: none; background: var(--green-soft); }
.nav-link.active { background: var(--green-deep); color: #fff; }

.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-name { color: var(--ink-soft); font-size: 13px; }

.main-content {
    flex: 1;
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px 28px 60px;
}

.footer {
    text-align: center;
    color: var(--ink-soft);
    font-size: 12px;
    padding: 18px;
    border-top: 1px solid var(--line);
}

.page-loading {
    text-align: center;
    color: var(--ink-soft);
    padding: 80px 0;
}

.page-date {
    font-size: 14px;
    font-weight: 400;
    color: var(--ink-soft);
    margin-left: 8px;
}

/* ---- 按钮 ---- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 999px;
    padding: 9px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
    font-family: inherit;
}

.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--green-deep); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--green); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover:not(:disabled) { background: var(--line); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover:not(:disabled) { background: #F9E8E4; }
.btn-sm { padding: 5px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-complete { background: var(--green-soft); color: var(--green-deep); }
.btn-complete:hover:not(:disabled) { background: var(--green-deep); color: #fff; }

/* ---- 表单 ---- */

.form-field { margin-bottom: 14px; }
.form-field label {
    display: block;
    font-size: 13px;
    color: var(--ink-soft);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-field input, .form-field select, .form-field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: #fff;
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    transition: border-color .15s;
}

.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    outline: none;
    border-color: var(--green);
}

.form-error {
    background: #F9E8E4;
    color: var(--red);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 14px;
}

/* ---- 图形验证码 ---- */

.captcha-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.captcha-row input {
    flex: 1;
    min-width: 0;
}

.captcha-image {
    width: 120px;
    height: 44px;
    flex-shrink: 0;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.captcha-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.captcha-placeholder {
    font-size: 12px;
    color: var(--ink-soft);
}

/* ---- 登录/注册 ---- */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 20%, #E4F0E2 0%, transparent 40%),
        radial-gradient(circle at 85% 80%, #F2E8D5 0%, transparent 45%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 36px 32px;
    text-align: center;
}

.auth-card h1 { margin: 8px 0 4px; }
.auth-sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 24px; }
.auth-logo { font-size: 44px; }
.auth-card .form-field { text-align: left; }
.auth-switch { margin-top: 18px; font-size: 13px; color: var(--ink-soft); }

/* ---- 统计块 ---- */

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-num { font-size: 26px; font-weight: 700; display: block; }
.stat-label { font-size: 12px; color: var(--ink-soft); }
.stat-overdue .stat-num { color: var(--red); }
.stat-today .stat-num { color: var(--amber); }
.stat-upcoming .stat-num { color: var(--blue); }
.stat-plants .stat-num { color: var(--green-deep); }

/* ---- 任务列表 ---- */

.task-section { margin-bottom: 28px; }

.section-title {
    font-size: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--line);
}

.section-title.section-danger { color: var(--red); border-color: var(--red); }
.section-title.section-muted { color: var(--ink-soft); font-size: 14px; border: none; }

.section-empty {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 22px;
    color: var(--ink-soft);
    text-align: center;
    margin-top: 12px;
}

.task-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

.task-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow);
    transition: box-shadow .15s;
}

.task-item:hover { box-shadow: var(--shadow-hover); }
.task-item.is-overdue { border-left: 4px solid var(--red); }
.task-item.is-upcoming { opacity: .85; padding: 8px 16px; }

.task-avatar {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--green-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.task-info { flex: 1; min-width: 0; }
.task-plant { font-weight: 600; color: var(--ink); display: block; }
.task-species { font-size: 12px; color: var(--ink-soft); }

.task-care {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 999px;
    white-space: nowrap;
}

.care-water { background: #E3F0FA; color: #3A6FA5; }
.care-fert { background: #F5EDD8; color: #8A6D2F; }

.task-overdue-days { color: var(--red); font-size: 12px; font-weight: 600; }
.task-due-today { color: var(--amber); font-size: 12px; font-weight: 600; }
.task-due-future { color: var(--ink-soft); font-size: 12px; }

.upcoming-day { display: flex; gap: 14px; margin-top: 10px; align-items: flex-start; }
.upcoming-date {
    min-width: 72px;
    text-align: right;
    color: var(--ink-soft);
    font-size: 13px;
    padding-top: 14px;
}

.upcoming-tasks { flex: 1; display: flex; flex-direction: column; gap: 8px; }

/* ---- 卡片网格（植物库/我的植物）---- */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 20px;
}

.filter-bar input[type="text"] {
    padding: 9px 16px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    font-size: 14px;
    min-width: 220px;
    font-family: inherit;
    background: #fff;
}

.filter-bar input[type="text"]:focus { outline: none; border-color: var(--green); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1.5px solid var(--line);
    background: var(--bg-card);
    font-size: 13px;
    color: var(--ink-soft);
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
    white-space: nowrap;
}

.chip:hover { border-color: var(--green); color: var(--green-deep); }
.chip.active { background: var(--green-deep); border-color: var(--green-deep); color: #fff; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

/* ---- 植物卡片 + tooltip ---- */

.plant-card {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    text-align: center;
    display: block;
    color: var(--ink);
    transition: all .15s;
    outline: none;
}

.plant-card:hover {
    text-decoration: none;
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.plant-card .card-name { font-weight: 700; font-size: 15px; display: block; }
.plant-card .card-sub { font-size: 12px; color: var(--ink-soft); }

.card-badges {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
    min-height: 20px;
    flex-wrap: wrap;
}

.badge {
    font-size: 11px;
    padding: 2px 9px;
    border-radius: 999px;
    font-weight: 500;
}

.badge-water { background: #E3F0FA; color: #3A6FA5; }
.badge-fert { background: #F5EDD8; color: #8A6D2F; }
.badge-health { background: var(--green-soft); color: var(--green-deep); }
.badge-health.thirsty { background: #F7EFD8; color: #A08430; }
.badge-health.wilted { background: #F9E8E4; color: var(--red); }
.badge-health.hungry { background: #EDEBDD; color: #8A8560; }

/* tooltip（纯 CSS，键盘可达）*/
.tt-wrap { position: relative; }

.tt {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #3D3A32;
    color: #FFFDF6;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
    z-index: 30;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    text-align: left;
}

.tt-wrap:hover .tt,
.tt-wrap:focus-within .tt {
    opacity: 1;
}

.tt .tt-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.tt .tt-row .due { color: #F2C94C; }
.tt .tt-row .overdue { color: #F2998C; }

/* ---- 详情页 ---- */

.detail-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 760px) {
    .detail-layout { grid-template-columns: 1fr; }
}

.detail-side {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    text-align: center;
}

.detail-side .plant { margin: 0 auto; }

.detail-main { display: flex; flex-direction: column; gap: 20px; }

.panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
}

.panel h2 {
    font-size: 15px;
    color: var(--ink-soft);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.attr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.attr-item {
    background: var(--bg);
    border-radius: 12px;
    padding: 12px 14px;
}

.attr-item .attr-label { font-size: 12px; color: var(--ink-soft); display: block; }
.attr-item .attr-value { font-size: 14px; font-weight: 600; }

.schedule-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px dashed var(--line);
}

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

.schedule-care {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    min-width: 64px;
}

.schedule-meta { flex: 1; color: var(--ink-soft); font-size: 13px; }
.schedule-meta .strong { color: var(--ink); font-weight: 600; }
.schedule-tag {
    font-size: 11px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--green-soft);
    color: var(--green-deep);
    margin-left: 6px;
}
.schedule-tag.custom { background: #F5EDD8; color: #8A6D2F; }

.interval-editor {
    display: flex;
    align-items: center;
    gap: 8px;
}

.interval-editor input[type="number"] {
    width: 72px;
    padding: 6px 10px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font-size: 13px;
    font-family: inherit;
}

.timeline { display: flex; flex-direction: column; }

.timeline-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--line);
    font-size: 13px;
    align-items: center;
}

.timeline-item:last-child { border-bottom: none; }
.timeline-date { color: var(--ink-soft); min-width: 90px; }

/* ---- 空态 ---- */

.empty-state {
    text-align: center;
    padding: 70px 20px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.empty-emoji { font-size: 52px; margin-bottom: 8px; }
.empty-state p { color: var(--ink-soft); margin: 8px 0 20px; }

/* ---- 标签管理 ---- */

.tag-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 10px;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 12px;
    border-radius: 999px;
    background: var(--green-soft);
    color: var(--green-deep);
    font-size: 12px;
    font-weight: 600;
}

/* ---- 添加植物弹层 ---- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(50, 45, 35, .4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
}

.modal {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 28px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-hover);
}

.modal h2 { margin-top: 0; }

/* ---- 物种管理 ---- */

.nav-admin { color: var(--terra); font-weight: 600; }
.nav-admin.active { background: var(--terra); color: #fff; }

.admin-species-list { display: flex; flex-direction: column; gap: 8px; }

.admin-species-row {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 8px 16px;
}

.admin-species-row.is-inactive { opacity: .55; }

.admin-species-avatar {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: var(--green-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.admin-species-info { min-width: 0; }

.admin-preview { text-align: center; }

/* ---- 响应式 ---- */

@media (max-width: 640px) {
    .topnav { gap: 0; }
    .nav-link { padding: 6px 8px; font-size: 13px; }
    .main-content { padding: 16px 14px 40px; }
    .task-item { flex-wrap: wrap; }
    .upcoming-day { flex-direction: column; gap: 6px; }
    .upcoming-date { text-align: left; padding-top: 0; }
}
