:root {
  color-scheme: light;
  --ink: #172722;
  --muted: #50655e;
  --brand: #106856;
  --brand-hover: #0a5143;
  --brand-soft: #e0f1ea;
  --surface: #fff;
  --paper: #f4f8f6;
  --line: #dbe7e1;
  --soft-line: #eaf0ed;
  --danger: #982f30;
  --danger-bg: #fff1ef;
  --radius: .65rem;
  font-family: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  font-size: 15px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--paper); }
button, input, textarea, select { font: inherit; color: inherit; }
button {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 2.25rem;
  padding: .35rem .75rem;
  white-space: nowrap;
}
button:hover:not(:disabled) { border-color: #a8c9bd; background: var(--paper); }
button:disabled { opacity: .55; cursor: wait; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 680; }
button.primary:hover:not(:disabled) { background: var(--brand-hover); }
button.danger { color: var(--danger); }
button.quiet { border-color: transparent; background: none; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input:not([type="checkbox"]), textarea, select {
  border: 1px solid var(--line);
  border-radius: .45rem;
  background: var(--surface);
  padding: .45rem .55rem;
  min-height: 2.3rem;
  min-width: 0;
}
textarea { resize: vertical; }
h1, h2, p { margin-block-start: 0; }
h1 { line-height: 1.2; letter-spacing: -.035em; }
.kicker { color: var(--brand); font-weight: 750; font-size: .8rem; letter-spacing: .04em; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: .35rem 0 0; overflow-wrap: anywhere; }
.notice {
  width: max-content;
  max-width: min(90vw, 42rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 .5rem 2rem #233a3020;
  padding: .65rem 1rem;
}
#notices { position: fixed; top: 4.5rem; left: 50%; transform: translateX(-50%); z-index: 6; }
.mark {
  width: 2.35rem;
  height: 2.35rem;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: .6rem;
  background: var(--brand-soft);
  color: var(--brand);
}
.mark svg { width: 1.2rem; height: 1.2rem; }
.login-shell {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: minmax(17rem, 1fr) minmax(18rem, 31rem);
  max-width: 76rem;
  margin-inline: auto;
  padding: clamp(1rem, 6vw, 5rem);
  gap: clamp(1.25rem, 7vw, 6rem);
  align-items: center;
}
.login-brand { align-self: stretch; display: flex; flex-direction: column; justify-content: center; color: #f6fffa; background: #164735; border-radius: 1.5rem; padding: clamp(1.25rem, 4vw, 3.5rem); min-height: 19rem; }
.login-word { display: flex; gap: .65rem; align-items: center; font-size: 1.1rem; font-weight: 720; margin-bottom: clamp(2rem, 13vh, 6rem); }
.login-brand h1 { max-width: 12ch; font-size: clamp(2rem, 4vw, 3rem); margin-bottom: .5rem; }
.login-brand p { color: #d4eee3; margin-bottom: 0; max-width: 27ch; }
.login-panel { border: 1px solid var(--line); padding: clamp(1.1rem, 4vw, 2.5rem); border-radius: 1.1rem; background: var(--surface); }
.login-panel h2 { font-size: 1.65rem; line-height: 1.3; margin-bottom: .4rem; }
.stack { display: grid; gap: 1rem; }
.stack label { display: grid; gap: .35rem; font-weight: 650; }
.stack input { width: 100%; }
.stack button { min-height: 2.65rem; }
.top {
  min-height: 3.6rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: .55rem clamp(.65rem, 2vw, 1.5rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brandbar, .top-actions, .grid-action-buttons { display: flex; align-items: center; gap: .55rem; }
.brandbar { min-width: 0; }
.brandbar a { text-decoration: none; font-size: 1rem; font-weight: 770; }
.top-actions .account-name { max-width: 13ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: grid; place-items: center; border-radius: 50%; width: 1.8rem; height: 1.8rem; background: var(--brand-soft); color: var(--brand); font-weight: 740; flex: none; }
.top-actions a { white-space: nowrap; }
.content { width: min(100%, 72rem); margin-inline: auto; padding: clamp(1rem, 4vw, 3.4rem); }
.page-title { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-title h1 { font-size: clamp(1.7rem, 3vw, 2.75rem); margin-bottom: .2rem; }
.page-title p { margin-bottom: 0; }
.doc-list { padding: 0; margin: 0; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; overflow: hidden; }
.doc-link { display: flex; text-decoration: none; gap: .75rem; justify-content: space-between; align-items: center; padding: .95rem 1rem; color: var(--ink); }
.doc-list li + li { border-top: 1px solid var(--soft-line); }
.doc-link:hover { background: #f1f8f4; }
.doc-link .title { display: flex; gap: .55rem; align-items: center; min-width: 0; }
.doc-link .title strong { overflow-wrap: anywhere; }
.role { display: inline-flex; align-items: center; background: var(--brand-soft); color: #205643; font-size: .78rem; border-radius: .4rem; padding: .22rem .47rem; font-weight: 650; white-space: nowrap; }
.role.read { background: #eaf0f3; color: #415962; }
.empty { padding: clamp(1.5rem, 6vw, 4rem) 1rem; text-align: center; color: var(--muted); }
.empty strong { color: var(--ink); display: block; margin-bottom: .35rem; }
.card { border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); }
.grid .editing td { background: #eff8f3; border-bottom-color: #d3e6dc; }
.grid .cell-input { display: block; width: 100%; }
.grid textarea.cell-input { min-height: 2.9rem; padding-top: .35rem; }
.grid .field-disabled { color: var(--muted); font-size: .82rem; }
.grid .field-list { display: grid; gap: .2rem; }
.grid .field-list a { overflow-wrap: anywhere; }
.grid details { background: #fff; border: 1px solid var(--line); border-radius: .42rem; padding: .34rem .45rem; }
.grid details summary { cursor: pointer; white-space: nowrap; }
.grid details label { display: flex; align-items: baseline; gap: .3rem; }
.grid .file-picker { width: 100%; }
.grid .attachment-item { display: flex; align-items: center; gap: .35rem; font-size: .82rem; }
.grid .attachment-item span { min-width: 0; overflow-wrap: anywhere; }
.grid .attachment-item button { flex: none; padding: .1rem .3rem; min-height: 1.5rem; line-height: 1.1; }
.grid-panel-main { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .65rem; }
.conflict-note { color: var(--danger); background: var(--danger-bg); border-radius: .45rem; padding: .5rem .7rem; margin: .5rem 0; overflow-wrap: anywhere; }
dialog { border: 1px solid var(--line); border-radius: 1rem; padding: 1.25rem; width: min(calc(100vw - 2rem), 27rem); color: var(--ink); box-shadow: 0 1rem 3rem #172d2250; }
dialog::backdrop { background: #132d245c; }
dialog h2 { margin-bottom: .55rem; font-size: 1.25rem; }
.dialog-actions { display: flex; justify-content: end; gap: .5rem; }
@media (max-width: 650px) {
  .login-shell { grid-template-columns: 1fr; align-content: center; max-width: 30rem; }
  .login-brand { min-height: auto; padding: 1rem 1.25rem; border-radius: .8rem; }
  .login-word { margin-bottom: 0; }
  .login-brand h1, .login-brand p { display: none; }
  .top { gap: .3rem; }
  .top-actions { gap: .4rem; }
  .top-actions .account-name { display: none; }
}

dialog.view-dialog { width: min(calc(100vw - 2rem), 48rem); }
.view-rule-form, .view-rule-list { display: grid; gap: .7rem; }
.view-rule-form label { display: grid; gap: .25rem; min-width: 0; font-size: .86rem; }
.view-rule-form > label { justify-self: start; }
.view-rule-form label span, .view-options legend { color: var(--muted); }
.view-rule { display: grid; grid-template-columns: minmax(7rem, 1fr) minmax(0, 2.5fr) auto; align-items: end; gap: .6rem; padding: .58rem; border: 1px solid var(--line); border-radius: var(--radius); }
.view-rule-detail { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem; min-width: 0; }
.view-rule-detail > label { flex: 1 1 7.5rem; }
.view-rule-actions, .view-add-rule { display: flex; align-items: center; gap: .3rem; }
.view-rule-actions button { padding-inline: .3rem; font-size: .84rem; }
.view-rule-actions button:disabled { cursor: default; }
.view-add-rule { gap: .6rem; }
.view-range { display: flex; align-items: end; flex-wrap: wrap; gap: .35rem; }
.view-range label { flex: 1 1 7.75rem; }
.view-options { flex: 1 1 10rem; min-width: 0; max-height: 8rem; overflow: auto; margin: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.view-options legend { font-size: .8rem; }
.view-options label { display: flex; align-items: baseline; gap: .3rem; overflow-wrap: anywhere; }
.grid .view-group td, .grid .view-group:hover td { padding-block: .12rem; background: #f5faf7; }
.view-group-toggle {
  display: inline-flex;
  position: sticky;
  left: .65rem;
  align-items: baseline;
  gap: .45rem;
  min-height: 1.85rem;
  max-width: min(85vw, 34rem);
  border: 0;
  padding: .2rem .35rem .2rem calc(.35rem + var(--group-depth, 0) * 1.1rem);
  background: transparent;
  font-size: .85rem;
  text-align: start;
  white-space: normal;
  overflow-wrap: anywhere;
}
.view-group-field, .view-group-count { color: var(--muted); }
.view-group-count { font-size: .8rem; white-space: nowrap; }
.view-group-chevron { color: var(--brand); }
@media (max-width: 650px) {
  .view-rule { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
  .view-rule-actions { justify-content: end; }
}

.table-inline-name { display: flex; align-items: center; gap: .15rem; }
.table-inline-name input { width: clamp(6.5rem, 16vw, 13rem); min-height: 2rem; padding-block: .22rem; }
.table-inline-name button { padding-inline: .3rem; min-height: 1.9rem; }
.table-action-menu { margin: 0; inset: auto; padding: .32rem; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 .4rem 1.6rem #172d2233; }
.table-action-menu button { display: block; width: 100%; text-align: start; }
.all-table-list { list-style: none; margin: 0; padding: 0; max-height: 45vh; overflow: auto; }
.all-table-list button { width: 100%; text-align: start; white-space: normal; margin-block-end: .25rem; }
.all-table-list .active-table { background: var(--brand-soft); color: var(--brand); }
.table-copy-scope { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.table-copy-scope label { display: flex; align-items: center; justify-content: start; padding: .3rem 0; }
.table-copy-scope input { width: auto; min-height: 0; }
.field-default { display: grid; gap: .35rem; }
.record-detail { width: min(calc(100vw - 2rem), 34rem); }
.record-detail-title { font-weight: 700; overflow-wrap: anywhere; }
.record-detail dl, .conflict-values { display: grid; grid-template-columns: minmax(5rem, 1fr) minmax(0, 3fr); gap: .55rem .8rem; }
.record-detail dl { overflow-y: auto; max-height: min(44vh, 28rem); }
.record-detail dt, .conflict-values dt { color: var(--muted); }
.record-detail dd, .conflict-values dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.notice { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.notice button { min-height: 1.9rem; }
.grid [aria-invalid="true"] { border-color: var(--danger); }

@media (max-width: 590px) {
  .table-inline-name { flex-wrap: wrap; }
}

.attachment-link { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
.attachment-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.attachment-preview { display: inline-flex; padding: 1px; min-height: 0; border-color: transparent; }
.attachment-thumbnail { width: 33px; height: 30px; object-fit: cover; border-radius: 3px; }
.attachment-preview:has(.attachment-thumbnail[hidden])::after { content: "预览"; padding: 0 4px; color: var(--muted); }
.attachment-large-preview { display: block; max-width: 100%; max-height: 60dvh; margin: 0 auto; object-fit: contain; }
.attachment-popover { width: min(19rem, calc(100vw - 16px)); }
.attachment-drop { display: grid; justify-items: center; gap: 7px; padding: 14px 8px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.attachment-editor:not(:empty) { margin-bottom: 8px; }
.attachment-editor .attachment-item { display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; }
.attachment-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-item .icon-button { margin-inline-start: auto; }
.option-initial { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: 10px; }
#notices { max-width: min(32rem, calc(100vw - 20px)); }

.grid-row-menu [role="menuitem"] { display: flex; align-items: center; gap: 7px; }
.grid .option-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  overflow-wrap: anywhere;
  margin-inline-end: 4px;
  min-height: 19px;
  margin-block: 1px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--swatch, var(--brand)) 15%, var(--surface));
  padding: 1px 6px;
  font-size: 12px;
  color: color-mix(in srgb, var(--swatch, var(--brand)) 60%, var(--ink));
}
.grid .option-person { padding-inline: 0 3px; background: transparent; color: var(--ink); }
