:root {
  color-scheme: light;
  --bg: #eef3f5;
  --surface: #ffffff;
  --surface-soft: #f7fafb;
  --ink: #1d2b2f;
  --muted: #65767b;
  --line: #dce6e8;
  --teal: #0f8b7f;
  --teal-dark: #087166;
  --blue: #2f6fbb;
  --amber: #b87913;
  --red: #bd3b3b;
  --green: #257f4f;
  --shadow: 0 18px 45px rgba(25, 49, 55, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

body:not(.authenticated) .app {
  display: none;
}

body.authenticated .login-screen {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 20%, rgba(15, 139, 127, 0.16), transparent 32%),
    linear-gradient(135deg, #eef3f5 0%, #f8fbfb 54%, #e8f3f1 100%);
}

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

.login-card h2 {
  margin: 10px 0 0;
  font-size: 24px;
}

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

.login-brand {
  color: var(--ink);
  padding: 0;
}

.login-brand p {
  color: var(--muted);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  background: #17383d;
  color: #f6fbfa;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e6f6f2;
}

.brand-mark span,
.brand-mark span::before,
.brand-mark span::after {
  display: block;
  background: var(--teal);
  content: "";
}

.brand-mark span {
  width: 22px;
  height: 7px;
  border-radius: 2px;
  position: relative;
}

.brand-mark span::before {
  position: absolute;
  left: 7px;
  top: -7px;
  width: 7px;
  height: 21px;
  border-radius: 2px;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.brand p,
.server-card small,
.server-card span {
  margin: 3px 0 0;
  color: rgba(246, 251, 250, 0.7);
  font-size: 13px;
}

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

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(246, 251, 250, 0.78);
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

.icon {
  width: 22px;
  height: 22px;
  position: relative;
  flex: 0 0 auto;
}

.icon::before,
.icon::after {
  position: absolute;
  content: "";
}

.pulse::before {
  left: 1px;
  top: 10px;
  width: 20px;
  height: 3px;
  background: currentColor;
  clip-path: polygon(0 50%, 22% 50%, 32% 0, 45% 100%, 58% 28%, 69% 50%, 100% 50%, 100% 72%, 63% 72%, 58% 62%, 45% 100%, 32% 18%, 27% 72%, 0 72%);
}

.people::before,
.people::after {
  border: 2px solid currentColor;
  border-radius: 50%;
}

.people::before {
  width: 9px;
  height: 9px;
  left: 6px;
  top: 2px;
}

.people::after {
  width: 18px;
  height: 10px;
  left: 2px;
  bottom: 2px;
  border-radius: 10px 10px 4px 4px;
}

.chart::before {
  inset: 3px 2px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.chart::after {
  left: 5px;
  top: 8px;
  width: 15px;
  height: 9px;
  border-left: 3px solid currentColor;
  border-bottom: 3px solid currentColor;
  transform: skew(-30deg);
}

.pill::before {
  width: 20px;
  height: 11px;
  left: 1px;
  top: 6px;
  border: 2px solid currentColor;
  border-radius: 999px;
  transform: rotate(-35deg);
}

.pill::after {
  width: 2px;
  height: 11px;
  left: 10px;
  top: 6px;
  background: currentColor;
  transform: rotate(-35deg);
}

.file::before {
  inset: 2px 5px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.file::after {
  right: 5px;
  top: 2px;
  width: 7px;
  height: 7px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  background: #17383d;
}

.server-card {
  margin-top: auto;
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.server-card strong {
  font-size: 15px;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.topbar h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 11px;
  background: #fff;
  color: var(--ink);
}

.top-actions select {
  min-width: 160px;
}

.primary,
.ghost,
.danger-btn {
  min-height: 42px;
  border-radius: 7px;
  padding: 0 15px;
  border: 1px solid transparent;
  font-weight: 700;
}

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

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

.ghost {
  background: #f0f6f7;
  color: var(--teal-dark);
  border-color: #d6e7e8;
}

.danger-btn {
  background: #fae6e6;
  color: var(--red);
  border-color: #efc4c4;
}

.mini {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.row-actions.compact {
  margin-top: 0;
  flex-wrap: nowrap;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric-card,
.panel,
.member-card,
.medicine-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 17px;
  min-height: 118px;
  display: grid;
  gap: 7px;
  border-top: 4px solid var(--blue);
}

.metric-card.ok {
  border-top-color: var(--green);
}

.metric-card.warn {
  border-top-color: var(--amber);
}

.metric-card.danger {
  border-top-color: var(--red);
}

.metric-card span,
.metric-card small,
label,
td {
  color: var(--muted);
}

.metric-card strong {
  font-size: 34px;
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(280px, 0.85fr);
  gap: 16px;
  margin-bottom: 16px;
}

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

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

.invite-head {
  margin-top: 22px;
}

h3 {
  margin: 0;
  font-size: 18px;
}

.trend-panel canvas {
  width: 100%;
  height: 270px;
  display: block;
  border-radius: 6px;
  background: var(--surface-soft);
}

.task-list,
.doc-list,
.cards-panel,
.member-cards {
  display: grid;
  gap: 12px;
}

.task {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--teal);
}

.dot.warn {
  background: var(--amber);
}

.dot.danger {
  background: var(--red);
}

.task strong,
.doc strong {
  display: block;
  margin-bottom: 3px;
}

.task small,
.doc small,
.member-card small,
.medicine-card small {
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
}

.table-wrap.tall {
  max-height: 560px;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: #405156;
  background: #f3f8f8;
  font-weight: 800;
}

.editing-row input,
.editing-row select {
  width: 150px;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.editing-row td:nth-child(4) input,
.editing-row td:nth-child(7) input {
  width: 190px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.status.ok {
  background: #e5f5ed;
  color: var(--green);
}

.status.warn {
  background: #fff2d6;
  color: var(--amber);
}

.status.danger {
  background: #fae6e6;
  color: var(--red);
}

.section-row {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.form-panel {
  position: sticky;
  top: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.wide {
  grid-column: 1 / -1;
}

.member-cards {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.member-card,
.medicine-card,
.doc {
  padding: 16px;
}

.member-card {
  display: grid;
  gap: 11px;
}

.member-top,
.medicine-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.avatar {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e8f6f3;
  color: var(--teal-dark);
  font-weight: 900;
  font-size: 20px;
}

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

.tag {
  padding: 5px 8px;
  border-radius: 999px;
  background: #f0f6f7;
  color: #426066;
  font-size: 12px;
}

.cards-panel {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.medicine-card {
  border-top: 4px solid var(--teal);
}

.medicine-card strong {
  font-size: 18px;
}

.doc-list {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.doc {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.doc-link {
  width: fit-content;
  color: var(--teal-dark);
  font-weight: 700;
  text-decoration: none;
}

.doc-link:hover {
  text-decoration: underline;
}

.file-box input {
  padding-top: 9px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 13px 16px;
  border-radius: 8px;
  background: #17383d;
  color: #fff;
  box-shadow: var(--shadow);
}

@media (max-width: 1060px) {
  .app {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .brand div:last-child,
  .nav-item span:last-child,
  .server-card {
    display: none;
  }

  .nav-item {
    justify-content: center;
  }

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

  .dashboard-grid,
  .section-row {
    grid-template-columns: 1fr;
  }

  .form-panel {
    position: static;
  }
}

@media (max-width: 680px) {
  .app {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .nav {
    grid-template-columns: repeat(9, 1fr);
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }
}
