:root {
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --faint: #9ca3af;
    --line: #e5e7eb;
    --input-line: #d1d5db;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --accent-soft: #eff6ff;
    --danger: #dc2626;
    --ok: #059669;
    --head: #f3f4f6;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

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

a {
    color: var(--accent);
    text-decoration: none;
}

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

.small {
    font-size: 12px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

.container > .card {
    padding: 20px;
}

.container > .card + .card {
    margin-top: 16px;
}

.card h2 {
    font-size: 16px;
    margin-bottom: 14px;
}

/* 登录 */
.login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
}

.login-card {
    width: 100%;
    max-width: 360px;
    padding: 32px 28px;
}

.login-card h1 {
    font-size: 22px;
}

.login-card > * + * {
    margin-top: 14px;
}

.login-card > .muted:first-of-type {
    margin-top: 2px;
}

/* 顶栏 */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    max-width: 1280px;
    height: 54px;
    margin: 0 auto;
    padding: 0 16px;
}

.brand {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.tabs {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
}

.tabs a {
    padding: 6px 12px;
    color: var(--muted);
    border-radius: 8px;
    white-space: nowrap;
}

.tabs a:hover {
    color: var(--text);
    background: var(--head);
}

.tabs a.active {
    color: var(--accent);
    font-weight: 600;
    background: var(--accent-soft);
}

.me {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.me #me-name {
    color: var(--text);
    font-weight: 600;
}

/* 表单控件 */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

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

input,
select,
textarea {
    width: 100%;
    font: inherit;
    color: inherit;
    background: #fff;
    border: 1px solid var(--input-line);
    border-radius: 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input,
select {
    height: 36px;
    padding: 0 10px;
}

input[type="checkbox"] {
    width: auto;
    height: auto;
}

textarea {
    display: block;
    padding: 8px 10px;
    line-height: 1.6;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 34px;
    padding: 0 14px;
    font: inherit;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--input-line);
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover {
    background: var(--head);
}

.btn.primary {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

.btn.primary:hover {
    background: var(--accent-dark);
}

.btn.danger {
    color: var(--danger);
}

.btn.small {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
}

.btn.block {
    width: 100%;
    height: 40px;
    font-size: 15px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.link {
    font: inherit;
    color: var(--accent);
    background: none;
    border: 0;
    cursor: pointer;
}

.form-error {
    color: var(--danger);
    font-size: 13px;
}

/* 工具条 */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.period {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0 6px;
    font-size: 16px;
}

.badge {
    padding: 1px 8px;
    font-size: 12px;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 999px;
}

.toolbar select.scope {
    width: auto;
    height: 34px;
}

.save-state {
    margin-left: auto;
    font-size: 12px;
    color: var(--muted);
}

.save-state.ok {
    color: var(--ok);
}

.save-state.error {
    color: var(--danger);
}

/* 报表表格 */
.table-wrap {
    overflow-x: auto;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.report-table th,
.report-table td {
    padding: 8px 10px;
    vertical-align: middle;
    border: 1px solid var(--line);
}

.report-table th {
    font-weight: 600;
    color: var(--muted);
    background: var(--head);
    white-space: nowrap;
}

.report-table td {
    white-space: pre-wrap;
    word-break: break-word;
}

.report-table .c-week {
    width: 104px;
    text-align: center;
    font-weight: 600;
}

.report-table .c-week small {
    display: block;
    font-weight: 600;
    color: #c00000;
}

.report-table .c-name {
    width: 88px;
    text-align: center;
}

.report-table .c-date {
    width: 86px;
    text-align: center;
    white-space: nowrap;
}

.report-table .c-wd {
    width: 56px;
    text-align: center;
}

.report-table .c-label {
    text-align: center;
    font-weight: 600;
    color: var(--muted);
}

.report-table .empty {
    padding: 28px;
    text-align: center;
    color: var(--muted);
}

.report-table.edit {
    min-width: 720px;
}

.report-table.edit td {
    padding: 4px;
}

.report-table.edit td.c-date,
.report-table.edit td.c-wd {
    padding: 8px 4px;
}

.report-table.edit textarea {
    min-height: 60px;
    border-color: transparent;
    resize: none;
    overflow: hidden;
}

.report-table.edit textarea:hover {
    border-color: var(--line);
}

.report-table.edit textarea:focus {
    border-color: var(--accent);
}

.report-table tr.weekend td.c-date,
.report-table tr.weekend td.c-wd {
    color: var(--faint);
}

.report-table tr.today td.c-date,
.report-table tr.today td.c-wd {
    color: var(--accent);
    font-weight: 700;
}

.next-plan {
    margin-top: 18px;
}

.next-plan h3 {
    margin-bottom: 8px;
    font-size: 14px;
}

.next-plan textarea {
    min-height: 96px;
}

/* 汇总与账号 */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 16px;
}

.filters .field {
    width: 180px;
}

.filters .field.kind {
    width: auto;
}

.segmented {
    display: inline-flex;
    padding: 2px;
    background: var(--head);
    border-radius: 8px;
}

.segmented button {
    height: 30px;
    padding: 0 14px;
    white-space: nowrap;
    font: inherit;
    color: var(--muted);
    background: none;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.segmented button.active {
    color: var(--text);
    font-weight: 600;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.report-title {
    margin-bottom: 10px;
    font-size: 16px;
    text-align: center;
}

.missing {
    margin-bottom: 12px;
    padding: 8px 12px;
    font-size: 13px;
    color: #b45309;
    background: #fffbeb;
    border-radius: 8px;
}

.notice {
    margin-bottom: 16px;
    padding: 12px 14px;
    color: #065f46;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 8px;
}

.notice code {
    padding: 1px 6px;
    font-family: Consolas, Menlo, monospace;
    font-size: 14px;
    background: #fff;
    border-radius: 4px;
}

.add-user {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 20px;
}

.password-input {
    display: flex;
    gap: 6px;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    white-space: nowrap;
}

.users-table {
    table-layout: auto;
}

.users-table td {
    white-space: nowrap;
}

.users-table .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    display: inline-block;
    padding: 0 8px;
    font-size: 12px;
    border-radius: 999px;
}

.tag.admin {
    color: var(--accent);
    background: var(--accent-soft);
}

.tag.off {
    color: var(--danger);
    background: #fef2f2;
}

.tag.on {
    color: var(--ok);
    background: #ecfdf5;
}

.narrow {
    max-width: 420px;
}

.narrow form > * + * {
    margin-top: 14px;
}

/* 周报表格 */
.hint {
    margin-bottom: 12px;
    padding: 8px 12px;
    font-size: 13px;
    color: #1e40af;
    background: var(--accent-soft);
    border-radius: 8px;
}

.weekly-sheet + .weekly-sheet {
    margin-top: 24px;
}

.weekly-form {
    width: 100%;
    min-width: 1060px;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 13px;
}

.weekly-form th,
.weekly-form td {
    padding: 6px 8px;
    border: 1px solid #a3a3a3;
    vertical-align: middle;
}

.weekly-form .label {
    font-weight: 700;
    text-align: center;
    background: #d9d9d9;
}

.weekly-form .value {
    text-align: center;
}

.weekly-form .week {
    font-weight: 700;
    text-align: center;
    background: #e2efda;
}

.weekly-form .heads th {
    padding: 10px 8px;
    font-size: 15px;
    text-align: center;
    background: #d9d9d9;
}

.weekly-form .heads em {
    font-style: normal;
    color: #ff0000;
}

.weekly-form .import {
    display: block;
    margin: 4px auto 0;
    font-size: 12px;
    font-weight: 400;
}

.weekly-form .content td {
    padding: 4px;
    vertical-align: top;
}

.weekly-form .content td.center {
    vertical-align: middle;
    text-align: center;
}

.weekly-form input,
.weekly-form textarea {
    border-color: transparent;
}

.weekly-form input {
    height: 30px;
    padding: 0 4px;
    text-align: center;
}

.weekly-form td.value {
    padding: 4px;
}

.weekly-form textarea {
    min-height: 420px;
    padding: 6px;
    font-size: 13px;
    line-height: 1.6;
    resize: none;
    overflow: hidden;
}

.weekly-form .center textarea {
    text-align: center;
}

.weekly-form input:hover,
.weekly-form textarea:hover {
    border-color: var(--line);
}

.weekly-form input:focus,
.weekly-form textarea:focus {
    border-color: var(--accent);
}

.cell-text,
.print-text {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}

.weekly-form .content .cell-text {
    min-height: 240px;
    padding: 6px;
}

.weekly-form .content td.center .cell-text {
    min-height: 0;
}

.print-text,
.print-only {
    display: none;
}

/* 月度考核表格 */
.assess-sheet + .assess-sheet {
    margin-top: 24px;
}

.assess-form {
    width: 100%;
    min-width: 1000px;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 13px;
}

.assess-form th,
.assess-form td {
    padding: 6px 8px;
    border: 1px solid #a3a3a3;
    vertical-align: middle;
}

.assess-form .label,
.assess-form .heads th {
    font-weight: 700;
    text-align: center;
    background: #d9d9d9;
}

.assess-form .heads th {
    padding: 8px;
    font-size: 14px;
}

.assess-form .value,
.assess-form .center {
    text-align: center;
}

.assess-form .strong {
    font-weight: 700;
}

.assess-form .goal-title {
    display: flex;
    align-items: center;
    font-weight: 700;
    color: #ff0000;
    white-space: nowrap;
}

.assess-form .goal-title input {
    flex: 1;
    min-width: 0;
    font-weight: 700;
    color: #ff0000;
    text-align: left;
}

.assess-form .goal .cell-text {
    margin-top: 2px;
}

.assess-form .goal-actions {
    display: flex;
    gap: 12px;
    margin-top: 6px;
    font-size: 12px;
}

.link.danger {
    color: var(--danger);
}

.assess-form .week-no {
    text-align: center;
}

.assess-form .week-no strong,
.assess-form .week-no small {
    display: block;
}

.assess-form .week-no small {
    font-size: 11px;
    color: var(--muted);
}

.assess-form .week-text,
.assess-form .result {
    padding: 3px;
}

.assess-form input,
.assess-form textarea {
    border-color: transparent;
}

.assess-form input {
    height: 30px;
    padding: 0 4px;
    text-align: center;
}

.assess-form textarea {
    min-height: 56px;
    padding: 4px 6px;
    font-size: 13px;
    line-height: 1.55;
    resize: none;
    overflow: hidden;
}

.assess-form .goal textarea,
.assess-form .result textarea {
    min-height: 120px;
}

.assess-form input:hover,
.assess-form textarea:hover {
    border-color: var(--line);
}

.assess-form input:focus,
.assess-form textarea:focus {
    border-color: var(--accent);
}

.assess-form .total td {
    padding: 10px;
    font-size: 16px;
    font-weight: 700;
    text-align: center;
}

.assess-form .sign th,
.assess-form .sign td {
    height: 48px;
}

.assess-form .add-row td {
    padding: 8px;
    text-align: center;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    z-index: 50;
    max-width: 90vw;
    padding: 10px 16px;
    color: #fff;
    background: #111827;
    border-radius: 8px;
    transform: translateX(-50%);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.toast.error {
    background: var(--danger);
}

@media (max-width: 760px) {
    .topbar-inner {
        flex-wrap: wrap;
        height: auto;
        gap: 6px 16px;
        padding: 10px 12px;
    }

    .tabs {
        order: 3;
        flex-basis: 100%;
    }

    .me {
        margin-left: auto;
    }

    .container {
        padding: 12px 8px 32px;
    }

    .container > .card {
        padding: 14px;
    }

    .add-user {
        grid-template-columns: 1fr;
    }
}

@page {
    size: A4 landscape;
    margin: 8mm;
}

@media print {
    body {
        background: #fff;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .hint,
    .import {
        display: none !important;
    }

    .table-wrap {
        overflow: visible;
    }

    .weekly-form {
        min-width: 0;
        font-size: 10px;
    }

    .weekly-form th,
    .weekly-form td {
        border-color: #666;
    }

    .weekly-form .heads th {
        font-size: 12px;
    }

    .weekly-form input,
    .weekly-form textarea {
        display: none;
    }

    .weekly-form .print-text {
        display: block;
    }

    .weekly-form .content td {
        height: 120mm;
    }

    .weekly-form .content .cell-text {
        min-height: 0;
    }

    .weekly-sheet {
        break-after: page;
        page-break-after: always;
    }

    .weekly-sheet:last-child {
        break-after: auto;
        page-break-after: auto;
    }

    .screen-only {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }

    .assess-form {
        min-width: 0;
        font-size: 10px;
    }

    .assess-form th,
    .assess-form td {
        border-color: #666;
    }

    .assess-form input {
        display: none;
    }

    .assess-form .print-text {
        display: block;
    }

    .assess-form .heads th,
    .assess-form .total td {
        font-size: 12px;
    }

    .assess-sheet {
        break-after: page;
        page-break-after: always;
    }

    .assess-sheet:last-child {
        break-after: auto;
        page-break-after: auto;
    }

    .topbar,
    .toolbar,
    .filters,
    .no-print,
    .toast {
        display: none !important;
    }

    .container {
        max-width: none;
        padding: 0;
    }

    .container > .card {
        padding: 0;
        border: 0;
        box-shadow: none;
    }

    .report-table {
        font-size: 11px;
    }

    .report-table th,
    .report-table td {
        border-color: #999;
    }
}
