:root {
  color-scheme: dark;
  --bg: #060817;
  --panel: rgba(17, 22, 48, 0.62);
  --panel-strong: rgba(24, 30, 64, 0.78);
  --line: rgba(218, 226, 255, 0.13);
  --line-hot: rgba(255, 159, 95, 0.42);
  --text: #f7f8ff;
  --soft: #d8ddf7;
  --muted: #8f99c4;
  --dim: #69739c;
  --orange: #ff9f5f;
  --violet: #8b7cff;
  --blue: #5573ff;
  --green: #79b8a2;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
  --inner: inset 0 1px 0 rgba(255,255,255,0.12), inset 0 -1px 0 rgba(255,255,255,0.04);
  --blur: blur(26px) saturate(1.18);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --font: "Inter", "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  font-family: var(--font);
}

* { box-sizing: border-box; }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 8%, rgba(85,115,255,.34), transparent 29%),
    radial-gradient(circle at 82% 18%, rgba(139,124,255,.28), transparent 27%),
    radial-gradient(circle at 78% 82%, rgba(255,159,95,.14), transparent 26%),
    linear-gradient(145deg, #050713 0%, #0b1030 45%, #1b1438 100%);
}

.cinema-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), transparent 18%, transparent 78%, rgba(0,0,0,.34)),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: auto, 72px 72px, 72px 72px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.75), transparent 82%);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button, input, select, textarea, a { transition: transform .22s ease, border-color .22s ease, background .22s ease, box-shadow .22s ease, opacity .22s ease; }
.hidden, [hidden] { display: none !important; }

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: calc(100vh - 32px);
  margin: 16px;
  border: 1px solid var(--line);
  border-radius: 34px;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(12,16,38,.72), rgba(11,14,32,.44));
  box-shadow: var(--shadow), var(--inner);
  backdrop-filter: var(--blur);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(3, 6, 20, .72);
  backdrop-filter: blur(24px);
}

.login-card {
  width: min(440px, calc(100vw - 36px));
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(25,31,68,.82), rgba(9,12,30,.62));
  box-shadow: var(--shadow), var(--inner);
}

.login-card h1, .screen-head h2, .panel h3 { margin: 0; letter-spacing: 0; }
.login-note, .screen-head span, .page-title p, small { color: var(--muted); line-height: 1.6; }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.025));
}

.brand, .sidebar-footer { display: flex; align-items: center; gap: 12px; }
.brand-mark, .user-avatar {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 17px;
  background: linear-gradient(145deg, rgba(255,255,255,.26), rgba(255,255,255,.08));
  font-weight: 900;
  box-shadow: var(--inner);
}
.brand strong, .brand span, .sidebar-footer strong, .sidebar-footer span { display: block; }
.brand strong { font-size: 13px; letter-spacing: .08em; }
.brand span, .sidebar-footer span { color: var(--muted); font-size: 12px; }

.nav-list { display: grid; gap: 7px; }
.nav-section { margin: 12px 8px 5px; color: var(--dim); font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.nav-item {
  min-height: 48px;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  text-align: left;
}
.nav-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover, .nav-item.active {
  color: var(--text);
  background: linear-gradient(90deg, rgba(255,159,95,.16), rgba(85,115,255,.12));
  transform: translateX(2px);
  box-shadow: var(--inner);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  grid-template-columns: 46px 1fr;
}
.sidebar-logout {
  grid-column: 1 / -1;
  min-height: 42px;
  border: 1px solid rgba(255,159,95,.28);
  border-radius: 16px;
  background: rgba(255,159,95,.1);
  color: var(--soft);
  font-weight: 800;
}

.workspace { min-width: 0; padding: 26px; }
.topbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 460px);
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}
.eyebrow { margin: 0 0 7px; color: var(--orange); font-size: 11px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.page-title h1 { margin: 0; font-size: 34px; line-height: 1.12; }
.page-title p { margin: 8px 0 0; }

.global-search {
  min-height: 50px;
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(218, 226, 255, 0.16);
  border-radius: 999px;
  background: rgba(8, 11, 27, 0.46);
  padding: 0 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 14px 40px rgba(0,0,0,.18);
  backdrop-filter: blur(18px) saturate(1.08);
}
.global-search svg { width: 19px; fill: none; stroke: var(--muted); stroke-width: 2; }
.global-search:focus-within {
  border-color: rgba(255, 159, 95, 0.34);
  background: rgba(11, 15, 34, 0.62);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.10), 0 0 0 4px rgba(255,159,95,.10), 0 18px 46px rgba(0,0,0,.22);
}
.global-search input {
  min-height: 48px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}
.global-search input:focus {
  border-color: transparent;
  box-shadow: none;
  background: transparent;
}

.pill, .soft-badge, .panel-head span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.055);
  color: var(--muted);
  padding: 5px 10px;
  white-space: nowrap;
}

.view { display: none; }
.view.active { display: block; animation: viewIn .34s cubic-bezier(.2,.8,.2,1) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(12px) scale(.992); } to { opacity: 1; transform: none; } }

.screen-head, .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.screen-head h2 { font-size: 28px; }
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(145deg, rgba(27,34,73,.58), rgba(8,11,29,.38));
  box-shadow: 0 22px 70px rgba(0,0,0,.26), var(--inner);
  backdrop-filter: var(--blur);
  padding: 18px;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(280px, 1.25fr) repeat(2, minmax(180px, .55fr)) minmax(300px, .95fr);
  gap: 16px;
  margin-bottom: 18px;
}
.hero-card, .metric-card {
  position: relative;
  overflow: hidden;
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(85,115,255,.24), rgba(139,124,255,.12) 48%, rgba(255,159,95,.12));
  box-shadow: var(--shadow), var(--inner);
  padding: 20px;
}
.hero-card strong, .metric-card strong { display: block; margin-top: 14px; font-size: 44px; line-height: 1; }
.hero-kicker, .metric-card span { color: var(--muted); font-weight: 800; }
.metric-card small { display: block; margin-top: 10px; }
.hero-bars { position: absolute; right: 20px; bottom: 18px; display: flex; align-items: end; gap: 7px; height: 70px; }
.hero-bars i { width: 12px; border-radius: 999px; background: linear-gradient(180deg, var(--orange), var(--violet)); box-shadow: 0 0 22px rgba(255,159,95,.36); }
.hero-bars i:nth-child(1) { height: 30%; } .hero-bars i:nth-child(2) { height: 62%; } .hero-bars i:nth-child(3) { height: 45%; } .hero-bars i:nth-child(4) { height: 82%; } .hero-bars i:nth-child(5) { height: 56%; }

.client-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
  gap: 18px;
  align-items: start;
}
.client-table-panel { min-width: 0; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; }

label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(5, 8, 24, .42);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  box-shadow: var(--inner);
}
textarea { min-height: 92px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--dim); }
input:focus, select:focus, textarea:focus { border-color: var(--line-hot); box-shadow: 0 0 0 4px rgba(255,159,95,.12), var(--inner); }

.custom-select {
  position: relative;
  min-width: 152px;
  isolation: isolate;
}
.filter-bar .custom-select { min-width: 138px; }
.form-grid .custom-select,
.task-form .custom-select,
.login-card .custom-select { width: 100%; }
.native-select {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}
.select-trigger {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(218, 226, 255, .15);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.105), rgba(255,255,255,.035)),
    rgba(6, 9, 27, .52);
  color: var(--text);
  padding: 0 13px 0 15px;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 14px 34px rgba(0,0,0,.18);
  backdrop-filter: blur(18px) saturate(1.12);
}
.select-trigger span {
  display: block;
  min-height: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  box-shadow: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}
.select-trigger svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--soft);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .22s ease;
}
.custom-select.open .select-trigger {
  border-color: rgba(255,159,95,.42);
  background:
    linear-gradient(135deg, rgba(255,159,95,.16), rgba(95,111,255,.13)),
    rgba(8, 11, 32, .72);
  box-shadow: 0 0 0 4px rgba(255,159,95,.10), 0 18px 46px rgba(0,0,0,.24), var(--inner);
}
.custom-select.open .select-trigger svg { transform: rotate(180deg); }
.select-menu {
  position: absolute;
  z-index: 80;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: none;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  border: 1px solid rgba(218, 226, 255, .16);
  border-radius: 18px;
  background:
    radial-gradient(circle at 18% 0%, rgba(255,159,95,.18), transparent 42%),
    linear-gradient(145deg, rgba(24, 30, 70, .92), rgba(7, 10, 29, .88));
  box-shadow: 0 28px 70px rgba(0,0,0,.42), var(--inner);
  backdrop-filter: blur(24px) saturate(1.18);
}
.custom-select.open .select-menu { display: grid; gap: 4px; animation: dropdownIn .18s ease both; }
.select-option {
  min-height: 40px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--soft);
  padding: 0 12px;
  text-align: left;
  font-weight: 760;
}
.select-option:hover,
.select-option.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(255,159,95,.22), rgba(85,115,255,.18));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.11);
}
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-6px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.form-grid textarea, .form-grid button { grid-column: 1 / -1; }

.primary-action, .ghost-action {
  min-height: 44px;
  border-radius: var(--radius-md);
  padding: 0 16px;
  color: #fff;
  font-weight: 900;
  white-space: nowrap;
}
.primary-action {
  border: 1px solid rgba(255,255,255,.26);
  background: linear-gradient(135deg, #5368df, #8b67dc 60%, #c77b55);
  box-shadow: 0 16px 34px rgba(72,80,200,.32), var(--inner);
}
.ghost-action {
  border: 1px solid rgba(255,159,95,.34);
  background: linear-gradient(135deg, rgba(255,159,95,.18), rgba(85,115,255,.14));
}
.primary-action:hover, .ghost-action:hover, .task-card:hover { transform: translateY(-2px); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 20px; background: rgba(5,8,24,.28); }
table { width: 100%; min-width: 900px; border-collapse: collapse; }
th, td { padding: 14px; border-bottom: 1px solid rgba(218,226,255,.09); text-align: left; vertical-align: top; }
th { color: var(--muted); background: rgba(255,255,255,.05); font-size: 12px; }
td strong, td small { display: block; }
td small { color: var(--muted); margin-top: 4px; }
tbody tr:hover { background: rgba(255,255,255,.045); }
.team-stack { display: grid; gap: 3px; color: var(--muted); font-size: 12px; }
.link-button { border: 0; background: transparent; color: var(--orange); font-weight: 900; padding: 0; }
.row-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.danger-link { color: #ff8b8b; }
.danger-link:hover { color: #ffc2c2; }

.region-flow {
  display: grid;
  gap: 12px;
}
.region-flow-item {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(218, 226, 255, 0.10);
  border-radius: 16px;
  background: rgba(255,255,255,.04);
  padding: 10px;
}
.region-flow-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.region-flow-meta span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.region-flow-meta i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  box-shadow: 0 0 16px rgba(255,159,95,.26);
}
.region-flow-meta b {
  color: var(--soft);
}
.region-flow-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,.07);
}
.region-flow-track em {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.task-command { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr); gap: 16px; margin-bottom: 16px; }
.task-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.task-form button { grid-column: auto; }
.task-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.task-column {
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.025));
  padding: 16px;
  box-shadow: var(--inner);
}
.task-column.featured { border-color: rgba(255,159,95,.25); background: linear-gradient(180deg, rgba(255,159,95,.09), rgba(255,255,255,.03)); }
.task-column-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.task-column-head h3 { margin: 0; }
.task-column-head span { min-width: 30px; height: 30px; display: grid; place-items: center; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--soft); }
.task-card {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(7,10,28,.48);
  padding: 14px;
  box-shadow: var(--inner);
}
.task-card span, .task-card small, .empty-text { color: var(--muted); }

.region-grid, .planner-grid, .admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.region-card, .plan-block { border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.045); padding: 16px; }
.region-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.school-item { border-top: 1px solid var(--line); padding: 12px 0; }
.school-item a { color: var(--orange); text-decoration: none; font-weight: 900; }
.large-textarea { min-height: 260px; margin: 12px 0; }
.plan-output { display: grid; gap: 12px; }
.ai-output {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.045);
  color: var(--soft);
  padding: 16px;
  line-height: 1.8;
  white-space: normal;
}
button:disabled {
  cursor: wait;
  opacity: .68;
  transform: none !important;
}
.chat-panel { display: grid; grid-template-rows: minmax(420px, 55vh) auto; gap: 12px; }
.chat-messages { overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.chat-message { max-width: 80%; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.055); padding: 12px; }
.chat-message.teacher { align-self: flex-end; background: rgba(85,115,255,.14); }
.chat-message span { color: var(--orange); font-size: 12px; font-weight: 900; }
.chat-input { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.account-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 3; flex-direction: row; align-items: center; overflow-x: auto; }
  .nav-list { display: flex; align-items: center; }
  .nav-section, .sidebar-footer { display: none; }
  .home-hero, .client-layout, .task-command, .task-board, .region-grid, .planner-grid, .admin-grid { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-shell { margin: 8px; border-radius: 22px; }
  .workspace { padding: 18px; }
  .screen-head, .panel-head { flex-direction: column; align-items: stretch; }
  .form-grid, .task-form { grid-template-columns: 1fr; }
  .primary-action, .ghost-action { width: 100%; }
}
