:root {
  --canvas: #f3f5f2;
  --surface: #ffffff;
  --surface-soft: #f8faf8;
  --ink: #20272a;
  --muted: #667174;
  --line: #dce2dd;
  --line-strong: #c7d0c9;
  --green: #087761;
  --green-dark: #075746;
  --green-soft: #e4f3ed;
  --red: #b0443c;
  --red-soft: #f9e9e6;
  --amber: #a36b08;
  --amber-soft: #fff2d5;
  --blue: #2d5f8f;
  --blue-soft: #e7f0f8;
  --sidebar: #182725;
  --shadow: 0 14px 36px rgba(30, 45, 41, 0.08);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 7px;
  color: var(--red);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
}

.login-screen {
  min-height: 100vh;
  padding: 28px clamp(24px, 6vw, 84px);
  background: linear-gradient(120deg, #f4f7f3 0 62%, #e7efea 62%);
}

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

.login-brand img { width: min(250px, 52vw); }
.login-brand span { padding-left: 16px; border-left: 1px solid var(--line-strong); color: var(--muted); font-weight: 800; }

.login-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 400px;
  gap: clamp(42px, 8vw, 120px);
  align-items: center;
  width: min(1180px, 100%);
  min-height: calc(100vh - 120px);
  margin: auto;
}

.login-copy h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(36px, 4.2vw, 64px);
  line-height: 1.14;
  letter-spacing: 0;
}

.login-copy > p:last-child { max-width: 650px; margin: 20px 0 0; color: var(--muted); font-size: 17px; line-height: 1.75; }

.login-form {
  display: grid;
  gap: 18px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-form h2 { margin: 0 0 4px; font-size: 22px; }

label { display: grid; gap: 7px; }
label > span, .field-label { color: var(--muted); font-size: 12px; font-weight: 800; }

input, select, textarea {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: 0;
}

input, select { height: 42px; padding: 0 11px; }
textarea { min-height: 88px; padding: 10px 11px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(8, 119, 97, 0.12); }

.primary-button, .secondary-button, .danger-button, .quiet-button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button { color: #fff; background: var(--green); }
.primary-button:hover { background: var(--green-dark); }
.secondary-button { color: var(--green-dark); background: #fff; border-color: var(--line-strong); }
.danger-button { color: var(--red); background: var(--red-soft); border-color: #efc9c4; }
.quiet-button { color: #cbd8d4; background: transparent; border-color: #405451; }
.icon-button { width: 38px; padding: 0; color: var(--muted); background: #fff; border-color: var(--line); font-size: 24px; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

.form-message { min-height: 20px; margin: 0; color: var(--muted); font-size: 13px; }
.form-message.is-error { color: var(--red); }
.form-message.is-ok { color: var(--green-dark); }

.app-shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  color: #eef5f2;
  background: var(--sidebar);
  border-right: 1px solid #32423f;
}

.sidebar-brand { display: block; min-height: 94px; padding: 21px 20px 16px; border-bottom: 1px solid #344541; }
.sidebar-brand img { display: block; width: 190px; filter: brightness(0) invert(1); }
.sidebar-brand span { display: block; margin-top: 9px; color: #a8bab5; font-size: 12px; font-weight: 700; }
.sidebar-brand b { color: #fff; }

.side-nav { display: grid; gap: 4px; padding: 16px 12px; overflow-y: auto; }
.nav-button {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  color: #b9c8c4;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  font-weight: 700;
}
.nav-button:hover { color: #fff; background: #243936; }
.nav-button.is-active { color: #fff; background: var(--green); }
.nav-symbol { color: currentColor; font-size: 15px; font-weight: 900; }

.sidebar-foot { margin-top: auto; padding: 14px; border-top: 1px solid #344541; }
.account-summary { display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: center; margin-bottom: 12px; }
.account-summary > span { display: grid; place-items: center; width: 36px; height: 36px; color: #fff; background: var(--red); border-radius: 50%; font-weight: 900; }
.account-summary strong, .account-summary small { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-summary strong { font-size: 13px; }
.account-summary small { margin-top: 3px; color: #9db0ab; font-size: 11px; }
.sidebar-foot .quiet-button { width: 100%; }

.workspace { min-width: 0; padding: 28px clamp(24px, 3vw, 46px) 54px; }
.workspace-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-bottom: 24px; }
.workspace-head h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
.workspace-head > div:first-child > p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.view-actions { display: flex; align-items: center; gap: 9px; }

.view-root { min-width: 0; }
.loading-state, .empty-state { display: grid; place-items: center; min-height: 260px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 8px; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; }
.metric-card { min-height: 116px; padding: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 20px rgba(30,45,41,.04); }
.metric-card span { color: var(--muted); font-size: 12px; font-weight: 800; }
.metric-card strong { display: block; margin-top: 8px; color: var(--green-dark); font-size: 30px; }
.metric-card small { display: block; margin-top: 5px; color: var(--muted); }
.metric-card.is-alert strong { color: var(--red); }

.content-band { margin-top: 20px; padding: 20px 0; border-top: 1px solid var(--line); }
.band-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.band-head h2 { margin: 0; font-size: 18px; }
.band-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.filter-bar { display: grid; grid-template-columns: minmax(220px, 1fr) 180px 180px auto; gap: 9px; margin-bottom: 14px; }
.filter-bar.two { grid-template-columns: minmax(220px, 1fr) 200px; }
.search-input { position: relative; }

.data-table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.data-table { width: 100%; min-width: 820px; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.data-table th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: #f6f8f6; font-size: 11px; font-weight: 900; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafcfb; }
.data-table strong { display: block; }
.data-table small { display: block; margin-top: 4px; color: var(--muted); line-height: 1.5; }
.table-action { padding: 0; color: var(--green-dark); background: transparent; border: 0; cursor: pointer; font-weight: 800; }
.table-actions { display: flex; align-items: center; gap: 12px; white-space: nowrap; }

.status-badge, .role-badge, .category-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}
.status-published, .status-completed, .status-active { color: var(--green-dark); background: var(--green-soft); }
.status-draft, .status-pending { color: var(--amber); background: var(--amber-soft); }
.status-disabled, .status-archived { color: var(--muted); background: #edf0ed; }
.status-review { color: var(--blue); background: var(--blue-soft); }
.role-super_admin { color: var(--red); background: var(--red-soft); }
.role-operator { color: var(--blue); background: var(--blue-soft); }
.category-badge { color: var(--green-dark); background: var(--green-soft); }

.feature-grid { display: grid; grid-template-columns: repeat(3, minmax(240px, 1fr)); gap: 12px; }
.feature-card { display: grid; grid-template-rows: auto 1fr auto; min-height: 190px; padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.feature-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.feature-card h3 { margin: 10px 0 0; font-size: 16px; }
.feature-card p { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.feature-card footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 15px; padding-top: 12px; border-top: 1px solid var(--line); }
.feature-route { min-width: 0; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.split-view { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 14px; align-items: start; }
.detail-panel { position: sticky; top: 24px; padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.detail-panel h2 { margin: 0; font-size: 18px; }
.detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.detail-meta div { padding: 10px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; }
.detail-meta span, .detail-meta strong { display: block; }
.detail-meta span { color: var(--muted); font-size: 10px; font-weight: 800; }
.detail-meta strong { margin-top: 5px; font-size: 13px; word-break: break-word; }
.payload-view { max-height: 420px; margin: 12px 0 0; padding: 12px; overflow: auto; color: #d9e5e1; background: #172421; border-radius: 6px; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; }

.database-grid { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: 12px; }
.database-card { padding: 15px; background: #fff; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.database-card:hover { border-color: var(--green); }
.database-card h3 { margin: 0; font: 700 14px ui-monospace, SFMono-Regular, Menlo, monospace; }
.database-card strong { display: block; margin-top: 12px; color: var(--green-dark); font-size: 25px; }
.database-card p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }

.permission-grid { display: grid; grid-template-columns: repeat(3, minmax(170px, 1fr)); gap: 8px; margin-top: 10px; }
.permission-option { display: flex; grid-template: none; flex-direction: row; align-items: center; gap: 8px; min-height: 38px; padding: 8px 10px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; }
.permission-option input { width: 16px; height: 16px; }
.permission-option span { color: var(--ink); font-size: 12px; }

.editor-dialog { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 28px 80px rgba(19, 34, 30, .24); }
.editor-dialog.is-wide { width: min(1280px, calc(100vw - 32px)); }
.editor-dialog::backdrop { background: rgba(20, 31, 29, .48); }
.dialog-frame { margin: 0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 20px; }
.dialog-body { max-height: calc(100vh - 120px); padding: 20px; overflow-y: auto; }
.editor-form { display: grid; gap: 14px; }
.form-grid { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-section { margin: 8px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.form-section h3 { margin: 0 0 12px; font-size: 14px; }
.form-help { margin: -5px 0 12px; color: var(--muted); font-size: 12px; }
.country-editor-form { gap: 10px; }
.country-editor-workbench { display: grid; gap: 10px; }
.country-editor-intro {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #f7fbf9;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--green);
}
.country-editor-intro > span {
  display: grid;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  place-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 20px;
}
.country-editor-intro > div { min-width: 0; flex: 1; }
.country-editor-intro strong { display: block; font-size: 15px; }
.country-editor-intro p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.country-editor-intro button { flex: 0 0 auto; }
.country-editor-form .country-flat-section {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-top: 2px solid var(--line-strong);
}
.country-editor-form .country-core-section { border-top: 3px solid var(--green); }
.country-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-strong);
}
.country-section-head > div { min-width: 0; }
.country-section-head span {
  display: block;
  margin-bottom: 2px;
  color: var(--red);
  font-size: 9px;
  font-weight: 900;
}
.country-editor-form .country-section-head h3 {
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}
.country-editor-form .country-section-head h3::before { display: none; }
.country-section-head p { max-width: 560px; margin: 0; color: var(--muted); font-size: 11px; text-align: right; }
.country-editor-form .form-grid { gap: 8px 10px; }
.country-editor-form .form-grid + .form-grid { margin-top: 8px; }
.country-editor-form label { gap: 4px; }
.country-editor-form label > span { font-size: 11px; }
.country-editor-form input, .country-editor-form select { height: 36px; }
.country-editor-form textarea { min-height: 62px; padding-block: 8px; line-height: 1.4; }
.country-editor-form .form-help { margin: -2px 0 8px; font-size: 11px; }
.country-editor-form .config-rows, .country-editor-form .config-repeater { gap: 8px; }
.country-editor-form .config-row { gap: 8px; padding: 10px; border-radius: 4px; }
.country-editor-form .config-step-links { gap: 8px; padding: 9px; border-radius: 4px; }
.country-editor-form > .form-actions {
  position: sticky;
  z-index: 4;
  bottom: -20px;
  margin: 0 -20px -20px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line-strong);
  box-shadow: 0 -10px 24px rgba(15, 36, 33, 0.08);
}
.config-repeater { display: grid; gap: 10px; }
.config-rows { display: grid; gap: 10px; }
.config-row { display: grid; gap: 10px; padding: 12px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; }
.config-row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.config-row-head strong { font-size: 12px; }
.config-remove, .config-add { min-height: 34px; padding: 0 11px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.config-remove { color: var(--red); background: #fff; border: 1px solid #efc9c4; }
.config-add { justify-self: start; color: var(--green-dark); background: #fff; border: 1px solid var(--green); }
.config-step-links { display: grid; gap: 10px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.config-step-links-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.config-step-links-head strong { display: block; font-size: 12px; }
.config-step-links-head p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.config-step-link-rows { display: grid; gap: 8px; }
.config-step-link-row { display: grid; grid-template-columns: minmax(180px, .85fr) minmax(260px, 1.4fr) auto; gap: 9px; align-items: end; padding-top: 9px; border-top: 1px solid var(--line); }
.config-step-link-row label { min-width: 0; }
.config-step-link-add, .config-step-link-remove { min-height: 34px; padding: 0 11px; border-radius: 6px; font-size: 12px; font-weight: 750; white-space: nowrap; }
.config-step-link-add { flex: 0 0 auto; color: var(--green-dark); background: var(--green-soft); border: 1px solid rgba(10, 161, 116, .4); }
.config-step-link-remove { color: var(--red); background: #fff; border: 1px solid #efc9c4; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.checkbox-field { display: flex; grid-template: none; flex-direction: row; align-items: center; gap: 8px; min-height: 42px; }
.checkbox-field input { width: 17px; height: 17px; }

@media (max-width: 760px) {
  .config-step-links-head { align-items: flex-start; }
  .config-step-link-row { grid-template-columns: 1fr; }
  .config-step-link-remove { justify-self: start; }
}

.country-document-manager { display: grid; gap: 10px; }
.country-document-entry { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 12px; padding: 10px 12px; color: var(--ink); background: #f7fbf9; border: 1px solid var(--line-strong); border-left: 3px solid var(--green); border-radius: 4px; }
.country-document-entry strong { display: block; font-size: 14px; }
.country-document-entry p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.country-document-entry button { flex: 0 0 auto; }

.country-table-wrap { overflow-x: auto; }
.country-data-table { width: 100%; min-width: 1100px; table-layout: fixed; }
.country-data-table th { position: sticky; overflow: visible; }
.country-data-table th > span { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.country-data-table td { overflow: hidden; text-overflow: ellipsis; }
.country-data-table td small { overflow-wrap: anywhere; }
.country-data-table td:last-child { overflow: visible; }
.country-column-resizer {
  position: absolute;
  top: 0;
  right: -5px;
  z-index: 3;
  width: 10px;
  height: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: col-resize;
  touch-action: none;
}
.country-column-resizer::after { position: absolute; top: 20%; bottom: 20%; left: 4px; width: 1px; background: transparent; content: ""; }
.country-column-resizer:hover::after, .country-column-resizer:focus-visible::after { background: var(--green); }
body.is-resizing-column, body.is-resizing-column * { cursor: col-resize !important; user-select: none !important; }
.document-manager-intro { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: #f7fbf9; border: 1px solid var(--line-strong); border-left: 4px solid var(--green); }
.document-manager-intro > span { display: grid; width: 42px; height: 42px; place-items: center; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; font-size: 22px; }
.document-manager-intro strong { display: block; font-size: 17px; }
.document-manager-intro p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.document-workbench, .document-flat-section { display: grid; gap: 10px; padding: 12px; background: #fff; border: 1px solid var(--line-strong); border-top: 3px solid var(--green); }
.document-flat-section { border-top-color: #273c37; }
.document-flat-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; padding-bottom: 8px; border-bottom: 1px solid var(--line-strong); }
.document-flat-head span { display: block; margin-bottom: 2px; color: var(--red); font-size: 9px; font-weight: 900; }
.document-flat-head h3 { margin: 0; font-size: 15px; }
.document-flat-head p { max-width: 560px; margin: 0; color: var(--muted); font-size: 11px; text-align: right; }
.template-library-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line-strong); }
.template-library { min-width: 0; padding: 10px; border-right: 1px solid var(--line-strong); }
.template-library:last-child { border-right: 0; }
.template-library-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.template-library-title strong { font-size: 13px; }
.template-library-title small { color: var(--muted); font-size: 9px; text-align: right; }
.template-choice-grid { display: grid; gap: 5px; }
.template-choice { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 7px 8px; background: var(--surface-soft); border: 1px solid var(--line); cursor: pointer; }
.template-choice:has(input:checked) { background: var(--green-soft); border-color: var(--green); }
.template-choice input { flex: 0 0 auto; width: 15px; height: 15px; }
.template-choice span, .template-choice strong, .template-choice small { display: block; min-width: 0; }
.template-choice strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.template-choice small { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.template-creator-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.template-creator-grid details { align-self: start; border: 1px solid var(--line); background: var(--surface-soft); }
.template-creator-grid summary { padding: 8px 10px; color: var(--green-dark); cursor: pointer; font-size: 11px; font-weight: 850; }
.template-creator-grid details[open] { grid-column: 1 / -1; }
.template-create-form { padding: 10px; background: #fff; border-top: 1px solid var(--line); }
.scope-option-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.scope-option-columns > div + div { padding-left: 12px; border-left: 1px solid var(--line-strong); }
.document-config-section h4 { margin: 0; font-size: 12px; }
.compact-actions { margin-top: 0; padding-top: 8px; }
.compact-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.compact-list > div:nth-child(odd) { border-right: 1px solid var(--line); }
.province-check-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.province-check-grid label { display: flex; align-items: center; gap: 5px; min-height: 32px; padding: 5px 7px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; font-size: 10px; }
.province-check-grid label:has(input:checked) { color: var(--green-dark); background: var(--green-soft); font-weight: 800; }
.province-check-grid input { width: 14px; height: 14px; }
.document-config-section { display: grid; gap: 9px; }
.document-config-section h3 { margin: 0; font-size: 14px; }
.document-config-section > p { margin: -4px 0 0; color: var(--muted); font-size: 12px; }
.document-option-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.document-option-grid .permission-option span { display: grid; gap: 2px; }
.document-option-grid .permission-option small { color: var(--muted); font-size: 10px; }
.document-inline-form { margin-top: 4px; padding-top: 10px; border-top: 2px solid var(--line-strong); }
.document-rule-list, .document-file-list { display: grid; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.document-rule-list > div, .document-file-list > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; border-bottom: 1px solid var(--line); }
.document-rule-list > div:last-child, .document-file-list > div:last-child { border-bottom: 0; }
.document-rule-list strong, .document-rule-list small, .document-file-list strong, .document-file-list small { display: block; }
.document-rule-list small, .document-file-list small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.document-empty { padding: 20px; color: var(--muted); background: var(--surface-soft); border: 1px dashed var(--line-strong); border-radius: 7px; font-size: 12px; text-align: center; }
.document-preview-filter { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; align-items: end; margin-bottom: 14px; }
.document-preview-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--green-soft); border-radius: 7px; }
.document-preview-summary span { color: var(--muted); font-size: 11px; }
.document-preview-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.document-preview-groups section { padding: 12px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 7px; }
.document-preview-groups h4 { margin: 0 0 8px; font-size: 13px; }
.document-preview-groups section > div { padding: 7px 0; border-top: 1px solid var(--line); }
.document-preview-groups strong, .document-preview-groups small { display: block; }
.document-preview-groups small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.toast { position: fixed; right: 26px; bottom: 26px; z-index: 100; max-width: 360px; padding: 12px 16px; color: #fff; background: #20312e; border-radius: 6px; box-shadow: var(--shadow); font-size: 13px; font-weight: 700; }
.toast.is-error { background: var(--red); }

@media (max-width: 1180px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .feature-grid, .database-grid { grid-template-columns: repeat(2, 1fr); }
  .split-view { grid-template-columns: 1fr; }
  .detail-panel { position: static; }
  .template-library-grid { grid-template-columns: 1fr; }
  .template-library { border-right: 0; border-bottom: 1px solid var(--line-strong); }
  .template-library:last-child { border-bottom: 0; }
  .province-check-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .login-screen { padding: 22px; }
  .login-layout { grid-template-columns: 1fr; min-height: auto; margin-top: 70px; }
  .login-copy h1 { font-size: 38px; }
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar-brand { min-height: 76px; padding: 18px 10px; }
  .sidebar-brand img { width: 54px; object-fit: cover; object-position: left; }
  .sidebar-brand span, .nav-button span:last-child, .account-summary div, .sidebar-foot .quiet-button { display: none; }
  .nav-button { grid-template-columns: 1fr; place-items: center; padding: 0; }
  .account-summary { grid-template-columns: 1fr; justify-items: center; }
  .workspace { padding: 22px 18px 42px; }
  .filter-bar, .filter-bar.two { grid-template-columns: 1fr 1fr; }
  .scope-option-columns { grid-template-columns: 1fr; }
  .scope-option-columns > div + div { padding-top: 10px; padding-left: 0; border-top: 1px solid var(--line-strong); border-left: 0; }
  .province-check-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .workspace-head { align-items: flex-start; flex-direction: column; }
  .metrics-grid, .feature-grid, .database-grid, .permission-grid, .form-grid.two, .form-grid.three, .form-grid.four { grid-template-columns: 1fr; }
  .filter-bar, .filter-bar.two { grid-template-columns: 1fr; }
  .login-brand span { display: none; }
  .login-form { padding: 20px; }
  .document-option-grid, .document-preview-groups, .document-preview-filter { grid-template-columns: 1fr; }
  .country-document-entry { align-items: stretch; flex-direction: column; }
  .country-editor-intro { align-items: stretch; flex-wrap: wrap; }
  .country-editor-intro button { width: 100%; }
  .country-section-head { align-items: flex-start; flex-direction: column; gap: 4px; }
  .country-section-head p { text-align: left; }
  .document-flat-head { align-items: flex-start; flex-direction: column; }
  .document-flat-head p { text-align: left; }
  .template-creator-grid, .compact-list { grid-template-columns: 1fr; }
  .compact-list > div:nth-child(odd) { border-right: 0; }
  .province-check-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
