:root {
  --background: #f8faf9;
  --foreground: #17201e;
  --card: #ffffff;
  --card-foreground: #17201e;
  --popover: #ffffff;
  --primary: #0f766e;
  --primary-hover: #0b625c;
  --primary-foreground: #ffffff;
  --secondary: #f2f5f4;
  --secondary-foreground: #263431;
  --muted: #f3f6f5;
  --muted-foreground: #697773;
  --accent: #edf5f3;
  --accent-foreground: #0f615b;
  --border: #e2e8e6;
  --input: #dce3e1;
  --ring: rgba(15, 118, 110, 0.22);
  --success: #14805e;
  --success-soft: #eaf7f1;
  --warning: #b86c0f;
  --warning-soft: #fff7e8;
  --danger: #c03d3d;
  --danger-soft: #fff0f0;
  --info: #3568a9;
  --info-soft: #eef5ff;
  --sidebar: #ffffff;
  --sidebar-accent: #eef5f3;
  --sidebar-border: #e3e9e7;
  --shadow-sm: 0 1px 2px rgba(20, 34, 30, 0.04);
  --shadow-md: 0 12px 32px rgba(25, 45, 39, 0.1);
  --radius: 8px;
  --font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display: "Manrope", "Noto Sans SC", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

html.dark {
  --background: #101513;
  --foreground: #ecf2f0;
  --card: #161d1b;
  --card-foreground: #ecf2f0;
  --popover: #1b2321;
  --primary: #43b3a8;
  --primary-hover: #5ac2b8;
  --primary-foreground: #071c19;
  --secondary: #202825;
  --secondary-foreground: #e6eeeb;
  --muted: #1c2422;
  --muted-foreground: #94a29e;
  --accent: #18322e;
  --accent-foreground: #89d9d0;
  --border: #29332f;
  --input: #33403c;
  --ring: rgba(67, 179, 168, 0.22);
  --success: #55c69b;
  --success-soft: #19362c;
  --warning: #e6a449;
  --warning-soft: #382914;
  --danger: #ef7777;
  --danger-soft: #3b2020;
  --info: #79a7df;
  --info-soft: #1e2c3c;
  --sidebar: #141a18;
  --sidebar-accent: #1d302c;
  --sidebar-border: #29332f;
  --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--foreground);
  background: var(--background);
  font-family: var(--font-sans);
  font-size: 14px;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button:not(:disabled),
[role="button"]:not(:disabled) {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

svg {
  display: block;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: 252px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  background: var(--sidebar);
  transition: transform 180ms ease;
}

.sidebar-brand {
  min-height: 68px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #ffffff;
  background: #0f766e;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.brand-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.brand-copy strong {
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.2;
}

.brand-copy span {
  color: var(--muted-foreground);
  font-size: 11px;
}

.icon-button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted-foreground);
  background: transparent;
}

.icon-button:hover {
  border-color: var(--border);
  color: var(--foreground);
  background: var(--secondary);
}

.icon-button svg,
.button svg,
.quick-prompts svg,
.nav-item svg,
.runtime-button svg,
.search-trigger svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.8;
}

.sidebar-close {
  display: none;
  margin-left: auto;
}

.account-switcher {
  width: calc(100% - 24px);
  min-height: 54px;
  margin: 12px;
  padding: 8px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 9px;
  text-align: left;
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.account-switcher:hover {
  background: var(--muted);
}

.account-switcher > svg {
  width: 15px;
  height: 15px;
  color: var(--muted-foreground);
}

.account-avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #744610;
  background: #f8d9a7;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
}

.account-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.account-copy strong,
.account-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy strong {
  font-size: 12px;
  font-weight: 600;
}

.account-copy small {
  color: var(--muted-foreground);
  font-size: 10px;
}

.sidebar-nav {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 16px;
}

.nav-group + .nav-group {
  margin-top: 20px;
}

.nav-label {
  margin: 0 8px 6px;
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 600;
}

.nav-item {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  color: var(--muted-foreground);
  background: transparent;
  text-align: left;
  font-size: 13px;
}

.nav-item:hover {
  color: var(--foreground);
  background: var(--secondary);
}

.nav-item.active {
  color: var(--accent-foreground);
  background: var(--sidebar-accent);
  font-weight: 600;
}

.nav-count {
  min-width: 20px;
  margin-left: auto;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted-foreground);
  font-size: 10px;
  text-align: center;
}

.nav-dot {
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--danger);
}

.sidebar-runtime {
  margin: 12px;
  padding: 12px;
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  background: var(--muted);
}

.runtime-head,
.runtime-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.runtime-head {
  margin-bottom: 10px;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 10px;
}

.runtime-head > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 15%, transparent);
}

.runtime-row {
  min-height: 25px;
  color: var(--muted-foreground);
  font-size: 11px;
}

.runtime-row strong {
  color: var(--foreground);
  font-family: var(--font-mono);
  font-weight: 600;
}

.runtime-button {
  width: 100%;
  min-height: 32px;
  margin-top: 8px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--secondary-foreground);
  background: var(--card);
  font-size: 11px;
}

.runtime-button:hover {
  background: var(--secondary);
}

.main-shell {
  min-width: 0;
  min-height: 100vh;
  margin-left: 252px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 58px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--background) 90%, transparent);
  backdrop-filter: blur(12px);
}

.topbar-left,
.topbar-actions,
.breadcrumb,
.page-actions {
  display: flex;
  align-items: center;
}

.topbar-left,
.topbar-actions {
  gap: 8px;
}

.breadcrumb {
  gap: 6px;
  color: var(--muted-foreground);
  font-size: 12px;
}

.breadcrumb svg {
  width: 13px;
  height: 13px;
}

.breadcrumb strong {
  color: var(--foreground);
  font-weight: 500;
}

.mobile-menu {
  display: none;
}

.search-trigger {
  width: 220px;
  height: 34px;
  padding: 0 8px 0 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted-foreground);
  background: var(--card);
  font-size: 11px;
  text-align: left;
}

.search-trigger span {
  flex: 1;
}

kbd {
  min-width: 34px;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted-foreground);
  background: var(--muted);
  font-family: var(--font-sans);
  font-size: 9px;
  text-align: center;
}

.avatar-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  background: #355f86;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
}

.page {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 28px 28px 64px;
}

.page-heading {
  margin-bottom: 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.page-heading h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.35;
  font-weight: 700;
}

.page-heading p {
  margin: 5px 0 0;
  color: var(--muted-foreground);
  font-size: 13px;
}

.page-actions {
  gap: 8px;
}

.button {
  min-height: 36px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.button.primary {
  color: var(--primary-foreground);
  background: var(--primary);
}

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

.button.secondary {
  border-color: var(--border);
  color: var(--secondary-foreground);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.button.secondary:hover {
  background: var(--secondary);
}

.button.ghost {
  color: var(--muted-foreground);
  background: transparent;
}

.button.ghost:hover {
  color: var(--foreground);
  background: var(--secondary);
}

.agent-composer {
  padding: 16px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.agent-badge {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--accent-foreground);
  background: var(--accent);
}

.agent-badge svg {
  width: 18px;
  height: 18px;
}

.composer-main {
  min-width: 0;
}

.composer-title {
  min-height: 26px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.composer-title strong {
  font-size: 13px;
  font-weight: 600;
}

.composer-title span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted-foreground);
  font-size: 10px;
}

.prompt-form {
  position: relative;
}

.prompt-form input {
  width: 100%;
  height: 42px;
  padding: 0 46px 0 12px;
  border: 1px solid var(--input);
  border-radius: 7px;
  color: var(--foreground);
  background: var(--background);
  font-size: 13px;
}

.prompt-form input::placeholder,
.field-control::placeholder {
  color: color-mix(in srgb, var(--muted-foreground) 75%, transparent);
}

.send-button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  color: var(--primary-foreground);
  background: var(--primary);
}

.send-button svg {
  width: 16px;
  height: 16px;
}

.quick-prompts {
  margin-top: 10px;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
}

.quick-prompts::-webkit-scrollbar {
  display: none;
}

.quick-prompts button {
  min-height: 30px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted-foreground);
  background: transparent;
  font-size: 11px;
  white-space: nowrap;
}

.quick-prompts button:hover {
  color: var(--foreground);
  background: var(--secondary);
}

.conversation {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.conversation-message {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted-foreground);
  font-size: 11px;
}

.conversation-message .message-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted-foreground);
  background: var(--card);
}

.conversation-message .message-icon svg {
  width: 13px;
  height: 13px;
}

.conversation-message strong {
  color: var(--foreground);
  font-weight: 600;
}

.surface {
  min-width: 0;
  animation: surface-in 260ms ease both;
}

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

.ui-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.ui-card-header {
  min-height: 64px;
  padding: 15px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.ui-card-heading {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.ui-card-heading h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.35;
  font-weight: 700;
}

.ui-card-heading p {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 11px;
  line-height: 1.5;
}

.ui-card-body {
  padding: 18px;
}

.ui-card-footer {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 65%, transparent);
}

.ui-card-footer .footer-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted-foreground);
  font-size: 10px;
}

.ui-card-footer .footer-note svg {
  width: 13px;
  height: 13px;
}

.button-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.badge {
  min-height: 22px;
  padding: 2px 7px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted-foreground);
  background: var(--muted);
  font-size: 9px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.success {
  border-color: color-mix(in srgb, var(--success) 22%, var(--border));
  color: var(--success);
  background: var(--success-soft);
}

.badge.warning {
  border-color: color-mix(in srgb, var(--warning) 24%, var(--border));
  color: var(--warning);
  background: var(--warning-soft);
}

.badge.danger {
  border-color: color-mix(in srgb, var(--danger) 22%, var(--border));
  color: var(--danger);
  background: var(--danger-soft);
}

.section-block + .section-block {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

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

.section-heading h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
}

.section-heading span {
  color: var(--muted-foreground);
  font-size: 10px;
}

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

.field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--secondary-foreground);
  font-size: 11px;
  font-weight: 500;
}

.field-label small {
  color: var(--muted-foreground);
  font-size: 9px;
  font-weight: 400;
}

.required::after {
  content: " *";
  color: var(--danger);
}

.field-control {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--input);
  border-radius: 6px;
  color: var(--foreground);
  background: var(--background);
  font-size: 12px;
}

textarea.field-control {
  min-height: 76px;
  padding-top: 9px;
  resize: vertical;
  line-height: 1.5;
}

select.field-control {
  appearance: none;
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted-foreground) 50%), linear-gradient(135deg, var(--muted-foreground) 50%, transparent 50%);
  background-position: calc(100% - 15px) 16px, calc(100% - 11px) 16px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

.input-wrap {
  position: relative;
}

.input-wrap .field-control.prefix {
  padding-left: 27px;
}

.input-wrap .field-control.suffix {
  padding-right: 42px;
}

.input-affix {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  font-size: 11px;
  pointer-events: none;
}

.input-affix.left { left: 10px; }
.input-affix.right { right: 10px; }

.tag-select {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag-option {
  position: relative;
}

.tag-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tag-option span {
  min-height: 30px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted-foreground);
  background: var(--card);
  font-size: 10px;
}

.tag-option input:checked + span {
  border-color: color-mix(in srgb, var(--primary) 52%, var(--border));
  color: var(--accent-foreground);
  background: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 18%, transparent);
}

.tag-option input:focus-visible + span {
  box-shadow: 0 0 0 3px var(--ring);
}

.switch-row {
  min-height: 54px;
  padding: 9px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.switch-copy {
  display: grid;
  gap: 2px;
}

.switch-copy strong {
  font-size: 11px;
  font-weight: 600;
}

.switch-copy span {
  color: var(--muted-foreground);
  font-size: 10px;
}

.switch {
  position: relative;
  width: 34px;
  height: 19px;
  flex: 0 0 34px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: var(--input);
  transition: background 160ms ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 160ms ease;
}

.switch input:checked + .switch-track {
  background: var(--primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(15px);
}

.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px var(--ring);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}

.metric {
  min-width: 0;
  padding: 16px 18px;
}

.metric + .metric {
  border-left: 1px solid var(--border);
}

.metric-head {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted-foreground);
  font-size: 10px;
}

.metric-head svg {
  width: 14px;
  height: 14px;
}

.metric-value {
  overflow: hidden;
  color: var(--card-foreground);
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1.25;
  font-weight: 700;
  text-overflow: ellipsis;
}

.metric-trend {
  margin-top: 5px;
  color: var(--muted-foreground);
  font-size: 9px;
}

.metric-trend strong.up { color: var(--success); }
.metric-trend strong.down { color: var(--danger); }
.metric-trend strong.good-down { color: var(--success); }

.analytics-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(250px, 0.75fr);
  gap: 0;
}

.chart-panel {
  min-width: 0;
  padding: 18px;
  border-right: 1px solid var(--border);
}

.panel-heading {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading strong {
  font-size: 12px;
  font-weight: 600;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: 6px;
  background: var(--muted);
}

.segmented button {
  min-width: 36px;
  height: 24px;
  padding: 0 7px;
  border: 0;
  border-radius: 4px;
  color: var(--muted-foreground);
  background: transparent;
  font-size: 9px;
}

.segmented button.active {
  color: var(--foreground);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.chart-wrap {
  width: 100%;
  height: 240px;
  position: relative;
}

.chart-wrap svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-grid-line {
  stroke: var(--border);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-line-primary,
.chart-line-secondary {
  fill: none;
  stroke-width: 2.2;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-line-primary { stroke: var(--primary); }
.chart-line-secondary { stroke: var(--warning); }
.chart-point-primary { fill: var(--primary); stroke: var(--card); stroke-width: 1.5; vector-effect: non-scaling-stroke; }

.chart-legend {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted-foreground);
  font-size: 9px;
}

.legend-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 5px;
  border-radius: 50%;
}

.legend-dot.primary { background: var(--primary); }
.legend-dot.warning { background: var(--warning); }

.insight-panel {
  padding: 18px;
}

.insight-panel h3 {
  margin: 0 0 4px;
  font-size: 12px;
}

.insight-panel > p {
  margin: 0 0 14px;
  color: var(--muted-foreground);
  font-size: 10px;
}

.insight-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
  list-style: none;
}

.insight-item {
  padding-left: 12px;
  border-left: 2px solid var(--border);
}

.insight-item.success { border-color: var(--success); }
.insight-item.warning { border-color: var(--warning); }
.insight-item.info { border-color: var(--info); }

.insight-item strong {
  display: block;
  margin-bottom: 3px;
  font-size: 10px;
}

.insight-item span {
  display: block;
  color: var(--muted-foreground);
  font-size: 9px;
  line-height: 1.55;
}

.table-section {
  border-top: 1px solid var(--border);
}

.table-heading {
  min-height: 48px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.table-heading strong {
  font-size: 11px;
}

.text-link {
  padding: 4px;
  border: 0;
  color: var(--accent-foreground);
  background: transparent;
  font-size: 10px;
}

.data-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  height: 42px;
  padding: 0 18px;
  border-top: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
}

.data-table th {
  color: var(--muted-foreground);
  background: color-mix(in srgb, var(--muted) 55%, transparent);
  font-size: 9px;
  font-weight: 500;
}

.data-table td {
  color: var(--secondary-foreground);
  font-size: 10px;
}

.platform-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.platform-mark {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 700;
}

.platform-mark.bytedance { background: #252c2a; }
.platform-mark.meta { background: #3568a9; }
.platform-mark.tencent { background: #14805e; }
.platform-mark.google { background: #b86c0f; }

.strategy-summary {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.strategy-summary p {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 10px;
}

.strategy-list {
  border-top: 1px solid var(--border);
}

.strategy-item {
  position: relative;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
}

.checkbox-input {
  position: absolute;
  opacity: 0;
}

.checkbox-box {
  width: 17px;
  height: 17px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  border: 1px solid var(--input);
  border-radius: 4px;
  color: var(--primary-foreground);
  background: var(--card);
}

.checkbox-box svg {
  width: 12px;
  height: 12px;
  opacity: 0;
}

.checkbox-input:checked + .checkbox-box {
  border-color: var(--primary);
  background: var(--primary);
}

.checkbox-input:checked + .checkbox-box svg {
  opacity: 1;
}

.checkbox-input:focus-visible + .checkbox-box {
  box-shadow: 0 0 0 3px var(--ring);
}

.strategy-copy {
  min-width: 0;
}

.strategy-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.strategy-title-row strong {
  font-size: 11px;
  font-weight: 600;
}

.strategy-copy p {
  margin: 5px 0 0;
  color: var(--muted-foreground);
  font-size: 10px;
  line-height: 1.55;
}

.strategy-impact {
  min-width: 90px;
  display: grid;
  align-content: center;
  justify-items: end;
  gap: 2px;
}

.strategy-impact strong {
  color: var(--success);
  font-family: var(--font-display);
  font-size: 12px;
}

.strategy-impact span {
  color: var(--muted-foreground);
  font-size: 9px;
}

.strategy-controls {
  margin-top: 16px;
  padding-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.pacing-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
}

.pacing-list,
.risk-list {
  padding: 18px;
}

.pacing-list {
  border-right: 1px solid var(--border);
}

.pacing-list h3,
.risk-list h3 {
  margin: 0 0 15px;
  font-size: 12px;
}

.pacing-row + .pacing-row {
  margin-top: 17px;
}

.pacing-meta {
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pacing-meta strong {
  font-size: 10px;
  font-weight: 500;
}

.pacing-meta span {
  color: var(--muted-foreground);
  font-size: 9px;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--muted);
}

.progress-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
}

.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

.risk-items {
  display: grid;
  gap: 9px;
}

.risk-item {
  padding: 10px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--background);
}

.risk-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
}

.risk-icon svg {
  width: 14px;
  height: 14px;
}

.risk-icon.danger { color: var(--danger); background: var(--danger-soft); }
.risk-icon.warning { color: var(--warning); background: var(--warning-soft); }
.risk-icon.info { color: var(--info); background: var(--info-soft); }

.risk-copy strong {
  display: block;
  margin-bottom: 2px;
  font-size: 10px;
}

.risk-copy span {
  display: block;
  color: var(--muted-foreground);
  font-size: 9px;
  line-height: 1.45;
}

.success-state {
  min-height: 270px;
  padding: 32px 20px;
  display: grid;
  place-items: center;
  text-align: center;
}

.success-content {
  width: min(440px, 100%);
}

.success-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--success);
  background: var(--success-soft);
}

.success-mark svg {
  width: 22px;
  height: 22px;
}

.success-content h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
}

.success-content > p {
  margin: 7px 0 18px;
  color: var(--muted-foreground);
  font-size: 11px;
  line-height: 1.6;
}

.success-details {
  margin: 0 auto 18px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--background);
}

.success-detail {
  min-width: 0;
}

.success-detail + .success-detail {
  border-left: 1px solid var(--border);
}

.success-detail span,
.success-detail strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.success-detail span {
  color: var(--muted-foreground);
  font-size: 9px;
}

.success-detail strong {
  margin-top: 3px;
  font-size: 10px;
}

.inspector-sheet {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 60;
  width: min(460px, calc(100vw - 24px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  border-left: 1px solid var(--border);
  background: var(--popover);
  box-shadow: var(--shadow-md);
  transform: translateX(102%);
  transition: transform 200ms ease;
}

.inspector-sheet.open {
  transform: translateX(0);
}

.sheet-header {
  min-height: 76px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.sheet-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 14px;
}

.sheet-header p {
  margin: 4px 0 0;
  color: var(--muted-foreground);
  font-size: 10px;
}

.sheet-tabs {
  height: 44px;
  padding: 7px 16px;
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
}

.sheet-tabs button {
  min-width: 62px;
  border: 0;
  border-radius: 5px;
  color: var(--muted-foreground);
  background: transparent;
  font-size: 10px;
}

.sheet-tabs button.active {
  color: var(--foreground);
  background: var(--secondary);
  font-weight: 600;
}

.inspector-sheet pre {
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 16px;
  overflow: auto;
  color: var(--secondary-foreground);
  background: var(--background);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.sheet-scrim,
.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  visibility: hidden;
  opacity: 0;
  background: rgba(8, 15, 13, 0.38);
  transition: opacity 180ms ease, visibility 180ms ease;
}

.sheet-scrim.open,
.sidebar-scrim.open {
  visibility: visible;
  opacity: 1;
}

.sidebar-scrim {
  z-index: 35;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  min-height: 42px;
  max-width: min(430px, calc(100vw - 32px));
  padding: 9px 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--foreground);
  background: var(--popover);
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
  font-size: 11px;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast svg {
  width: 16px;
  height: 16px;
  color: var(--success);
}

.toast.error svg {
  color: var(--danger);
}

@media (max-width: 1020px) {
  .analytics-layout {
    grid-template-columns: 1fr;
  }

  .chart-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .metric:nth-child(4) {
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 820px) {
  .sidebar {
    transform: translateX(-102%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close,
  .mobile-menu {
    display: inline-grid;
  }

  .main-shell {
    margin-left: 0;
  }

  .page {
    padding-left: 20px;
    padding-right: 20px;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 12px;
  }

  .breadcrumb span,
  .breadcrumb svg,
  .search-trigger,
  #openInspector {
    display: none;
  }

  .page {
    padding: 20px 12px 48px;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .page-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-actions .button {
    width: 100%;
  }

  .agent-composer {
    grid-template-columns: 1fr;
    padding: 13px;
  }

  .agent-badge {
    display: none;
  }

  .composer-title span {
    display: none;
  }

  .ui-card-header,
  .ui-card-body,
  .ui-card-footer,
  .chart-panel,
  .insight-panel,
  .pacing-list,
  .risk-list {
    padding-left: 13px;
    padding-right: 13px;
  }

  .ui-card-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .ui-card-footer .footer-note {
    order: 2;
  }

  .button-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .button-row .button {
    width: 100%;
  }

  .form-grid,
  .strategy-controls,
  .pacing-grid {
    grid-template-columns: 1fr;
  }

  .pacing-list {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

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

  .metric + .metric,
  .metric:nth-child(3),
  .metric:nth-child(4) {
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .metric {
    padding: 13px;
  }

  .chart-wrap {
    height: 190px;
  }

  .strategy-item {
    grid-template-columns: 20px minmax(0, 1fr);
  }

  .strategy-impact {
    grid-column: 2;
    min-width: 0;
    justify-items: start;
  }

  .success-details {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .success-detail + .success-detail {
    padding-top: 9px;
    border-left: 0;
    border-top: 1px solid var(--border);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
