/* ---------------------------------------------------------------------------
   植物浇水管理后台 - 单文件样式
   配色：黑 #0f172a / 蓝 #1d4ed8 / 白 #ffffff / 浅灰 #f7f8fa / 分割线 #e5e7eb
   --------------------------------------------------------------------------- */

:root {
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e5e7eb;
    --line-soft: #f1f2f4;
    --bg: #f7f8fa;
    --white: #ffffff;
    --blue: #1d4ed8;
    --blue-dark: #1e40af;
    --blue-weak: #eff4ff;
    --radius: 4px;
    --nav-width: 200px;
    --topbar-height: 48px;
}

* {
    box-sizing: border-box;
}

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

body {
    font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 13px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1,
h2,
h3 {
    font-weight: 600;
}

/* ---------------------------------- 导航 --------------------------------- */

.nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--nav-width);
    background: var(--ink);
    color: #ffffff;
    overflow-y: auto;
    z-index: 10;
}

.nav-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

.nav-group {
    padding: 14px 16px 5px;
    font-size: 11px;
    color: #94a3b8;
}

.nav a {
    display: block;
    padding: 7px 16px;
    color: #cbd5e1;
    font-size: 13px;
    border-left: 2px solid transparent;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    text-decoration: none;
}

.nav a.active {
    background: #1e293b;
    color: #ffffff;
    border-left-color: var(--blue);
}

/* ---------------------------------- 框架 --------------------------------- */

.main {
    margin-left: var(--nav-width);
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 20px;
    background: var(--white);
    border-bottom: 1px solid var(--line);
}

.topbar-title {
    font-size: 13px;
    font-weight: 600;
}

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

.content {
    padding: 20px;
    max-width: 1440px;
}

/* ---------------------------------- 排版 --------------------------------- */

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.page-head h1 {
    font-size: 16px;
    margin: 0;
}

.page-head p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.muted {
    color: var(--muted);
}

.ta-r {
    text-align: right;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

/* ---------------------------------- 卡片 --------------------------------- */

.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
}

.card-head h2 {
    margin: 0;
    font-size: 13px;
}

.card-body {
    padding: 14px;
}

.card-body.p0 {
    padding: 0;
}

/* ---------------------------------- 表格 --------------------------------- */

.table-wrap {
    overflow-x: auto;
}

.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.tbl th {
    padding: 8px 12px;
    text-align: left;
    font-weight: 500;
    font-size: 12px;
    color: var(--muted);
    background: #fafbfc;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.tbl td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}

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

.tbl tbody tr:hover {
    background: #fafbfc;
}

.tbl .empty {
    padding: 28px 12px;
    text-align: center;
    color: var(--muted);
}

.tbl .ta-r {
    text-align: right;
}

/* ---------------------------------- 标记 --------------------------------- */

.badge {
    display: inline-block;
    padding: 1px 6px;
    font-size: 12px;
    line-height: 18px;
    border-radius: 3px;
    border: 1px solid var(--line);
    background: #f8fafc;
    color: var(--ink-2);
    white-space: nowrap;
}

.badge-ok {
    background: var(--blue-weak);
    border-color: #dbe6ff;
    color: var(--blue);
}

.badge-warn {
    background: #fff9ec;
    border-color: #f0e3c2;
    color: #8a6100;
}

.badge-bad {
    background: #fdf3f3;
    border-color: #f2d8d8;
    color: #a12a2a;
}

.badge-muted {
    background: #f4f5f7;
    border-color: var(--line);
    color: var(--muted);
}

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

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 130px;
}

.field-label {
    font-size: 12px;
    color: var(--muted);
}

.field-hint {
    font-size: 12px;
    color: var(--muted);
}

input,
select,
textarea {
    height: 28px;
    padding: 0 8px;
    font: inherit;
    color: var(--ink);
    background: var(--white);
    border: 1px solid #d7dbe2;
    border-radius: var(--radius);
}

textarea {
    height: auto;
    padding: 6px 8px;
    line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 1px var(--blue);
}

input[type="checkbox"] {
    height: 14px;
    width: 14px;
    padding: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.form-grid-full {
    grid-column: 1 / -1;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.check {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12px;
    color: #6b7280;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 10px;
    font: inherit;
    font-size: 13px;
    color: var(--ink);
    background: var(--white);
    border: 1px solid #d7dbe2;
    border-radius: var(--radius);
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover {
    border-color: #b8c0cc;
    text-decoration: none;
}

.btn-primary {
    background: var(--blue);
    border-color: var(--blue);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--blue-dark);
    border-color: var(--blue-dark);
}

.btn-danger {
    color: #a12a2a;
    border-color: #f2d8d8;
    background: #ffffff;
}

.btn-sm {
    height: 24px;
    padding: 0 8px;
    font-size: 12px;
}

.btn-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--blue);
    font: inherit;
    cursor: pointer;
}

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

.btn-link.danger {
    color: #a12a2a;
}

form.inline {
    display: inline;
    margin: 0;
}

.row-actions {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    white-space: nowrap;
}

/* ---------------------------------- 分页 --------------------------------- */

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-top: 1px solid var(--line);
    font-size: 13px;
}

.pager-links a,
.pager-links .current {
    display: inline-block;
    min-width: 26px;
    padding: 2px 6px;
    margin-left: 4px;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 3px;
    color: var(--ink-2);
}

.pager-links a:hover {
    border-color: var(--blue);
    color: var(--blue);
    text-decoration: none;
}

.pager-links .current {
    background: var(--blue);
    border-color: var(--blue);
    color: #ffffff;
}

/* ---------------------------------- 键值 --------------------------------- */

.kv {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 8px 14px;
    margin: 0;
}

.kv dt {
    color: var(--muted);
    font-size: 12px;
}

.kv dd {
    margin: 0;
    word-break: break-all;
}

/* ---------------------------------- 提示 --------------------------------- */

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 8px 12px;
    background: var(--white);
    border: 1px solid var(--line);
    border-left: 2px solid var(--blue);
    border-radius: 3px;
    font-size: 13px;
}

.toast-mark {
    color: var(--blue);
    font-weight: 600;
}

.toast-warn {
    border-left-color: #8a6100;
}

.toast-warn .toast-mark {
    color: #8a6100;
}

.toast-bad {
    border-left-color: #a12a2a;
}

.toast-bad .toast-mark {
    color: #a12a2a;
}

/* ---------------------------------- 登录 --------------------------------- */

.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-box {
    width: 320px;
    padding: 22px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.login-box h1 {
    margin: 0 0 16px;
    font-size: 15px;
}

.login-box .field {
    margin-bottom: 12px;
}

.login-box button[type="submit"] {
    width: 100%;
    height: 32px;
    margin-top: 4px;
    font: inherit;
    color: #ffffff;
    background: var(--blue);
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
}

.login-box button[type="submit"]:hover {
    background: var(--blue-dark);
}

.login-note {
    margin: 14px 0 0;
    font-size: 12px;
    color: var(--muted);
}

/* ---------------------------------- 其他 --------------------------------- */

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
}

.stat {
    padding: 12px 14px;
    background: var(--white);
}

.stat dt {
    font-size: 12px;
    color: var(--muted);
}

.stat dd {
    margin: 4px 0 0;
    font-size: 16px;
    font-weight: 600;
}

details summary {
    color: var(--blue);
    cursor: pointer;
    font-size: 12px;
}

pre {
    max-height: 320px;
    margin: 8px 0 0;
    padding: 10px;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.5;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 3px;
    white-space: pre-wrap;
    word-break: break-all;
}

@media (max-width: 900px) {
    .nav {
        position: static;
        width: auto;
    }

    .main {
        margin-left: 0;
    }

    .kv {
        grid-template-columns: 110px 1fr;
    }
}
