:root {
    color-scheme: light;
    --bg: #f6f7fb;
    --panel: #ffffff;
    --text: #18202f;
    --muted: #6b7280;
    --line: #d8dde8;
    --accent: #2468f2;
    --accent-pressed: #174fc5;
    --danger: #c2410c;
    --ok: #0f766e;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.policy-shell {
    width: min(760px, 100%);
    margin: 0 auto;
    padding: 28px 18px 44px;
}

.policy-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
    padding: 24px;
}

.policy-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    border-bottom: 1px solid var(--line);
    padding-bottom: 18px;
    margin-bottom: 22px;
}

.policy-meta {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 13px;
}

h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.2;
    letter-spacing: 0;
}

.policy-user {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
    padding-top: 6px;
}

.policy-form {
    display: grid;
    gap: 16px;
}

.policy-workbench {
    display: grid;
    gap: 14px;
    margin-bottom: 22px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.policy-workbench[hidden] {
    display: none;
}

.policy-workbench-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.policy-workbench h2,
.policy-workbench h3,
.policy-workbench p {
    margin: 0;
    letter-spacing: 0;
}

.policy-workbench h2 {
    font-size: 18px;
    line-height: 1.25;
}

.policy-workbench h3 {
    margin-bottom: 8px;
    font-size: 15px;
    line-height: 1.3;
}

.policy-workbench p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.policy-list-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.policy-record-list {
    display: grid;
    gap: 8px;
}

.policy-record-item {
    display: grid;
    gap: 7px;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fbfcff;
}

.policy-record-title {
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    overflow-wrap: anywhere;
    text-decoration: none;
}

.policy-record-title:hover {
    color: var(--accent);
}

.policy-record-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.policy-status-pending {
    color: #b91c1c;
    font-weight: 700;
}

.policy-record-action {
    justify-self: start;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.policy-empty {
    border: 1px dashed var(--line);
    border-radius: 7px;
    padding: 12px;
    color: var(--muted);
    background: #fafafa;
    font-size: 13px;
}

.policy-secondary-button {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    padding: 8px 12px;
    font-size: 13px;
}

.policy-secondary-button:hover {
    border-color: var(--accent);
    background: #f8fbff;
}

label {
    display: grid;
    gap: 7px;
    font-size: 14px;
    font-weight: 600;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 11px 12px;
    color: var(--text);
    background: #fff;
    font: inherit;
    font-weight: 400;
}

textarea {
    resize: vertical;
    min-height: 88px;
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid rgba(36, 104, 242, 0.16);
    border-color: var(--accent);
}

input[type="file"] {
    padding: 9px 10px;
    background: #fbfcff;
}

.policy-dropzone {
    border: 1px dashed #b7c4df;
    border-radius: 8px;
    padding: 12px;
    background: #f8fbff;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.policy-dropzone:hover,
.policy-dropzone:focus,
.policy-dropzone.dragging {
    border-color: var(--accent);
    background: #eef6ff;
    outline: none;
}

.policy-dropzone input[type="file"] {
    padding: 0;
    border: 0;
    background: transparent;
}

.policy-dropzone strong {
    display: block;
    margin-top: 8px;
    color: var(--text);
    font-size: 14px;
}

.policy-dropzone em {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-style: normal;
    font-size: 12px;
}

.policy-file-list {
    display: grid;
    gap: 6px;
    margin-top: 10px;
}

.policy-file-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 9px;
    border-radius: 7px;
    background: #eef2ff;
    color: #1e3a8a;
    font-size: 12px;
}

.policy-file-chip span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.policy-note {
    border: 1px solid #dbeafe;
    color: #1e3a8a;
    background: #eff6ff;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.5;
}

button {
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    padding: 12px 18px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

button:hover {
    background: var(--accent-pressed);
}

.policy-secondary-button:hover {
    color: var(--accent);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.policy-result {
    margin-top: 18px;
    border-radius: 6px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.policy-result.ok {
    border: 1px solid rgba(15, 118, 110, 0.28);
    background: #ecfdf5;
    color: var(--ok);
}

.policy-result.error {
    border: 1px solid rgba(194, 65, 12, 0.28);
    background: #fff7ed;
    color: var(--danger);
}

.policy-modal[hidden] {
    display: none;
}

.policy-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 20px;
}

.policy-modal-open {
    overflow: hidden;
}

.policy-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.46);
}

.policy-modal-card {
    position: relative;
    width: min(420px, 100%);
    border: 1px solid rgba(15, 118, 110, 0.22);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.2);
    padding: 22px;
}

.policy-modal-card h2 {
    margin: 0;
    color: var(--ok);
    font-size: 22px;
    line-height: 1.25;
    letter-spacing: 0;
}

.policy-modal-card p {
    margin: 12px 0 18px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.policy-modal-card button {
    width: 100%;
}

.stage-section {
    display: grid;
    gap: 12px;
    margin-top: 22px;
}

.stage-section h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.3;
    letter-spacing: 0;
}

.revision-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.revision-history-header .policy-secondary-button {
    width: auto;
    padding: 8px 0;
}

.revision-latest,
.revision-history-list {
    display: grid;
    gap: 10px;
}

.revision-history-list[hidden] {
    display: none;
}

.revision-card {
    display: grid;
    gap: 7px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fbfcff;
    padding: 11px 12px;
}

.revision-card h3,
.revision-card p {
    margin: 0;
    letter-spacing: 0;
}

.revision-card h3 {
    font-size: 15px;
    line-height: 1.35;
}

.revision-meta {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.revision-fields {
    display: grid;
    grid-template-columns: minmax(78px, 120px) 1fr;
    gap: 6px 10px;
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
}

.revision-fields dt,
.revision-fields dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.revision-fields dt {
    color: var(--muted);
}

.revision-content {
    margin: 0;
    max-height: 180px;
    overflow: auto;
    border-radius: 6px;
    background: #f3f6fb;
    padding: 9px 10px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.stage-fields {
    display: grid;
    grid-template-columns: minmax(120px, 180px) 1fr;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    margin: 0;
}

.stage-fields dt,
.stage-fields dd {
    min-width: 0;
    margin: 0;
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    line-height: 1.5;
}

.stage-fields dt {
    background: #f8fafc;
    color: var(--muted);
    font-weight: 700;
}

.stage-fields dd {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.stage-fields dt:last-of-type,
.stage-fields dd:last-of-type {
    border-bottom: 0;
}

.attachment-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.attachment-card {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 10px;
    align-items: center;
    min-width: 0;
    min-height: 58px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    background: #fff;
}

.attachment-card:hover {
    border-color: var(--accent);
}

.attachment-card.image {
    grid-template-columns: 72px 1fr;
}

.attachment-card img {
    width: 72px;
    height: 54px;
    object-fit: cover;
    border-radius: 4px;
    background: #f1f5f9;
}

@media (max-width: 640px) {
    .policy-list-grid {
        grid-template-columns: 1fr;
    }

    .policy-workbench-header {
        align-items: stretch;
        flex-direction: column;
    }

    .policy-secondary-button {
        width: 100%;
    }
}

.attachment-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 4px;
    background: #eef2ff;
    color: #1d4ed8;
    font-size: 11px;
    font-weight: 800;
}

.attachment-meta {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.attachment-meta strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.attachment-meta small {
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 640px) {
    .policy-shell {
        padding: 0;
    }

    .policy-panel {
        min-height: 100vh;
        border-radius: 0;
        border: 0;
        padding: 20px 16px 32px;
        box-shadow: none;
    }

    .policy-header {
        display: grid;
    }

    .policy-user {
        white-space: normal;
        padding-top: 0;
    }

    .stage-fields {
        grid-template-columns: 1fr;
    }

    .stage-fields dt {
        border-bottom: 0;
        padding-bottom: 4px;
    }

    .stage-fields dd {
        padding-top: 4px;
    }
}
