:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --border: #e6e0d6;
  --text: #2b2723;
  --muted: #7a7166;
  --primary: #2f6b4f;
  --primary-soft: #e3efe8;
  --accent: #c8643b;
  --accent-soft: #f7e6dd;
  --danger: #b3382c;
  --danger-soft: #f8e1de;
  --warn: #b7862b;
  --warn-soft: #f7ecd5;
  --info: #2f6f9a;
  --info-soft: #e1edf5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(43, 39, 35, .06), 0 4px 16px rgba(43, 39, 35, .04);
  --sidebar: 232px;
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; background: #213a2e; color: #e8efe9;
  padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 1.1rem; }
.brand svg { flex-shrink: 0; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px;
  color: #cfdcd3; font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255,255,255,.13); color: #fff; }
.nav .sep { height: 1px; background: rgba(255,255,255,.1); margin: 10px 8px; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar-foot { margin-top: 18px; padding: 10px 12px; font-size: .85rem; color: #9fb3a6; }
.sidebar-foot a { color: #cfe3d6; }
.main { flex: 1; min-width: 0; padding: 26px 32px 60px; max-width: 1280px; }
.topbar { display: none; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card h2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack > * + * { margin-top: 16px; }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: .8rem; color: var(--muted); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fcfbf8; }
td.r, th.r { text-align: right; }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: #eee; color: #555; }
.st-visited, .st-done, .st-published { background: var(--primary-soft); color: var(--primary); }
.st-in_contact, .st-fundraising, .st-scheduled, .st-sent { background: var(--info-soft); color: var(--info); }
.st-contacted, .st-planned, .st-shopping, .st-draft { background: var(--warn-soft); color: #8a6417; }
.st-not_fit, .st-cancelled, .st-failed { background: var(--danger-soft); color: var(--danger); }
.st-new, .st-idea { background: #efece6; color: var(--muted); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: .8rem; margin: 0 4px 4px 0; }

/* forms */
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 4px; color: #4a443d; }
.field { margin-bottom: 14px; }
.field .help { font-size: .8rem; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=number], input[type=date], input[type=datetime-local], input[type=password],
input[type=search], input[type=url], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: 9px;
  font: inherit; background: #fff; color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47,107,79,.25); border-color: var(--primary); }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox input { width: auto; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters input, .filters select { width: auto; min-width: 150px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--border); background: #fff; color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #275b43; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #b05630; }
.btn-danger { color: var(--danger); border-color: #ecc8c3; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 4px 10px; font-size: .85rem; }
.btn-link { background: none; border: none; color: var(--primary); padding: 0; font-weight: 500; cursor: pointer; font: inherit; }
.inline { display: inline; }

.flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.flash-ok { background: var(--primary-soft); color: var(--primary); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.note { background: var(--warn-soft); border-radius: 10px; padding: 10px 14px; color: #6d5313; font-size: .9rem; }
.note-info { background: var(--info-soft); color: #234f6e; }

/* detail */
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; white-space: pre-line; word-break: break-word; }
.prewrap { white-space: pre-line; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active, .tabs a:hover { color: var(--primary); border-color: var(--primary); text-decoration: none; }
.money-row { display: flex; gap: 22px; flex-wrap: wrap; }
.money-row .item .label { font-size: .8rem; color: var(--muted); }
.money-row .item .value { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pos { color: var(--primary); }
.neg { color: var(--danger); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; position: relative; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); display: block; background: var(--surface-2); }
.gallery figcaption { font-size: .75rem; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery .del { position: absolute; top: 6px; right: 6px; }
.file-tile { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; border-radius: 10px; border: 1px dashed var(--border); background: var(--surface-2); font-weight: 600; color: var(--muted); }

.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 9px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.list-plain li:last-child { border-bottom: none; }
.done-need { text-decoration: line-through; color: var(--muted); }

.bar { height: 8px; background: #eee7dc; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.bars-year { display: grid; gap: 10px; }
.bars-year .row { display: grid; grid-template-columns: 56px 1fr 150px; gap: 10px; align-items: center; font-size: .9rem; }

.post-preview {
  background: #e7efe5; border-radius: 14px; padding: 16px; font-size: .95rem;
  white-space: pre-wrap; word-break: break-word; max-width: 520px; font-family: system-ui, sans-serif;
}
.post-preview .bubble { background: #fff; border-radius: 12px; padding: 12px 14px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.counter { font-size: .8rem; color: var(--muted); text-align: right; }

.markdown { line-height: 1.65; }
.markdown table { margin: 10px 0; }
.markdown blockquote { margin: 10px 0; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.markdown code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }

.calc-grid { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.sticky { position: sticky; top: 16px; }
.big-total { font-size: 2rem; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.qty-input { width: 80px !important; padding: 4px 6px !important; text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 24px; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calc-grid { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
@media (max-width: 860px) {
  .layout { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #213a2e; color: #fff; position: sticky; top: 0; z-index: 40; }
  .topbar button { background: none; border: none; color: #fff; font-size: 1.4rem; cursor: pointer; }
  .main { padding: 18px 16px 50px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { margin-top: 8px; }
  .bars-year .row { grid-template-columns: 44px 1fr; }
  .bars-year .row .num { grid-column: 2; }
}
