:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --text: #1f2633;
  --muted: #697386;
  --line: #e6eaf0;
  --line-strong: #d7dde8;
  --blue: #1677ff;
  --blue-dark: #0b5ed7;
  --blue-soft: #eaf3ff;
  --green: #12a35c;
  --orange: #f59f00;
  --red: #e5484d;
  --sidebar: #111b2e;
  --sidebar-2: #17243a;
  --sidebar-line: rgba(255,255,255,.08);
  --shadow: 0 10px 30px rgba(20, 32, 54, .08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

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

button { cursor: pointer; }

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

.app-shell.is-collapsed {
  grid-template-columns: 76px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: rgba(255,255,255,.86);
  overflow: hidden;
  border-right: 1px solid rgba(255,255,255,.08);
}

.brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--sidebar-line);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2d8cff, #73c0ff);
  color: #fff;
  font-weight: 800;
  letter-spacing: -.04em;
  box-shadow: 0 8px 22px rgba(22, 119, 255, .32);
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.brand-subtitle {
  margin-top: 2px;
  color: rgba(255,255,255,.45);
  font-size: 11px;
  white-space: nowrap;
}

.is-collapsed .brand-title,
.is-collapsed .brand-subtitle,
.is-collapsed .menu-group-title span,
.is-collapsed .menu-item span,
.is-collapsed .menu-count { display: none; }

.menu {
  padding: 14px 10px 28px;
  height: calc(100vh - 64px);
  overflow: auto;
}

.menu-group {
  margin-bottom: 10px;
}

.menu-group-title {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 34px;
  padding: 0 10px;
  color: rgba(255,255,255,.52);
  font-size: 12px;
  font-weight: 600;
}

.menu-dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: rgba(255,255,255,.42);
}

.menu-item {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px 0 22px;
  color: rgba(255,255,255,.76);
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}

.menu-item:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}

.menu-item.is-active {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 8px 22px rgba(22,119,255,.25);
}

.menu-icon {
  width: 16px;
  opacity: .9;
  text-align: center;
}

.menu-count {
  margin-left: auto;
  color: rgba(255,255,255,.44);
  font-size: 11px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.breadcrumb {
  color: var(--muted);
  font-size: 12px;
  max-width: 720px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

h1 {
  margin: 2px 0 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tabs-row {
  height: 42px;
  display: flex;
  align-items: end;
  padding: 0 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.visited-tabs {
  display: flex;
  gap: 6px;
  overflow: hidden;
}

.visited-tab {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #f8fafc;
  color: #4b5565;
}

.visited-tab.is-active {
  color: var(--blue);
  background: #fff;
  border-color: var(--blue-soft);
}

.content {
  padding: 18px 22px 28px;
  overflow: auto;
  height: calc(100vh - 106px);
}

.summary-foot {
  margin-top: 6px;
  color: #8a94a6;
  font-size: 12px;
}

.query-card, .table-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.query-card { padding: 16px 16px 14px; }
.table-card { margin-top: 14px; overflow: hidden; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: #202939;
  font-weight: 700;
}

.table-title {
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.table-title em {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px 16px;
  max-height: 86px;
  overflow: hidden;
  transition: max-height .2s ease;
}

.filter-grid.is-expanded {
  max-height: 420px;
}

.form-item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.form-item label {
  color: #394150;
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

.input-shell {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid #d8dde8;
  border-radius: 6px;
  background: #fff;
  color: #9aa4b2;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.input-shell:hover, .input-shell:focus-within {
  border-color: #8bbcff;
  box-shadow: 0 0 0 3px rgba(22,119,255,.08);
}

.input-shell input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  color: #263142;
  background: transparent;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.primary-button, .ghost-button, .link-button, .icon-button, .danger-button {
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: #fff;
  color: #263142;
}

.primary-button {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.primary-button:hover { background: var(--blue-dark); }

.ghost-button {
  border-color: var(--line-strong);
}

.ghost-button:hover {
  color: var(--blue);
  border-color: #9ac7ff;
}

.danger-button {
  color: var(--red);
  border-color: #ffd6d9;
  background: #fff7f7;
}

.link-button {
  padding: 0;
  height: auto;
  border: 0;
  color: var(--blue);
  background: transparent;
}

.icon-button {
  width: 32px;
  padding: 0;
  border-color: var(--line);
}

.small {
  height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 420px);
  min-height: 260px;
}

table {
  width: 100%;
  min-width: 1100px;
  border-collapse: separate;
  border-spacing: 0;
}

th, td {
  height: 42px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f6f8fb;
  color: #4a5568;
  font-size: 13px;
  font-weight: 650;
}

th:last-child,
td:last-child {
  position: sticky;
  right: 0;
  z-index: 3;
  box-shadow: -8px 0 16px rgba(20, 32, 54, .05);
}

th:last-child {
  z-index: 4;
}

td {
  color: #263142;
  background: #fff;
}

.long-field-preview {
  display: inline-block;
  max-width: 108px;
  overflow: hidden;
  color: #1f4f8f;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

tr:hover td {
  background: #f8fbff;
}

tr:hover td:last-child {
  background: #f8fbff;
}

.cell-muted { color: #9aa4b2; }

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 99px;
  font-size: 12px;
  border: 1px solid transparent;
}

.status-green { color: #0c8b4a; background: #eaf8f0; border-color: #bfe8cf; }
.status-blue { color: #1264c7; background: #eaf3ff; border-color: #c8e0ff; }
.status-orange { color: #a45f00; background: #fff7e6; border-color: #ffe0a3; }
.status-gray { color: #667085; background: #f2f4f7; border-color: #e4e7ec; }
.status-red { color: #c92a2a; background: #fff1f1; border-color: #ffc9c9; }

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.row-actions button {
  border: 0;
  padding: 0;
  color: var(--blue);
  background: transparent;
}

.row-actions button:hover { color: var(--blue-dark); }

.empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: #8a94a6;
}

.empty-illustration {
  width: 84px;
  height: 60px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background:
    linear-gradient(#eef3fb, #eef3fb) 18px 12px / 48px 8px no-repeat,
    linear-gradient(#e1e8f4, #e1e8f4) 18px 28px / 40px 8px no-repeat,
    linear-gradient(135deg, #f8fafc, #edf2f7);
  border: 1px solid #e1e8f4;
}

.pagination {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.page-button {
  min-width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.page-button.is-active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.toast-host {
  position: fixed;
  top: 78px;
  right: 24px;
  z-index: 80;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 14px 34px rgba(20,32,54,.14);
  animation: toast-in .18s ease-out;
}

@keyframes toast-in {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(17, 27, 46, .34);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 2px 0 0;
  font-size: 18px;
}

.modal-body {
  padding: 18px 20px;
  overflow: auto;
}

.detail-grid {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  gap: 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 10px;
  overflow: hidden;
}

.attribute-panel {
  margin-top: 16px;
  padding: 14px;
  background: #f8fbff;
  border: 1px solid #dbeafe;
  border-radius: 12px;
}

.attribute-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.attribute-title span {
  font-weight: 750;
  color: #17243a;
}

.attribute-title em {
  padding: 3px 8px;
  color: var(--blue-dark);
  background: var(--blue-soft);
  border-radius: 999px;
  font-style: normal;
  font-size: 12px;
}

.attribute-panel p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.attribute-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.attribute-group {
  min-width: 0;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.attribute-group h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #243044;
}

.attribute-row {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 8px;
  padding: 4px 0;
  border-top: 1px dashed #edf1f6;
  font-size: 12px;
}

.attribute-row span {
  color: var(--muted);
}

.attribute-row strong {
  min-width: 0;
  color: #202939;
  font-weight: 600;
  word-break: break-all;
}

.detail-label, .detail-value {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}

.detail-label {
  color: #596579;
  background: #f8fafc;
}

.detail-value {
  min-width: 0;
  word-break: break-all;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 75;
  width: 720px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(17,27,46,.22);
}

.modal-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.modal-form .form-field {
  display: grid;
  gap: 6px;
}

.modal-form label {
  color: #394150;
  font-size: 13px;
}

.modal-form input, .modal-form textarea {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: 0;
}

.modal-form textarea {
  min-height: 78px;
  padding: 8px 10px;
  resize: vertical;
}

.confirm-box {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.confirm-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--orange);
  font-weight: 800;
}

.confirm-box h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.confirm-box p {
  margin: 0 0 8px;
  color: var(--muted);
}

.confirm-target {
  color: var(--text) !important;
  font-weight: 650;
}

.permission-view {
  min-height: calc(100vh - 180px);
  display: grid;
  place-items: center;
}

.permission-card {
  width: min(520px, 100%);
  padding: 42px;
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.permission-code {
  font-size: 70px;
  line-height: 1;
  font-weight: 800;
  color: #cfd8e6;
}

.permission-card h2 { margin: 12px 0 8px; }
.permission-card p { margin: 0 0 20px; color: var(--muted); }

.hidden { display: none !important; }

@media (max-width: 1180px) {
  .filter-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .attribute-groups { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar-right { display: none; }
  .filter-grid { grid-template-columns: 1fr; }
  .form-item { grid-template-columns: 84px minmax(0, 1fr); }
}
