:root {
  color-scheme: light;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --soft: #86868b;
  --line: #d2d2d7;
  --paper: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #ffffff;
  --accent: #0071e3;
  --accent-dark: #005bb5;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --danger: #b3261e;
  --shadow: 0 22px 62px rgba(31, 35, 42, 0.11);
  --shadow-soft: 0 10px 28px rgba(31, 35, 42, 0.07);
  --glass-line: rgba(255, 255, 255, 0.62);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.78), transparent 24%),
    linear-gradient(135deg, #dff1ff 0%, #f8e7ef 42%, #e8f6ee 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(0, 113, 227, 0.22);
  outline-offset: 2px;
}
.hidden { display: none !important; }
.shell { min-height: 100vh; padding: 18px 28px 28px; }

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

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 20px;
  padding: 30px;
  border: 1px solid var(--glass-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.desktop-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin: 0 auto 20px;
  max-width: 1440px;
  min-height: 56px;
  padding: 10px 14px;
  border: 1px solid var(--glass-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(20px);
}

.desktop-topbar h1 {
  font-size: 24px;
}

.desktop-view {
  max-width: 1440px;
  min-height: calc(100vh - 140px);
  margin: 0 auto;
  padding: 28px 28px 96px;
  border: 1px solid rgba(255, 255, 255, 0.54);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0.28)),
    rgba(255, 255, 255, 0.34);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  position: relative;
  overflow: hidden;
}

.desktop-view::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: min(520px, calc(100% - 42px));
  height: 58px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.46);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.10);
  backdrop-filter: blur(20px);
  pointer-events: none;
}

.desktop-section h2 { margin-bottom: 18px; }
.desktop-section h2 {
  font-size: 18px;
  font-weight: 750;
  color: rgba(29, 29, 31, 0.82);
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 132px));
  gap: 24px 20px;
  max-width: 760px;
  position: relative;
  z-index: 1;
}

.app-icon {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 150px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 12px;
  text-decoration: none;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}

.app-icon:hover {
  background: rgba(255,255,255,.45);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.55);
  transform: translateY(-2px);
}

.app-icon:active {
  transform: translateY(0) scale(.98);
}

.app-symbol {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 20px;
  background: linear-gradient(145deg, #0a84ff 0%, #24c8db 48%, #32d74b 100%);
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 12px 26px rgba(0, 113, 227, 0.25);
  position: relative;
  overflow: hidden;
}

.app-symbol::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.38), transparent 46%);
}

.app-symbol {
  isolation: isolate;
}

.app-symbol {
  text-shadow: 0 1px 2px rgba(0,0,0,.18);
}

.app-review .app-symbol {
  background: linear-gradient(145deg, #5e5ce6 0%, #bf5af2 46%, #ff9f0a 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 12px 26px rgba(126, 87, 194, 0.24);
}

.app-icon strong {
  max-width: 124px;
  text-align: center;
  line-height: 1.28;
  font-size: 13px;
  min-height: 34px;
  display: flex;
  align-items: center;
}

.app-icon small {
  color: rgba(29, 29, 31, 0.58);
  font-size: 12px;
}

.user-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
}

.ghost, .secondary, button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease, color .14s ease;
}

.ghost:hover, .secondary:hover, button:hover {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08), 0 8px 18px rgba(0, 0, 0, 0.07);
}

.ghost:active, .secondary:active, button:active {
  transform: translateY(1px);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.05);
}

.link-button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.primary {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #0a84ff, #0071e3);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(0, 113, 227, 0.24);
}

.primary:hover {
  background: linear-gradient(180deg, #1b8dff, #006edb);
  box-shadow: 0 13px 24px rgba(0, 113, 227, 0.28);
}
.primary:disabled { cursor: wait; opacity: .72; }

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 408px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1440px;
  margin: 0 auto;
}

.agent-page-shell .desktop-topbar {
  margin-bottom: 14px;
}

.panel, .results, .detail-panel, .stat-card, .task-item, .table-wrap {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--glass-line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel, .results { min-height: calc(100vh - 122px); }
.panel { display: flex; flex-direction: column; gap: 28px; padding: 30px; }
.results { padding: 26px; overflow: auto; }

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 36px; line-height: 1.08; letter-spacing: 0; }
form { display: grid; gap: 20px; }

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(235, 238, 242, 0.7);
}

.mode-tab {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  box-shadow: none;
}

.mode-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

.mode-panel.active { display: grid; }

.dropzone {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 190px;
  padding: 24px;
  border: 1px dashed rgba(0, 113, 227, 0.34);
  border-radius: 8px;
  text-align: center;
  background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(248,251,255,.82));
  transition: border-color .14s ease, background .14s ease, box-shadow .14s ease, transform .14s ease;
}

.dropzone:hover {
  border-color: rgba(0, 113, 227, 0.6);
  box-shadow: inset 0 0 0 1px rgba(0, 113, 227, 0.08), 0 10px 22px rgba(0, 113, 227, 0.08);
  transform: translateY(-1px);
}

.compact-dropzone { min-height: 132px; padding: 18px; }
.dropzone input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.drop-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(180deg, #0a84ff, #0071e3); color: #fff; font-size: 26px; box-shadow: 0 8px 18px rgba(0, 113, 227, 0.22); }
.dropzone strong { max-width: 100%; overflow-wrap: anywhere; font-size: 17px; }
.dropzone small, .field span { color: var(--muted); line-height: 1.45; }
.field { display: grid; gap: 8px; }
.field span { font-size: 13px; font-weight: 650; }

.analysis-mode { grid-template-columns: 1fr 1fr; gap: 8px; padding: 0; border: 0; }
.analysis-mode legend { grid-column: 1 / -1; color: var(--muted); font-size: 13px; font-weight: 650; }
.analysis-mode label { display: grid; grid-template-columns: 18px 1fr; gap: 8px; min-height: 78px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.74); transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease; }
.analysis-mode input { margin: 3px 0 0; accent-color: var(--accent); }
.analysis-mode label:has(input:checked) { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(0,113,227,.1); }
.analysis-mode label:hover { transform: translateY(-1px); border-color: rgba(0, 113, 227, 0.38); }
.analysis-mode span { display: grid; gap: 4px; }
.analysis-mode strong { color: var(--ink); font-size: 14px; }
.analysis-mode small { color: var(--muted); font-size: 12px; line-height: 1.35; }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(255,255,255,.9);
  color: var(--ink);
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}

textarea { resize: vertical; line-height: 1.55; }

input:hover, textarea:hover, select:hover {
  border-color: #b8c0c8;
}

input:focus, textarea:focus, select:focus {
  border-color: rgba(0, 113, 227, 0.62);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.10);
  background: #fff;
  outline: none;
}

.empty, .loading { min-height: 100%; display: grid; place-items: center; text-align: center; color: var(--muted); }
.spinner { width: 42px; height: 42px; border: 3px solid #d2d2d7; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

.report { display: grid; gap: 18px; }
.hero-report { display: flex; justify-content: space-between; gap: 18px; padding: 22px; border-radius: 8px; background: linear-gradient(180deg, #fff, #f8fbff); border: 1px solid var(--glass-line); box-shadow: var(--shadow-soft); }
.score { display: grid; place-items: center; min-width: 112px; border-radius: 8px; background: #f5f8ff; color: var(--accent); }
.score b { font-size: 34px; }
.section { padding: 20px; border-radius: 8px; background: rgba(255,255,255,.94); border: 1px solid var(--glass-line); box-shadow: var(--shadow-soft); }
.section-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.copybox, .transcript, .markdown-report, .result-box { padding: 14px; border-radius: 8px; background: #f5f7fa; white-space: pre-wrap; line-height: 1.65; border: 1px solid rgba(0,0,0,.04); }
.table-wrap, .review-table-wrap { overflow: auto; box-shadow: none; }
.sop-table, .review-table, table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 12px; text-align: left; vertical-align: top; }
.sop-table th, .review-table th { background: #f5f7fa; color: rgba(29,29,31,.78); font-weight: 750; }
tr:hover td { background: rgba(0, 113, 227, 0.025); }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { padding: 7px 10px; border-radius: 999px; background: rgba(0, 113, 227, 0.08); color: #07579f; }
.rewrite-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.rewrite { padding: 14px; border-radius: 8px; background: #f5f7fa; border: 1px solid rgba(0,0,0,.04); }
.frames { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.frames img { width: 100%; border-radius: 8px; border: 1px solid var(--line); box-shadow: 0 8px 18px rgba(0,0,0,.08); }

.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); max-width: 1440px; margin: 0 auto; min-height: calc(100vh - 122px); }
.sidebar { display: grid; align-content: start; gap: 8px; padding: 18px; border: 1px solid var(--glass-line); border-radius: 8px 0 0 8px; background: rgba(255,255,255,.54); backdrop-filter: blur(18px); }
.content { padding: 20px; border: 1px solid var(--glass-line); border-left: 0; border-radius: 0 8px 8px 0; background: rgba(255,255,255,.72); backdrop-filter: blur(18px); }
.nav-item { width: 100%; text-align: left; background: transparent; box-shadow: none; }
.nav-item:hover { background: rgba(255,255,255,.66); box-shadow: none; }
.nav-item.active { background: #fff; color: var(--accent); box-shadow: inset 3px 0 0 var(--accent), 0 5px 14px rgba(0,0,0,.05); }
.panel-view { display: none; gap: 18px; }
.panel-view.active { display: grid; }
.panel-head, .task-top, .detail-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.task-list, .stats-grid { display: grid; gap: 12px; }
.task-item, .detail-panel, .stat-card { padding: 16px; transition: transform .14s ease, box-shadow .14s ease; }
.task-item:hover, .stat-card:hover { transform: translateY(-1px); box-shadow: 0 15px 34px rgba(31,35,42,.09); }
.task-cleanup-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--glass-line); border-radius: 8px; background: rgba(255,255,255,.84); box-shadow: var(--shadow-soft); }
.task-cleanup-actions span { color: var(--muted); font-size: 13px; }
.task-title-row { display: flex; align-items: flex-start; gap: 12px; }
.task-select { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: rgba(255,255,255,.82); color: var(--muted); font-size: 12px; white-space: nowrap; }
.task-select input { width: auto; }
.task-select:has(input:checked) { border-color: rgba(0,113,227,.5); background: rgba(0,113,227,.08); color: #07579f; }
.task-select:has(input:disabled) { opacity: .58; }
.progress-line { display: grid; gap: 6px; margin: 12px 0; }
.progress-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.progress-bar { height: 8px; border-radius: 999px; overflow: hidden; background: #e8eef0; }
.progress-bar span { display: block; height: 100%; background: linear-gradient(90deg, #0a84ff, #32d74b); }
.status { display: inline-flex; align-items: center; min-height: 28px; border-radius: 999px; padding: 0 10px; background: #eef3f3; font-size: 12px; font-weight: 750; }
.status.queued { background: #f2f2f7; color: #636366; }
.status.running { background: #eaf4ff; color: #0068c9; }
.status.completed { background: #eaf8ef; color: #198038; }
.status.failed, .status.cancelled { background: #fff0ef; color: var(--danger); }
.error { color: var(--danger); }
.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.metric-card { display: grid; gap: 6px; padding: 16px; border: 1px solid var(--glass-line); border-radius: 8px; background: #fff; box-shadow: var(--shadow-soft); }
.metric-card strong { font-size: 30px; }
.storage-actions, .download-row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.download-link { display: inline-flex; align-items: center; min-height: 34px; border-radius: 6px; background: rgba(255,255,255,.86); color: var(--ink); padding: 0 12px; text-decoration: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06), 0 4px 10px rgba(0,0,0,.04); }
.download-link:hover { background: #fff; color: var(--accent); }
.admin-block { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--glass-line); border-radius: 8px; background: rgba(255,255,255,.86); box-shadow: var(--shadow-soft); }
.block-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.block-head h3, .section-title { margin: 0; font-size: 17px; }
.block-head p { margin: 4px 0 0; color: var(--muted); line-height: 1.45; }
.logic-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; border: 1px solid rgba(0, 113, 227, 0.18); border-radius: 8px; background: rgba(0, 113, 227, 0.07); color: #07579f; }
.logic-strip span, .logic-strip strong { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 999px; background: rgba(255,255,255,.82); font-size: 13px; }
.logic-strip strong { background: #fff; color: var(--ink); }
.role-form, .user-form, .settings-form, .permission-quick-form { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) auto; gap: 10px; padding: 14px; border: 1px solid var(--glass-line); border-radius: 8px; background: rgba(255,255,255,.9); box-shadow: var(--shadow-soft); }
.role-form { grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto; }
.settings-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.permission-quick-form { grid-template-columns: minmax(140px, .8fr) minmax(180px, 1fr) minmax(280px, 2fr) auto; align-items: end; }
.check-row { display: flex; align-items: center; gap: 10px; }
.check-row.compact { min-width: 74px; }
.check-row input { width: auto; }
.permission-agent-picker { display: grid; gap: 7px; }
.permission-agent-picker > span { color: var(--muted); font-size: 13px; font-weight: 700; }
.agent-checks { display: flex; flex-wrap: wrap; gap: 8px; min-height: 44px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.86); }
.agent-check { display: inline-grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 6px; min-width: 132px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 13px; }
.agent-check input { width: auto; }
.agent-check small { grid-column: 2; color: var(--soft); font-size: 11px; }
.permission-editor { display: grid; gap: 16px; }
.permission-editor section { display: grid; gap: 10px; }
.permission-editor h3 { margin: 0; font-size: 17px; }
.permission-editor p { margin: 0; color: var(--muted); }
.permission-grid { overflow: auto; border: 1px solid var(--glass-line); border-radius: 8px; background: #fff; box-shadow: var(--shadow-soft); }
.permission-grid table { min-width: 720px; }
.permission-table th:first-child, .permission-table td:first-child { min-width: 190px; }
.permission-table td strong { display: block; }
.permission-table td small { display: block; margin-top: 4px; color: var(--soft); font-size: 12px; }
.switch-row { display: inline-flex; align-items: center; gap: 8px; min-width: 74px; }
.switch-row input { width: auto; }
.permission-table select { min-width: 104px; padding: 8px 10px; min-height: 36px; }
.permission-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 52px; min-height: 26px; border-radius: 999px; padding: 0 9px; font-size: 12px; font-weight: 750; }
.permission-pill.allow { background: #eaf8ef; color: #198038; }
.permission-pill.deny { background: #fff0ef; color: var(--danger); }
.user-edit-table input, .user-edit-table select { min-width: 118px; padding: 8px 10px; min-height: 36px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; min-width: 148px; }
.muted-note { color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .shell { padding: 14px; }
  .desktop-topbar { align-items: flex-start; flex-direction: column; }
  .desktop-topbar h1, h1 { font-size: 28px; }
  .desktop-view { padding: 20px 18px 92px; }
  .app-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 18px 12px; }
  .app-symbol { width: 68px; height: 68px; border-radius: 18px; }
  .workspace, .layout { grid-template-columns: 1fr; }
  .panel, .results { min-height: auto; }
  .content, .sidebar { border-radius: 8px; border: 1px solid var(--line); }
  .metric-grid, .role-form, .user-form, .settings-form, .permission-quick-form, .analysis-mode { grid-template-columns: 1fr; }
  .hero-report, .section-toolbar, .panel-head, .task-top, .detail-head { flex-direction: column; }
  .user-box { justify-content: flex-start; }
}
