:root {
  --ink: #162331;
  --muted: #64748b;
  --line: #d7e1ea;
  --soft: #f5f8fb;
  --blue: #1f6f9f;
  --teal: #258c7b;
  --amber: #c68422;
  --danger: #b9564d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: #f8fafc;
  font-family: "Microsoft JhengHei", "Noto Sans TC", Arial, sans-serif;
}
body.fixed-page {
  height: 100vh;
  overflow: hidden;
}
body.admin-page {
  height: 100vh;
  overflow: hidden;
}
a { color: var(--blue); text-decoration: none; }
button, input, select { font: inherit; }
button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: white;
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
}
button.secondary { background: white; color: var(--blue); }
button.ghost {
  background: white;
  color: var(--ink);
  border-color: var(--line);
}
button.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-color: var(--line);
  background: white;
  color: var(--ink);
}
button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: white;
  border-bottom: 1px solid var(--line);
}
.brand-home {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.brand-home:hover .brand,
.brand-home:focus-visible .brand {
  text-decoration: underline;
  text-underline-offset: 4px;
}
.brand {
  max-width: min(52vw, 560px);
  font-size: 22px;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.subbrand { color: var(--muted); font-size: 14px; margin-top: 2px; }
.topbar nav { display: flex; align-items: center; gap: 14px; }
.front-topbar {
  position: relative;
  z-index: 5;
}
.main-menu a, .main-menu button {
  min-width: 64px;
  text-align: center;
}
.main-menu [data-auth-action="logout"] {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-user-badge {
  max-width: min(40vw, 520px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid #bddbd5;
  border-radius: 999px;
  background: #eff7f5;
  color: #1f6f5d;
  padding: 6px 10px;
  font-size: 13px;
}
.main-menu a {
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--ink);
}
.main-menu a.active {
  background: #e7f0f6;
  color: var(--blue);
  font-weight: 700;
}

.home-gis-stage {
  height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  overflow: hidden;
}
.hero-map {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #dfece8 0%, #edf2f6 50%, #d8e7ee 100%);
}
.terrain-grid {
  position: absolute;
  inset: -12%;
  background-image:
    linear-gradient(30deg, rgba(31,111,159,.12) 1px, transparent 1px),
    linear-gradient(120deg, rgba(37,140,123,.13) 1px, transparent 1px);
  background-size: 80px 80px;
  transform: perspective(900px) rotateX(58deg) rotateZ(-14deg) translateY(120px);
}
.show-layer {
  position: absolute;
  min-width: 116px;
  padding: 11px 14px;
  border-radius: 8px;
  background: white;
  border: 1px solid rgba(15, 23, 42, .12);
  box-shadow: 0 18px 50px rgba(15, 23, 42, .16);
  font-weight: 700;
}
.layer-land { left: 20%; top: 33%; color: var(--teal); }
.layer-risk { left: 54%; top: 28%; color: var(--danger); }
.layer-adapt { left: 42%; top: 58%; color: var(--amber); }
.layer-boundary { left: 68%; top: 62%; color: var(--blue); }
.home-copy {
  position: absolute;
  left: 42px;
  bottom: 42px;
  width: min(560px, calc(100% - 84px));
  color: #132335;
}
.home-copy h1 {
  margin: 0 0 12px;
  font-size: 42px;
}
.home-copy p {
  margin: 0;
  line-height: 1.8;
  font-size: 18px;
}
.home-panel {
  padding: 22px;
  background: white;
  border-left: 1px solid var(--line);
  overflow: auto;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
}
.swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}
.swatch.green { background: var(--teal); }
.swatch.red { background: var(--danger); }
.swatch.amber { background: var(--amber); }
.swatch.blue { background: var(--blue); }

.files-shell {
  height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: 33.333% 66.667%;
  overflow: hidden;
}
.file-tree-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: white;
  border-right: 1px solid var(--line);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
}
.panel-head h1 {
  margin: 0;
  font-size: 22px;
}
.file-search {
  display: grid;
  gap: 6px;
  padding: 0 18px 12px;
}
.file-search span {
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
}
.file-search input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--ink);
  background: #f8fbfd;
}
.file-search input:focus {
  outline: 2px solid rgba(31, 111, 159, .18);
  border-color: var(--blue);
  background: white;
}
.project-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 0 18px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}
.project-tabs button {
  flex: 0 0 auto;
  min-width: 76px;
  min-height: 42px;
  white-space: nowrap;
  background: white;
  color: var(--ink);
  border-color: var(--line);
}
.project-tabs button.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
.file-tree {
  min-height: 0;
  height: 100%;
  overflow: auto;
  padding: 10px 12px 16px;
}
.file-folder-group {
  margin-bottom: 10px;
}
.file-folder-title {
  display: flex;
  align-items: center;
  min-height: 31px;
  padding: 5px 8px;
  color: var(--blue);
  font-size: 14px;
  font-weight: 800;
  background: #eef6fb;
  border: 1px solid #d7e8f2;
  border-radius: 6px;
}
.file-node {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(120px, 1fr) 86px 92px;
  gap: 10px;
  align-items: center;
  text-align: left;
  background: white;
  color: var(--ink);
  border-color: transparent;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 8px;
}
.file-node:hover, .file-node.active {
  background: #eff7f5;
  border-color: #bddbd5;
  border-radius: 8px;
}
.file-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  background: white;
  color: var(--blue);
  font-weight: 800;
}
.file-icon.active {
  border-color: #f0c7c3;
  background: #fff4f2;
  color: var(--danger);
}
.file-node strong, .file-type, .file-share {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-type {
  color: var(--muted);
}
.file-share {
  min-width: 0;
  border-color: var(--line);
  background: white;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 8px;
  font-size: 13px;
}
.file-share.public {
  border-color: #d9bc82;
  background: #fff8e8;
  color: #8a5a10;
}
.file-share.internal {
  border-color: #9fd3c8;
  background: #eefaf7;
  color: #1c6b5d;
}
.empty-tree {
  padding: 18px;
  color: var(--muted);
}
.gis-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
}
#files-map {
  position: absolute;
  inset: 0;
}
.leaflet-control-layers {
  border-radius: 6px;
  color: var(--ink);
  font-family: "Microsoft JhengHei", "Noto Sans TC", Arial, sans-serif;
}
.leaflet-control-layers-list {
  display: grid;
  gap: 4px;
}
.leaflet-control-layers label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  margin: 0;
  color: var(--ink);
  white-space: nowrap;
}
.leaflet-control-layers label span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.leaflet-control-layers input {
  width: auto;
  margin: 0;
  flex: 0 0 auto;
}
.feature-popup {
  min-width: 180px;
  max-width: 320px;
}
.feature-popup strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
}
.feature-popup dl {
  display: grid;
  gap: 5px;
  margin: 0;
}
.feature-popup dl div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 8px;
}
.feature-popup dt {
  color: var(--muted);
}
.feature-popup dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
.map-info {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: min(360px, calc(100% - 36px));
  max-height: min(360px, calc(100% - 36px));
  z-index: 500;
  display: grid;
  gap: 9px;
  padding: 10px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .16);
  overflow: auto;
}
.map-info span {
  color: var(--muted);
  font-size: 13px;
}
.map-info.empty {
  width: min(300px, calc(100% - 36px));
}
.layer-stack-empty {
  color: var(--muted);
  line-height: 1.6;
  padding: 2px 4px;
}
.layer-stack-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}
.layer-stack-head strong {
  font-size: 15px;
}
.layer-stack-head span {
  color: var(--muted);
  font-size: 12px;
}
.layer-stack-list {
  display: grid;
  gap: 7px;
}
.layer-stack-item {
  display: grid;
  grid-template-columns: 28px 10px minmax(0, 1fr) 24px;
  gap: 8px;
  align-items: center;
  min-height: 48px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--layer-color);
  border-radius: 7px;
  background: #f8fbfd;
  cursor: grab;
}
.layer-stack-item.dragging {
  opacity: .55;
}
.layer-stack-item:active {
  cursor: grabbing;
}
.layer-stack-close,
.layer-stack-handle {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-color: var(--line);
  background: white;
  color: var(--ink);
}
.layer-stack-close {
  color: var(--danger);
}
.layer-stack-swatch {
  width: 10px;
  height: 28px;
  border-radius: 999px;
  background: var(--layer-color);
}
.layer-stack-text {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.layer-stack-text strong,
.layer-stack-text small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.layer-stack-text strong {
  color: var(--ink);
  font-size: 15px;
}
.layer-stack-text small {
  color: var(--muted);
  font-size: 12px;
}
.layer-stack-handle {
  color: var(--muted);
  cursor: grab;
}
.api-shell, .center-message {
  height: calc(100vh - 72px);
  display: grid;
  place-items: center;
  padding: 24px;
}
.api-shell section, .center-message {
  text-align: center;
}
.api-shell h1, .center-message h1 {
  font-size: 34px;
  margin: 0 0 10px;
}
.api-shell p, .center-message p {
  color: var(--muted);
  line-height: 1.8;
}
.primary-link {
  display: inline-block;
  margin-top: 12px;
  color: white;
  background: var(--blue);
  border-radius: 6px;
  padding: 10px 16px;
}

.front-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  padding: 22px;
}
.map-stage, .side-panel, .login-box, .admin-content {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.map-toolbar {
  display: flex;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.map-toolbar span { color: var(--muted); }
.mock-map {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  background: linear-gradient(135deg, #e6f1ed, #edf5fa);
}
.region {
  position: absolute;
  border: 2px solid rgba(31, 111, 159, .55);
  background: rgba(37, 140, 123, .18);
  transform: rotate(-12deg);
}
.region-a { left: 18%; top: 18%; width: 38%; height: 28%; }
.region-b { right: 14%; bottom: 18%; width: 34%; height: 26%; background: rgba(198,132,34,.2); }
.river {
  position: absolute;
  left: 12%;
  top: 48%;
  width: 78%;
  height: 8px;
  background: var(--blue);
  transform: rotate(-19deg);
}
.marker {
  position: absolute;
  left: 47%;
  top: 41%;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
}
.side-panel { padding: 20px; }
.side-panel h1, .admin-content h1 { margin: 0 0 10px; font-size: 24px; }
.side-panel p { color: var(--muted); line-height: 1.7; }
.metric-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.metric-row div, .card {
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 8px;
  padding: 14px;
}
.metric-row b { display: block; font-size: 28px; color: var(--teal); }
.metric-row span { color: var(--muted); }
.list .item, .table-list .row {
  border-bottom: 1px solid var(--line);
  padding: 11px 0;
}
.muted { color: var(--muted); }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #edf3f7;
}
.login-box {
  width: min(420px, calc(100vw - 32px));
  padding: 28px;
}
.login-box h1 { margin: 10px 0; font-size: 24px; }
.login-box p { color: var(--muted); }
label { display: grid; gap: 6px; color: #334155; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: white;
}
.login-box form { display: grid; gap: 14px; margin-top: 18px; }
.message { margin-top: 12px; color: var(--danger); min-height: 20px; }
.back-link { display: inline-block; margin-top: 16px; }

.admin-shell {
  height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
  padding: 18px;
  overflow: hidden;
}
.admin-nav {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}
.admin-nav .nav-group,
.admin-nav .tab {
  width: 100%;
  text-align: left;
  background: white;
  color: var(--ink);
  border-color: var(--line);
}
.admin-nav .nav-group {
  font-weight: 800;
}
.admin-nav .nav-group.active,
.admin-nav .tab.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
.nav-submenu {
  display: grid;
  gap: 6px;
  padding: 0 0 4px 14px;
  border-left: 2px solid #d9e7ef;
  margin: -2px 0 4px 10px;
}
.nav-submenu .tab {
  padding: 8px 12px;
  font-size: 15px;
}
.admin-content {
  height: 100%;
  min-height: 0;
  padding: 20px;
  overflow: hidden;
}
.banner {
  background: #eff7f5;
  border: 1px solid #bddbd5;
  color: #1f6f5d;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 18px;
}
.panel { display: none; }
.panel.active {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.panel[hidden],
.tab[hidden],
.nav-group[hidden],
.nav-submenu[hidden] {
  display: none;
}
.section-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.option-tabs {
  margin-bottom: 12px;
  padding-left: 0;
  padding-right: 0;
}
.layer-folder-tools {
  flex: 0 0 auto;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: -2px 0 14px;
}
.layer-folder-tools label {
  width: min(520px, 100%);
  display: grid;
  gap: 6px;
}
.layer-folder-tools label span,
.folder-manager-tools label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.folder-manager {
  display: grid;
  gap: 12px;
}
.folder-manager-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.folder-manager-tools label {
  display: grid;
  gap: 6px;
}
.folder-manager .table-list {
  max-height: min(56vh, 520px);
  overflow: auto;
}
.cards { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: 12px; }
.card b { display: block; font-size: 30px; color: var(--blue); }
.grid-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  margin-bottom: 18px;
}
.grid-form .wide { grid-column: span 2; }
.table-list {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: auto;
}
.panel.active > .table-list {
  flex: 1 1 auto;
}
.table-list .table-row {
  display: grid;
  grid-template-columns: var(--cols, 1.2fr 1fr 1fr 1fr 52px);
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.table-list .table-row:not(.head) {
  cursor: pointer;
}
.table-list .table-row:not(.head):hover {
  background: #f7fbfd;
}
.table-list .table-row.head {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 42px;
  background: var(--soft);
  color: var(--muted);
  font-weight: 700;
  cursor: default;
}
.sort-head {
  width: fit-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  text-align: left;
}
.sort-head:hover,
.sort-head.active {
  color: var(--blue);
}
.sort-head span {
  flex: 0 0 auto;
  font-size: 12px;
  line-height: 1;
}
.table-list .table-row:last-child {
  border-bottom: 0;
}
.table-list .actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
.tree-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding-left: calc(var(--tree-depth, 0) * 22px);
}
.tree-label strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-branch {
  width: 18px;
  flex: 0 0 18px;
  color: var(--muted);
  font-weight: 700;
}
.edit-icon {
  font-size: 18px;
  line-height: 1;
}
.danger-button {
  color: var(--danger);
}
.detail-grid {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 10px 14px;
}
.detail-grid dt {
  color: var(--muted);
}
.detail-grid dd {
  margin: 0;
  min-width: 0;
  word-break: break-word;
}
.detail-grid.compact {
  grid-template-columns: 96px minmax(0, 1fr);
  margin: 12px 0 0;
}
.button-link {
  display: inline-block;
  border: 1px solid var(--blue);
  background: var(--blue);
  color: white;
  border-radius: 6px;
  padding: 9px 14px;
  text-align: center;
}
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e7f0f6;
  color: var(--blue);
  font-size: 12px;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, .38);
  z-index: 5000;
}
#login-dialog {
  z-index: 6000;
}
.modal-backdrop[hidden] {
  display: none;
}
.modal {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: white;
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .24);
  overflow: hidden;
}
.modal-head, .modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}
.modal-head h2 {
  margin: 0;
  font-size: 20px;
}
#download-body {
  padding: 18px 20px 12px;
}
.confirm-title {
  margin: 0 0 14px;
  font-size: 17px;
  line-height: 1.6;
}
.download-detail {
  display: grid;
  gap: 8px;
  margin: 0;
}
.download-detail div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.download-detail dt {
  color: var(--muted);
}
.download-detail dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
#modal-body {
  overflow: auto;
  padding: 18px;
}
.modal-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.modal-form .wide {
  grid-column: 1 / -1;
}
.modal-form label {
  align-content: start;
}
.scope-picker {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.scope-picker-head {
  color: var(--muted);
  margin-bottom: 10px;
}
.scope-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}
.scope-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}
.scope-list input {
  width: auto;
}
.upload-field {
  display: grid;
}
.upload-drop {
  width: 100%;
  min-height: 96px;
  display: grid;
  place-items: center;
  gap: 6px;
  border: 1px dashed #9db4c8;
  background: #f8fbfd;
  color: var(--ink);
  text-align: center;
}
.upload-drop strong,
.upload-drop span {
  display: block;
}
.upload-drop span {
  color: var(--muted);
  font-size: 14px;
}
.upload-drop:hover,
.upload-drop.dragging {
  border-color: var(--blue);
  background: #eef7fb;
}
.switch {
  width: 44px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
  background: #e2e8f0;
}
.switch.on {
  justify-content: flex-end;
  background: #cdece5;
  border-color: #98d2c6;
}
.switch::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .2);
}
.share-chip {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 999px;
  padding: 5px 9px;
  cursor: pointer;
}
.share-chip.public {
  border-color: #d9bc82;
  background: #fff8e8;
  color: #8a5a10;
}
.share-chip.internal {
  border-color: #9fd3c8;
  background: #eefaf7;
  color: #1c6b5d;
}
.permission-list {
  display: grid;
  gap: 8px;
}
.permission-list label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.permission-list input {
  width: auto;
}
.permission-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0 0 12px;
  padding: 10px 12px 12px;
}
.permission-group legend {
  color: var(--blue);
  font-weight: 700;
}
.segmented-field {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.segmented-field legend {
  color: var(--muted);
  padding: 0 4px;
}
.segmented-field label {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
}
.segmented-field input {
  width: auto;
}
.login-tabs {
  display: flex;
  gap: 8px;
  padding: 14px 22px 0;
}
.login-tab {
  flex: 1;
  background: white;
  color: var(--ink);
  border-color: var(--line);
  min-height: 46px;
}
.login-tab.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
.login-modal {
  width: min(560px, calc(100vw - 32px));
}
.confirm-modal {
  width: min(460px, calc(100vw - 32px));
  grid-template-rows: auto auto auto;
}
.confirm-modal .modal-head {
  padding: 12px 20px;
}
.confirm-modal .modal-footer {
  padding: 12px 20px 16px;
}
#login-body {
  padding: 18px 22px 16px;
}
.login-modal .modal-head,
.login-modal .modal-footer {
  padding-left: 22px;
  padding-right: 22px;
}
.login-modal .message {
  margin-top: 8px;
}
.modal-form.single {
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (max-width: 900px) {
  .front-shell, .admin-shell { grid-template-columns: 1fr; }
  .home-gis-stage, .files-shell { grid-template-columns: 1fr; }
  .home-panel { display: none; }
  .file-tree-panel { height: 42vh; }
  .grid-form, .cards, .modal-form { grid-template-columns: 1fr; }
  .table-list .table-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .table-list .table-row.head {
    display: none;
  }
}
