:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d2430;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #1f6f5b;
  --accent-dark: #155342;
  --warning: #fff6d8;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
  display: flex;
  min-height: 100vh;
  line-height: 1.45;
}
.sidebar {
  width: 240px;
  background: #16202a;
  color: white;
  padding: 22px 16px;
  flex-shrink: 0;
}
.brand { font-size: 18px; font-weight: 700; margin-bottom: 28px; line-height: 1.25; }
.sidebar nav { display: grid; gap: 10px; }
.sidebar a { color: #e7edf3; text-decoration: none; padding: 11px 12px; border-radius: 6px; line-height: 1.25; }
.sidebar a:hover { background: #263545; }
.main { flex: 1; min-width: 0; }
.topbar {
  min-height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 24px;
  align-items: flex-start;
}
.notice { background: var(--warning); border: 1px solid #ead68f; padding: 10px 12px; border-radius: 6px; font-size: 13px; line-height: 1.4; max-width: 820px; }
.account, .actions, .tabs { display: flex; gap: 12px; row-gap: 12px; align-items: center; flex-wrap: wrap; }
.account { justify-content: flex-end; margin-left: auto; }
.account a { color: var(--accent-dark); text-decoration: none; padding: 8px 10px; border-radius: 6px; }
.account a:hover { background: #e8eef3; }
.actions form, .account form, .tabs form { margin: 0; }
.content { padding: 28px; max-width: 1320px; width: 100%; }
.page-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 22px; }
.page-head.compact { align-items: flex-start; margin-bottom: 14px; gap: 18px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 28px; line-height: 1.2; margin-bottom: 8px; }
h2 { font-size: 20px; line-height: 1.25; margin-bottom: 12px; }
h3 { font-size: 16px; line-height: 1.3; margin-bottom: 10px; }
p, dd, small { color: var(--muted); }
p:last-child { margin-bottom: 0; }
.panel, .auth-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.panel { overflow-x: auto; }
.auth-box { max-width: 520px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; margin-bottom: 20px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-bottom: 20px; }
.action-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  display: grid;
  gap: 8px;
}
.action-card:hover { border-color: var(--accent); }
.action-card span { color: var(--muted); line-height: 1.4; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.metric span { display: block; font-size: 30px; font-weight: 700; }
form { margin: 0; }
button, .button, .small-button {
  border: 0;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  max-width: 100%;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  word-break: normal;
}
button:hover, .button:hover, .small-button:hover { background: var(--accent-dark); }
.small-button { padding: 8px 12px; min-height: 34px; font-size: 13px; }
.secondary, .ghost { background: #e8eef3; color: var(--text); }
.secondary:hover, .ghost:hover { background: #d9e2ea; color: var(--text); }
.ghost { border: 1px solid var(--line); }
.tabs { margin-bottom: 20px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.tabs a { color: var(--accent-dark); text-decoration: none; padding: 9px 11px; border-radius: 6px; }
.tabs a:hover { background: #e8eef3; }
.form { display: grid; gap: 16px; max-width: 560px; }
.form.wide { max-width: 840px; }
.project-type-form { max-width: 980px; }
.form-section { display: grid; gap: 16px; }
.grid-form { max-width: none; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); align-items: end; }
label { display: grid; gap: 7px; color: var(--muted); line-height: 1.3; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  font: inherit;
  background: white;
  min-width: 0;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(31, 111, 91, 0.18);
  border-color: var(--accent);
}
textarea { min-height: 110px; resize: vertical; }
.check-row { display: flex; grid-template-columns: none; align-items: center; gap: 8px; }
.check-row input { width: auto; }
.admin-user-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 10px;
  align-items: center;
  min-width: 620px;
}
.extend-form { display: grid; grid-template-columns: 82px auto; gap: 10px; align-items: center; min-width: 170px; }
.document-editor { min-height: 420px; font-family: Consolas, monospace; line-height: 1.45; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
.panel > table { min-width: 640px; }
th, td { text-align: left; padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.status { background: #e4f3ed; color: var(--accent-dark); padding: 4px 8px; border-radius: 999px; font-size: 12px; }
pre { white-space: pre-wrap; word-wrap: break-word; font-family: Consolas, monospace; color: #243242; background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; padding: 12px; overflow-x: auto; }
.markdown-content { color: var(--text); display: grid; gap: 12px; }
.markdown-content h3,
.markdown-content h4,
.markdown-content h5 { margin: 8px 0 0; color: var(--text); line-height: 1.25; }
.markdown-content h3 { font-size: 19px; }
.markdown-content h4 { font-size: 17px; }
.markdown-content h5 { font-size: 15px; }
.markdown-content p { margin: 0; color: var(--text); }
.markdown-content ul,
.markdown-content ol { margin: 0; padding-left: 22px; color: var(--text); }
.markdown-content li { margin: 5px 0; }
.markdown-content strong { color: var(--text); font-weight: 700; }
.markdown-content code { background: #eef2f6; border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; font-family: Consolas, monospace; font-size: 0.95em; }
.markdown-content .table-wrap { margin: 2px 0; }
.markdown-content table { min-width: 560px; }
.markdown-content th { background: #f2f5f8; color: var(--text); }
.markdown-content td,
.markdown-content th { border: 1px solid var(--line); }
dt { font-weight: 700; margin-top: 10px; }
dd { margin-left: 0; }
.qa { display: grid; gap: 12px; border-bottom: 1px solid var(--line); padding: 18px 0; }
.drawing-preview { width: 100%; max-height: 520px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: white; }
.figure-elements { display: grid; gap: 16px; }
.element-editor {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) repeat(5, minmax(92px, 1fr)) minmax(140px, auto);
  gap: 12px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}
.element-editor label { min-width: 0; }
.element-editor input { min-width: 0; }
.query-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.query-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.hint { color: var(--muted); font-size: 13px; }
@media (max-width: 760px) {
  body { display: block; }
  .sidebar { width: 100%; }
  .topbar, .page-head { display: grid; }
  .topbar { padding: 14px 16px; }
  .account { justify-content: flex-start; margin-left: 0; }
  .content { padding: 16px; }
  .panel, .auth-box { padding: 16px; }
  .actions { align-items: stretch; }
  .actions > *, .actions form, .actions button, .actions .button, .actions .small-button { width: 100%; }
  .page-head.compact .actions { width: 100%; }
  .grid.two { grid-template-columns: 1fr; }
  .query-list li { grid-template-columns: 1fr; align-items: stretch; }
  .element-editor { grid-template-columns: 1fr 1fr; }
  .admin-user-form { grid-template-columns: 1fr; min-width: 0; }
  .extend-form { grid-template-columns: 1fr; min-width: 0; }
}
