/* Layout */
.controller-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
  margin-bottom: 1.2rem;
}

.controller-grid > .form-shell {
  grid-column: span 6;
}

.controller-grid > .form-shell.panel-wide {
  grid-column: 1 / -1;
}

.form-shell {
  display: grid;
  gap: 0.78rem;
}

.panel-form {
  display: grid;
  gap: 0.65rem;
}

/* Threat guide */
.threat-guide {
  margin-top: 1rem;
  border: 1px solid var(--line);
  background: rgba(16, 24, 38, 0.72);
  border-radius: 10px;
  padding: 0.92rem;
  display: grid;
  gap: 0.5rem;
}

.threat-guide h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--accent-strong);
}

.threat-guide-level {
  border-top: 1px solid rgba(174, 184, 198, 0.22);
  padding-top: 0.62rem;
  display: grid;
  gap: 0.38rem;
}

.threat-guide-level:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.threat-guide-level h4 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--accent-strong);
}

.threat-guide p {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
}

.threat-guide ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text);
  font-size: 0.89rem;
  line-height: 1.42;
  display: grid;
  gap: 0.2rem;
}

.threat-guide li {
  margin: 0;
}

/* Action buttons */
.btn-danger {
  color: #fff2f2;
  background: linear-gradient(145deg, #dc5a5a, #b43e3e);
  box-shadow: 0 10px 24px -14px rgba(220, 90, 90, 0.85);
}

.btn-danger:hover {
  filter: brightness(1.05);
}

/* Bot status */
.bot-status-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.bot-status-item {
  border: 1px solid var(--line);
  background: rgba(16, 24, 38, 0.72);
  border-radius: 10px;
  padding: 0.66rem 0.72rem;
}

.bot-status-item h3 {
  margin: 0;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.bot-status-item p {
  margin: 0.45rem 0 0;
  color: var(--accent-strong);
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

/* Log and audit lists */
.clock-log-list,
.audit-log-list {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.65rem;
}

.timepull-import-shell {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.6rem;
}

.timepull-import-header {
  border: 1px solid var(--line);
  background: rgba(16, 24, 38, 0.72);
  border-radius: 10px;
  padding: 0.6rem 0.72rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.timepull-import-title {
  color: var(--accent-strong);
  font-size: 0.93rem;
}

.timepull-read-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  flex: 1 1 230px;
}

.timepull-import-list {
  display: grid;
  gap: 0.6rem;
}

.timepull-modal {
  position: fixed;
  inset: 0;
  z-index: 1800;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.timepull-modal.hidden {
  display: none !important;
}

.timepull-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(3, 8, 16, 0.72);
  cursor: pointer;
}

.timepull-modal-card {
  position: relative;
  width: min(1080px, 96vw);
  max-height: min(86vh, 920px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(10, 18, 32, 0.98);
  box-shadow: 0 24px 64px -28px rgba(0, 0, 0, 0.75);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.timepull-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid rgba(174, 184, 198, 0.2);
}

.timepull-modal-header h3 {
  margin: 0;
  color: var(--accent-strong);
  font-size: 1rem;
}

.timepull-modal .timepull-import-list {
  margin: 0;
  padding: 0.8rem;
  overflow: auto;
}

.timepull-department-card {
  border: 1px solid var(--line);
  background: rgba(16, 24, 38, 0.72);
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.timepull-department-lspd {
  border-color: rgba(102, 194, 255, 0.42);
  box-shadow: inset 0 1px 0 rgba(102, 194, 255, 0.12);
}

.timepull-department-lspd .timepull-department-header strong,
.timepull-department-lspd .timepull-entry-hours {
  color: #66c2ff;
}

.timepull-department-bcso {
  border-color: rgba(132, 222, 171, 0.42);
  box-shadow: inset 0 1px 0 rgba(132, 222, 171, 0.12);
}

.timepull-department-bcso .timepull-department-header strong,
.timepull-department-bcso .timepull-entry-hours {
  color: #84deab;
}

.timepull-department-sahp {
  border-color: rgba(238, 197, 104, 0.42);
  box-shadow: inset 0 1px 0 rgba(238, 197, 104, 0.12);
}

.timepull-department-sahp .timepull-department-header strong,
.timepull-department-sahp .timepull-entry-hours {
  color: #eec568;
}

.timepull-department-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.72rem 0.8rem 0.15rem;
}

.timepull-department-header strong {
  color: var(--accent-strong);
}

.timepull-department-stats {
  font-size: 0.83rem;
  color: var(--muted);
}

.timepull-department-meta {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0 0.8rem 0.62rem;
}

.timepull-entry-list {
  border-top: 1px solid rgba(174, 184, 198, 0.22);
  display: grid;
  max-height: min(42vh, 360px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.timepull-entry-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.5rem;
  padding: 0.5rem 0.8rem;
  font-size: 0.9rem;
}

.timepull-entry-row + .timepull-entry-row {
  border-top: 1px solid rgba(174, 184, 198, 0.14);
}

.timepull-entry-name {
  color: var(--text);
  overflow-wrap: anywhere;
}

.timepull-entry-hours {
  color: var(--accent-strong);
  font-weight: 600;
}

.timepull-entry-payments {
  color: var(--muted);
  font-size: 0.83rem;
}

.clock-log-item,
.audit-log-item {
  border: 1px solid var(--line);
  background: rgba(16, 24, 38, 0.72);
  border-radius: 10px;
  padding: 0.72rem 0.8rem;
}

.audit-log-item {
  display: grid;
  gap: 0.35rem;
}

.clock-log-item strong {
  color: var(--accent-strong);
}

.clock-log-meta,
.audit-log-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  font-size: 0.83rem;
  color: var(--muted);
}

.clock-log-meta {
  margin-bottom: 0.35rem;
}

.audit-log-actor {
  color: var(--accent-strong);
  font-weight: 600;
}

.audit-log-target,
.audit-log-detail {
  color: var(--text);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.empty-state {
  border: 1px dashed rgba(174, 184, 198, 0.35);
  border-radius: 10px;
  color: var(--muted);
  padding: 0.85rem;
}

/* Audit controls */
.audit-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 0.65rem;
}

.audit-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 0.55rem;
  flex: 1 1 540px;
}

.audit-filter-field {
  display: grid;
  gap: 0.28rem;
}

.audit-filter-field span {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.audit-filter-field select,
.audit-filter-field input {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(16, 24, 38, 0.75);
  color: var(--text);
  padding: 0.55rem 0.65rem;
  min-height: 2.5rem;
}

.audit-filter-field select:focus,
.audit-filter-field input:focus {
  outline: 2px solid rgba(207, 161, 99, 0.4);
  outline-offset: 1px;
}

.audit-results-meta {
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.83rem;
}

.audit-pagination {
  margin-top: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
}

.audit-pagination span {
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 7.5rem;
  text-align: center;
}

/* Responsive */
@media (max-width: 920px) {
  .controller-grid {
    grid-template-columns: 1fr;
  }

  .controller-grid > .form-shell,
  .controller-grid > .form-shell.panel-wide {
    grid-column: 1 / -1;
  }

  .bot-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .audit-filters {
    grid-template-columns: 1fr;
    flex-basis: 100%;
  }

  .audit-controls {
    align-items: stretch;
  }

  .audit-controls .actions {
    width: 100%;
    justify-content: flex-end;
  }
}

@media (max-width: 560px) {
  .bot-status-grid {
    grid-template-columns: 1fr;
  }

  .timepull-import-header {
    align-items: stretch;
  }

  .timepull-import-header .btn {
    width: 100%;
  }

  .timepull-modal {
    padding: 0.5rem;
  }

  .timepull-modal-card {
    width: 100%;
    max-height: 92vh;
  }

  .timepull-entry-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.2rem;
  }
}
