:root {
  --blue: #1969d1;
  --line: #e3e9f0;
  --ink: #1d3046;
  --sub: #61768b;
  --surface: #f5f7fa;
  --danger: #ac2d37;
  color: var(--ink);
  font: 15px/1.5 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--surface); }
button, input, select, textarea { color: inherit; font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid #90baf0; outline-offset: 2px; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid #d7e1ec;
  border-radius: 7px;
  background: #fff;
  color: #425a72;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { color: var(--blue); border-color: #a5c4e9; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover:not(:disabled) { color: #fff; background: #1358b1; }
.btn.small { min-height: 30px; padding: 4px 9px; font-size: 13px; }
.btn.danger { background: #ba303f; border-color: #ba303f; color: #fff; }
.btn.danger:hover:not(:disabled) { color: #fff; background: #a52733; }
.btn.text { border-color: transparent; color: var(--blue); background: transparent; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.muted { color: var(--sub); }

.shell { min-height: 100dvh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.top { display: flex; align-items: center; gap: 18px; padding: 10px 22px; border-bottom: 1px solid var(--line); background: #fff; z-index: 3; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 750; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 33px; height: 33px; color: white; background: var(--blue); border-radius: 8px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.top-tools { flex: 1; justify-content: flex-end; }
.layout { display: grid; grid-template-columns: 205px minmax(0, 1fr); min-height: 0; }
.sidebar { padding: 16px 11px; min-height: 0; overflow: auto; background: #fff; border-right: 1px solid var(--line); }
.tree-head { display: flex; justify-content: space-between; align-items: center; gap: 4px; padding: 0 3px 0 8px; }
.side-label { color: var(--sub); font-size: 13px; font-weight: 700; margin: 15px 9px 8px; }
.tree-head .side-label { margin: 0; }
.tree-add { color: var(--blue); background: #edf5ff; border: 0; border-radius: 5px; padding: 5px 7px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.tree-add:hover { background: #dcecff; }
.project-tree { padding-block: 10px 14px; border-bottom: 1px solid #edf1f5; }
.tree-row { display: flex; align-items: center; gap: 2px; min-width: 0; }
.tree-row.room { margin-left: 14px; }
.tree-item { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; border: 0; padding: 7px 8px; border-radius: 6px; background: transparent; color: #4d657d; }
.tree-item:hover, .tree-item.active { background: #eaf3ff; color: #1262c3; }
.tree-item.project-item { font-weight: 700; }
.tree-item.room-item { font-size: 14px; }
.tree-item.room-item::before { content: ""; display: inline-block; width: 7px; height: 7px; border: 1px solid #8a9eb3; border-radius: 2px; margin-right: 8px; }
.tree-note { padding: 5px 8px; font-size: 13px; color: var(--sub); }
.nav { display: grid; gap: 4px; }
.nav button { display: flex; align-items: center; gap: 9px; text-align: left; background: none; border: 0; border-radius: 7px; padding: 8px; color: #4d657d; white-space: nowrap; }
.nav button:hover:not(:disabled), .nav button.active { background: #eaf3ff; color: #1262c3; }
.nav button.active { font-weight: 700; }

.menu { position: relative; flex: none; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.tree-menu summary { border-radius: 5px; padding-inline: 5px; color: #5c7289; }
.tree-menu summary:hover { color: var(--blue); background: #edf5ff; }
.menu-list { position: absolute; z-index: 8; right: 0; top: calc(100% + 4px); display: grid; min-width: 120px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: white; box-shadow: 0 8px 25px #20395526; }
.menu-list button { text-align: left; border: 0; border-radius: 5px; background: white; padding: 7px 8px; white-space: nowrap; }
.menu-list button:hover { background: #edf5ff; }
.menu-list .danger-text { color: var(--danger); }
.tree-menu .menu-list { right: auto; left: -104px; }

.main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.page-head { padding: 16px 22px 12px; background: #fff; }
.eyebrow { font-size: 13px; color: var(--sub); min-height: 1.5em; }
.heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.heading h1 { margin: 3px 0 1px; font-size: 25px; line-height: 1.3; font-weight: 760; overflow-wrap: anywhere; }
.tabs { display: flex; gap: 25px; overflow-x: auto; flex: none; padding: 0 22px; background: #fff; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; white-space: nowrap; padding: 10px 0; color: #536b81; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--blue); border-color: var(--blue); font-weight: 700; }
#guidance:empty { display: none; }
#guidance:not(:empty) { margin: 10px 14px 0; }
.work { display: grid; grid-template-columns: minmax(0, 1fr) 268px; flex: 1; min-height: 0; }
.work.full-width { grid-template-columns: minmax(0, 1fr); }
.canvas { min-height: 0; min-width: 0; overflow: auto; padding: 14px; }
.detail-panel { min-height: 0; min-width: 0; overflow: auto; background: #fff; border-left: 1px solid var(--line); }
.empty-state { display: grid; justify-items: center; align-content: center; gap: 12px; min-height: 245px; text-align: center; color: var(--sub); }
.empty-state p { margin: 0; }

.dialog { width: min(545px, calc(100vw - 28px)); max-height: min(90dvh, 900px); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); box-shadow: 0 20px 65px #182d4f40; }
.dialog.wide { width: min(900px, calc(100vw - 28px)); }
.dialog::backdrop { background: #1b2b4560; }
.dialog form { max-height: inherit; display: flex; flex-direction: column; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 20px; }
.dialog-head p { margin: 4px 0 0; color: var(--sub); }
.dialog-body { padding: 15px 20px; min-height: 0; overflow: auto; }
.dialog-foot { border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 11px 20px; }
.x { border: 0; border-radius: 5px; background: #f0f4f8; color: #4b6076; width: 29px; min-width: 29px; height: 29px; font-size: 20px; line-height: 1; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 600; color: #3c536a; }
.field.full { grid-column: 1 / -1; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
  min-width: 0; width: 100%; min-height: 37px; padding: 6px 9px; border: 1px solid #d5dfeb; border-radius: 6px; background: #fff; color: #203850; font-weight: 400;
}
.field textarea { min-height: 70px; resize: vertical; }
.form-stack { display: grid; gap: 12px; }
.project-viewers { display: grid; gap: 6px; list-style: none; margin: 0; padding: 0; }
.project-viewers li { padding: 8px 0; border-top: 1px solid var(--line); }
.project-viewers li > span { flex: 1 1 8rem; min-width: 0; overflow-wrap: anywhere; }
.project-viewers select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.notice { margin: 0 0 12px; padding: 9px 11px; border: 1px solid #d4e4f9; border-radius: 7px; color: #365779; background: #f1f7ff; overflow-wrap: anywhere; }
.detail { margin-bottom: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 7px; }
.detail h3 { margin: 0 0 8px; font-size: 15px; }
.room-create-dialog { width: min(640px, calc(100vw - 24px)); }
.room-create-dialog .dialog-head { padding: 11px 16px; }
.room-create-dialog .dialog-head p { margin-top: 1px; }
.room-create-dialog .dialog-body { padding: 12px 16px; }
.room-create-dialog .dialog-foot { padding: 8px 16px; }
.room-create-fields, .room-cabinet-specs { display: grid; gap: 8px 12px; }
.room-create-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.room-cabinet-specs { grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.room-create-fields .field { gap: 3px; }
.room-create-fields .field input { min-height: 33px; padding-block: 4px; }
.room-create-fields .field textarea { min-height: 50px; padding-block: 4px; }
.room-numbering { grid-column: 1 / -1; min-width: 0; margin: 0; padding: 0; border: 0; color: #3c536a; }
.room-numbering legend { padding: 0; margin-bottom: 3px; font-size: 14px; font-weight: 600; }
.room-numbering-options { display: flex; flex-wrap: wrap; gap: 5px; }
.room-numbering-options label {
  display: flex; align-items: center; gap: 5px; padding: 4px 8px; border: 1px solid var(--line);
  border-radius: 6px; cursor: pointer; font-size: 14px;
}
.room-numbering-options input { margin: 0; accent-color: var(--blue); }
.room-numbering-options label:has(input:checked) { border-color: #afccef; color: var(--blue); background: #edf5ff; }
.room-number-preview {
  grid-column: 1 / -1; display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: start;
  gap: 8px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px;
}
.form-error { margin: 0 20px 12px; color: var(--danger); overflow-wrap: anywhere; }
.reload-action { margin-inline-start: .6rem; }
.toast { max-width: min(540px, calc(100vw - 28px)); position: fixed; z-index: 5; right: 18px; bottom: 18px; padding: 10px 14px; background: #263e5a; border-radius: 8px; color: #fff; box-shadow: 0 5px 15px #20395533; }

.auth-page { display: grid; place-items: center; min-height: 100dvh; padding: 22px; background: radial-gradient(ellipse at 35% 25%, #e8f2ff, var(--surface) 70%); }
.auth-layout { width: min(960px, 100%); display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: center; gap: clamp(24px, 5vw, 64px); }
.auth-page-compact .auth-layout { width: min(410px, 100%); grid-template-columns: minmax(0, 1fr); }
.auth-intro h1 { margin: 0 0 8px; font-size: clamp(25px, 4vw, 36px); line-height: 1.2; }
.auth-intro p { margin: 0; color: var(--sub); }
.auth-intro ul { display: grid; gap: 8px; margin: 16px 0; padding: 0; list-style: none; }
.auth-intro li { border-inline-start: 2px solid #b7d1ee; padding-inline-start: 10px; }
.auth-card { width: min(410px, 100%); border: 1px solid var(--line); border-radius: 13px; background: #fff; padding: 27px; box-shadow: 0 12px 35px #385a8612; }
.auth-card h1, .auth-card h2 { margin: 0 0 12px; font-size: 22px; }
.auth-card .actions { justify-content: flex-end; padding-top: 4px; }
.auth-card .form-error { margin: 0; }
.account-page { padding: 22px; overflow: auto; flex: 1; min-height: 0; }
.account-page h2 { margin: 0 0 8px; font-size: 21px; }
.account-page .actions { margin: 8px 0 14px; }
.account-page .audit-filters { align-items: flex-end; }
.account-table { width: 100%; border-collapse: collapse; background: #fff; }
.account-table th, .account-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.account-table th { color: #486179; background: #eef4fb; }
.account-table td:last-child .actions { margin: 0; }

@media (max-width: 1050px) {
  .layout { grid-template-columns: 174px minmax(0, 1fr); }
  .work { grid-template-columns: minmax(0, 1fr) 230px; }
  .page-head { padding-inline: 15px; }
  .tabs { padding-inline: 15px; gap: 18px; }
}
@media (max-width: 730px) {
  .auth-layout { width: min(460px, 100%); grid-template-columns: minmax(0, 1fr); }
  .auth-card { width: 100%; }
  .shell { height: auto; grid-template-columns: minmax(0, 1fr); }
  .layout { display: block; }
  .top { padding-inline: 11px; gap: 8px; flex-wrap: wrap; }
  .top-tools { flex: 0 1 100%; min-width: 0; justify-content: flex-start; }
  .top-tools .user-menu { max-width: 100%; }
  .top-tools .user-menu > summary { white-space: normal; overflow-wrap: anywhere; }
  .sidebar { padding: 8px; display: flex; gap: 8px; align-items: start; overflow: auto; border-bottom: 1px solid var(--line); }
  .sidebar > .side-label, .sidebar .workspace-nav { display: none; }
  .project-tree { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; padding: 0; border: 0; }
  .project-tree .tree-row.room { margin-left: 0; }
  .tree-head { padding-left: 0; }
  .tree-head .side-label { display: none; }
  .work { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(380px, 62dvh) auto; }
  .work.full-width { grid-template-rows: minmax(340px, auto); }
  .canvas, .account-page { padding: 9px; }
  .detail-panel { max-height: 430px; border-left: 0; border-top: 1px solid var(--line); }
  .heading h1 { font-size: 21px; }
}
