:root {
  --sidebar-width: 260px;
  --header-height: 48px;
  --page-max: 1680px;
  --header: #222d32;
  --sidebar: #1f2d3d;
  --sidebar-dark: #17212b;
  --active: #00a65a;
  --blue: #3c8dbc;
  --body: #ecf0f5;
  --line: #d2d6de;
  --text: #222;
  --muted: #6b7280;
  --panel: #fff;
  --gold: #f6c85f;
  --danger: #dd4b39;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Arial, "Microsoft YaHei", sans-serif; color: var(--text); background: var(--body); font-size: 13px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.error { min-height: 20px; color: var(--danger); }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding-top: 92px;
  background: #f1f4fd;
}
.login-box {
  width: min(430px, calc(100vw - 40px));
  position: relative;
  display: grid;
  gap: 14px;
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 0 30px rgba(0,0,0,.10);
  overflow: hidden;
  padding: 0 30px 30px;
}
.login-head {
  height: 110px;
  margin: 0 -30px 8px;
  background: linear-gradient(135deg, #899fe1, #708eea);
}
.avatar {
  width: 92px;
  height: 92px;
  margin: -58px auto 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 5px solid #fff;
  color: #708eea;
  background: #eef2ff;
  font-size: 34px;
  font-weight: 700;
}
.login-box h1 { margin: 0 0 4px; text-align: center; font-size: 22px; font-weight: 500; }
label { display: grid; gap: 6px; color: #344054; font-size: 13px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 8px 10px;
  background: #fff;
}
textarea { min-height: 220px; font-family: Consolas, monospace; }
.checkline { display: flex; align-items: center; gap: 8px; }
.checkline input { width: auto; }
.primary, .secondary, .ghost, .top-btn, .icon-btn {
  border: 0;
  border-radius: 3px;
  padding: 8px 13px;
}
.primary { background: #708eea; color: #fff; }
.secondary { background: #3c8dbc; color: #fff; }
.ghost { border: 1px solid var(--line); background: #fff; color: #333; }
.block { width: 100%; font-size: 16px; padding: 10px; }

.layout {
  height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: var(--header-height) minmax(0, 1fr);
  overflow: hidden;
}
.main-header {
  grid-column: 1 / 3;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  background: var(--header);
  color: #fff;
}
.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #367fa9;
  font-size: 17px;
  font-weight: 600;
}
.logo-mini { display: none; }
.navbar {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #3c8dbc;
}
.icon-btn, .top-btn {
  height: var(--header-height);
  border-radius: 0;
  background: transparent;
  color: #fff;
}
.icon-btn { width: 48px; font-size: 18px; }
.top-btn { padding: 0 16px; }
.tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: end;
  gap: 3px;
  overflow-x: auto;
  padding-top: 9px;
}
.tab {
  flex: 0 0 auto;
  border: 0;
  border-radius: 3px 3px 0 0;
  padding: 8px 13px;
  color: #444;
  background: #e8edf2;
}
.tab.active { background: #fff; color: #111; }
.user-chip { padding: 0 10px; white-space: nowrap; color: #eef7ff; }

.main-sidebar {
  grid-column: 1;
  grid-row: 2;
  background: var(--sidebar);
  color: #cfd8df;
  overflow: auto;
  overscroll-behavior: contain;
}
.menu-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 10px;
  background: #243642;
}
.menu-search input {
  border: 0;
  border-radius: 3px;
  background: #374850;
  color: #fff;
  padding: 8px 10px;
}
.menu-search input::placeholder { color: #b8c7ce; }
.menu-search span { color: #b8c7ce; font-size: 14px; }
.menu-group-title {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 15px 7px;
  color: #8aa4af;
  background: var(--sidebar-dark);
  font-size: 12px;
}
.menu-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 0;
  border-left: 3px solid transparent;
  min-height: 40px;
  padding: 10px 14px;
  background: transparent;
  color: #cfd8df;
  text-align: left;
}
.menu-btn:hover, .menu-btn.active {
  border-left-color: var(--active);
  background: #263747;
  color: #fff;
}
.menu-btn .badge { color: #8aa4af; font-size: 11px; }

.page {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  padding: 12px 14px 18px;
  overflow: auto;
}
.page > * {
  max-width: var(--page-max);
  margin-left: auto;
  margin-right: auto;
}
.page-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 10px;
}
.page-title h2 { margin: 0; font-size: 20px; font-weight: 500; }
.page-title p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.readonly-badge {
  border: 1px solid #f0d89a;
  border-radius: 3px;
  padding: 6px 10px;
  background: #fff8df;
  color: #8a6400;
  font-size: 12px;
}

.box {
  border-top: 3px solid #d2d6de;
  background: #fff;
  box-shadow: 0 1px 1px rgba(0,0,0,.08);
  margin-bottom: 12px;
}
.box.blue { border-top-color: var(--blue); }
.box.green { border-top-color: var(--active); }
.box.gold { border-top-color: var(--gold); }
.box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f4f4f4;
  min-height: 42px;
  padding: 9px 12px;
}
.box-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.box-body { padding: 10px 12px; }

.hero-board {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  gap: 12px;
  padding: 12px;
  border-radius: 4px;
  color: #f7fbff;
  background:
    radial-gradient(circle at 18% 18%, rgba(246,200,95,.22), transparent 32%),
    linear-gradient(135deg, #182432, #1e3c4f 55%, #17212b);
}
.hero-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.hero-title h3 { margin: 0; font-size: 20px; font-weight: 500; }
.hero-actions { display: flex; gap: 8px; }
.hero-actions button { border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: #fff; border-radius: 3px; padding: 6px 10px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat-card {
  min-height: 74px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 4px;
  background: rgba(255,255,255,.08);
}
.stat-card span { display: block; color: #cfe1ec; font-size: 12px; }
.stat-card strong { display: block; margin-top: 7px; font-size: 22px; }
.task-list { display: grid; gap: 9px; }
.task-item { padding: 10px; border: 1px solid rgba(255,255,255,.12); border-radius: 4px; background: rgba(0,0,0,.16); }
.progress { height: 6px; margin-top: 8px; background: rgba(255,255,255,.16); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--gold); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(130px, 150px)) auto;
  gap: 8px;
  align-items: end;
}
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 9px 10px; }
.form-grid label.wide { grid-column: span 2; }
.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }

.summary { display: grid; grid-template-columns: repeat(5, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.summary div { min-height: 62px; padding: 9px 10px; background: #fff; border-top: 3px solid var(--blue); box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.summary strong { display: block; margin-top: 4px; font-size: 19px; }

.table-wrap { max-width: 100%; overflow: auto; border: 1px solid #ddd; background: #fff; }
table { width: 100%; min-width: 1080px; border-collapse: collapse; font-size: 12px; }
th, td { border: 1px solid #e5e7eb; padding: 6px 8px; text-align: left; white-space: nowrap; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; background: #f7f7f7; color: #333; font-weight: 600; }
tr:nth-child(even) td { background: #fcfcfc; }
.status { display: inline-block; border-radius: 2px; padding: 2px 6px; color: #fff; background: #777; }
.status.ok { background: #00a65a; }
.status.warn { background: #f39c12; }

pre { max-height: 260px; overflow: auto; padding: 10px; background: #111827; color: #d1e7dd; }
a button { pointer-events: none; }
.empty-note {
  margin-bottom: 10px;
  padding: 9px 10px;
  border: 1px solid #f0d89a;
  background: #fff8df;
  color: #6f5200;
}
.page-snapshot-wrap {
  padding: 0;
  height: min(72vh, 760px);
  background: #e5ebf1;
}
.page-snapshot {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.mirror-toolbar {
  max-width: none;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border-top: 3px solid #f6c85f;
  border-bottom: 1px solid #d9dee4;
  background: #fff;
  box-shadow: 0 1px 1px rgba(0,0,0,.06);
}
.mirror-toolbar strong {
  font-size: 14px;
}
.mirror-toolbar span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: #667085;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mirror-toolbar button {
  padding: 5px 10px;
}
.mirror-frame-wrap {
  max-width: none;
  height: calc(100vh - var(--header-height) - 118px);
  min-height: 560px;
  border: 1px solid #d9dee4;
  border-top: 0;
  background: #fff;
}
.mirror-frame {
  height: 100%;
}
.sync-panel {
  max-width: none;
  margin-top: 10px;
  margin-bottom: 12px;
  border-top: 3px solid var(--blue);
  background: #fff;
  box-shadow: 0 1px 1px rgba(0,0,0,.08);
}
.sync-panel summary {
  cursor: pointer;
  padding: 10px 12px;
  border-bottom: 1px solid #f4f4f4;
  font-weight: 600;
}

@media (max-width: 1024px) {
  :root { --sidebar-width: 100%; }
  .layout { height: auto; min-height: 100vh; grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; overflow: visible; }
  .main-header { grid-column: 1; grid-template-columns: 1fr; }
  .main-sidebar { grid-column: 1; grid-row: 2; max-height: 44vh; }
  .page { grid-column: 1; grid-row: 3; }
  .hero-board, .grid-2, .toolbar, .form-grid, .summary { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid label.wide { grid-column: span 1; }
  .mirror-frame-wrap { height: 70vh; min-height: 520px; }
}

@media (min-width: 1440px) {
  :root { --sidebar-width: 268px; }
  .page { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 640px) {
  .navbar { flex-wrap: wrap; min-height: var(--header-height); }
  .tabs { order: 3; flex-basis: 100%; padding: 0 8px; }
  .page-title { align-items: flex-start; flex-direction: column; }
  .readonly-badge { align-self: flex-start; }
  .stat-grid { grid-template-columns: 1fr; }
  .form-actions { flex-wrap: wrap; }
}
