/* TMC Policy Manager — shared admin + front-end styles */

.pol-wrap { --pol-accent: #760323; --pol-line: #dfe3e8; --pol-bg: #f6f7f9; color: #22262b; }
.pol-wrap * { box-sizing: border-box; }
.pol-frontend { max-width: 1180px; margin: 0 auto; padding: 16px; font-size: 15px; }

.pol-page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 12px 0 8px; }
.pol-page-head h1 { margin: 0; font-size: 22px; line-height: 1.3; }
.pol-page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pol-nav { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--pol-line); margin-bottom: 18px; }
.pol-nav-item { padding: 9px 14px; text-decoration: none; color: #555; border-bottom: 2px solid transparent; font-weight: 500; }
.pol-nav-item:hover { color: var(--pol-accent); }
.pol-nav-item.is-active { color: var(--pol-accent); border-bottom-color: var(--pol-accent); }
.pol-badge { background: #c0392b; color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; margin-left: 4px; }

.pol-card { background: #fff; border: 1px solid var(--pol-line); border-radius: 6px; padding: 18px; margin-bottom: 18px; }
.pol-card h3 { margin-top: 0; font-size: 16px; }
.pol-narrow { max-width: 640px; }

.pol-btn { display: inline-block; padding: 7px 14px; border: 1px solid var(--pol-line); background: #fff; border-radius: 4px; cursor: pointer; text-decoration: none; color: #22262b; font-size: 13px; line-height: 1.6; }
.pol-btn:hover { border-color: var(--pol-accent); color: var(--pol-accent); }
.pol-btn-primary { background: var(--pol-accent); border-color: var(--pol-accent); color: #fff; }
.pol-btn-primary:hover { opacity: .9; color: #fff; }
.pol-btn-danger { border-color: #c0392b; color: #c0392b; }
.pol-btn-small { padding: 4px 9px; font-size: 12px; }
.pol-btn[disabled] { opacity: .5; cursor: not-allowed; }

.pol-field { margin-bottom: 14px; }
.pol-field > label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
.pol-field input[type=text], .pol-field input[type=url], .pol-field input[type=email], .pol-field input[type=number],
.pol-field input[type=date], .pol-field input[type=search], .pol-field select, .pol-field textarea { width: 100%; padding: 7px 9px; border: 1px solid var(--pol-line); border-radius: 4px; font-size: 14px; background: #fff; }
.pol-field textarea { font-family: inherit; }
.pol-help { color: #6b7280; font-size: 12px; margin: 4px 0 0; }
.pol-inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 400 !important; }
.pol-inline-pair { display: flex; gap: 6px; }
.pol-checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.pol-checks label { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }
.pol-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.pol-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 18px; }
.pol-center { text-align: center; }
.pol-muted { color: #6b7280; }
.pol-nowrap { white-space: nowrap; }
.pol-overdue { color: #c0392b; font-weight: 600; }
.pol-empty { color: #6b7280; padding: 20px 0; }
.pol-scroll { overflow-x: auto; }

.pol-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.pol-filters input, .pol-filters select { padding: 6px 9px; border: 1px solid var(--pol-line); border-radius: 4px; }

.pol-table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13.5px; }
.pol-table th, .pol-table td { border: 1px solid var(--pol-line); padding: 8px 10px; text-align: left; vertical-align: top; }
.pol-table thead th { background: var(--pol-bg); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.pol-row-actions a { margin-right: 8px; font-size: 12.5px; }

.pol-chip { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11.5px; background: #eef1f5; color: #384150; white-space: nowrap; }
.pol-status-draft { background: #eef1f5; }
.pol-status-in_review { background: #fdf0d5; color: #8a6100; }
.pol-status-approved { background: #e3f1e6; color: #226b32; }
.pol-status-published { background: #dbeafe; color: #1d4ed8; }
.pol-status-rejected { background: #fde2e1; color: #9b2c2c; }
.pol-status-archived { background: #eceff1; color: #6b7280; }

.pol-notice { padding: 10px 14px; border-radius: 4px; margin: 10px 0 16px; border-left: 4px solid #999; background: #f4f6f8; }
.pol-notice-success { border-color: #2e7d32; background: #edf7ee; }
.pol-notice-warning { border-color: #e0a800; background: #fdf7e6; }
.pol-notice-error { border-color: #c0392b; background: #fdecea; }

/* Editor */
.pol-editor-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.pol-section { border: 1px solid var(--pol-line); border-radius: 5px; margin-bottom: 12px; background: #fff; }
.pol-section-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: var(--pol-bg); border-bottom: 1px solid var(--pol-line); }
.pol-section-type { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; font-weight: 600; }
.pol-section-tools a { text-decoration: none; padding: 0 5px; color: #6b7280; font-size: 15px; }
.pol-section-tools a:hover { color: var(--pol-accent); }
.pol-section-body { padding: 12px; }
.pol-section-body input[type=text], .pol-section-body textarea, .pol-section-body select { width: 100%; padding: 6px 8px; border: 1px solid var(--pol-line); border-radius: 4px; margin-bottom: 8px; font-size: 14px; font-family: inherit; }
.pol-item { display: flex; gap: 6px; align-items: center; }
.pol-item input { flex: 1; }
.pol-item-remove, .pol-row-remove, .pol-col-remove { text-decoration: none; color: #b0343c; padding: 0 4px; }
.pol-table-editor { width: 100%; border-collapse: collapse; }
.pol-table-editor th, .pol-table-editor td { border: 1px solid var(--pol-line); padding: 4px; }
.pol-table-editor th { background: var(--pol-bg); }
.pol-table-editor textarea { min-height: 42px; }
.pol-add-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; border-top: 1px dashed var(--pol-line); padding-top: 12px; }
.pol-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.pol-save-state { color: #2e7d32; font-size: 12px; }
.pol-list-plain { list-style: none; margin: 0; padding: 0; }
.pol-list-plain li { padding: 4px 0; border-bottom: 1px solid var(--pol-line); font-size: 13px; }

/* Reader */
.pol-readbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.pol-reader { background: #fff; border: 1px solid var(--pol-line); border-radius: 6px; padding: 32px 38px; }
.pol-reader .pol-document { max-width: 900px; margin: 0 auto; }
.pol-ackbox { background: #fdf7e6; border: 1px solid #f0d99a; border-radius: 6px; padding: 16px; margin-top: 16px; }

/* Diff */
.pol-diff-table td { font-size: 12.5px; }
.pol-diff-old { background: #fdecea; }
.pol-diff-new { background: #edf7ee; }
.pol-diff-head { font-size: 13px; color: #6b7280; }

/* Approvals */
.pol-approval-actions { display: flex; gap: 8px; margin: 10px 0; }
.pol-decision-comment { width: 100%; padding: 8px; border: 1px solid var(--pol-line); border-radius: 4px; }

/* Permissions */
.pol-matrix th { font-size: 12px; font-weight: 600; }
.pol-matrix tbody th { text-align: left; font-weight: 500; }
.pol-matrix code { font-size: 10.5px; color: #8892a0; }
.pol-grant { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--pol-line); border-radius: 4px; padding: 5px 9px; margin-bottom: 5px; font-size: 13px; }
.pol-grant-remove { text-decoration: none; color: #b0343c; }

/* Template editor */
.pol-template-code textarea { font-family: Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.5; width: 100%; }
.pol-tokens code { background: var(--pol-bg); padding: 1px 5px; border-radius: 3px; }

.pol-simple-list { list-style: none; padding: 0; }
.pol-simple-list li { padding: 6px 0; border-bottom: 1px solid var(--pol-line); }

@media (max-width: 960px) {
	.pol-editor-wrap { grid-template-columns: 1fr; }
	.pol-grid-2, .pol-grid-4 { grid-template-columns: 1fr; }
}

/* ---------------------------------------- Template background + palette */

.pol-subcard { border: 1px solid #e2e6ec; border-radius: 6px; padding: 14px 16px; margin: 16px 0; background: #fbfcfd; }
.pol-subcard h4 { margin: 0 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: #4a5568; }

.pol-bg-layout { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.pol-bg-preview { width: 150px; min-height: 200px; flex: 0 0 150px; border: 1px solid #d8dde4; background: #fff repeating-conic-gradient(#f2f4f7 0% 25%, #fff 0% 50%) 50% / 14px 14px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pol-bg-preview img { width: 100%; height: auto; display: block; }
.pol-bg-empty { font-size: 11px; color: #8b93a1; }
.pol-bg-controls { flex: 1 1 320px; min-width: 300px; }
.pol-bg-controls input[type="file"] { max-width: 100%; margin-bottom: 6px; }
.pol-bg-filename { font-size: 12px; color: #4a5568; margin-left: 8px; }
.pol-bg-state { font-size: 12px; color: #6b7280; margin-left: 8px; }

.pol-colour-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 16px; margin: 10px 0 18px; }
.pol-colour-field label { display: block; font-size: 11px; color: #4a5568; margin-bottom: 3px; }
.pol-colour-row { display: flex; align-items: center; gap: 6px; }
.pol-colour-row input[type="color"] { width: 34px; height: 30px; padding: 2px; border: 1px solid #d8dde4; border-radius: 4px; background: #fff; cursor: pointer; }
.pol-colour-row input[type="text"] { width: 92px; font-family: monospace; font-size: 12px; }

.pol-btn-link { background: none; border: none; color: #760323; text-decoration: underline; padding: 0 6px; cursor: pointer; }

/* ------------------------------------------------------- Rich text fields */

.pol-rich { border: 1px solid #ccd2da; border-radius: 5px; background: #fff; overflow: hidden; }
.pol-rich-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px 6px; background: #f5f7fa; border-bottom: 1px solid #e2e6ec; }
.pol-rich-btn { min-width: 28px; height: 26px; padding: 0 6px; border: 1px solid transparent; border-radius: 3px; background: transparent; color: #33415c; font-size: 13px; line-height: 1; cursor: pointer; }
.pol-rich-btn:hover { background: #e6ebf2; }
.pol-rich-btn.is-active { background: #dbe4f0; border-color: #b9c7db; }
.pol-rich-btn.is-bold { font-weight: 700; }
.pol-rich-btn.is-italic { font-style: italic; }
.pol-rich-btn.is-underline { text-decoration: underline; }

.pol-rich-area { min-height: 110px; padding: 10px 12px; font-size: 14px; line-height: 1.5; outline: none; }
.pol-rich-area:focus { box-shadow: inset 0 0 0 2px #dbe4f0; }
.pol-rich-area p { margin: 0 0 8px; }
.pol-rich-area p:last-child { margin-bottom: 0; }
.pol-rich-area ul, .pol-rich-area ol { margin: 0 0 8px 20px; padding: 0; }
.pol-rich-area:empty::before { content: attr(data-placeholder); color: #9aa3b2; }

.pol-rich-source { display: none; width: 100%; border: 0; border-top: 1px solid #e2e6ec; padding: 10px 12px; font-family: Menlo, Consolas, monospace; font-size: 12px; }
.pol-rich.is-source .pol-rich-area { display: none; }
.pol-rich.is-source .pol-rich-source { display: block; }
.pol-rich.is-locked .pol-rich-bar { display: none; }
.pol-rich.is-locked .pol-rich-area { background: #f7f8fa; color: #5a6475; }

/* --------------------------------------------------- Per-person permissions */

.pol-people td { vertical-align: top; }
.pol-pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; line-height: 18px; }
.pol-pill-allow { background: #e3f1e6; color: #24603a; }
.pol-pill-deny { background: #fbe6e6; color: #8a2222; }

.pol-grant-add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.pol-grant-add select { max-width: 220px; }

.pol-grant { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid #e2e6ec; border-radius: 4px; margin-bottom: 5px; background: #fff; font-size: 13px; }
.pol-grant.is-deny { border-left: 3px solid #c0392b; }
.pol-grant.is-allow { border-left: 3px solid #2e7d4f; }
.pol-grant-effect { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; min-width: 40px; }
.pol-grant-remove { margin-left: auto; text-decoration: none; color: #8a2222; }

.pol-effective-wrap { margin-top: 14px; }
.pol-effective-wrap summary { cursor: pointer; font-weight: 600; }
.pol-effective .pol-eff-mark { font-size: 15px; width: 40px; }
.pol-effective tr.is-yes .pol-eff-mark { color: #2e7d4f; }
.pol-effective tr.is-no .pol-eff-mark { color: #9aa3b2; }
.pol-effective tr.is-partial .pol-eff-mark { color: #b7791f; }
.pol-admin-warning { background: #fff8e5; border-left: 3px solid #e0b040; padding: 8px 12px; }

.pol-test-state { display: block; margin-top: 6px; font-size: 12px; color: #2e7d4f; }
.pol-test-state.is-error { color: #8a2222; }

.pol-snippet { margin-top: 4px; font-size: 12px; color: #5a6475; line-height: 1.45; }
.pol-snippet mark { background: #fdf0a8; padding: 0 2px; }
.pol-reindex-state { font-size: 12px; color: #4a5568; margin-left: 8px; }
.pol-token-help summary { cursor: pointer; font-weight: 600; margin: 6px 0 10px; }
.pol-dept-code-edit { text-transform: uppercase; font-family: monospace; }

/* ---- Policy structure: numbering preview, clauses, nested list items ---- */
.pol-section-number { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 3px; background: #f3e6e9; color: #760323; font-weight: 700; letter-spacing: 0; text-transform: none; }
.pol-clause-toggle { display: inline-block; margin-bottom: 6px; }
.pol-item-level-1 { padding-left: 28px; }
.pol-item-level-2 { padding-left: 56px; }
.pol-item-in, .pol-item-out { text-decoration: none; color: #4b5563; padding: 0 3px; font-weight: 700; }
.pol-item-in.is-disabled, .pol-item-out.is-disabled { color: #d1d5db; pointer-events: none; }

/* On-screen reading view mirrors the printed policy */
.pol-document-screen .pol-clause { position: relative; padding-left: 34px; margin-left: 22px; }
.pol-document-screen .pol-clause-no { position: absolute; left: 0; top: 0; }
.pol-document-screen .pol-closing th { text-align: left; padding-right: 14px; }
