/* KeepNote - 黑白极简风格 */
*, *::before, *::after { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
    background: #ffffff;
    color: #111111;
    line-height: 1.55;
    font-size: 14px;
}

a { color: #111; text-decoration: none; border-bottom: 1px solid #111; }
a:hover { background: #111; color: #fff; }
a.btn-link, .btn-link { border-bottom: none; color: #555; }
a.btn-link:hover, .btn-link:hover { color: #000; background: transparent; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    border-bottom: 1px solid #111;
    background: #fff;
}
.topbar .brand a { font-weight: 700; font-size: 18px; border-bottom: none; letter-spacing: 1px; }
.topbar .nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.topbar .nav a { border-bottom: none; padding: 4px 10px; border: 1px solid transparent; }
.topbar .nav a:hover { border-color: #111; background: transparent; color: #111; }
.muted { color: #888; font-size: 13px; }

.container {
    max-width: 1100px;
    margin: 28px auto;
    padding: 0 24px;
}

.footer {
    text-align: center;
    padding: 24px;
    border-top: 1px solid #eee;
    margin-top: 40px;
}

/* Flash messages */
.flash-area { margin-bottom: 16px; }
.flash {
    padding: 10px 14px;
    border: 1px solid #111;
    margin-bottom: 8px;
    background: #fff;
}
.flash-error { border-color: #000; background: #f5f5f5; }
.flash-success { background: #111; color: #fff; }

/* Cards */
.card {
    border: 1px solid #111;
    padding: 22px 24px;
    margin-bottom: 24px;
    background: #fff;
}
.card.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.card h2 { margin: 0 0 16px; font-size: 18px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h2 { margin: 0; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; }
.form-group small { display: block; margin-top: 4px; }
input[type="text"], input[type="password"], input[type="number"], textarea, select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #111;
    background: #fff;
    color: #111;
    font: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid #111; outline-offset: -1px; }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
textarea.code { font-size: 13px; line-height: 1.5; }

.btn, button.btn, button[type=submit] {
    display: inline-block;
    padding: 8px 18px;
    background: #111;
    color: #fff;
    border: 1px solid #111;
    cursor: pointer;
    text-decoration: none;
    font: inherit;
}
.btn:hover { background: #fff; color: #111; }
.btn-sm {
    display: inline-block;
    padding: 4px 10px;
    border: 1px solid #111;
    background: #fff;
    color: #111;
    cursor: pointer;
    font-size: 12px;
    margin-right: 4px;
    text-decoration: none;
}
.btn-sm:hover { background: #111; color: #fff; }
.btn-sm.danger:hover { background: #000; color: #fff; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; align-items: center; }
form.inline { display: inline; }

/* Tables */
.kv { border-collapse: collapse; width: 100%; max-width: 720px; }
.kv th, .kv td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eee; vertical-align: top; }
.kv th { width: 140px; color: #555; font-weight: 600; }
.apikey { font-size: 13px; word-break: break-all; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eee; }
.data-table th { border-bottom: 2px solid #111; background: #fafafa; }
.data-table tr:hover { background: #fafafa; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    border: 1px solid #111;
    font-size: 12px;
    background: #fff;
}

code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #f5f5f5; padding: 2px 6px; }

.hint-box {
    margin-top: 12px;
    border: 1px dashed #999;
    padding: 8px 12px;
    background: #fafafa;
}
.hint-box summary { cursor: pointer; font-weight: 600; }
.hint-box pre {
    margin: 8px 0 0;
    background: transparent;
    padding: 0;
    font-size: 12px;
    white-space: pre-wrap;
}

/* Login */
.login-box {
    max-width: 360px;
    margin: 60px auto;
    border: 1px solid #111;
    padding: 32px;
}
.login-box h1 { margin: 0 0 20px; font-size: 22px; }
.login-box .hint { margin-top: 14px; font-size: 12px; }

.info-box { padding: 12px; border: 1px solid #ddd; background: #fafafa; }
.info-box h3 { margin: 0 0 8px; font-size: 14px; }
.info-box p { margin: 4px 0; }

.fieldset {
    border: 1px solid #ddd;
    padding: 12px 16px;
    margin: 16px 0;
}
.fieldset legend { padding: 0 6px; font-weight: 600; }

.summary-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 4px 0 12px;
}
.summary-row .tag {
    background: #fafafa;
}
.hint {
    font-size: 13px;
    margin: 6px 0 16px;
}

/* \u6570\u636e\u770b\u677f */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin: 8px 0 4px;
}
.stat {
    border: 1px solid #ddd;
    padding: 14px 16px;
    background: #fafafa;
}
.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}
.stat-label {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

/* \u70ed\u529b\u56fe */
.heatmap {
    display: grid;
    grid-template-columns: repeat(30, 1fr);
    gap: 4px;
    margin: 12px 0 6px;
    max-width: 720px;
}
.hm-cell {
    aspect-ratio: 1 / 1;
    border-radius: 2px;
    cursor: help;
    border: 1px solid rgba(0, 0, 0, 0.06);
}
.hm-axis {
    display: flex;
    justify-content: space-between;
    max-width: 720px;
    font-size: 12px;
    color: #666;
}
.hm-legend {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin: 0 4px -2px 8px;
    border: 1px solid rgba(0,0,0,0.1);
}
.hm-l0 { background: #ebedf0; }
.hm-l1 { background: #2e7d32; }   /* \u6df1\u7eff */
.hm-l2 { background: #c0ca33; }   /* \u9ec4\u7eff */
.hm-l3 { background: #ef6c00; }   /* \u6a59 */
.hm-l4 { background: #c62828; }   /* \u6df1\u7ea2 */

/* \u5206\u9875 */
.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    justify-content: center;
}

/* \u5b88\u62a4\u6a21\u5f0f\u5355\u9009 */
.inline-radio {
    display: block;
    margin: 6px 0;
    cursor: pointer;
}
.inline-radio input[type="radio"] {
    margin-right: 6px;
}

/* \u9875\u9762\u7f16\u8f91\uff1a\u6a21\u5f0f\u5fbd\u7ae0\u4e0e\u5757\u72b6\u6001 */
.mode-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: normal;
    vertical-align: middle;
}
.mode-badge.active {
    background: #27a567;
    color: #fff;
}
.mode-badge.inactive {
    background: #4a5159;
    color: #cfd2d6;
}
[data-mode-block].mode-inactive {
    opacity: 0.55;
    border-left: 3px dashed #5b6068;
    padding-left: 8px;
}
[data-mode-block].mode-inactive textarea,
[data-mode-block].mode-inactive input {
    background: #2a2d31;
    color: #888;
    cursor: not-allowed;
}

@media (max-width: 720px) {
    .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
    .container { padding: 0 14px; }
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 8px 6px; }
}
