:root {
    --ink: #18201f;
    --muted: #65706c;
    --line: #dfe5df;
    --paper: #f6f8f4;
    --panel: #ffffff;
    --green: #0f7b5f;
    --green-soft: #e5f4ee;
    --coral: #df6047;
    --amber: #b97808;
    --blue: #315f9f;
    --violet: #744f9c;
    --shadow: 0 18px 40px rgba(31, 43, 38, 0.08);
    --radius: 8px;
    --lane-label: 190px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background:
        linear-gradient(90deg, rgba(15, 123, 95, 0.05) 1px, transparent 1px),
        linear-gradient(rgba(24, 32, 31, 0.04) 1px, transparent 1px),
        var(--paper);
    background-size: 26px 26px;
    color: var(--ink);
    font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

svg {
    width: 16px;
    height: 16px;
}

.shell {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    background: rgba(246, 248, 244, 0.94);
    backdrop-filter: blur(16px);
}

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

.brand-mark {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 2px solid var(--ink);
    background: var(--green);
    color: #fff;
    font-weight: 800;
    box-shadow: 5px 5px 0 var(--ink);
}

.brand strong,
.brand span {
    display: block;
}

.brand strong {
    font-size: 18px;
    line-height: 1.1;
}

.brand span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

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

.date-field {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border: 1px solid var(--line);
    background: var(--panel);
}

.date-field span {
    color: var(--muted);
    font-size: 12px;
}

.date-field input,
.stack-form input,
.time-row input {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    outline: none;
}

.date-field input {
    border: 0;
}

.stack-form input,
.time-row input {
    width: 100%;
    padding: 10px 11px;
}

.date-field input:focus,
.stack-form input:focus,
.time-row input:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(15, 123, 95, 0.12);
}

.primary-btn,
.secondary-btn,
.dark-btn,
.icon-btn,
.mini-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 36px;
    border: 1px solid var(--ink);
    border-radius: 6px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.primary-btn {
    padding: 0 15px;
    background: var(--coral);
    color: #fff;
    font-weight: 700;
    box-shadow: 4px 4px 0 var(--ink);
}

.dark-btn {
    padding: 0 13px;
    background: var(--ink);
    color: #fff;
}

.secondary-btn,
.icon-btn,
.mini-btn {
    background: var(--panel);
    color: var(--ink);
}

.secondary-btn {
    padding: 0 12px;
}

.icon-btn {
    width: 38px;
}

.mini-btn {
    width: 28px;
    height: 28px;
    min-height: 28px;
    border-color: var(--line);
}

.primary-btn:hover,
.dark-btn:hover,
.secondary-btn:hover,
.icon-btn:hover,
.mini-btn:hover {
    transform: translateY(-1px);
}

.primary-btn:active,
.dark-btn:active,
.secondary-btn:active,
.icon-btn:active,
.mini-btn:active {
    transform: translateY(1px);
    box-shadow: none;
}

.workspace {
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    gap: 18px;
    padding: 18px 20px 24px;
}

.side-panel,
.board-panel {
    min-width: 0;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel-section,
.board-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow);
}

.panel-section {
    padding: 14px;
}

.section-title,
.board-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.section-title {
    align-items: center;
    margin-bottom: 12px;
}

.section-title h2,
.board-head h1 {
    margin: 0;
}

.section-title h2 {
    font-size: 15px;
}

.section-title span,
.muted-text {
    color: var(--muted);
    font-size: 12px;
}

.stack-form {
    display: grid;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--line);
}

.role-checks {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
}

.role-checks label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
}

.role-checks input {
    width: auto;
}

.time-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.time-row label {
    color: var(--muted);
    font-size: 12px;
}

.time-row input {
    margin-top: 4px;
}

.form-actions {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 8px;
}

.employee-list,
.room-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.employee-chip,
.room-item {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.employee-chip {
    cursor: grab;
}

.employee-chip.dragging {
    opacity: 0.52;
}

.chip-head,
.room-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chip-head strong,
.room-head strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.role-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.role-tag {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--green-soft);
    color: var(--green);
    font-size: 12px;
    font-weight: 700;
}

.role-tag.assistant {
    background: #eef2ff;
    color: #4152a3;
}

.role-tag.control {
    background: #fff1e7;
    color: #a44d16;
}

.room-time {
    color: var(--muted);
    font-size: 12px;
}

.item-actions {
    display: flex;
    gap: 6px;
    flex: none;
}

.board-panel {
    padding: 16px;
}

.board-head {
    align-items: flex-start;
    margin-bottom: 12px;
}

.board-head h1 {
    font-size: clamp(22px, 3vw, 34px);
    line-height: 1.05;
}

.board-head p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.board-tools {
    display: grid;
    justify-items: end;
    gap: 9px;
}

.view-switch {
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
    border: 1px solid var(--ink);
    border-radius: 6px;
    background: #fff;
}

.view-btn {
    min-width: 78px;
    min-height: 34px;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-weight: 800;
}

.view-btn.active {
    background: var(--ink);
    color: #fff;
}

.stats-strip {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.stat {
    min-width: 76px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.stat b,
.stat span {
    display: block;
}

.stat b {
    font-size: 17px;
}

.stat span {
    color: var(--muted);
    font-size: 11px;
}

.work-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.work-card {
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
}

.work-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.work-card-head strong,
.work-card-head span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.work-card-head span {
    color: var(--green);
    font-weight: 900;
}

.work-bar {
    height: 7px;
    margin: 8px 0;
    overflow: hidden;
    border-radius: 999px;
    background: #edf1ec;
}

.work-bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--green), var(--coral));
}

.work-roles {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.work-roles span {
    color: var(--muted);
    font-size: 11px;
}

.work-roles .anchor {
    color: var(--green);
}

.work-roles .assistant {
    color: var(--blue);
}

.work-roles .control {
    color: var(--amber);
}

.empty-state {
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    min-height: 360px;
    border: 1px dashed #b8c4be;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.65);
    text-align: center;
}

.empty-state strong {
    font-size: 18px;
}

.empty-state span {
    color: var(--muted);
}

.timeline-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.timeline-board {
    min-width: 840px;
}

.time-header {
    position: sticky;
    top: 0;
    z-index: 12;
    height: 42px;
    margin-left: var(--lane-label);
    border-bottom: 1px solid var(--line);
    background:
        repeating-linear-gradient(90deg, rgba(24, 32, 31, 0.12) 0 1px, transparent 1px 204px),
        #f4f7f2;
}

.time-tick {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(24, 32, 31, 0.18);
}

.time-tick b {
    position: absolute;
    top: 10px;
    left: 7px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.timeline-row {
    display: grid;
    grid-template-columns: var(--lane-label) minmax(0, 1fr);
    min-height: 96px;
    border-bottom: 1px solid var(--line);
}

.lane-label {
    position: sticky;
    left: 0;
    z-index: 8;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-width: var(--lane-label);
    padding: 11px 12px;
    border-right: 1px solid var(--line);
    background: #fbfcf9;
}

.lane-label strong,
.lane-label span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lane-label strong {
    font-size: 14px;
}

.lane-label span {
    color: var(--muted);
    font-size: 12px;
}

.lane-track {
    position: relative;
    min-height: 96px;
    background:
        repeating-linear-gradient(90deg, rgba(24, 32, 31, 0.08) 0 1px, transparent 1px 204px),
        repeating-linear-gradient(90deg, transparent 0 50px, rgba(24, 32, 31, 0.035) 50px 51px, transparent 51px 102px),
        #fff;
}

.shift-block {
    position: absolute;
    top: 11px;
    bottom: 11px;
    display: block;
    min-width: 28px;
    padding: 9px 36px 9px 11px;
    border: 1px solid rgba(24, 32, 31, 0.18);
    border-radius: 7px;
    color: var(--ink);
    background: var(--green-soft);
    box-shadow: 0 8px 16px rgba(24, 32, 31, 0.08);
}

.shift-block.anchor {
    background: #e4f5ee;
    border-color: rgba(15, 123, 95, 0.35);
}

.shift-block.assistant {
    background: #eef2ff;
    border-color: rgba(49, 95, 159, 0.3);
}

.shift-block.control {
    background: #fff1e4;
    border-color: rgba(185, 120, 8, 0.32);
}

.shift-block.warning {
    background: #fff9eb;
    border-color: #e1ad45;
}

.shift-block.locked {
    border-color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--ink);
}

.shift-block.drop-over {
    outline: 3px solid rgba(223, 96, 71, 0.22);
}

.block-main {
    min-width: 0;
}

.block-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 6px;
    min-width: 0;
}

.block-role {
    display: inline-flex;
    align-items: center;
    min-height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.62);
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
    vertical-align: top;
}

.block-name {
    display: block;
    min-width: 0;
    overflow: visible;
    color: var(--ink);
    font-size: 15px;
    font-weight: 900;
    line-height: 1.12;
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

.block-time {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.2;
    white-space: normal;
    word-break: keep-all;
}

.block-main em {
    display: block;
    margin-top: 1px;
    color: var(--amber);
    font-size: 10px;
    font-style: normal;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.block-lock {
    position: absolute;
    top: 7px;
    right: 7px;
    display: inline-grid;
    width: 26px;
    height: 26px;
    place-items: center;
    border: 1px solid rgba(24, 32, 31, 0.18);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.74);
    color: var(--ink);
}

.block-lock.locked {
    background: var(--ink);
    color: #fff;
}

.resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 10px;
    cursor: ew-resize;
}

.resize-handle.start {
    left: -4px;
}

.resize-handle.end {
    right: -4px;
}

.resize-handle::after {
    position: absolute;
    top: 10px;
    bottom: 10px;
    width: 2px;
    border-radius: 2px;
    background: rgba(24, 32, 31, 0.35);
    content: "";
}

.resize-handle.start::after {
    left: 4px;
}

.resize-handle.end::after {
    right: 4px;
}

body.resizing {
    cursor: ew-resize;
    user-select: none;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 40;
    max-width: min(420px, calc(100vw - 36px));
    padding: 12px 14px;
    border: 1px solid var(--ink);
    border-radius: 6px;
    background: var(--ink);
    color: #fff;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 1180px) {
    .workspace {
        grid-template-columns: 300px minmax(0, 1fr);
    }
}

@media (max-width: 980px) {
    .topbar,
    .board-head {
        flex-direction: column;
        align-items: stretch;
    }

    .workspace {
        display: flex;
        flex-direction: column;
        padding: 12px;
    }

    .top-actions,
    .stats-strip {
        justify-content: stretch;
    }

    .board-tools {
        justify-items: stretch;
    }

    .date-field,
    .primary-btn {
        flex: 1;
    }
}

@media (max-width: 640px) {
    :root {
        --lane-label: 132px;
    }

    .topbar {
        padding: 12px;
    }

    .top-actions {
        display: grid;
        grid-template-columns: 1fr 42px;
    }

    .primary-btn {
        grid-column: 1 / -1;
    }

    .role-checks,
    .form-actions,
    .time-row {
        grid-template-columns: 1fr;
    }

    .brand-mark {
        width: 36px;
        height: 36px;
        box-shadow: 4px 4px 0 var(--ink);
    }

    .board-panel,
    .panel-section {
        padding: 12px;
    }

    .stats-strip,
    .work-summary {
        grid-template-columns: 1fr;
    }

    .timeline-board {
        min-width: 760px;
    }
}
