:root {
  --bg: #f3f0ea;
  --bg-accent: #e8e2d6;
  --surface: #fffcf7;
  --ink: #1f2a24;
  --muted: #5c6b63;
  --line: #d5cec2;
  --brand: #1a5c4a;
  --brand-soft: #d7ebe3;
  --accent: #b4532a;
  --danger: #9b2c2c;
  --ok: #1a5c4a;
  --shadow: 0 10px 30px rgba(31, 42, 36, 0.08);
  --radius: 14px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, #e7f2ed 0, transparent 35%),
    linear-gradient(160deg, var(--bg), var(--bg-accent));
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: #143f34;
  color: #eef7f3;
  padding: 1.4rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.brand { font-size: 1.35rem; font-weight: 700; margin: 0; letter-spacing: 0.02em; }
.brand span { color: #9fd6c4; }
.brand-sub { margin: 0.25rem 0 0; color: #b7d5cb; font-size: 0.85rem; }
.nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.nav a {
  color: #d7ebe3;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  text-decoration: none;
}
.nav a:hover, .nav a.active { background: rgba(255,255,255,0.12); color: #fff; }
.sidebar-footer { display: flex; flex-direction: column; gap: 0.6rem; }
.sidebar-version { margin: 0; font-size: 0.75rem; color: #8fb5a8; }

.main-column { display: flex; flex-direction: column; min-width: 0; }
.main { padding: 1.5rem 1.75rem 2.5rem; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.page-header h1 { margin: 0; font-size: 1.7rem; }
.page-header p { margin: 0.35rem 0 0; color: var(--muted); }

.flash {
  padding: 0.85rem 1rem; border-radius: 10px; margin-bottom: 1rem;
  border: 1px solid transparent;
}
.flash-success { background: #e7f6ef; border-color: #b7dfcb; color: var(--ok); }
.flash-error { background: #fdecec; border-color: #f0c0c0; color: var(--danger); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.card .label { color: var(--muted); font-size: 0.85rem; margin: 0; }
.card .value { font-size: 1.45rem; font-weight: 700; margin: 0.35rem 0 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.panel h2 { margin: 0 0 0.85rem; font-size: 1.1rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left; padding: 0.7rem 0.55rem;
  border-bottom: 1px solid var(--line); vertical-align: top;
}
th { color: var(--muted); font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: rgba(26, 92, 74, 0.03); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.35rem; border: 1px solid transparent; border-radius: 10px;
  padding: 0.55rem 0.9rem; cursor: pointer; font: inherit;
  background: var(--brand); color: #fff; text-decoration: none;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; }
.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem 1rem;
}
.form-grid .full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 10px; padding: 0.55rem 0.7rem;
}
textarea { min-height: 120px; resize: vertical; }
.form-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1rem; }

.badge {
  display: inline-block; padding: 0.2rem 0.55rem; border-radius: 999px;
  font-size: 0.78rem; background: var(--brand-soft); color: var(--brand);
}
.badge-warn { background: #f8e8d8; color: var(--accent); }
.badge-muted { background: #eceae4; color: var(--muted); }
.badge-danger { background: #fde8e8; color: var(--danger); }

.filters {
  display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem;
}
.filters label { min-width: 140px; }

.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.6rem;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 0.35rem; }
.auth-card .subtitle { margin: 0 0 1.2rem; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 0.85rem; }

.muted { color: var(--muted); }
.note-content {
  background: #f7f4ee; border-radius: 10px;
  padding: 0.85rem; border: 1px solid var(--line);
}

.markdown-field { display: flex; flex-direction: column; gap: 0.35rem; }
.md-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem;
  padding: 0.4rem; border: 1px solid var(--line); border-radius: 10px 10px 0 0;
  background: #fffcf7; border-bottom: none;
}
.md-toolbar__btn {
  appearance: none; border: 1px solid transparent; background: transparent;
  color: var(--ink); border-radius: 7px; padding: 0.28rem 0.55rem;
  font: inherit; font-size: 0.82rem; line-height: 1.2; cursor: pointer;
}
.md-toolbar__btn:hover,
.md-toolbar__btn:focus-visible {
  background: #fff; border-color: var(--line); outline: none;
}
.md-toolbar__btn:active { background: #f0ebe3; }
.md-toolbar__sep {
  width: 1px; height: 1.1rem; background: var(--line); margin: 0 0.15rem;
}
.markdown-field:has(.md-toolbar) .md-textarea {
  border-radius: 0 0 10px 10px;
}
.md-textarea {
  width: 100%; min-height: 14rem; font: inherit; line-height: 1.55;
  border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.85rem;
  resize: vertical; background: #fff; color: var(--ink);
}
.md-preview {
  margin-top: 0.5rem; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; overflow: hidden;
}
.md-preview__label {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--muted);
  padding: 0.45rem 0.75rem; border-bottom: 1px solid var(--line); background: #fffcf7;
}
.md-preview__body { padding: 0.85rem 0.95rem; min-height: 3rem; }

.md-guide {
  margin-top: 0.75rem; border: 1px solid var(--line); border-radius: 10px;
  background: #f7f4ee; overflow: hidden;
}
.md-guide__summary {
  cursor: pointer; list-style: none; padding: 0.65rem 0.95rem;
  font-size: 0.875rem; font-weight: 600; user-select: none;
}
.md-guide__summary::-webkit-details-marker { display: none; }
.md-guide__summary::before {
  content: '▸'; display: inline-block; margin-right: 0.45rem; color: var(--muted);
}
.md-guide[open] > .md-guide__summary::before { content: '▾'; }
.md-guide__body {
  padding: 0 0.95rem 0.95rem; border-top: 1px solid var(--line);
  background: #fff; font-size: 0.875rem; line-height: 1.5;
}
.md-guide__body h3 {
  margin: 0.85rem 0 0.35rem; font-size: 0.8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
.md-guide__body ul { margin: 0; padding-left: 1.15rem; }
.md-guide__body li { margin: 0.2rem 0; }
.md-guide__body code {
  font-size: 0.82em; padding: 0.1rem 0.35rem; border-radius: 4px; background: #f3f0ea;
}
.md-guide__more { margin: 0.85rem 0 0; }
.md-guide__more a { font-weight: 500; }

.login-other-methods {
  margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 1rem;
}
.login-other-methods__item {
  padding: 0.85rem; border: 1px solid var(--line); border-radius: 10px; background: #fffcf7;
}

.rich-text-display { line-height: 1.6; }
.rich-text-display ul,
.rich-text-display ol { margin: 0.5rem 0 0.5rem 1.25rem; }
.rich-text-display h2,
.rich-text-display h3,
.rich-text-display h4 { margin: 0.85rem 0 0.4rem; }
.rich-text-display p { margin: 0 0 0.75rem; }
.rich-text-display p:last-child { margin-bottom: 0; }
.rich-text-display a { word-break: break-word; }
.rich-text-display blockquote {
  margin: 0.5rem 0; padding: 0.35rem 0.75rem;
  border-left: 3px solid var(--brand); color: var(--muted); background: #f7f4ee;
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
}
