/* Box 客户应用共用外壳、登录页和设计令牌。 */

:root {
  color-scheme: light;
  --brand-ink: #202124;
  --brand-ink-2: #111111;
  --brand-violet: #202124;
  --brand-magenta: #3f3f3c;
  --brand-pink: #7a7a75;
  --brand-lav: #f1f0ed;
  --brand-paper: #fbfaf8;
  --brand-slate: #7a7a75;
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --bg-hover: #f1f0ed;
  --border: #e6e5e1;
  --text: #202124;
  --text-muted: #7a7a75;
  --text-faint: #9b9a94;
  --accent: #202124;
  --accent-2: #111111;
  --accent-soft: rgba(32, 33, 36, 0.075);
  --success: #15803d;
  --warn: #a16207;
  --error: #dc2626;
  --thought: #202124;
  --tool-border: #e6e5e1;
  --focus-border: #b9b8b2;
  --neutral-action: #f1f0ed;
  --neutral-action-hover: #ecebea;
  --neutral-action-border: #deddd8;
  --sidebar-bg: #fbfaf8;
  --sidebar-bg-hover: #ecebea;
  --sidebar-border: rgba(32, 33, 36, 0.08);
  --sidebar-text: #202124;
  --sidebar-muted: #7a7a75;
  --sidebar-active: #202124;
  --sidebar-w: 268px;
  --font-base: 15px;
  --font-ui: 15px;
  --font-small: 13px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  background-image: none;
  color: var(--text);
  min-height: 100vh;
  font-size: var(--font-base);
}

.hidden { display: none !important; }

/* ===== 应用外壳:侧边栏 + 内容区 ===== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 0;
  box-shadow: inset -1px 0 var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  padding: 18px 20px 16px;
  border-bottom: 0;
}
.sidebar .brand .name {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 17px;
  font-weight: 800;
  color: var(--sidebar-text);
  letter-spacing: 0;
}
.sidebar .brand .name::before,
.login-card .login-brand::before {
  content: "";
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  background: url("/assets/goldendata-logo-web.png") center / contain no-repeat;
  filter: none;
}
.sidebar .brand .sub {
  font-size: 12px;
  color: var(--sidebar-muted);
  margin-top: 5px;
  letter-spacing: 0.5px;
}

.sidebar nav {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
}
.sidebar .nav-label {
  height: 1px;
  margin: 8px 12px;
  padding: 0;
  overflow: hidden;
  background: transparent;
  color: transparent;
  font-size: 0 !important;
  line-height: 0;
  opacity: 1;
}
.sidebar nav a,
.sidebar .sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 2px;
  transition: background 0.12s, color 0.12s;
}
.sidebar nav a:hover,
.sidebar .sidebar-footer a:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text);
}
.sidebar nav a.active {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-active);
  font-weight: 600;
  box-shadow: none;
}
.sidebar nav a svg,
.sidebar .sidebar-footer a svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.sidebar .sidebar-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 6px;
  align-items: center;
  padding: 12px 10px;
  border-top: 0;
}
.sidebar .sidebar-footer a {
  order: 1;
  min-width: 0;
  margin-bottom: 0;
}
.sidebar .sidebar-footer .lang-toggle {
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--sidebar-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.sidebar .sidebar-footer .lang-toggle {
  order: 2;
}
.sidebar .sidebar-footer .lang-toggle:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text);
}
.sidebar .sidebar-footer .lang-toggle {
  font-size: 12px;
  font-weight: 700;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 30px 34px 64px;
}
.content > .content-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.page-head {
  margin-bottom: 22px;
}
.page-head h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.page-head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* ===== 登录页(全屏居中) ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(rgba(32, 33, 36, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 33, 36, 0.026) 1px, transparent 1px),
    var(--brand-paper);
  background-size: 44px 44px;
}
.login-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: none;
  pointer-events: none;
}
.login-card {
  width: 100%;
  max-width: 392px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  position: relative;
  z-index: 1;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 26px 70px -54px rgba(32, 33, 36, 0.8);
}
.login-card .lang-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  margin: 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.login-card .lang-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.login-card .login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.4px;
  margin: 4px 0 2px;
}
.login-card .login-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  padding-left: 42px;
}
.login-card label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin: 10px 0 4px;
}
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.login-card input:focus {
  outline: none;
  border-color: var(--focus-border);
  box-shadow: 0 0 0 4px rgba(32, 33, 36, 0.075);
}
.login-card button {
  width: 100%;
  padding: 10px;
  margin-top: 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
}
.login-card .err {
  color: var(--error);
  font-size: 13px;
  margin-top: 10px;
  min-height: 14px;
}

/* 页面内联样式历史上偏小;用共用层统一抬高可读性。 */
:where(input, select, textarea, button) {
  font-size: var(--font-ui) !important;
}
:where(table, th, td, label, .muted, .mono, .badge, .pill, .metric-pill, .row-help,
  .error-msg, .ok-msg, .detail-empty, .detail-meta, .role-title, .role-desc,
  .doc-type, .doc-source, .file-folder, .section-desc, .subtable h4) {
  font-size: var(--font-small) !important;
}
:where(th, button, .btn, .badge, .pill, .metric-pill, .doc-source, .file-download) {
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
}
:where(.cell-ellipsis, .truncate) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
:where(.panel h3, .section h2, .config-card h3) {
  font-size: 15px !important;
}
:where(.stat .label, .sidebar .brand .sub) {
  font-size: 12px !important;
}
:where(.stat .value) {
  font-size: 24px !important;
}
:where(.panel, .section, .config-card, .stat, .login-card) {
  border-color: var(--border) !important;
  box-shadow: 0 18px 48px -42px rgba(32, 33, 36, 0.38);
}
:where(button:not(.lang-toggle), .btn) {
  border-radius: 8px !important;
}
:where(button:not(.lang-toggle):not(.send):not(.secondary):not(.danger):not(.success):not(.primary-action):not(.btn-primary):not(.connection-button):not(.question-suggestion):not(.question-suggestions-refresh),
  .btn:not(.btn-primary):not(.btn-upload):not(.btn-secondary):not(.danger):not(.success)) {
  background: var(--neutral-action) !important;
  color: var(--text) !important;
  border: 1px solid var(--neutral-action-border) !important;
}
:where(button.secondary, .btn-secondary) {
  background: var(--bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}
:where(.primary-action, .btn-primary, .login-card button) {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: transparent !important;
}
:where(.btn-upload) {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: transparent !important;
}
:where(input, select, textarea) {
  border-color: var(--border) !important;
}
:where(input, select, textarea):focus {
  outline: none !important;
  border-color: var(--focus-border) !important;
  box-shadow: 0 0 0 4px rgba(32, 33, 36, 0.075) !important;
}

/* ===== 响应式:窄屏侧边栏折叠为顶栏 ===== */
@media (max-width: 840px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--sidebar-border);
    padding: 0 8px;
  }
  .sidebar .brand {
    border-bottom: none;
    padding: 12px 12px;
    white-space: nowrap;
  }
  .sidebar .brand .name::before { width: 25px; height: 25px; flex-basis: 25px; }
  .sidebar .brand .sub { display: none; }
  .sidebar nav {
    display: flex;
    padding: 8px 4px;
    overflow-x: auto;
  }
  .sidebar .nav-label { display: none; }
  .sidebar nav a { white-space: nowrap; margin-bottom: 0; }
  .sidebar .sidebar-footer {
    display: grid;
    grid-template-columns: 34px 40px;
    border-top: none;
    padding: 8px 4px;
    margin-left: auto;
  }
  .sidebar .sidebar-footer .lang-toggle { margin: 0; }
  .sidebar .sidebar-footer a {
    justify-content: center;
    white-space: nowrap;
    margin-bottom: 0;
    padding: 8px 10px;
  }
  .sidebar .sidebar-footer a span { display: none; } /* 窄屏只留图标 */
  .content { padding: 18px 16px 48px; }
}
