/* ============================================================
   排班系统 · 全局样式
   浅色主题，桌面优先，兼顾平板 / 手机
   ============================================================ */

:root {
    --bg: #f4f6fa;
    --card: #ffffff;
    --line: #e3e8f0;
    --line-strong: #cdd5e2;
    --text: #1a1f2b;
    --text-2: #4a5464;
    --muted: #8590a2;
    --primary: #1f6feb;
    --primary-dark: #1858bd;
    --primary-soft: #edf4ff;
    --danger: #d93a3a;
    --danger-soft: #fdeeee;
    --warn: #b8720a;
    --warn-soft: #fff6e8;
    --ok: #17845a;
    --ok-soft: #e9f8f1;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }

.muted { color: var(--muted); }

/* ============================ 顶部栏 ============================ */

.topbar {
    height: 60px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}

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

.brand h1 {
    font-size: 17px;
    letter-spacing: .5px;
}

.logo-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.btn-ghost {
    font-size: 13px;
    color: var(--text-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 14px;
    transition: .18s;
    background: #fff;
    cursor: pointer;
}
.btn-ghost:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ============================ 展示页 ============================ */

body.display-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
body.display-page .wrap {
    flex: 1 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.wrap {
    max-width: 1320px;
    margin: 0 auto;
    padding: 26px 28px 40px;
}

.week-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.nav-arrow {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-2);
    line-height: 1;
    padding-bottom: 3px;
    transition: .18s;
    flex: 0 0 auto;
}
.nav-arrow:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}

.week-title { flex: 1; min-width: 0; }
.week-title .range {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: .3px;
}
.week-title .sub {
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 2px;
}

.btn-today {
    font-size: 13px;
    padding: 7px 14px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    flex: 0 0 auto;
    transition: .18s;
}
.btn-today:hover { background: var(--primary-dark); }

.today-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.strip-label {
    font-size: 12.5px;
    color: var(--muted);
    letter-spacing: .5px;
    flex: 0 0 auto;
}

.chip {
    display: inline-block;
    font-size: 13px;
    padding: 3px 12px;
    border-radius: 999px;
    line-height: 1.5;
}
.chip-rest {
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 500;
}

.week-grid {
    display: flex;
    align-items: stretch;
    gap: 12px;
}

.day-card {
    flex: 1 1 0;
    min-width: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 12px 12px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    transition: .18s;
}

.day-card.is-weekend { background: #fbfcfe; }

.day-card.is-today {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-soft), var(--shadow);
}

.day-card.is-meeting {
    background: var(--warn-soft);
    border-color: #f0dcb8;
}

.day-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--line);
}

.day-weekday {
    font-size: 13px;
    color: var(--text-2);
    letter-spacing: .5px;
}
.is-today .day-weekday { color: var(--primary); font-weight: 600; }
.is-weekend .day-weekday { color: var(--muted); }

.day-date {
    font-size: 24px;
    font-weight: 600;
    line-height: 1;
    color: var(--text);
}
.is-today .day-date { color: var(--primary); }

.badge-meeting {
    margin-top: 10px;
    font-size: 11.5px;
    color: var(--warn);
    background: #fff;
    border: 1px solid #f0dcb8;
    border-radius: 6px;
    padding: 2px 8px;
    align-self: flex-start;
}

.day-body {
    flex: 1;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.person {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    background: var(--primary-soft);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-dark);
}

.person-tag {
    font-size: 10.5px;
    background: var(--primary);
    color: #fff;
    border-radius: 4px;
    padding: 0 5px;
    line-height: 16px;
    flex: 0 0 auto;
}

.empty-note {
    font-size: 12.5px;
    color: #b3bccb;
    padding: 6px 0;
}

.day-foot {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
    font-size: 11.5px;
    color: var(--muted);
    text-align: right;
}

/* 月度进度 */

.month-bar {
    margin-top: 22px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.month-bar-title {
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 14px;
    font-weight: 500;
}

.progress-list {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 34px;
}

.progress-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.pi-name { min-width: 56px; color: var(--text-2); }

.pi-bar {
    width: 120px;
    height: 6px;
    border-radius: 99px;
    background: #eef1f6;
    overflow: hidden;
    display: block;
}
.pi-bar i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #4d92f5, var(--primary));
    border-radius: 99px;
}

.pi-num { color: var(--muted); font-variant-numeric: tabular-nums; }

.page-foot {
    text-align: center;
    font-size: 12px;
    color: #a8b1c0;
    padding: 0 20px 30px;
}

/* ============================ 登录页 ============================ */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 32px 28px 26px;
    box-shadow: 0 8px 40px rgba(16, 24, 40, .07);
}

.login-card h2 {
    font-size: 20px;
    margin-bottom: 4px;
}
.login-card .hint {
    font-size: 12.5px;
    color: var(--muted);
    margin-bottom: 22px;
}

.field { margin-bottom: 14px; }
.field label {
    display: block;
    font-size: 12.5px;
    color: var(--text-2);
    margin-bottom: 6px;
}

input[type="text"], input[type="password"], input[type="number"], select {
    width: 100%;
    height: 40px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    padding: 0 12px;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: .18s;
    font-family: inherit;
}
input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.btn-primary {
    width: 100%;
    height: 42px;
    border: none;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    font-size: 14.5px;
    font-weight: 500;
    cursor: pointer;
    transition: .18s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.alert {
    font-size: 13px;
    border-radius: 8px;
    padding: 9px 12px;
    margin-bottom: 14px;
}
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }

/* ============================ 后台 ============================ */

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

.page-head h2 {
    font-size: 19px;
}

.month-picker {
    display: flex;
    align-items: center;
    gap: 8px;
}

.month-picker input[type="month"] {
    width: 158px;
    height: 38px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    padding: 0 12px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    outline: none;
}

.tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    height: 36px;
    padding: 0 15px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: #fff;
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: .18s;
    white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-solid {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-solid:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }

.stats-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 16px;
    font-size: 13px;
    color: var(--text-2);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
}
.stat-card b { color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums; }
.stat-card.is-warn { border-color: #f0dcb8; background: var(--warn-soft); }

/* ---- 排班网格 ---- */

.grid-wrap {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: auto;
    box-shadow: var(--shadow);
    max-height: calc(100vh - 260px);
}

.shift-grid {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    min-width: max-content;
    font-size: 13px;
}

.shift-grid th,
.shift-grid td {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.shift-grid thead th {
    position: sticky;
    top: 0;
    background: #fafbfd;
    z-index: 3;
    padding: 0;
    height: 52px;
    font-weight: 500;
    color: var(--text-2);
    vertical-align: middle;
}

.shift-grid thead th.col-name {
    left: 0;
    z-index: 5;
    min-width: 108px;
    padding: 0 12px;
    text-align: left;
    font-size: 13px;
}

.col-day {
    min-width: 34px;
    text-align: center;
    line-height: 1.25;
}
.col-day .cd-num {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.col-day .cd-wk {
    display: block;
    font-size: 10.5px;
    color: var(--muted);
}
.col-day.is-weekend { background: #f6f8fb; }
.col-day.is-weekend .cd-wk { color: #b0b9c8; }
.col-day.is-meeting { background: var(--warn-soft); }
.col-day.is-meeting .cd-num { color: var(--warn); }
.col-day.is-meeting .cd-wk { color: #c79a4f; }
.col-day.is-today { box-shadow: inset 0 -2px 0 var(--primary); }

.col-day .cd-cnt {
    display: block;
    font-size: 10px;
    line-height: 12px;
    min-height: 12px;
    padding-top: 4px;
    color: #9aa5b6;
}
.col-day .cd-cnt.is-full { color: var(--danger); font-weight: 600; }

.shift-grid tbody td.col-name {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 2;
    min-width: 108px;
    padding: 0 14px;
    text-align: left;
    font-weight: 500;
    border-right: 1px solid var(--line-strong);
}
.shift-grid tbody tr:hover td.col-name { background: #fafbfd; }

.name-cell {
    display: flex;
    align-items: center;
    gap: 7px;
}
.name-mutex {
    font-size: 9.5px;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0 4px;
    line-height: 15px;
}

.cell {
    height: 40px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: background .12s;
    position: relative;
}
.cell:hover { background: var(--primary-soft); }
.cell.is-meeting { background: #fdf9f3; cursor: not-allowed; }
.cell.is-meeting:hover { background: #fdf9f3; }
.cell.is-rest {
    background: var(--primary-soft);
}
.cell.is-rest::after {
    content: "休";
    display: inline-block;
    width: 24px;
    height: 24px;
    line-height: 24px;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
}
.cell.is-rest:hover { background: #e2edff; }
.cell.is-blocked { background: #fbfcfe; }

/* 拖动改期 */
.cell[draggable="true"] { cursor: grab; }
.cell[draggable="true"]:active { cursor: grabbing; }
.cell.is-dragging { opacity: .35; }
.cell.is-drop-target {
    background: #d8e8ff !important;
    box-shadow: inset 0 0 0 2px var(--primary);
}
.cell.is-drop-target::after {
    content: "放";
    display: inline-block;
    width: 24px;
    height: 24px;
    line-height: 24px;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    opacity: .75;
}

.col-total {
    position: sticky;
    right: 0;
    background: #fafbfd;
    z-index: 3;
    min-width: 80px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    padding: 0 6px;
    font-size: 11.5px;
}
.shift-grid tbody td.col-total {
    background: #fff;
    border-left: 1px solid var(--line-strong);
}

.total-num { font-weight: 600; color: var(--text); }
.total-num.is-full { color: var(--ok); }
.total-num.is-over { color: var(--danger); }
.total-quota { color: var(--muted); font-size: 11.5px; }

.legend {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--muted);
    margin-top: 12px;
    padding-left: 2px;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
    border: 1px solid var(--line);
}
.lg-rest { background: var(--primary); border-color: var(--primary); }
.lg-meeting { background: var(--warn-soft); border-color: #f0dcb8; }
.lg-weekend { background: #f6f8fb; }

/* 违规提示条 */

.audit-box {
    margin-top: 14px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--card);
    overflow: hidden;
}
.audit-head {
    padding: 10px 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fafbfd;
    border-bottom: 1px solid var(--line);
}
.audit-head.has-issue { background: var(--danger-soft); color: var(--danger); border-bottom-color: #f7d9d9; }
.audit-head.is-clean { background: var(--ok-soft); color: var(--ok); }
.audit-body { padding: 12px 16px; font-size: 13px; }
.audit-item { margin-bottom: 8px; }
.audit-item:last-child { margin-bottom: 0; }
.audit-item b { color: var(--danger); }
.audit-item ul { margin: 4px 0 0; padding-left: 18px; color: var(--text-2); }
.audit-item li { margin-bottom: 2px; }

/* ============================ 弹窗 ============================ */

.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(19, 26, 38, .38);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal-mask.show { display: flex; }

.modal {
    background: var(--card);
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(16, 24, 40, .2);
    overflow: hidden;
}
.modal-head {
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-head h3 { font-size: 16px; }
.modal-close {
    border: none;
    background: none;
    font-size: 20px;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot {
    padding: 14px 22px 18px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-row {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}
.form-row label {
    font-size: 13px;
    color: var(--text-2);
    text-align: right;
}
.form-row .tip {
    grid-column: 2;
    font-size: 11.5px;
    color: var(--muted);
    margin-top: -6px;
}

/* 员工列表 */

.staff-list { display: flex; flex-direction: column; gap: 8px; }
.staff-row {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
}
.staff-row.is-off { opacity: .5; }
.staff-row .sr-name { font-weight: 500; min-width: 68px; }
.staff-row .sr-meta { font-size: 12px; color: var(--muted); flex: 1; }
.staff-row .sr-ops { display: flex; gap: 6px; }
.staff-row .mini {
    font-size: 12px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 6px;
    padding: 3px 9px;
    cursor: pointer;
    color: var(--text-2);
}
.staff-row .mini:hover { border-color: var(--primary); color: var(--primary); }
.staff-row .mini.danger:hover { border-color: var(--danger); color: var(--danger); }

/* 提示条 toast */

.toast {
    position: fixed;
    left: 50%;
    bottom: 40px;
    transform: translate(-50%, 20px);
    background: #1f2937;
    color: #fff;
    font-size: 13.5px;
    padding: 11px 20px;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .2);
    opacity: 0;
    pointer-events: none;
    transition: .25s;
    z-index: 200;
    max-width: 88vw;
    text-align: center;
    line-height: 1.5;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: #b42318; }
.toast.is-ok { background: #15803d; }

/* ============================ 响应式 ============================ */

@media (max-width: 1000px) {
    .week-grid { overflow-x: auto; padding-bottom: 6px; }
    .day-card { flex: 0 0 132px; }
    .wrap { padding: 20px 16px 32px; }
    .topbar { padding: 0 16px; }
}

@media (max-width: 720px) {
    .day-card { flex: 0 0 118px; }
    .week-title .range { font-size: 17px; }
    .day-card { min-height: 150px; }
    .page-head { align-items: flex-start; }
    .tools { width: 100%; }
    .grid-wrap { max-height: none; }
    .modal { max-width: 100%; }
    .form-row { grid-template-columns: 1fr; gap: 4px; }
    .form-row label { text-align: left; }
}

@media (max-width: 420px) {
    .day-card { flex: 0 0 104px; }
}

/* 打印 */

@media print {
    .topbar, .btn-ghost, .nav-arrow, .btn-today, .page-foot, .tools, .legend { display: none !important; }
    body { background: #fff; }
    .grid-wrap { max-height: none; overflow: visible; border: none; box-shadow: none; }
    .shift-grid thead th { position: static; }
    .shift-grid tbody td.col-name { position: static; }
}
