:root {
  --navy-950: #0b2234;
  --navy-900: #123149;
  --navy-800: #1a405c;
  --blue-700: #12638f;
  --blue-100: #e8f3f8;
  --canvas: #f3f6f7;
  --surface: #ffffff;
  --surface-subtle: #f7f9fa;
  --line: #d7e0e4;
  --line-strong: #b9c7ce;
  --ink: #142630;
  --muted: #647680;
  --green: #167052;
  --green-soft: #e6f4ef;
  --amber: #9a6500;
  --amber-soft: #fff4d6;
  --red: #b33b3b;
  --red-soft: #fdeaea;
  --focus: #1681b8;
  --topbar-height: 68px;
  --sidebar-width: 236px;
  --radius: 8px;
  --shadow: 0 8px 24px rgba(12, 39, 55, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 14px/1.5 "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif; }
a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(22, 129, 184, .32); outline-offset: 2px; }

.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-height); display: flex; align-items: center; justify-content: space-between; padding: 0 22px; background: var(--navy-950); color: #fff; border-bottom: 1px solid rgba(255,255,255,.1); }
.topbar-start, .brand, .userbox { display: flex; align-items: center; }
.brand { gap: 11px; color: #fff; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.42); border-radius: 8px; background: #fff; color: var(--navy-900); font-size: 20px; font-weight: 900; }
.brand-copy { display: grid; line-height: 1.2; }
.brand-copy strong { font-size: 16px; letter-spacing: .04em; }
.brand-copy small { margin-top: 4px; color: #a9c2d2; font-size: 11px; }
.userbox { gap: 10px; }
.user-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #d9edf5; color: var(--navy-900); font-weight: 800; }
.user-copy { display: grid; min-width: 80px; line-height: 1.25; }
.user-copy strong { font-size: 13px; }
.user-copy small { margin-top: 3px; color: #a9c2d2; font-size: 11px; }
.userbox .link-button { color: #dbeaf1; }
.nav-toggle { display: none; width: 42px; height: 42px; margin-right: 10px; padding: 10px; border: 0; background: transparent; }
.nav-toggle span { display: block; height: 2px; margin: 4px 0; background: #fff; }

.shell { min-height: calc(100vh - var(--topbar-height)); display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar { position: sticky; top: var(--topbar-height); align-self: start; height: calc(100vh - var(--topbar-height)); overflow-y: auto; padding: 18px 12px; background: var(--navy-900); color: #dbe7ed; }
.sidebar p { margin: 20px 10px 7px; color: #88a8ba; font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.sidebar a { display: flex; align-items: center; gap: 10px; min-height: 42px; margin: 2px 0; padding: 8px 10px; border-radius: 6px; color: #e9f1f4; font-weight: 600; }
.sidebar a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.sidebar a > span { display: grid; place-items: center; flex: 0 0 26px; width: 26px; height: 26px; border: 1px solid rgba(255,255,255,.18); border-radius: 5px; color: #b7cfda; font-size: 11px; }
.sidebar a.is-active { background: #fff; color: var(--navy-900); box-shadow: 0 3px 12px rgba(0,0,0,.12); }
.sidebar a.is-active > span { border-color: #9cc4d7; background: var(--blue-100); color: var(--blue-700); }
.sidebar-foot { margin: 24px 10px 10px; padding-top: 15px; border-top: 1px solid rgba(255,255,255,.13); }
.sidebar-foot small, .sidebar-foot strong { display: block; }
.sidebar-foot small { color: #88a8ba; }
.sidebar-foot strong { margin-top: 3px; font-size: 12px; }
.nav-scrim { display: none; }

.content { min-width: 0; width: 100%; padding: 26px clamp(18px, 2.4vw, 38px) 48px; }
.content-auth { grid-column: 1 / -1; padding: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.page-head h1 { margin: 3px 0 4px; font-size: clamp(25px, 2.4vw, 34px); line-height: 1.2; letter-spacing: -.03em; }
.page-head p { max-width: 800px; margin: 0; color: var(--muted); }
.eyebrow { color: var(--blue-700); font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.actions, .row-actions, .form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.actions form { display: inline-flex; margin: 0; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 13px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--ink); font-weight: 700; line-height: 1.2; cursor: pointer; }
.button:hover { border-color: #8ea6b1; background: var(--surface-subtle); text-decoration: none; }
.button-primary { border-color: var(--blue-700); background: var(--blue-700); color: #fff; }
.button-primary:hover { border-color: #0e5074; background: #0e5074; }
.button-danger { border-color: #c77070; color: #922d2d; }
.button:disabled { border-color: var(--line); background: #edf1f2; color: #8c9ba2; cursor: wait; }
.link-button { padding: 4px 7px; border: 0; background: transparent; color: var(--blue-700); font-weight: 700; cursor: pointer; }
.danger-text { color: var(--red) !important; }
.primary-link { font-weight: 800; }
.row-actions a { white-space: nowrap; }

.panel, .table-wrap { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.panel { padding: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 13px; }
.panel-head h2 { margin: 0; font-size: 17px; }
.two-column { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.metric-strip { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); margin-bottom: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }
.metric-strip > div { min-width: 0; padding: 15px 17px; border-right: 1px solid var(--line); }
.metric-strip > div:last-child { border-right: 0; }
.metric-strip span, .metric-strip small { display: block; color: var(--muted); }
.metric-strip span { font-size: 12px; font-weight: 700; }
.metric-strip strong { display: block; margin: 3px 0 1px; font-size: 25px; line-height: 1.25; }
.metric-strip small { font-size: 11px; }
.compact-list, .event-list { display: grid; }
.compact-list a { display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; padding: 11px 2px; border-bottom: 1px solid var(--line); color: var(--ink); }
.compact-list a:last-child { border-bottom: 0; }
.compact-list a:hover strong { color: var(--blue-700); }
.compact-list span, .compact-list small { color: var(--muted); font-size: 12px; }
.compact-list small { grid-column: 1 / -1; color: var(--blue-700); }
.event-list > div { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.event-list > div:last-child { border-bottom: 0; }
.event-list span { color: var(--muted); font-variant-numeric: tabular-nums; }
.event-list p { margin: 0; }

.table-wrap { max-width: 100%; overflow: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #e8eef1; color: #314955; font-size: 12px; font-weight: 800; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background-color: #f8fbfc; }
td { font-variant-numeric: tabular-nums; }
.empty, .empty-cell { padding: 32px 18px; color: var(--muted); text-align: center; }
.muted { color: var(--muted); }
.action-separator { margin: 0 5px; color: var(--line-strong); }

.notice { margin-bottom: 16px; padding: 12px 15px; border: 1px solid #a8c9d8; border-left: 4px solid var(--blue-700); border-radius: 5px; background: #edf7fb; }
.notice-success { border-color: #93c5b4; border-left-color: var(--green); background: var(--green-soft); }
.notice-warning { border-color: #dfbd63; border-left-color: var(--amber); background: var(--amber-soft); }
.notice-error { border-color: #dfa0a0; border-left-color: var(--red); background: var(--red-soft); }
.notice summary { cursor: pointer; }
.issue-box { margin-bottom: 16px; padding: 15px; border: 1px solid #dfa0a0; border-radius: var(--radius); background: var(--red-soft); }
.issue-box h2 { margin: 0 0 8px; font-size: 17px; }

.form-panel { max-width: 980px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid label, .schedule-filter label { display: grid; align-content: start; gap: 6px; color: #29414d; font-weight: 700; }
.form-grid label > span b { margin-left: 3px; color: var(--red); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea, .form-control { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; color: var(--ink); }
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(22,129,184,.12); outline: 0; }
.form-grid small { color: var(--muted); font-size: 11px; font-weight: 400; }
.form-grid em, .field-error, .errorlist { color: var(--red); font-style: normal; }
.check-field { grid-template-columns: auto 1fr; align-items: center; }
.check-field > span { grid-column: 1 / -1; }
.check-field input { width: 18px; height: 18px; }
.form-actions { justify-content: flex-end; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }

.status { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; background: #e8edef; color: #53656e; font-size: 11px; font-weight: 800; }
.status-draft, .status-pending_target, .status-pending_pharmacy, .status-pending_department { background: var(--amber-soft); color: #775000; }
.status-published, .status-approved, .status-ready, .status-accepted { background: var(--green-soft); color: #155d46; }
.status-rejected, .status-cancelled { background: var(--red-soft); color: #8d2e2e; }
.status-no_replacement, .status-covered_by_surplus { background: #e8edef; color: #40545e; }
.status-needs_confirmation { background: var(--amber-soft); color: #775000; }
.status-unsafe { background: var(--red-soft); color: #8d2e2e; }
.status-adjusted_shortage { background: #fff1d6; color: #8a5a00; }
.status-replaced { background: var(--green-soft); color: #155d46; }
.leave-affected { border-color: #e7b04b !important; background: #fffaf0 !important; }
.pagination { display: flex; justify-content: center; gap: 18px; padding: 18px; }
.check-list { display: grid; gap: 12px; margin: 16px 0 20px; }
.check-list label { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-subtle); }
.check-list input { margin-top: 3px; }

.schedule-board { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }
.day-row { display: grid; grid-template-columns: 105px minmax(0, 1fr); border-bottom: 1px solid var(--line); }
.day-row:last-child { border-bottom: 0; }
.day-row > header { padding: 14px; background: #e8eef1; }
.day-row > header strong, .day-row > header span { display: block; }
.day-assignments { display: flex; gap: 8px; overflow-x: auto; padding: 9px; }
.day-assignments article { min-width: 210px; padding: 8px 10px; border-left: 4px solid var(--blue-700); background: #f3f8fa; }
.day-assignments article span { color: var(--muted); font-size: 11px; }
.day-assignments article p { margin: 2px 0; }

.login-panel { min-height: calc(100vh - var(--topbar-height)); display: grid; grid-template-columns: minmax(320px, .8fr) minmax(380px, 1.2fr); align-items: center; gap: clamp(40px, 8vw, 120px); padding: clamp(30px, 8vw, 110px); background: linear-gradient(110deg, var(--navy-900) 0 46%, var(--canvas) 46%); }
.login-panel > div { color: #fff; }
.login-panel > div .eyebrow { color: #9fd0e3; }
.login-panel > div h1 { margin: 8px 0; font-size: clamp(34px, 4vw, 52px); }
.login-panel > div p { max-width: 440px; color: #c4d8e2; font-size: 16px; }
.login-panel form { max-width: 460px; padding: 28px; box-shadow: var(--shadow); }
.login-panel form h2 { margin-top: 0; }
.login-panel form label { display: grid; gap: 6px; margin: 15px 0; font-weight: 700; }
.login-panel form .button { width: 100%; margin-top: 8px; }

@media (max-width: 1080px) {
  .nav-toggle { display: block; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; top: var(--topbar-height); left: 0; width: min(86vw, var(--sidebar-width)); transform: translateX(-102%); transition: transform .18s ease; box-shadow: var(--shadow); }
  .nav-open .sidebar { transform: translateX(0); }
  .nav-scrim { position: fixed; z-index: 45; inset: var(--topbar-height) 0 0; width: 100%; height: auto; border: 0; background: rgba(4,22,33,.48); }
  .nav-open .nav-scrim { display: block; }
  .content { grid-column: 1; }
  .metric-strip { grid-template-columns: repeat(3, 1fr); }
  .metric-strip > div { border-bottom: 1px solid var(--line); }
  .login-panel { background: var(--canvas); }
  .login-panel > div { color: var(--ink); }
  .login-panel > div p { color: var(--muted); }
}

@media (max-width: 700px) {
  :root { --topbar-height: 60px; }
  .topbar { padding: 0 12px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-copy strong { font-size: 14px; }
  .user-avatar, .user-copy { display: none; }
  .content { padding: 18px 12px 36px; }
  .page-head { align-items: flex-start; flex-direction: column; gap: 14px; }
  .page-head h1 { font-size: 26px; }
  .actions { width: 100%; }
  .actions .button, .actions form, .actions form .button { flex: 1 1 auto; }
  .button { min-height: 44px; }
  .two-column, .form-grid { grid-template-columns: 1fr; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric-strip > div { padding: 13px; }
  .panel { padding: 14px; }
  .table-wrap { border-radius: 6px; }
  th, td { padding: 10px; }
  .day-row { grid-template-columns: 80px minmax(0, 1fr); }
  .login-panel { min-height: calc(100vh - var(--topbar-height)); grid-template-columns: 1fr; gap: 20px; padding: 24px 16px; }
  .login-panel > div h1 { font-size: 32px; }
  .login-panel form { width: 100%; padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
