:root {
    --blue: #1677ff;
    --blue-dark: #0958d9;
    --blue-soft: #eaf3ff;
    --teal: #13a8a8;
    --teal-soft: #e6fffb;
    --green: #22a06b;
    --orange: #e98b16;
    --red: #d84a4a;
    --purple: #7257d5;
    --ink: #172033;
    --muted: #6f7c91;
    --line: #e6ebf2;
    --surface: #ffffff;
    --canvas: #f4f7fb;
    --sidebar: 228px;
    --shadow: 0 10px 30px rgba(28, 52, 84, .07);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font: 14px/1.55 "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 80;
    width: var(--sidebar);
    padding: 22px 16px 18px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid var(--line);
}
.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 48px;
    padding: 0 8px;
    color: var(--ink);
    text-decoration: none;
}
.brand-mark {
    position: relative;
    width: 39px;
    height: 39px;
    flex: 0 0 39px;
    border-radius: 12px;
    background: linear-gradient(145deg, #2097ff, #0967e8);
    box-shadow: 0 8px 18px rgba(22, 119, 255, .24);
}
.brand-mark::before, .brand-mark::after {
    content: "";
    position: absolute;
    inset: 9px 17px;
    border-radius: 3px;
    background: #fff;
}
.brand-mark::after { inset: 17px 9px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .02em; }
.brand small { margin-top: 1px; color: #94a0b2; font-size: 11px; }

.side-nav { margin-top: 25px; display: flex; flex-direction: column; gap: 4px; }
.nav-label {
    margin: 16px 10px 5px;
    color: #a3adbb;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
}
.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 43px;
    padding: 0 12px;
    border-radius: 10px;
    color: #536176;
    text-decoration: none;
    font-weight: 600;
    transition: background .18s, color .18s, transform .18s;
}
.nav-link:hover { color: var(--blue); background: #f3f7fd; transform: translateX(2px); }
.nav-link.active { color: var(--blue-dark); background: var(--blue-soft); }
.nav-link.active::before {
    content: "";
    position: absolute;
    left: -16px;
    width: 3px;
    height: 22px;
    border-radius: 0 4px 4px 0;
    background: var(--blue);
}
.nav-icon { width: 21px; text-align: center; font-size: 18px; font-weight: 400; }
.sidebar-foot { margin-top: auto; padding: 14px 7px 0; border-top: 1px solid var(--line); }
.sidebar-help { display: flex; align-items: center; gap: 9px; color: #647187; }
.sidebar-help > span {
    display: grid; place-items: center; width: 30px; height: 30px;
    border-radius: 9px; background: #f0f4f9; font-weight: 800;
}
.sidebar-help strong, .sidebar-help small { display: block; }
.sidebar-help strong { color: #455267; font-size: 12px; }
.sidebar-help small { color: #9aa4b4; font-size: 10px; }
.system-state { display: block; margin-top: 13px; color: #8b96a7; font-size: 10px; }
.system-state i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #34b37b; box-shadow: 0 0 0 3px #e6f7ef; }

.app-shell { min-height: 100vh; padding-left: var(--sidebar); }
.topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    height: 76px;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: rgba(255,255,255,.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}
.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title h1 { margin: 0; font-size: 20px; line-height: 1.3; letter-spacing: -.02em; }
.topbar-title p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.today-label { color: #8390a4; font-size: 12px; white-space: nowrap; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 5px 9px; border-radius: 11px; text-decoration: none; }
.user-chip:hover { background: #f2f6fb; }
.avatar {
    display: grid; place-items: center; width: 35px; height: 35px; border-radius: 50%;
    background: linear-gradient(145deg, #def4ff, #dce9ff); color: var(--blue-dark); font-weight: 800;
}
.user-chip strong, .user-chip small { display: block; }
.user-chip strong { font-size: 12px; }
.user-chip small { color: #939dad; font-size: 10px; }
.logout-link { padding: 7px 9px; border-radius: 8px; color: #8290a3; font-size: 12px; text-decoration: none; }
.logout-link:hover { background: #fff1f0; color: var(--red); }
.mobile-menu { display: none; border: 0; background: transparent; color: #526076; font-size: 22px; cursor: pointer; }
.sidebar-scrim { display: none; }

.main-content { width: 100%; max-width: 1600px; margin: 0 auto; padding: 26px 28px 42px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.page-head p { margin: 5px 0 0; color: var(--muted); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.card {
    margin-bottom: 18px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 15px;
    box-shadow: var(--shadow);
}
.card > h2 { margin: 0 0 16px; color: var(--ink); font-size: 17px; }
.card > h3 { margin: 0 0 12px; font-size: 15px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 16px; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.welcome-card {
    position: relative;
    overflow: hidden;
    min-height: 190px;
    padding: 28px;
    color: #fff;
    background: linear-gradient(120deg, #116fe7, #1687ef 60%, #18a3c4);
    border: 0;
    box-shadow: 0 18px 38px rgba(17, 111, 231, .2);
}
.welcome-card::after {
    content: ""; position: absolute; right: -70px; top: -115px; width: 330px; height: 330px;
    border: 55px solid rgba(255,255,255,.08); border-radius: 50%;
}
.welcome-card::before {
    content: ""; position: absolute; right: 130px; bottom: -100px; width: 180px; height: 180px;
    border-radius: 50%; background: rgba(255,255,255,.07);
}
.welcome-card > * { position: relative; z-index: 1; }
.eyebrow { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; opacity: .9; }
.eyebrow::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #79f2cf; box-shadow: 0 0 0 4px rgba(121,242,207,.17); }
.welcome-card h2 { margin: 12px 0 5px; color: #fff; font-size: 28px; }
.welcome-card p { max-width: 610px; margin: 0; color: rgba(255,255,255,.79); }
.welcome-actions { display: flex; gap: 9px; margin-top: 22px; flex-wrap: wrap; }
.welcome-card .btn-light { color: var(--blue-dark); background: #fff; }
.welcome-card .btn-ghost { border-color: rgba(255,255,255,.4); color: #fff; background: rgba(255,255,255,.1); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .75fr); gap: 18px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.metric-card { padding: 18px; }
.metric-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.metric-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--blue-soft); color: var(--blue); font-size: 17px; }
.metric-card strong { display: block; margin-top: 13px; font-size: 25px; line-height: 1; }
.metric-card small { display: block; margin-top: 7px; color: #97a2b2; }
.period-list { display: grid; gap: 10px; }
.period-item { display: grid; grid-template-columns: minmax(150px, 1.4fr) minmax(190px, 1fr) auto; align-items: center; gap: 14px; padding: 13px 14px; border: 1px solid #edf0f5; border-radius: 11px; }
.period-item:hover { border-color: #cfe1fb; background: #fbfdff; }
.period-name strong, .period-name small { display: block; }
.period-name small, .period-dates { color: var(--muted); font-size: 12px; }
.quick-links { display: grid; gap: 9px; }
.quick-link { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; text-decoration: none; transition: .18s; }
.quick-link:hover { border-color: #bcd7fa; transform: translateY(-1px); box-shadow: 0 7px 18px rgba(39,94,151,.08); }
.quick-link > span:first-child { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 10px; background: var(--blue-soft); color: var(--blue); font-size: 17px; }
.quick-link strong, .quick-link small { display: block; }
.quick-link small { color: var(--muted); font-size: 11px; }
.quick-link b { margin-left: auto; color: #a0a9b7; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 36px; padding: 7px 15px; border: 1px solid transparent; border-radius: 9px;
    color: #fff; text-decoration: none; font-size: 13px; font-weight: 650; cursor: pointer;
    transition: filter .18s, transform .18s, box-shadow .18s;
}
.btn:hover { filter: brightness(.97); transform: translateY(-1px); }
.btn-primary { background: var(--blue); box-shadow: 0 6px 15px rgba(22,119,255,.18); }
.btn-success { background: var(--green); }
.btn-danger { background: var(--red); }
.btn-warning { color: #684100; background: #ffd666; }
.btn-secondary { background: #78879a; }
.btn-outline { color: #4f5f74; background: #fff; border-color: #d9e0e9; }
.btn-light { background: #fff; }
.btn-ghost { border-color: #d9e0e9; background: transparent; }
.btn-sm { min-height: 30px; padding: 4px 10px; border-radius: 7px; font-size: 12px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar-spacer { flex: 1; }
.field, select {
    min-height: 38px; padding: 7px 11px; color: #334259; background: #fff;
    border: 1px solid #dbe2eb; border-radius: 9px; outline: none;
}
.field:focus, select:focus, textarea:focus { border-color: #78adf4; box-shadow: 0 0 0 3px rgba(22,119,255,.09); }
.search-box { position: relative; min-width: 220px; }
.search-box::before { content: "⌕"; position: absolute; left: 11px; top: 7px; color: #8d98a8; font-size: 17px; }
.search-box input { width: 100%; padding-left: 34px; }

.table-wrap, .schedule-table-wrapper { overflow: auto; border: 1px solid var(--line); border-radius: 12px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: separate; border-spacing: 0; color: #344158; font-size: 12px; }
th, td { padding: 10px 9px; text-align: center; border: 0; border-right: 1px solid #edf0f4; border-bottom: 1px solid #edf0f4; }
th:last-child, td:last-child { border-right: 0; }
tr:last-child td { border-bottom: 0; }
th { position: sticky; top: 0; z-index: 4; color: #647187; background: #f7f9fc; font-size: 11px; font-weight: 700; }
tbody tr { background: #fff; }
tbody tr:nth-child(even) { background: #fcfdff; }
tbody tr:hover { background: #f7fbff; }
.schedule-table th:first-child, .schedule-table td:first-child { position: sticky; left: 0; z-index: 3; min-width: 72px; background: inherit; }
.schedule-table th:nth-child(2), .schedule-table td:nth-child(2) { position: sticky; left: 72px; z-index: 3; min-width: 92px; box-shadow: 7px 0 12px rgba(35,61,94,.045); background: inherit; }
.schedule-table thead th:first-child, .schedule-table thead th:nth-child(2) { z-index: 6; background: #f7f9fc; }
.weekend-head { background: #fff8f2 !important; color: #ad6919; }
.today-head { background: var(--blue-soft) !important; color: var(--blue-dark); }
.person-cell strong, .person-cell small { display: block; }
.person-cell small { color: #98a2b1; font-size: 10px; }

.shift-pill, .shift-tag {
    display: inline-flex; align-items: center; justify-content: center; gap: 3px;
    min-height: 25px; margin: 2px 1px; padding: 3px 7px; border: 0; border-radius: 7px;
    color: #096c69; background: var(--teal-soft); font-size: 11px; font-weight: 700;
}
.shift-pill.rest, .shift-tag.rest, .cell-rest .shift-pill { color: #6f7887; background: #f0f2f5; }
.shift-pill.night, .shift-tag.night { color: #9a5b08; background: #fff2d8; }
.shift-pill.inner, .shift-tag.inner { color: #1262b3; background: #e6f4ff; }
.shift-pill.secondary, .shift-tag.secondary { color: #665000; background: #fff4b8; }
.shift-pill.custom, .shift-tag.custom { color: #b23a3a; background: #fff0f0; }
.shift-tag.primary { color: #6e7787; background: #f3f5f7; cursor: not-allowed; }
.shift-tag.pending { border: 1px dashed currentColor; box-shadow: 0 0 0 2px rgba(22,119,255,.05); }
.shift-tag .del-btn { padding: 0 2px; color: currentColor; opacity: .65; font-size: 14px; cursor: pointer; }
.shift-tag .del-btn:hover { opacity: 1; }
.cell-half { color: #9a5b08; font-weight: 700; }
.cell-night { background: #fffaf0 !important; }
.cell-inner { background: #f2f8ff !important; }
.cell-secondary { background: #fffbea !important; }
.cell-custom { color: var(--red) !important; font-weight: 700; }

.status-badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 99px; font-size: 10px; font-weight: 800; letter-spacing: .02em; }
.status-DRAFT { color: #687386; background: #eef1f4; }
.status-REVIEW { color: #93620b; background: #fff3cd; }
.status-PUBLISHED { color: #1262b3; background: #e6f4ff; }
.status-SUBMITTED { color: #7a52b5; background: #f4edff; }
.status-APPROVED { color: #13704a; background: #e8f7ef; }
.status-RECALLED { color: #ad4e00; background: #fff1e8; }

.progress-banner { display: grid; grid-template-columns: auto minmax(160px, 1fr) auto; align-items: center; gap: 18px; margin-bottom: 16px; padding: 14px 16px; color: #235489; background: linear-gradient(90deg, #eef6ff, #f2fbff); border: 1px solid #d7eaff; border-radius: 12px; }
.progress-summary strong { font-size: 19px; }
.progress-summary small { display: block; color: #6b88a7; font-size: 11px; }
.progress-track { height: 8px; overflow: hidden; background: #dbe9f6; border-radius: 99px; }
.progress-track i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--blue), #25b3bb); border-radius: inherit; transition: width .35s; }
.progress-note { color: #7189a2; font-size: 11px; }
.edit-help { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.edit-help span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: var(--blue); background: var(--blue-soft); font-weight: 800; }
.pending-save-status { align-self: center; color: var(--muted); font-size: 11px; white-space: nowrap; }
.pending-save-status.has-pending { color: #ad6800; font-weight: 700; }
.btn:disabled { cursor: not-allowed; filter: grayscale(.25); opacity: .55; transform: none; }
.cell-td { min-width: 108px; padding: 5px; vertical-align: top; }
.cell-list { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1px; min-height: 34px; }
.add-shift-btn { min-width: 28px; min-height: 27px; padding: 2px 7px; color: #718096; background: #fff; border: 1px dashed #cbd5e1; border-radius: 7px; cursor: pointer; }
.add-shift-btn:hover { color: var(--blue); border-color: var(--blue); background: var(--blue-soft); }
.add-shift-btn.empty { width: 100%; }
.locked-cell { color: #9ca6b5; font-size: 11px; }

.drawer-overlay { position: fixed; inset: 0; z-index: 109; background: rgba(17,30,50,.26); opacity: 0; visibility: hidden; transition: .22s; }
.shift-drawer { position: fixed; z-index: 110; inset: 0 0 0 auto; width: min(410px, 94vw); padding: 22px; overflow: auto; background: #fff; box-shadow: -20px 0 50px rgba(20,43,70,.14); transform: translateX(105%); transition: transform .24s ease; }
.shift-drawer.open { transform: translateX(0); }
.drawer-overlay.open { opacity: 1; visibility: visible; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer-head h2 { margin: 0; font-size: 19px; }
.drawer-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.drawer-close { width: 34px; height: 34px; border: 0; border-radius: 9px; color: #66758a; background: #f1f4f7; font-size: 20px; cursor: pointer; }
.drawer-search { margin: 19px 0; }
.drawer-group { margin-top: 21px; }
.drawer-group-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px; }
.drawer-group-head h3 { margin: 0; font-size: 14px; }
.drawer-group-head small { color: #9aa5b4; }
.shift-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shift-option { min-height: 40px; padding: 7px 5px; color: #176d70; background: var(--teal-soft); border: 1px solid #bcebe5; border-radius: 9px; cursor: pointer; font-weight: 700; }
.shift-option:hover { border-color: var(--teal); transform: translateY(-1px); }
.shift-option.rest { color: #657083; background: #f3f5f7; border-color: #e1e5ea; }
.shift-option.public { color: #215fa9; background: #edf5ff; border-color: #d2e5fb; }
.shift-option[hidden] { display: none; }
.custom-shift { display: flex; gap: 8px; }
.custom-shift input { min-width: 0; flex: 1; }

.lock-banner, .info-banner { padding: 13px 15px; color: #815700; background: #fff8e6; border: 1px solid #ffe1a8; border-radius: 10px; }
.notes-box { margin-top: 15px; padding: 13px 15px; color: #785c16; background: #fffbea; border: 1px solid #f7e8aa; border-radius: 10px; }
.filter-btn { color: var(--blue); cursor: pointer; font-size: 10px; }
.filter-btn:hover { text-decoration: underline; }
.overlay { position: fixed; inset: 0; z-index: 120; background: rgba(16,30,48,.3); }
.rest-popup { position: fixed; z-index: 121; top: 50%; left: 50%; width: min(400px, 90vw); padding: 22px; background: #fff; border-radius: 14px; box-shadow: 0 22px 60px rgba(17,35,58,.22); transform: translate(-50%,-50%); }
.rest-popup h3 { margin: 0 0 11px; }
.rest-popup ul { margin: 0; padding: 0; list-style: none; }
.rest-popup li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.flash-stack { position: relative; z-index: 20; }
.flash { display: flex; align-items: center; gap: 9px; margin-bottom: 13px; padding: 11px 14px; color: #176445; background: #edf9f3; border: 1px solid #caeddc; border-radius: 10px; }
.flash > span { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; background: var(--green); font-size: 11px; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 28px; padding: 10px 18px; color: #fff; background: #26364b; border-radius: 9px; box-shadow: 0 12px 30px rgba(0,0,0,.18); opacity: 0; pointer-events: none; transform: translate(-50%, 15px); transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.auth-page { min-height: 100vh; background: linear-gradient(135deg, #f3f8ff 0%, #f9fbfd 52%, #eefaf9 100%); }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-content { width: 100%; }
.login-wrap { width: min(430px, 100%); margin: auto; }
.login-brand { margin-bottom: 20px; text-align: center; }
.login-brand .brand-mark { display: inline-block; width: 48px; height: 48px; margin-bottom: 10px; }
.login-brand h1 { margin: 0; font-size: 23px; }
.login-brand p { margin: 5px 0 0; color: var(--muted); }
.login-card { padding: 28px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; color: #506078; font-weight: 700; font-size: 12px; }
.form-group input, .form-group textarea, .form-group select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #dbe2eb; border-radius: 9px; outline: none; }
.login-note { margin: 15px 0 0; color: #8a96a7; font-size: 11px; text-align: center; }

@media (max-width: 1120px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .today-label { display: none; }
}
@media (max-width: 800px) {
    :root { --sidebar: 250px; }
    .sidebar { transform: translateX(-105%); box-shadow: 18px 0 45px rgba(19,39,63,.16); transition: transform .22s; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 70; border: 0; background: rgba(20,34,52,.28); opacity: 0; visibility: hidden; transition: .2s; }
    .sidebar-scrim.open { opacity: 1; visibility: visible; }
    .app-shell { padding-left: 0; }
    .mobile-menu { display: inline-block; }
    .topbar { height: 68px; padding: 0 15px; }
    .topbar-title p, .user-chip > span:last-child, .logout-link { display: none; }
    .main-content { padding: 18px 13px 32px; }
    .metric-grid { grid-template-columns: 1fr; }
    .period-item { grid-template-columns: 1fr auto; }
    .period-dates { grid-column: 1 / -1; grid-row: 2; }
    .page-head { flex-direction: column; }
    .page-actions { width: 100%; }
    .search-box { width: 100%; }
    .progress-banner { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 520px) {
    .topbar-title h1 { font-size: 17px; }
    .card { padding: 15px; border-radius: 12px; }
    .welcome-card { padding: 22px 19px; }
    .welcome-card h2 { font-size: 23px; }
    .welcome-actions .btn { flex: 1; }
    .period-item { display: flex; align-items: flex-start; flex-direction: column; }
    .period-item .page-actions { width: auto; }
    .shift-options { grid-template-columns: repeat(2, 1fr); }
    .topbar-actions { gap: 4px; }
    .avatar { width: 32px; height: 32px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
