:root {
  --ink: #17201c;
  --muted: #69736e;
  --muted-2: #8f9994;
  --line: #dde3df;
  --line-soft: #edf0ee;
  --surface: #ffffff;
  --surface-soft: #f5f7f5;
  --surface-warm: #fbfaf7;
  --green: #176c4b;
  --green-bright: #208a62;
  --green-soft: #e7f3ed;
  --green-pale: #f1f8f4;
  --red: #a14545;
  --red-soft: #fbebeb;
  --shadow: 0 16px 50px rgba(25, 42, 34, 0.08);
  --sans: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
  --serif: Charter, 'Iowan Old Style', Georgia, serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: #eef2ef;
  font-family: var(--sans);
  overflow: hidden;
}

button, input, textarea { font: inherit; }
button { color: inherit; }

.app-shell {
  height: 100vh;
  min-height: 640px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.topbar {
  height: 68px;
  flex: 0 0 68px;
  display: grid;
  grid-template-columns: 270px 1fr 330px;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark, .model-icon, .message-avatar {
  display: grid;
  place-items: center;
  color: white;
  background: var(--green);
  font-family: var(--serif);
  font-weight: 600;
}
.brand-mark {
  width: 36px;
  height: 40px;
  border-radius: 6px 13px 6px 13px;
  font-size: 21px;
  transform: rotate(-2deg);
  box-shadow: 0 6px 16px rgba(23, 108, 75, 0.2);
}
.brand-name { font-weight: 700; font-size: 17px; line-height: 1.1; letter-spacing: -0.03em; }
.brand-subtitle { margin-top: 2px; color: var(--muted-2); font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase; }

.project-title-wrap { justify-self: center; display: flex; align-items: center; gap: 10px; min-width: 0; }
.project-title {
  width: min(380px, 38vw);
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}
.project-title:hover, .project-title:focus { border-color: var(--line); background: var(--surface-soft); }
.save-state { color: var(--muted-2); font-size: 11px; white-space: nowrap; }
.save-state.saving { color: var(--green); }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 7px; }

.button {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 12px;
  background: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: 150ms ease;
}
.button:hover { transform: translateY(-1px); border-color: #c5cec9; }
.button-ghost { background: transparent; color: #525d57; }
.button-secondary { background: var(--green-pale); border-color: #cce1d6; color: var(--green); }
.button-primary { color: white; border-color: var(--green); background: var(--green); }
.button-primary:hover { background: #125d40; }
.button-icon { width: 34px; padding: 8px 0; font-size: 14px; }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 210px minmax(700px, 1fr) 360px;
}

.project-sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
}
.sidebar-section { padding: 17px 13px 12px; }
.files-section { border-bottom: 1px solid var(--line); }
.outline-section { flex: 1; min-height: 0; overflow: auto; }
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px 9px;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.085em;
  text-transform: uppercase;
}
.icon-button {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
}
.icon-button:hover { color: var(--green); border-color: #bdd4c8; }
.icon-button.subtle { border-color: transparent; background: transparent; }

.file-list { display: flex; flex-direction: column; gap: 3px; }
.file-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #4b5650;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.file-item:hover { background: #ebefec; }
.file-item.active { color: var(--green); background: #e1eee7; font-weight: 600; }
.file-icon { width: 16px; color: #829088; font-family: var(--serif); font-size: 14px; text-align: center; }
.file-item.active .file-icon { color: var(--green); }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.outline { display: flex; flex-direction: column; gap: 2px; }
.outline-item {
  display: block;
  width: 100%;
  padding: 6px 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #647069;
  font-size: 11px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.outline-item:hover { color: var(--green); background: #e9efeb; }
.outline-level-2 { padding-left: 19px; color: #7d8882; }
.outline-empty { padding: 8px 7px; color: var(--muted-2); font-size: 11px; line-height: 1.5; }

.model-card {
  margin: 12px;
  padding: 11px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
}
.model-icon { width: 28px; height: 28px; border-radius: 8px; font-size: 14px; }
.model-info { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.model-label { color: var(--muted-2); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.model-info strong { margin-top: 2px; font-size: 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #b8c0bc; box-shadow: 0 0 0 3px #edf0ee; }
.status-dot.online { background: #28a471; box-shadow: 0 0 0 3px #e1f2e9; }
.status-dot.error { background: #c55b5b; box-shadow: 0 0 0 3px #f7e4e4; }

.editor-area { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: white; }
.editor-toolbar {
  height: 51px;
  flex: 0 0 51px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 19px;
  border-bottom: 1px solid var(--line-soft);
}
.view-switch { display: flex; align-items: center; gap: 4px; padding: 3px; border-radius: 8px; background: var(--surface-soft); }
.view-tab {
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.view-tab.active { color: var(--ink); background: white; box-shadow: 0 1px 5px rgba(30, 45, 38, .09); }
.editor-meta { color: var(--muted-2); font-size: 10px; }
.meta-separator { margin: 0 5px; }

.document-split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(340px, 1fr) minmax(330px, 47%); }
.source-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.editor-view { flex: 1; min-height: 0; display: grid; grid-template-columns: 45px 1fr; overflow: hidden; background: #fff; }
.line-numbers {
  padding: 22px 12px 80px 0;
  overflow: hidden;
  border-right: 1px solid var(--line-soft);
  background: #fafbfa;
  color: #b2bbb6;
  font: 11px/1.72 var(--mono);
  text-align: right;
  white-space: pre;
  user-select: none;
}
.code-editor {
  width: 100%;
  height: 100%;
  resize: none;
  padding: 22px 26px 80px 20px;
  border: 0;
  outline: 0;
  background: white;
  color: #26302b;
  font: 13px/1.72 var(--mono);
  caret-color: var(--green);
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}
.code-editor::selection { color: #12261d; background: #cde8da; }

.preview-view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 46px max(50px, 9%);
  background: #f4f2ec;
}
.preview-paper {
  max-width: 760px;
  min-height: 100%;
  margin: 0 auto;
  padding: 65px 72px 90px;
  background: white;
  box-shadow: 0 5px 24px rgba(44, 48, 44, .10);
  color: #252723;
  font: 16px/1.62 var(--serif);
}
.preview-paper h1 { margin: 0 0 12px; font-size: 28px; line-height: 1.15; text-align: center; }
.preview-paper .author { margin-bottom: 36px; color: #555c56; text-align: center; }
.preview-paper h2 { margin: 32px 0 12px; font-size: 21px; }
.preview-paper h3 { margin: 24px 0 8px; font-size: 17px; }
.preview-paper p { margin: 0 0 14px; text-align: justify; }
.preview-paper .abstract { margin: 25px 30px; padding: 17px 20px; border: 1px solid #ddd; font-size: 14px; }
.preview-paper code { color: var(--green); font: 13px var(--mono); }
.preview-paper .citation { color: var(--green); }
.preview-note { max-width: 760px; margin: 12px auto 0; color: #7f817c; font-size: 10px; text-align: center; }

.editor-footer {
  height: 28px;
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  padding: 0 14px;
  border-top: 1px solid var(--line-soft);
  background: #fafbfa;
  color: var(--muted-2);
  font-size: 9px;
}

.pdf-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: #e9ecea;
}
.pdf-toolbar {
  min-height: 43px;
  flex: 0 0 43px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 9px 0 12px;
  border-bottom: 1px solid #d4d9d6;
  background: #f8f9f8;
}
.pdf-title-wrap { min-width: 0; display: flex; align-items: baseline; gap: 7px; }
.pdf-title-wrap strong { font-size: 11px; letter-spacing: .04em; }
.compile-status { max-width: 105px; overflow: hidden; color: var(--muted-2); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.compile-status.success { color: var(--green); }
.compile-status.error { color: var(--red); }
.compile-status.running { color: #9b7120; }
.pdf-actions { display: flex; align-items: center; gap: 4px; }
.engine-label select {
  max-width: 88px;
  padding: 5px 20px 5px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: white;
  color: #56605a;
  font-size: 9px;
}
.auto-compile { display: inline-flex; align-items: center; gap: 3px; padding: 4px; color: var(--muted); font-size: 8px; cursor: pointer; }
.auto-compile input { width: 12px; height: 12px; margin: 0; accent-color: var(--green); }
.pdf-tool-button, .compile-button {
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  font-size: 9px;
  font-weight: 600;
  cursor: pointer;
}
.compile-button { border-color: var(--green); background: var(--green); color: white; }
.compile-button:hover { background: #125e40; }
.compile-button:disabled { opacity: .55; cursor: wait; }
.pdf-tool-button.active { border-color: #b7cfc3; background: var(--green-pale); color: var(--green); }
.pdf-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.pdf-frame { width: 100%; height: 100%; border: 0; background: #707572; }
.pdf-empty, .compile-error, .compile-loader {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: #e9ecea;
  text-align: center;
}
.pdf-empty strong, .compile-error strong { margin-top: 12px; font: 600 16px var(--serif); }
.pdf-empty p, .compile-error p { max-width: 260px; margin: 7px 0 15px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.pdf-sheet-icon {
  position: relative;
  width: 52px;
  height: 65px;
  display: grid;
  place-items: center;
  border: 1px solid #c7cfca;
  border-radius: 3px;
  background: white;
  box-shadow: 0 8px 18px rgba(32, 42, 37, .10);
}
.pdf-sheet-icon::after { content: ''; position: absolute; right: 6px; top: 8px; width: 19px; height: 2px; background: #dfe4e1; box-shadow: 0 7px 0 #dfe4e1, 0 14px 0 #dfe4e1; }
.pdf-sheet-icon span { align-self: end; margin-bottom: 9px; padding: 3px 5px; border-radius: 3px; background: var(--green); color: white; font-size: 8px; font-weight: 700; }
.compile-loader { gap: 12px; color: #56605a; font-size: 10px; background: rgba(233, 236, 234, .94); }
.compile-spinner { width: 27px; height: 27px; border: 3px solid #cbd7d0; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--red-soft); color: var(--red); font-weight: 700; }
.compile-log {
  height: 35%;
  min-height: 150px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-top: 1px solid #343b37;
  background: #202622;
  color: #d0d8d3;
  font: 9px/1.55 var(--mono);
  white-space: pre-wrap;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.assistant-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--surface-warm);
}
.assistant-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 20px 12px; }
.eyebrow, .changes-kicker { color: var(--green); font-size: 9px; font-weight: 700; letter-spacing: .12em; }
.assistant-header h1 { margin: 4px 0 0; font: 600 20px/1.2 var(--serif); }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 20px 14px; }
.quick-actions button {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.7);
  color: #58625d;
  font-size: 10px;
  cursor: pointer;
}
.quick-actions button:hover { color: var(--green); border-color: #bfd4c8; background: white; }
.quick-actions span { width: 15px; color: var(--green); font-weight: 700; }

.chat { flex: 1; min-height: 90px; overflow-y: auto; padding: 6px 20px 14px; scroll-behavior: smooth; }
.message { display: flex; gap: 10px; margin: 10px 0; }
.message-avatar { flex: 0 0 26px; width: 26px; height: 26px; margin-top: 2px; border-radius: 8px; font-size: 12px; }
.message-body { min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 3px 11px 11px 11px; background: white; color: #414a45; font-size: 11px; line-height: 1.55; box-shadow: 0 5px 18px rgba(29, 43, 35, .035); }
.message-body p { margin: 0 0 7px; }
.message-body p:last-child { margin-bottom: 0; }
.message-hint { color: var(--muted-2); }
.user-message { justify-content: flex-end; }
.user-message .message-body { max-width: 87%; border-color: #cfe0d7; border-radius: 11px 3px 11px 11px; background: var(--green-pale); color: #315142; }
.error-message .message-body { border-color: #f0cccc; background: #fff7f7; color: #8e4646; }
.typing .message-body { display: flex; gap: 4px; align-items: center; min-height: 36px; }
.typing-dot { width: 5px; height: 5px; border-radius: 50%; background: #8ba497; animation: bounce 1.1s infinite ease-in-out; }
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }

.changes-panel {
  margin: 0 14px 10px;
  border: 1px solid #c8ddd2;
  border-radius: 11px;
  background: white;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.changes-heading { display: flex; align-items: center; justify-content: space-between; padding: 11px 13px; border-bottom: 1px solid var(--line-soft); }
.changes-heading > div { display: flex; flex-direction: column; gap: 2px; }
.changes-heading strong { font-size: 11px; }
.diff-list { max-height: 190px; overflow: auto; padding: 5px 0; }
.diff-card { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); }
.diff-card:last-child { border-bottom: 0; }
.diff-file { margin-bottom: 6px; color: var(--muted); font: 10px var(--mono); }
.diff-row { display: grid; grid-template-columns: 16px 1fr; padding: 3px 5px; font: 9px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-row.remove { color: #874545; background: var(--red-soft); }
.diff-row.add { color: #276147; background: var(--green-soft); }
.diff-row.context { color: #7d8580; }
.changes-actions { display: flex; justify-content: flex-end; gap: 7px; padding: 10px 12px; border-top: 1px solid var(--line-soft); background: #fafbfa; }

.composer { flex: 0 0 auto; margin: 0 14px 14px; padding: 9px 11px 10px; border: 1px solid #cfd7d2; border-radius: 11px; background: white; box-shadow: 0 7px 25px rgba(30, 42, 36, .07); }
.composer:focus-within { border-color: #8bb7a1; box-shadow: 0 7px 25px rgba(23, 108, 75, .09), 0 0 0 2px rgba(23, 108, 75, .06); }
.context-badge { display: inline-flex; align-items: center; padding: 4px 7px; border-radius: 5px; background: var(--green-pale); color: var(--green); font-size: 9px; font-weight: 600; }
.composer textarea { width: 100%; resize: none; padding: 9px 2px 5px; border: 0; outline: none; color: var(--ink); font-size: 11px; line-height: 1.45; }
.composer textarea::placeholder { color: #a4aaa7; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; }
.privacy-note { color: var(--muted-2); font-size: 8px; }
.lock { color: var(--green); font-size: 6px; }
.send-button { width: 28px; height: 28px; border: 0; border-radius: 8px; background: var(--green); color: white; font-size: 17px; cursor: pointer; }
.send-button:hover { background: #125e40; }
.send-button:disabled { opacity: .45; cursor: wait; }

.dialog { width: min(390px, calc(100vw - 30px)); padding: 0; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 25px 80px rgba(18, 30, 24, .25); }
.dialog::backdrop { background: rgba(20, 30, 25, .35); backdrop-filter: blur(3px); }
.dialog form { padding: 24px; }
.dialog-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--green-soft); color: var(--green); font-size: 20px; }
.dialog h2 { margin: 13px 0 6px; font: 600 21px var(--serif); }
.dialog p { margin: 0 0 17px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.dialog label { display: block; margin-bottom: 6px; color: #505b55; font-size: 10px; font-weight: 600; }
.dialog input { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; outline: none; font: 12px var(--mono); }
.dialog input:focus { border-color: #8bb7a1; box-shadow: 0 0 0 2px var(--green-soft); }
.settings-dialog { width: min(470px, calc(100vw - 30px)); }
.settings-dialog label { margin-top: 11px; }
.settings-dialog .clear-key-label { display: flex; align-items: center; gap: 7px; margin: 8px 0 0; color: var(--muted); font-weight: 400; cursor: pointer; }
.settings-dialog .clear-key-label input { width: 13px; accent-color: var(--green); }
.settings-status { min-height: 28px; margin-top: 9px; padding: 7px 9px; border-radius: 6px; color: var(--muted); background: var(--surface-soft); font-size: 9px; }
.settings-status.success { color: var(--green); background: var(--green-pale); }
.settings-status.error { color: var(--red); background: #fff4f4; }
.field-error { min-height: 18px; padding-top: 4px; color: var(--red); font-size: 9px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 8px; }
.dialog-actions .test-connection { margin-right: auto; }

.toast { position: fixed; left: 50%; bottom: 35px; z-index: 20; padding: 9px 14px; border-radius: 8px; background: #26312b; color: white; box-shadow: var(--shadow); font-size: 11px; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: 180ms ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }
.auth-loading .app-shell, .auth-loading.admin-page { visibility: hidden; }
.current-user { display: inline-flex; align-items: center; gap: 6px; padding-left: 5px; border-left: 1px solid var(--line); }
.current-user span { max-width: 120px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background:
    radial-gradient(circle at 18% 20%, rgba(23, 108, 75, .12), transparent 32%),
    linear-gradient(145deg, #eef3ef, #faf8f2);
}
.auth-card { width: min(420px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.94); box-shadow: 0 28px 80px rgba(20, 37, 28, .14); }
.auth-brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.auth-heading { margin: 38px 0 24px; }
.auth-heading h1, .admin-heading h1 { margin: 7px 0 8px; font: 600 30px/1.15 var(--serif); }
.auth-heading p, .admin-heading p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.auth-form { display: grid; gap: 7px; }
.auth-form label { margin-top: 8px; color: #505b55; font-size: 10px; font-weight: 600; }
.auth-form input, .admin-form input, .admin-form select { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: white; color: var(--ink); font: 12px var(--mono); }
.auth-form input:focus, .admin-form input:focus, .admin-form select:focus { border-color: #8bb7a1; box-shadow: 0 0 0 2px var(--green-soft); }
.auth-submit { width: 100%; margin-top: 8px; padding: 11px; }
.auth-error { min-height: 18px; padding-top: 5px; color: var(--red); font-size: 10px; }
.auth-help { margin: 20px 0 0; color: var(--muted-2); font-size: 9px; line-height: 1.5; text-align: center; }

.admin-page { min-height: 100vh; overflow: auto; background: var(--surface-soft); }
.admin-topbar { min-height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 10px max(24px, calc((100vw - 1120px) / 2)); border-bottom: 1px solid var(--line); background: white; }
.admin-brand .brand-mark { width: 34px; height: 34px; }
.admin-layout { width: min(1120px, calc(100% - 40px)); margin: 42px auto 80px; }
.admin-heading { margin-bottom: 25px; }
.admin-panel { margin-top: 18px; padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 9px 35px rgba(29, 43, 35, .05); }
.admin-panel h2 { margin: 0 0 16px; font: 600 19px var(--serif); }
.admin-panel-heading { display: flex; align-items: center; justify-content: space-between; }
.admin-form { display: grid; grid-template-columns: 1fr 1.2fr 190px auto; align-items: end; gap: 12px; }
.admin-form label { display: grid; gap: 6px; color: #505b55; font-size: 10px; font-weight: 600; }
.admin-form button { min-height: 38px; }
.users-table-wrap { overflow-x: auto; }
.users-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.users-table th { padding: 10px 8px; border-bottom: 1px solid var(--line); color: var(--muted-2); font-size: 9px; font-weight: 600; text-align: left; }
.users-table td { padding: 13px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.users-table td:first-child { display: grid; gap: 3px; }
.users-table td:first-child span { color: var(--muted); font: 9px var(--mono); }
.user-status { display: inline-flex; padding: 4px 7px; border-radius: 99px; font-size: 9px; font-weight: 600; }
.user-status.active { background: var(--green-pale); color: var(--green); }
.user-status.disabled { background: var(--red-soft); color: var(--red); }
.user-actions { min-width: 190px; text-align: right; }
.table-action { padding: 4px 6px; border: 0; background: none; color: var(--green); font-size: 9px; cursor: pointer; }
.table-action:hover { text-decoration: underline; }
.password-dialog { width: min(480px, calc(100vw - 30px)); }
.password-result { padding: 26px; }
.password-result h2 { margin: 13px 0 6px; font: 600 21px var(--serif); }
.password-result p { color: var(--muted); font-size: 10px; line-height: 1.5; }
.generated-password { display: block; margin: 18px 0; padding: 14px; border: 1px dashed #9cb9aa; border-radius: 9px; background: var(--green-pale); color: #174e37; font: 600 16px var(--mono); text-align: center; user-select: all; }

@media (max-width: 1270px) {
  .workspace { grid-template-columns: minmax(680px, 1fr) 340px; }
  .project-sidebar { display: none; }
  .topbar { grid-template-columns: 220px 1fr 330px; }
  .brand-subtitle { display: none; }
}

@media (max-width: 820px) {
  body { overflow: auto; }
  .app-shell { min-width: 0; height: auto; min-height: 100vh; }
  .topbar { position: sticky; top: 0; grid-template-columns: auto 1fr; height: auto; min-height: 65px; padding: 10px 13px; }
  .project-title-wrap { justify-self: end; }
  .project-title { width: 210px; text-align: right; }
  .save-state, .top-actions { display: none; }
  .workspace { min-height: calc(100vh - 65px); grid-template-columns: 1fr; grid-template-rows: 700px minmax(620px, auto); }
  .editor-area { border-bottom: 1px solid var(--line); }
  .document-split { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .pdf-pane { border-top: 1px solid var(--line); border-left: 0; }
  .assistant-panel { border-left: 0; }
  .admin-form { grid-template-columns: 1fr; }
  .admin-layout { width: min(100% - 24px, 1120px); margin-top: 24px; }
  .admin-panel { padding: 16px; }
}
