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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f3f4f6;
  color: #111827;
  min-height: 100vh;
}

header {
  background: #1d4ed8;
  color: white;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 { font-size: 1.25rem; font-weight: 600; }

#user-info { font-size: 0.875rem; opacity: 0.9; }

#sign-out {
  background: none;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 4px;
  color: white;
  font-size: 0.8125rem;
  padding: 0.25rem 0.625rem;
  cursor: pointer;
}
#sign-out:hover { background: rgba(255,255,255,0.1); }

main {
  max-width: 1040px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

#status {
  text-align: center;
  padding: 4rem 0;
  color: #6b7280;
}

#error {
  display: none;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  color: #b91c1c;
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

#signed-out {
  display: none;
  text-align: center;
  padding: 4rem 0;
  color: #6b7280;
}
#signed-out p { margin-bottom: 1.25rem; }
#app { display: none; }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 1.5rem;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 0.625rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: color 0.1s, border-color 0.1s;
}
.tab-btn:hover { color: #1d4ed8; }
.tab-btn.active {
  color: #1d4ed8;
  border-bottom-color: #1d4ed8;
}

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

/* ── Cards ── */
.card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; }
.card p { font-size: 0.875rem; color: #6b7280; margin-bottom: 0.5rem; }

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 500;
  color: #6b7280;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
td {
  padding: 0.75rem;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

.table-wrap {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.empty-state {
  text-align: center;
  padding: 3rem 0;
  color: #9ca3af;
  font-size: 0.9375rem;
}

/* ── Status badges ── */
.badge {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-PENDING      { background: #fef9c3; color: #854d0e; }
.badge-APPROVED,
.badge-PROVISIONED  { background: #dcfce7; color: #166534; }
.badge-PROVISIONING { background: #fef3c7; color: #92400e; }
.badge-DENIED       { background: #fee2e2; color: #991b1b; }
.badge-EXPIRED      { background: #f3f4f6; color: #6b7280; }
.badge-REVOKED      { background: #fff7ed; color: #9a3412; }

.wh-warn-btn {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0.2rem;
  vertical-align: middle;
  line-height: 1;
}
.wh-warn-btn:hover { color: #991b1b; }

.auto-tag {
  display: inline-block;
  margin-left: 0.4em;
  padding: 0.1em 0.45em;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  background: #dbeafe;
  color: #1e40af;
  vertical-align: middle;
}

/* ── Form ── */
.form-group {
  margin-bottom: 1.25rem;
}
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.375rem;
}
input[type="number"], textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9375rem;
  color: #111827;
  background: white;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="number"]:focus, textarea:focus {
  border-color: #1d4ed8;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}
textarea { resize: vertical; min-height: 100px; }
.hint { font-size: 0.8125rem; color: #6b7280; margin-top: 0.25rem; }
.req-star { color: #dc2626; margin-left: 0.1em; }
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: normal;
  font-size: 0.9375rem;
  color: #374151;
}
.checkbox-label input[type="checkbox"] {
  margin-top: 0.2em;
  width: auto;
  flex-shrink: 0;
  accent-color: #1d4ed8;
}
.submit-notice {
  font-size: 0.8125rem;
  color: #6b7280;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}
.section-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}
a.jira-link { color: #1d4ed8; text-decoration: none; }
a.jira-link:hover { text-decoration: underline; }

/* ── Entitlement picker ── */
#ent-search {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px 6px 0 0;
  border-bottom: none;
  font-size: 0.9375rem;
  color: #111827;
  background: white;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#ent-search:focus {
  border-color: #1d4ed8;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
  z-index: 1;
  position: relative;
}
.ent-picker {
  border: 1px solid #d1d5db;
  border-radius: 0 0 6px 6px;
  max-height: 300px;
  overflow-y: auto;
  background: white;
}
.ent-row {
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.1s;
}
.ent-row:last-child { border-bottom: none; }
.ent-row:hover { background: #f0f4ff; }
.ent-row.selected { background: #dbeafe; }
.ent-row-name { font-size: 0.875rem; font-weight: 500; color: #111827; }
.ent-row-desc { font-size: 0.8125rem; color: #6b7280; margin-top: 0.15em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ent-row-meta { font-size: 0.75rem; color: #9ca3af; margin-top: 0.15em; }
.ent-empty { padding: 1.5rem; text-align: center; color: #9ca3af; font-size: 0.875rem; }
.ent-group-header {
  padding: 0.35rem 0.75rem;
  background: #f3f4f6;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 1;
}
.ent-row.grouped { padding-left: 1.25rem; }
.ent-selected-info {
  font-size: 0.8125rem;
  color: #1e40af;
  margin-top: 0.375rem;
  min-height: 1.1em;
}

.btn {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s;
}
.btn-primary { background: #1d4ed8; color: white; }
.btn-primary:hover { background: #1e40af; }
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }
.btn-success { background: #16a34a; color: white; font-size: 0.8125rem; padding: 0.3rem 0.75rem; }
.btn-success:hover { background: #15803d; }
.btn-danger  { background: #dc2626; color: white; font-size: 0.8125rem; padding: 0.3rem 0.75rem; }
.btn-danger:hover  { background: #b91c1c; }

#form-feedback {
  display: none;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
}
#form-feedback.success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
#form-feedback.error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ── Modals ── */
#webhook-modal, #approve-modal, #deny-modal, #detail-modal, #delegation-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#webhook-modal.open, #approve-modal.open, #deny-modal.open, #detail-modal.open, #delegation-modal.open { display: flex; }

.webhook-pre {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-family: monospace;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 160px;
  overflow-y: auto;
  margin-top: 0.25rem;
}
.webhook-ok { color: #166534; font-weight: 600; }
.webhook-fail { color: #991b1b; font-weight: 600; }
.modal-box {
  background: white;
  border-radius: 10px;
  padding: 1.5rem;
  width: 420px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-box h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
.btn-secondary { background: #f3f4f6; color: #374151; font-size: 0.875rem; padding: 0.4rem 0.9rem; }
.btn-secondary:hover { background: #e5e7eb; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.section-header h2 { font-size: 1.0625rem; font-weight: 600; }
.toggle-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.875rem; color: #6b7280; cursor: pointer; margin-left: auto; margin-right: 0.75rem; }

.refresh-btn {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8125rem;
  color: #6b7280;
  cursor: pointer;
}
.refresh-btn:hover { background: #f9fafb; color: #374151; }

/* ── Admin tab filter bar ── */
.filter-bar {
  display: flex;
  gap: 0.625rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
  padding: 0.375rem 0.625rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #374151;
  background: white;
  outline: none;
}
.filter-bar select:focus, .filter-bar input:focus {
  border-color: #1d4ed8;
  box-shadow: 0 0 0 3px rgba(29,78,216,0.1);
}
.filter-bar input { flex: 1; min-width: 180px; }

/* ── Pagination controls ── */
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.75rem 0.25rem 0;
  font-size: 0.875rem;
  color: #6b7280;
}
.pager-btn {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8125rem;
  color: #374151;
  cursor: pointer;
}
.pager-btn:hover:not(:disabled) { background: #f9fafb; }
.pager-btn:disabled { color: #9ca3af; cursor: not-allowed; border-color: #e5e7eb; }

/* ── Request detail modal ── */
.detail-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.375rem 1rem;
  font-size: 0.875rem;
}
.detail-grid dt { color: #6b7280; font-weight: 500; white-space: nowrap; }
.detail-grid dd { color: #111827; margin: 0; }

.timeline { list-style: none; padding: 0; position: relative; margin: 0; }
.timeline::before { content: ""; position: absolute; left: 0.6875rem; top: 0.3rem; bottom: 0.5rem; width: 2px; background: #e5e7eb; }
.tl-item { padding: 0 0 1rem 2rem; position: relative; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { width: 1rem; height: 1rem; border-radius: 50%; background: #9ca3af; border: 2px solid white; box-shadow: 0 0 0 1px #9ca3af; position: absolute; left: 0.1875rem; top: 0.15rem; }
.tl-dot-ok   { background: #16a34a; box-shadow: 0 0 0 1px #16a34a; }
.tl-dot-fail { background: #dc2626; box-shadow: 0 0 0 1px #dc2626; }
.tl-dot-neutral { background: #6b7280; box-shadow: 0 0 0 1px #6b7280; }
.tl-dot-wait    { background: #f59e0b; box-shadow: 0 0 0 1px #f59e0b; animation: tl-pulse 1.6s ease-in-out infinite; }
@keyframes tl-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }
.tl-time   { font-size: 0.75rem; color: #9ca3af; margin-bottom: 0.125rem; min-height: 1rem; }
.tl-label  { font-size: 0.875rem; font-weight: 500; color: #111827; }
.tl-detail { font-size: 0.8125rem; color: #6b7280; margin-top: 0.1875rem; white-space: pre-wrap; word-break: break-word; }
.tl-extra  { margin-top: 0.375rem; }
.approvers-details summary { font-size: 0.8rem; color: #6b7280; cursor: pointer; user-select: none; list-style: none; display: inline-flex; align-items: center; gap: 0.25rem; }
.approvers-details summary::-webkit-details-marker { display: none; }
.approvers-details summary::before { content: "▶"; font-size: 0.6rem; transition: transform 0.15s; }
.approvers-details[open] summary::before { transform: rotate(90deg); }
.approvers-list { margin: 0.375rem 0 0 0; padding: 0.5rem 0.75rem; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; list-style: none; display: flex; flex-direction: column; gap: 0.3rem; }
.approver-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8125rem; }
.approver-tag  { font-size: 0.7rem; padding: 1px 6px; border-radius: 4px; background: #e0e7ff; color: #3730a3; white-space: nowrap; }
.approver-val  { color: #374151; word-break: break-all; }

.req-id-btn {
  font-family: monospace;
  font-size: 0.8125rem;
  color: #1d4ed8;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.req-id-btn:hover { color: #1e40af; }

/* ── Delegation banner ── */
.delegation-banner {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  margin: 0.75rem 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
  color: #92400e;
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
}
.delegation-banner-cancel {
  background: none;
  border: 1px solid #f59e0b;
  border-radius: 4px;
  color: #92400e;
  font-size: 0.8125rem;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  margin-left: 1rem;
  white-space: nowrap;
}
.delegation-banner-cancel:hover { background: #fef3c7; }

.delegation-inbound-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  margin: 0.5rem auto 0;
  font-size: 0.875rem;
  color: #1e40af;
  max-width: 860px;
}

/* ── User menu ── */
.user-menu-wrap { position: relative; }
.user-menu-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 0.9375rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}
.user-menu-btn:hover { background: rgba(255,255,255,0.15); }
.user-menu-caret { font-size: 0.625rem; opacity: 0.7; }
.user-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  min-width: 200px;
  z-index: 200;
  padding: 0.25rem 0;
}
.user-menu.open { display: block; }
.user-menu-item {
  display: block;
  width: 100%;
  padding: 0.55rem 1rem;
  background: none;
  border: none;
  text-align: left;
  font-size: 0.875rem;
  color: #374151;
  cursor: pointer;
}
.user-menu-item:hover { background: #f9fafb; }
.user-menu-item--danger { color: #b91c1c; }
.user-menu-item--danger:hover { background: #fef2f2; }
