:root {
  --bg: #0f172a;
  --bg-elevated: #1e293b;
  --bg-panel: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #cbd5e1;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #dbeafe;
  --success: #16a34a;
  --warn: #f59e0b;
  --danger: #dc2626;
  --border: #e2e8f0;
  --radius: 10px;
  --shadow: 0 4px 20px -4px rgba(15, 23, 42, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", Menlo, Consolas, monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: var(--font);
  background: linear-gradient(135deg, #f1f5f9 0%, #e0e7ff 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app-header {
  background: var(--bg);
  color: white;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  background: var(--brand);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--brand);
}

.brand h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-tag {
  font-size: 12px;
  color: var(--text-light);
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-light);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-dot.offline {
  background: var(--danger);
}

main {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 28px;
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr 1fr;
}

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

.panel.info {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}

.panel-head h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.panel-head p {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 18px;
}

.panel-head .muted {
  font-size: 12px;
}

.new-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.new-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.new-form input,
.new-form textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.new-form textarea {
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
  min-height: 100px;
}

.new-form input:focus,
.new-form textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: white;
}

.new-form details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--brand);
  padding: 4px 0;
}

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, transform 0.05s;
  font-family: inherit;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--brand);
  color: white;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--brand-soft);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.btn-danger:hover {
  background: #fef2f2;
}

.proposal-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.proposal-list .empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}

.proposal-list li.proposal {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  transition: border-color 0.15s, background 0.15s;
}

.proposal-list li.proposal:hover {
  border-color: var(--brand);
  background: white;
}

.proposal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.proposal-title {
  font-weight: 600;
  font-size: 14px;
}

.proposal-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.proposal-client {
  color: var(--brand);
  font-size: 12px;
  font-weight: 500;
}

.proposal-actions {
  display: flex;
  gap: 8px;
  font-size: 12px;
}

.status-list {
  list-style: none;
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.status-list li {
  padding: 12px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.status-list strong {
  display: block;
  margin-bottom: 4px;
  color: var(--brand-dark);
}

.hint {
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--brand-soft);
  border-radius: 6px;
  font-size: 12px;
  color: var(--brand-dark);
  font-family: var(--mono);
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: rgba(37, 99, 235, 0.08);
  padding: 2px 5px;
  border-radius: 3px;
  color: var(--brand-dark);
}

footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 12px;
}

/* Detail page */
.doc-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 28px;
}

.doc-sidebar {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  height: fit-content;
  position: sticky;
  top: 20px;
}

.doc-sidebar h3 {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.doc-sidebar dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 12px;
  font-size: 12px;
  margin-bottom: 18px;
}

.doc-sidebar dt {
  color: var(--text-muted);
}

.doc-sidebar dd {
  font-family: var(--mono);
  word-break: break-all;
  font-size: 11px;
}

.doc-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-actions .btn {
  width: 100%;
  text-align: center;
}

.doc-main {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  min-height: 70vh;
}

.doc-main h1 {
  font-size: 28px;
  margin-bottom: 6px;
}

.doc-meta {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.markdown-render {
  font-size: 15px;
  line-height: 1.7;
}

.markdown-render h1,
.markdown-render h2,
.markdown-render h3 {
  margin: 24px 0 10px;
  color: var(--bg);
}

.markdown-render h1 { font-size: 24px; }
.markdown-render h2 { font-size: 19px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.markdown-render h3 { font-size: 16px; }

.markdown-render p { margin: 8px 0; }
.markdown-render ul, .markdown-render ol { margin: 8px 0 8px 24px; }
.markdown-render li { margin: 4px 0; }

.markdown-render pre {
  background: #f1f5f9;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
}

.markdown-render code {
  font-size: 0.9em;
}

.edit-textarea {
  width: 100%;
  min-height: 50vh;
  padding: 16px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
}

.edit-textarea:focus {
  outline: 2px solid var(--brand);
  border-color: var(--brand);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--bg);
  color: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 13px;
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.2s, opacity 0.2s;
  z-index: 1000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

@media (max-width: 720px) {
  main { grid-template-columns: 1fr; }
  .status-list { grid-template-columns: 1fr; }
  .doc-layout { grid-template-columns: 1fr; }
  .doc-sidebar { position: static; }
}
