/* ============================================================
   Astra CRM — audit view
   ============================================================ */

.audit-page {
  background:
    radial-gradient(1100px 500px at 8% -10%, rgba(177, 132, 69, .10), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

.audit-boot {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
  color: var(--muted-strong);
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.audit-boot__dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  position: relative;
}

.audit-boot__dot::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: var(--gold);
  animation: audit-pulse 1.4s var(--ease) infinite;
}

@keyframes audit-pulse {
  0%, 100% { transform: scale(.55); opacity: .4; }
  50% { transform: scale(1); opacity: 1; }
}

.audit-denied {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.audit-denied__card {
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-md);
}

.audit-denied__card h1 {
  font-family: var(--font-display);
  font-size: clamp(26px, 3vw, 34px);
  margin: 12px 0 10px;
}

.audit-denied__card p {
  color: var(--muted-strong);
  margin: 0 0 24px;
}

/* ---------- top bar ---------- */

.audit-top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 28px;
  background: rgba(25, 26, 21, .97);
  color: #f6f1e7;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  backdrop-filter: blur(12px);
}

.audit-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #f6f1e7;
}

.audit-brand .brand-symbol {
  color: var(--gold-bright);
}

.audit-brand__copy {
  display: flex;
  align-items: baseline;
  gap: 4px;
  letter-spacing: .04em;
}

.audit-brand__copy b {
  font-weight: 600;
}

.audit-brand__copy small {
  font-size: 10px;
  letter-spacing: .22em;
  color: rgba(246, 241, 231, .55);
}

.audit-brand__tag {
  margin-left: 6px;
  padding: 4px 9px;
  border: 1px solid rgba(215, 172, 106, .35);
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold-bright);
}

.audit-top__right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
}

.audit-user {
  color: rgba(246, 241, 231, .72);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-link {
  color: rgba(246, 241, 231, .72);
  border-bottom: 1px solid transparent;
  transition: color .2s, border-color .2s;
}

.audit-link:hover {
  color: #fff;
  border-color: rgba(215, 172, 106, .55);
}

.audit-logout {
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .18);
  color: #f6f1e7;
  font-size: 12px;
  transition: background .2s, border-color .2s;
}

.audit-logout:hover {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .35);
}

/* ---------- layout ---------- */

.audit-main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 34px 28px 72px;
  transition: opacity .2s;
}

.audit-main.is-loading {
  opacity: .62;
}

.audit-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.audit-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(34px, 4vw, 52px);
  line-height: 1.02;
  letter-spacing: -.02em;
  margin: 10px 0 8px;
}

.audit-hero p {
  max-width: 640px;
  margin: 0;
  color: var(--muted-strong);
}

.audit-hero__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.audit-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted-strong);
  cursor: pointer;
}

.audit-switch input {
  accent-color: var(--gold);
  width: 15px;
  height: 15px;
}

.audit-btn {
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface-raised);
  color: var(--ink-soft);
  font-size: 12px;
  transition: border-color .2s, background .2s, transform .2s;
}

.audit-btn:hover:not(:disabled) {
  border-color: var(--gold);
  transform: translateY(-1px);
}

.audit-btn--accent {
  background: var(--night);
  border-color: var(--night);
  color: #f6f1e7;
}

.audit-btn--accent:hover:not(:disabled) {
  background: #2a2b24;
  border-color: #2a2b24;
}

/* ---------- stats ---------- */

.audit-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.audit-stat {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-xs);
}

.audit-stat::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--blue);
}

.audit-stat--green::after { background: var(--green); }
.audit-stat--rose::after { background: var(--rose); }
.audit-stat--gold::after { background: var(--gold); }

.audit-stat__label {
  display: block;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.audit-stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(28px, 3vw, 38px);
  font-weight: 500;
  line-height: 1;
  margin: 10px 0 6px;
  font-variant-numeric: tabular-nums;
}

.audit-stat__hint {
  font-size: 11px;
  color: var(--muted);
}

/* ---------- trend ---------- */

.audit-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 20px 12px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-xs);
}

.audit-panel__head,
.audit-table-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.audit-panel__head h2,
.audit-table-head h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  margin: 4px 0 0;
}

.audit-panel__meta {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.audit-trend {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 132px;
  padding-top: 6px;
}

.audit-trend__col {
  flex: 1 1 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}

.audit-trend__bar {
  width: 100%;
  min-height: 3px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  opacity: .85;
  transition: height .35s var(--ease), opacity .2s;
}

.audit-trend__col:hover .audit-trend__bar {
  opacity: 1;
}

.audit-trend__label {
  font-size: 9px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}

/* ---------- filters ---------- */

.audit-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-xs);
}

.audit-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.audit-field > span {
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.audit-field select,
.audit-field input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 12px;
  color: var(--ink);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.audit-field select:focus,
.audit-field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(177, 132, 69, .13);
}

.audit-dates {
  display: contents;
}

.audit-field--search {
  grid-column: span 2;
}

.audit-reset {
  height: 36px;
  padding: 0 13px;
  border-radius: 9px;
  border: 1px dashed var(--line-strong);
  color: var(--muted-strong);
  font-size: 12px;
  white-space: nowrap;
  transition: border-color .2s, color .2s;
}

.audit-reset:hover {
  border-color: var(--rose);
  color: var(--rose);
}

/* ---------- table ---------- */

.audit-table-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 20px 12px;
  box-shadow: var(--shadow-xs);
}

.audit-table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 880px;
}

.audit-table th {
  text-align: left;
  padding: 9px 10px;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.audit-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink-soft);
}

.audit-table tbody tr {
  cursor: pointer;
  transition: background .15s;
}

.audit-table tbody tr:hover,
.audit-table tbody tr:focus-visible {
  background: var(--surface-soft);
}

.audit-table tbody tr:last-child td {
  border-bottom: 0;
}

.audit-time {
  display: flex;
  flex-direction: column;
  gap: 1px;
  white-space: nowrap;
}

.audit-time b {
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.audit-time span {
  font-size: 10px;
  color: var(--muted);
}

.audit-person {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 150px;
}

.audit-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--gold-wash);
  color: var(--gold);
  font-size: 10px;
  font-weight: 600;
  flex: 0 0 auto;
}

.audit-person__copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.audit-person__copy b {
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 170px;
}

.audit-person__copy span {
  font-size: 10px;
  color: var(--muted);
}

.audit-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: .02em;
  white-space: nowrap;
  background: var(--blue-wash);
  color: var(--blue);
}

.audit-badge--login,
.audit-badge--logout { background: var(--blue-wash); color: var(--blue); }
.audit-badge--read,
.audit-badge--list { background: var(--surface-soft); color: var(--muted-strong); }
.audit-badge--update,
.audit-badge--create { background: var(--violet-wash); color: var(--violet); }
.audit-badge--delete,
.audit-badge--access_denied { background: var(--rose-wash); color: var(--rose); }
.audit-badge--anonymize,
.audit-badge--retention,
.audit-badge--export { background: var(--gold-wash); color: var(--amber); }

.audit-outcome {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  white-space: nowrap;
}

.audit-outcome::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.audit-outcome--ok { color: var(--green); }
.audit-outcome--denied { color: var(--rose); }
.audit-outcome--not_found { color: var(--amber); }

.audit-entity {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 110px;
}

.audit-entity b {
  font-weight: 500;
  color: var(--ink);
}

.audit-entity span {
  font-size: 10px;
  color: var(--muted);
}

.audit-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.audit-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 2px 4px;
  font-size: 11px;
  color: var(--muted);
}

.audit-pager {
  display: flex;
  align-items: center;
  gap: 10px;
}

.audit-pager #auditPage {
  font-variant-numeric: tabular-nums;
  min-width: 54px;
  text-align: center;
}

.audit-empty {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
}

.audit-empty b {
  color: var(--ink-soft);
  font-weight: 500;
}

/* ---------- drawer ---------- */

.audit-drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 12, .34);
  z-index: 40;
  backdrop-filter: blur(2px);
}

.audit-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 94vw);
  background: var(--surface-raised);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 45;
  display: flex;
  flex-direction: column;
  animation: audit-slide .24s var(--ease);
}

@keyframes audit-slide {
  from { transform: translateX(24px); opacity: .6; }
  to { transform: translateX(0); opacity: 1; }
}

.audit-drawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.audit-drawer__head h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  margin: 6px 0 0;
}

.audit-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  font-size: 18px;
  line-height: 1;
  color: var(--muted-strong);
}

.audit-icon:hover {
  border-color: var(--gold);
  color: var(--ink);
}

.audit-drawer__body {
  padding: 18px 22px 28px;
  overflow-y: auto;
}

.audit-dl {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 9px 12px;
  margin: 0 0 18px;
  font-size: 12px;
}

.audit-dl dt {
  color: var(--muted);
}

.audit-dl dd {
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.audit-drawer h3 {
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}

.audit-pre {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
}

.audit-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 70;
  background: var(--night);
  color: #f6f1e7;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 12px;
  box-shadow: var(--shadow-md);
}

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  .audit-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .audit-field--search { grid-column: span 2; }
}

@media (max-width: 760px) {
  .audit-top { padding: 11px 16px; }
  .audit-user { display: none; }
  .audit-brand__tag { display: none; }
  .audit-main { padding: 24px 16px 56px; }
  .audit-hero { flex-direction: column; align-items: flex-start; }
  .audit-hero__actions { justify-content: flex-start; }
  .audit-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-field--search { grid-column: span 2; }
  .audit-dates { display: contents; }
  .audit-trend { height: 104px; gap: 3px; }
  .audit-trend__label { display: none; }
  .audit-col-ip,
  .audit-col-req,
  .audit-table td:nth-child(6),
  .audit-table td:nth-child(7) { display: none; }
  .audit-table { min-width: 620px; }
  .audit-foot { flex-direction: column; align-items: flex-start; }
  .audit-dl { grid-template-columns: 96px 1fr; }
}

@media (max-width: 460px) {
  .audit-stats { grid-template-columns: 1fr; }
  .audit-filters { grid-template-columns: 1fr; }
  .audit-field--search { grid-column: auto; }
  .audit-table { min-width: 520px; }
}
/* Клики сотрудников в интерфейсе */
.ui-events {
  display: flex;
  flex-direction: column;
  max-height: 420px;
  overflow: auto;
}

.ui-event {
  display: grid;
  grid-template-columns: 112px 150px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid #ece7dc;
  font-size: 11.5px;
}

.ui-event:last-child {
  border-bottom: 0;
}

.ui-event__time {
  color: #9a9384;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ui-event__actor {
  font-weight: 600;
  color: #2c2a24;
}

.ui-event__where {
  min-width: 0;
  color: #5d594f;
  overflow-wrap: anywhere;
}

.ui-event__lead {
  color: #8a6a2f;
  white-space: nowrap;
}

.ui-events__empty {
  padding: 18px 0;
  color: #9a9384;
  font-size: 12px;
}