/* health.jys-reality.win — single shared stylesheet (DESIGN.md §8) */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #23272f;
  --muted: #6b7280;
  --line: #e3e7ee;
  --primary: #2f6fd0;
  --primary-dark: #2559a8;
  --danger: #c22f45;
  --success: #2e9e5b;
  --warning: #e08a1e;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 24, 34, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

main { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }

h1 { font-size: 1.45rem; margin: 0 0 16px; }
h2 { font-size: 1.15rem; margin: 24px 0 10px; }
h3 { font-size: 1.05rem; margin: 0 0 12px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- header --- */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
}

.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }

.main-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.main-nav a {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
}
.main-nav a:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.main-nav a.active { background: #e8effb; color: var(--primary); }

.header-controls { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.seg button {
  border: 0;
  background: transparent;
  padding: 5px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--muted);
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--primary); color: #fff; }

.profile-menu { position: relative; }
.profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 180px;
  overflow: hidden;
}
.profile-dropdown button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 0.9rem;
}
.profile-dropdown button:hover { background: var(--bg); }
.hidden { display: none !important; }

/* --- cards / layout --- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

.metric { text-align: left; }
.metric .label { color: var(--muted); font-size: 0.85rem; }
.metric .value { font-size: 1.7rem; font-weight: 700; margin: 2px 0; }
.metric .sub { color: var(--muted); font-size: 0.85rem; }

/* --- forms --- */

.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; align-items: end; }
.form-grid .full { grid-column: 1 / -1; }

input, select, textarea {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b9d0f5; border-color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 4px 9px; font-size: 0.82rem; }
.btn-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* --- tables --- */

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:hover { background: #f8fafd; }
td.num { font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; }

/* --- chips --- */

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 4px 12px;
  font-size: 0.84rem;
  cursor: pointer;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-static { cursor: default; }
.chip-remove { color: var(--danger); }

.badge {
  display: inline-block;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-mild { background: #fdf6d8; color: #8a6d00; }
.badge-moderate { background: #fdebd7; color: #9a5410; }
.badge-severe { background: #fbdfe2; color: #a32236; }
.badge-role-admin { background: #e8effb; color: var(--primary); }
.badge-role-guest { background: #e5f5ea; color: #1e7a43; }
.badge-role-viewer { background: #eef0f4; color: #5a6270; }
.badge-ctx { background: #eef0f4; color: #4a5160; }

/* --- filters / toolbar --- */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.toolbar label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: var(--muted); }
.toolbar input, .toolbar select { width: auto; min-width: 130px; }

/* --- toasts --- */

#toasts {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: #2b303b;
  color: #fff;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s ease;
  max-width: 340px;
}
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--danger); }
.toast-success { background: var(--success); }

/* --- modals --- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 26, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 16px 16px;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(10, 14, 24, 0.25);
  padding: 20px 22px;
  width: 100%;
  max-width: 520px;
  position: relative;
  max-height: 82vh;
  overflow-y: auto;
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
.confirm-box p { margin-top: 0; }

/* --- charts --- */

.chart-box { position: relative; height: 340px; }
.chart-box + .chart-box { margin-top: 26px; }
.symptom-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* --- login --- */

.login-wrap { max-width: 360px; margin: 12vh auto 0; }
.login-wrap .card { padding: 28px; }
.login-title { text-align: center; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--muted); margin: 0 0 18px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-error { color: var(--danger); font-size: 0.88rem; min-height: 1.2em; }
.lang-corner { display: flex; justify-content: flex-end; max-width: 1080px; margin: 0 auto; padding-top: 12px; }

.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

@media (max-width: 700px) {
  .topbar { gap: 10px; }
  .main-nav { order: 3; width: 100%; }
  .metric .value { font-size: 1.4rem; }
}
