/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:       #0a2d5e;
  --brand-light: #1a4a9f;
  --accent:      #e8a020;
  --bg:          #f0f4f8;
  --surface:     #ffffff;
  --border:      #dde3ec;
  --text:        #1a2235;
  --muted:       #64748b;
  --p1:          #dc2626;
  --p2:          #ea580c;
  --p3:          #ca8a04;
  --p4:          #16a34a;
  --p1-bg:       #fef2f2;
  --p2-bg:       #fff7ed;
  --p3-bg:       #fefce8;
  --p4-bg:       #f0fdf4;
  --radius:      10px;
  --shadow:      0 2px 8px rgba(10,45,94,0.08);
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  color: #fff;
  padding: 0 24px;
  box-shadow: 0 2px 12px rgba(10,45,94,0.25);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

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

.brand-badge {
  background: var(--accent);
  color: var(--brand);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 1px;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.header-sub {
  font-size: 12px;
  opacity: 0.75;
}

.header-version {
  font-size: 12px;
  opacity: 0.8;
  text-align: right;
  line-height: 1.5;
}

/* ── Tab Nav ── */
.tab-nav {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  display: flex;
  gap: 0;
  padding: 0 24px;
  max-width: 100%;
  position: sticky;
  top: 64px;
  z-index: 90;
  box-shadow: 0 1px 4px rgba(10,45,94,0.06);
}

.tab-btn {
  background: none;
  border: none;
  padding: 14px 22px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover { color: var(--brand); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ── Main / Panes ── */
main { max-width: 1200px; margin: 0 auto; padding: 24px 24px 48px; }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.pane-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--brand);
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Playbook Section Blocks ── */
.section-block {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.section-num {
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  min-width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.section-body { flex: 1; }

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 10px;
}

/* ── Priority Badges (Playbook Section 4) ── */
.priority-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.priority-badge {
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 4px solid;
}

.priority-badge.p1 { background: var(--p1-bg); border-color: var(--p1); }
.priority-badge.p2 { background: var(--p2-bg); border-color: var(--p2); }
.priority-badge.p3 { background: var(--p3-bg); border-color: var(--p3); }
.priority-badge.p4 { background: var(--p4-bg); border-color: var(--p4); }

.p-code {
  font-weight: 800;
  font-size: 18px;
  min-width: 32px;
}
.p1 .p-code { color: var(--p1); }
.p2 .p-code { color: var(--p2); }
.p3 .p-code { color: var(--p3); }
.p4 .p-code { color: var(--p4); }

/* ── Roles Grid (Section 5) ── */
.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 8px;
}

.role-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--bg);
}

.role-level {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--brand-light);
  margin-bottom: 4px;
}

.role-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 8px;
}

.role-card ul {
  padding-left: 16px;
  color: var(--muted);
  font-size: 13px;
}

.role-card ul li { margin-bottom: 2px; }

/* ── Process Flow (Section 6) ── */
.process-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.flow-step {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
}

.step-num {
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.flow-arrow { color: var(--muted); font-size: 18px; }

/* ── SLA Table (Section 7) ── */
.sla-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 13px;
}

.sla-table th {
  background: var(--brand);
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
}

.sla-table th:first-child { border-radius: 6px 0 0 0; }
.sla-table th:last-child  { border-radius: 0 6px 0 0; }

.sla-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.sla-table tr:last-child td { border-bottom: none; }
.sla-table tr:nth-child(even) td { background: var(--bg); }

/* ── Priority/Status Tags ── */
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.tag.p1, .priority-tag.p1 { background: var(--p1-bg); color: var(--p1); border: 1px solid var(--p1); }
.tag.p2, .priority-tag.p2 { background: var(--p2-bg); color: var(--p2); border: 1px solid var(--p2); }
.tag.p3, .priority-tag.p3 { background: var(--p3-bg); color: var(--p3); border: 1px solid var(--p3); }
.tag.p4, .priority-tag.p4 { background: var(--p4-bg); color: var(--p4); border: 1px solid var(--p4); }

.status-tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.status-open       { background: #eff6ff; color: #1d4ed8; border: 1px solid #93c5fd; }
.status-in-progress{ background: #f0fdf4; color: #15803d; border: 1px solid #86efac; }
.status-escalated  { background: #fff7ed; color: #c2410c; border: 1px solid #fdba74; }
.status-resolved   { background: #f0fdf4; color: #166534; border: 1px solid #4ade80; }
.status-closed     { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }

/* ── Bullet List (Section 8) ── */
.bullet-list {
  padding-left: 20px;
  color: var(--text);
  font-size: 14px;
}

.bullet-list li { margin-bottom: 6px; }

/* ── Metrics Grid (Section 11) ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.metric-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
}

/* ── Document Info ── */
.doc-info-grid { display: flex; flex-direction: column; gap: 8px; }

.doc-info-row {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg);
}

.doc-info-row:last-child { border-bottom: none; }

.doc-label {
  font-weight: 600;
  color: var(--muted);
  min-width: 200px;
  font-size: 13px;
}

/* ── Form Styles ── */
.form-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin: 20px 0 12px;
}

.form-section-label:first-child { margin-top: 0; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.req { color: var(--p1); }

.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(26,74,159,0.1);
}

.form-group textarea { resize: vertical; min-height: 72px; }

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ── Buttons ── */
.btn-primary {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 9px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover { background: var(--brand-light); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.btn-secondary:hover { border-color: var(--brand); color: var(--brand); background: #f0f4f8; }

.btn-outline {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--brand);
  padding: 9px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-outline:hover { background: rgba(10,45,94,0.06); }

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
}

.btn-danger {
  background: var(--surface);
  color: var(--p1);
  border: 1px solid var(--p1);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-danger:hover { background: var(--p1-bg); }

/* ── Filter Bar (Records) ── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filter-bar input,
.filter-bar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
}

.filter-bar input { flex: 1; min-width: 200px; }
.filter-bar select { min-width: 150px; }

.filter-bar input:focus,
.filter-bar select:focus {
  outline: none;
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(26,74,159,0.1);
}

.records-count {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

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

/* ── Records Table ── */
.table-wrap { overflow-x: auto; }

#recordsTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

#recordsTable th {
  background: var(--brand);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  position: sticky;
  top: 0;
}

#recordsTable th:first-child { border-radius: 6px 0 0 0; }
#recordsTable th:last-child  { border-radius: 0 6px 0 0; }

#recordsTable td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#recordsTable tr:last-child td { border-bottom: none; }
#recordsTable tr:hover td { background: #f8fafd; }

.actions-cell { display: flex; gap: 5px; }

.no-records {
  text-align: center;
  color: var(--muted);
  padding: 32px 0;
  font-size: 14px;
}

.no-records a { color: var(--brand); text-decoration: none; font-weight: 600; }

/* ── Modal ── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10,45,94,0.45);
  backdrop-filter: blur(2px);
}

.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(10,45,94,0.25);
  width: min(700px, 95vw);
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--brand);
  color: #fff;
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.modal-close:hover { opacity: 1; }

.modal-body { padding: 20px 24px; overflow-y: auto; }

.modal-field { margin-bottom: 12px; }
.modal-field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 3px;
}
.modal-field-value { font-size: 14px; color: var(--text); }
.modal-field-value.multiline { white-space: pre-wrap; word-break: break-word; }

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
}

.modal-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin: 16px 0 10px;
  grid-column: 1 / -1;
}

/* ── Toasts ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--brand);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(10,45,94,0.3);
  z-index: 300;
  transform: translateY(80px);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: #166534; }
.toast.error   { background: var(--p1); }

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: 1; }
  .modal-grid { grid-template-columns: 1fr; }
  .modal-section-title { grid-column: 1; }
  .priority-grid, .roles-grid { grid-template-columns: 1fr; }
  .process-flow { flex-direction: column; }
  .flow-arrow { transform: rotate(90deg); }
  .tab-btn { padding: 12px 14px; font-size: 13px; }
  .pane-header { flex-direction: column; align-items: flex-start; }
}
