:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --brand: #0f7b8f;
  --brand-dark: #075466;
  --accent: #f28c28;
  --green: #168a55;
  --red: #c2413a;
  --shadow: 0 16px 40px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

body.h5-mode {
  background: #eef6f8;
}

body.h5-mode .app-shell,
body.h5-mode .login-screen,
body.h5-mode dialog:not(#linkDialog) {
  display: none;
}

body.logged-out:not(.h5-mode) .app-shell {
  display: none;
}

body:not(.logged-out) .login-screen {
  display: none;
}

.student-h5 {
  display: none;
}

body.h5-mode .student-h5 {
  min-height: 100vh;
  display: block;
  max-width: 560px;
  margin: 0 auto;
  background: #fff;
}

.h5-hero {
  min-height: 148px;
  padding: 28px 22px;
  background: linear-gradient(135deg, #0f7b8f, #168a55);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
}

.h5-hero strong {
  font-size: 24px;
  line-height: 1.25;
}

.h5-hero span {
  opacity: 0.9;
}

.h5-form {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.h5-form section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.h5-form h2 {
  font-size: 18px;
}

.h5-tip,
.h5-foot {
  color: var(--muted);
  font-size: 14px;
}

.h5-submit {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  min-height: 48px;
  font-weight: 700;
}

.h5-submit:disabled {
  opacity: 0.7;
}

.h5-submit-status {
  min-height: 20px;
  color: var(--danger);
  font-size: 14px;
  text-align: center;
}

.h5-success {
  display: none;
  margin: 18px;
  border: 1px solid #cdebdc;
  border-radius: 8px;
  padding: 20px;
  background: #eefaf3;
  color: var(--green);
}

.h5-success.active {
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef6f8 0%, #f7fbf8 55%, #fff7ed 100%);
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

.login-brand {
  margin-bottom: 4px;
}

.login-error {
  min-height: 20px;
  color: var(--red);
  font-size: 14px;
}

.login-help {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.login-help strong {
  color: var(--ink);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  background: #0c2330;
  color: #fff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 4px;
  color: #9fb1bd;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  text-align: left;
  color: #c8d7df;
  background: transparent;
}

.nav-item.active,
.nav-item:hover {
  background: #163848;
  color: #fff;
}

.role-box {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.role-box label {
  display: block;
  margin-bottom: 8px;
  color: #9fb1bd;
  font-size: 13px;
}

.role-box select,
.toolbar input,
.toolbar select,
label input,
label select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

.current-user {
  color: #fff;
  font-weight: 700;
  margin-bottom: 12px;
}

.logout-btn {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #163848;
  color: #fff;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.role-preview-label {
  margin-top: 4px;
}

.main {
  min-width: 0;
  padding: 0 28px 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-top: 24px;
  margin-bottom: 22px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
}

.topbar p {
  color: var(--muted);
  margin-top: 6px;
}

.workspace-tabs {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  overflow-x: auto;
  min-height: 46px;
  padding: 8px 10px 0;
  margin: 0 -28px;
  border-bottom: 1px solid #cfd8e3;
  background: #e9eef5;
}

.workspace-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  min-height: 38px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #dbe3ee;
  box-shadow: none;
}

.workspace-tab.active {
  border-color: #cfd8e3;
  background: var(--bg);
  position: relative;
  z-index: 1;
}

.workspace-tab-title,
.workspace-tab-close {
  border: 0;
  background: transparent;
  color: var(--ink);
}

.workspace-tab-title {
  min-width: 104px;
  padding: 10px 4px 9px 14px;
  text-align: left;
  font-weight: 700;
}

.workspace-tab-close {
  width: 26px;
  height: 26px;
  margin-right: 6px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.workspace-tab-close:hover {
  background: #cbd6e3;
  color: var(--brand-dark);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary,
.ghost,
.import-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 40px;
}

.primary {
  background: var(--brand);
  color: #fff;
}

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

.ghost,
.import-btn {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.import-btn {
  display: inline-grid;
  place-items: center;
}

.import-btn input {
  display: none;
}

.small {
  padding: 8px 12px;
  min-height: 34px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hidden {
  display: none !important;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card,
.panel,
.form-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 18px;
}

.stat-card span,
.stat-card small {
  color: var(--muted);
}

.stat-card strong {
  display: block;
  font-size: 30px;
  margin: 8px 0;
}

.split {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
}

.todo-panel {
  margin-top: 18px;
}

.panel {
  padding: 18px;
}

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

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px 220px;
  gap: 12px;
  margin-bottom: 14px;
}

.table-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: #f9fbfd;
  font-weight: 600;
}

.student-name strong,
.student-name small,
.stack strong,
.stack small {
  display: block;
}

.student-name small,
.stack small {
  color: var(--muted);
  margin-top: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  background: #edf2f7;
  color: #344054;
}

.badge.green {
  background: #e9f7ef;
  color: var(--green);
}

.badge.red {
  background: #fff0ee;
  color: var(--red);
}

.row-actions {
  display: flex;
  gap: 8px;
}

.row-actions button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 7px 10px;
}

.funnel {
  display: grid;
  gap: 10px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 90px 1fr 48px;
  gap: 12px;
  align-items: center;
}

.bar {
  height: 12px;
  border-radius: 999px;
  background: #edf2f7;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--brand);
}

.rank-item,
.agent-card,
.site-stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.rank-list,
.agent-grid,
.site-stats-grid,
.todo-list {
  display: grid;
  gap: 10px;
}

.site-stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.site-stat-card {
  display: grid;
  gap: 14px;
}

.site-stat-card strong,
.site-stat-card small {
  display: block;
}

.site-stat-card small {
  color: var(--muted);
  margin-top: 4px;
}

.site-stat-card dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.site-stat-card dt {
  color: var(--muted);
  font-size: 12px;
}

.site-stat-card dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.student-entry-panel {
  margin-top: 18px;
}

.rank-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.todo-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  background: #fff;
}

.todo-item small {
  color: var(--muted);
}

.agent-card .card-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.link-box {
  display: grid;
  gap: 14px;
}

.link-box textarea {
  min-height: 76px;
}

.qr-wrap {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.qr-wrap img {
  width: 180px;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.submit-layout {
  display: grid;
  gap: 16px;
}

.form-panel {
  padding: 18px;
}

.form-panel h2 {
  margin-bottom: 14px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.hint {
  color: var(--muted);
  margin: -4px 0 14px;
}

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

.check-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
}

.check-item input {
  width: 18px;
  height: 18px;
}

.field-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.upload-grid {
  display: grid;
  gap: 12px;
}

.upload-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.upload-item span {
  color: var(--ink);
  font-weight: 700;
}

.upload-item small {
  color: var(--muted);
}

.upload-item input {
  padding: 10px;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.full {
  margin-top: 14px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.notice-layout {
  display: grid;
  gap: 18px;
}

.notice-form {
  display: grid;
  gap: 14px;
}

.notice-list {
  display: grid;
  gap: 12px;
}

.notice-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  display: grid;
  gap: 12px;
}

.notice-card.unread {
  border-color: var(--brand);
  background: #f0fafb;
}

.notice-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.notice-card-head h3 {
  margin-top: 8px;
}

.notice-card-head small,
.notice-meta {
  color: var(--muted);
}

.notice-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
}

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

.materials article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfe;
}

.materials ul {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(760px, calc(100vw - 32px));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

dialog::backdrop {
  background: rgba(12, 35, 48, 0.42);
}

.dialog-card {
  padding: 20px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 22px;
  line-height: 1;
}

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

.detail-grid label {
  color: var(--muted);
}

.detail-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.settlement-card {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.settlement-card span {
  color: var(--muted);
}

.uploaded-materials {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.material-upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.material-upload-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.material-upload-card small {
  color: var(--muted);
}

.material-file {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.material-file img,
.file-badge {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #fff;
}

.file-badge {
  display: grid;
  place-items: center;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.followup-box {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.followup-list {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.followup-list p {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  color: var(--muted);
}

.followup-list strong {
  color: var(--ink);
  margin-right: 8px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .stats-grid,
  .split,
  .form-grid,
  .materials,
  .settlement-card,
  .material-upload-grid,
  .field-pair,
  .site-stats-grid,
  .site-stat-card dl {
    grid-template-columns: 1fr;
  }

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

  .topbar {
    flex-direction: column;
  }
}
