:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --panel: #ffffff;
  --panel-soft: #f9faf9;
  --line: #dfe5e2;
  --text: #202426;
  --muted: #687471;
  --sidebar: #202426;
  --sidebar-soft: #2c3134;
  --sidebar-text: #eef4f1;
  --accent: #167a72;
  --accent-strong: #0f5c55;
  --danger: #b7433e;
  --shadow: 0 18px 40px rgba(32, 36, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

body.is-frame-modal-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.is-hidden {
  display: none !important;
}

.auth-gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(244, 246, 245, 0.96)),
    var(--bg);
}

.auth-panel {
  display: grid;
  width: min(440px, 100%);
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-copy h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: 0;
}

.auth-copy p:last-child {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.auth-tab {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.auth-tab.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 8px 18px rgba(32, 36, 38, 0.08);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-message {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.6;
}

.user-label {
  max-width: 180px;
  overflow: hidden;
  padding: 7px 10px;
  border-radius: 999px;
  background: #e9f3ef;
  color: #176a50;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.shell {
  --sidebar-width: 268px;
  position: relative;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  transition: grid-template-columns 0.2s ease;
}

.shell.is-sidebar-collapsed {
  --sidebar-width: 0px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: 268px;
  min-width: 0;
  padding: 18px 14px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  transition: transform 0.2s ease;
  will-change: transform;
}

.shell.is-sidebar-collapsed .sidebar {
  pointer-events: none;
  transform: translateX(-100%);
}

.sidebar-toggle {
  position: absolute;
  top: 92px;
  left: calc(var(--sidebar-width) - 17px);
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 10px 22px rgba(32, 36, 38, 0.12);
  transition: left 0.2s ease, transform 0.15s ease, border-color 0.15s ease;
}

.sidebar-toggle:hover {
  transform: translateY(-1px);
  border-color: #bfc9c5;
}

.shell.is-sidebar-collapsed .sidebar-toggle {
  left: 10px;
}

.shell.is-sidebar-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: #f1b24a;
  color: #1d2022;
  font-size: 20px;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 15px;
  line-height: 1.3;
}

.brand span {
  margin-top: 3px;
  color: rgba(238, 244, 241, 0.62);
  font-size: 12px;
}

.nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-top: 14px;
}

.nav-group-label {
  padding: 18px 10px 8px;
  color: rgba(238, 244, 241, 0.48);
  font-size: 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  margin-bottom: 4px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(238, 244, 241, 0.78);
  text-align: left;
}

.nav-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--sidebar-soft);
  color: #ffffff;
}

.nav-item.is-active {
  background: #ffffff;
  color: var(--text);
}

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
}

.searchbox {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(560px, 100%);
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.searchbox input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
}

.topbar-actions,
.workspace-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.date-label {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.icon-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.text-button {
  gap: 8px;
  padding: 0 13px;
  text-decoration: none;
}

.icon-button:hover,
.text-button:hover {
  transform: translateY(-1px);
  border-color: #bfc9c5;
}

.primary,
.primary-fill {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.danger {
  color: var(--danger);
}

.view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 24px;
}

#workspaceView {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.view.is-hidden {
  display: none;
}

#workspaceView.is-hidden {
  display: none;
}

.section-title,
.workspace-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-title h1,
.workspace-head h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.muted {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metric {
  min-height: 94px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
  letter-spacing: 0;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.app-card {
  display: flex;
  flex-direction: column;
  min-height: 220px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.app-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}

.app-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--card-accent) 15%, white);
  color: var(--card-accent);
}

.status {
  min-width: 62px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #e9f3ef;
  color: #176a50;
  font-size: 12px;
  text-align: center;
}

.status.draft {
  background: #f6e9df;
  color: #9b4b20;
}

.app-card h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.45;
  letter-spacing: 0;
}

.app-card p {
  flex: 1;
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.app-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.category {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.launch-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--card-accent);
  color: #fff;
}

.frame-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: var(--panel);
  box-shadow: none;
}

#workspaceView .workspace-head {
  display: none;
}

.frame-wrap.is-frame-modal-expanded {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #fff;
}

iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

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

.form-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input,
select {
  height: 38px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  min-height: 92px;
  padding: 10px 11px;
  line-height: 1.6;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 122, 114, 0.12);
}

input[type="color"] {
  padding: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.table-panel {
  overflow: hidden;
}

.table-scroll {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td {
  color: var(--text);
  font-size: 14px;
}

.entry-text {
  max-width: 320px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-actions {
  display: flex;
  gap: 8px;
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  border: 1px dashed #c7d0cc;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 960px) {
  body {
    overflow: auto;
  }

  .shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .shell.is-sidebar-collapsed {
    --sidebar-width: 268px;
  }

  .sidebar-toggle {
    display: none;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    width: auto;
    min-height: auto;
    padding: 12px;
    transform: none;
  }

  .brand {
    min-height: 48px;
    padding-bottom: 10px;
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-top: 10px;
  }

  #appNav {
    display: flex;
    gap: 8px;
  }

  .nav-group-label,
  .sidebar-footer {
    display: none;
  }

  .nav-item {
    width: auto;
    min-width: max-content;
    margin: 0;
  }

  .main {
    height: auto;
    min-height: calc(100vh - 120px);
  }

  .topbar,
  .section-title,
  .workspace-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .view {
    padding: 18px;
  }

  .metrics,
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .frame-wrap {
    height: calc(100vh - 120px);
  }
}

@media (max-width: 540px) {
  .brand strong {
    font-size: 14px;
  }

  .section-title h1,
  .workspace-head h1 {
    font-size: 21px;
  }

  .metrics {
    gap: 10px;
  }

  .app-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .date-label {
    display: none;
  }
}
