:root {
  --bg: #070508;
  --panel: #120d14;
  --panel-2: #1b121d;
  --line: rgba(230, 182, 92, .25);
  --gold: #e5b65c;
  --gold-soft: #f5d28a;
  --crimson: #9d1235;
  --crimson-2: #d32955;
  --violet: #51335f;
  --text: #f4efe7;
  --muted: #b7a8b3;
  --danger: #e04a55;
  --blue: #9fd9ff;
  --green: #a3efb8;
  --red: #ffaaa7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(157,18,53,.28), transparent 34rem),
    radial-gradient(circle at 78% 18%, rgba(81,51,95,.34), transparent 32rem),
    linear-gradient(135deg, #050405, #0f0710 55%, #15080d);
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  position: relative;
  overflow: hidden;
}

.login-logo {
  width: min(72vh, 78vw);
  max-width: 690px;
  filter: drop-shadow(0 22px 50px rgba(0,0,0,.75));
}

.login-form {
  position: absolute;
  top: calc(50% + 88px);
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100vw - 44px));
  display: grid;
  gap: 11px;
}

.login-form .btn {
  width: 100%;
}

.login-card, .panel, .modal {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(32,20,33,.92), rgba(15,10,16,.95));
  box-shadow: 0 24px 80px rgba(0,0,0,.36);
}

.login-card {
  width: min(430px, 100%);
  padding: 32px;
}

.brand-title {
  margin: 0 0 24px;
  font-family: Georgia, serif;
  font-size: 44px;
  color: var(--gold-soft);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span {
  color: var(--muted);
  font-size: 14px;
}

input, select, textarea {
  width: 100%;
  color: var(--text);
  background: #0b080d;
  border: 1px solid rgba(245,210,138,.28);
  outline: none;
  padding: 12px 13px;
  border-radius: 8px;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(229,182,92,.13);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 15px;
  border-radius: 8px;
  color: #16090c;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  font-weight: 700;
}

.btn.secondary {
  color: var(--text);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
}

.btn.success {
  color: #07150b;
  background: linear-gradient(180deg, #bdf3c7, #78d894);
}

.btn.danger {
  color: #fff;
  background: linear-gradient(180deg, #d84a59, #8d102d);
}

.btn.small {
  min-height: 34px;
  padding: 8px 10px;
  font-size: 14px;
}

.app-shell {
  min-height: 100vh;
}

.app-header {
  height: 72px;
  display: flex;
  align-items: center;
  padding: 14px 18px;
}

.brand-button {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--gold-soft);
  background: transparent;
  padding: 0;
}

.brand-button img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 50%;
}

.brand-button strong {
  font-family: Georgia, serif;
  font-size: 28px;
  color: var(--gold-soft);
}

.drawer-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

.drawer-layer.open {
  pointer-events: auto;
}

.drawer-shade {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.68);
  opacity: 0;
  transition: opacity .22s ease;
}

.drawer-layer.open .drawer-shade {
  opacity: 1;
}

.drawer {
  position: absolute;
  inset: 0 auto 0 0;
  width: min(280px, 86vw);
  padding: 18px;
  border-right: 1px solid var(--line);
  background: rgba(7,5,8,.96);
  box-shadow: 20px 0 70px rgba(0,0,0,.55);
  transform: translateX(-100%);
  transition: transform .24s ease;
}

.drawer-layer.open .drawer {
  transform: translateX(0);
}

.drawer-brand {
  margin-bottom: 26px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav a, .logout {
  color: var(--muted);
  text-decoration: none;
  text-align: left;
  padding: 11px 12px;
  border-radius: 8px;
  background: transparent;
}

.nav a.active, .nav a:hover, .logout:hover {
  color: var(--text);
  background: rgba(229,182,92,.13);
}

.logout {
  width: 100%;
  margin-top: 18px;
}

.content {
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

h1, h2, h3, p {
  margin-top: 0;
}

h1 {
  font-size: 30px;
  letter-spacing: 0;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  padding: 18px;
  border-radius: 8px;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-align: left;
  vertical-align: middle;
}

.table th {
  color: var(--gold-soft);
  font-size: 13px;
  text-transform: uppercase;
}

.case-list {
  display: grid;
  gap: 12px;
  width: 100%;
  margin: 0 auto;
}

.case-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 15px 16px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  background: rgba(255,255,255,.045);
}

.case-card h3 {
  margin-bottom: 6px;
}

.case-main {
  min-width: 0;
}

.case-main h3,
.case-main p,
.case-link {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.case-main p {
  margin-bottom: 8px;
}

.case-link {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--gold-soft);
  text-decoration: none;
  border-bottom: 1px solid rgba(245,210,138,.45);
}

.case-meta, .muted {
  color: var(--muted);
  font-size: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.dept {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  color: #120d14;
  font-weight: 700;
  font-size: 12px;
}

.dept.investigation { background: var(--red); }
.dept.law { background: var(--blue); }
.dept.media { background: var(--green); }
.dept.leadership { background: #ff9ccc; }

.battery {
  width: 122px;
  height: 30px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  padding: 4px 8px 4px 4px;
  border: 2px solid rgba(255,255,255,.52);
  border-radius: 7px;
  position: relative;
}

.battery::after {
  content: "";
  position: absolute;
  right: -8px;
  top: 8px;
  width: 5px;
  height: 11px;
  border-radius: 0 3px 3px 0;
  background: rgba(255,255,255,.52);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 3px;
  background: rgba(255,255,255,.08);
}

.battery-count {
  position: absolute;
  z-index: 1;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
}

.cell.filled .battery-count {
  color: #10070a;
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
}

.cell.filled.level-1 { background: #fff; }
.cell.filled.level-2 { background: #ffd7d7; }
.cell.filled.level-3 { background: #ffaaa7; }
.cell.filled.level-4 { background: #ff7374; }
.cell.filled.level-5 { background: #e5293d; }

.staff-choice {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 420px));
  align-items: start;
  gap: 14px;
  margin-bottom: 16px;
}

.admin-forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 360px));
  justify-content: center;
  align-items: start;
  gap: 14px;
  margin: 0 auto 20px;
  max-width: 780px;
}

.compact-panel {
  padding: 14px;
}

.compact-panel h2, .logs-panel h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.compact-panel .field {
  margin-bottom: 10px;
}

.compact-panel input,
.compact-panel select {
  padding: 9px 10px;
}

.form-btn {
  width: 100%;
}

.strip-section {
  width: min(880px, 100%);
  margin: 0 auto 18px;
}

.strip-section h2 {
  font-size: 18px;
  margin-bottom: 10px;
}

.strip-list {
  display: grid;
  gap: 8px;
}

.strip-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 140px 128px 92px;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 8px;
  background: rgba(255,255,255,.045);
}

.users-section .strip-row {
  grid-template-columns: 1fr 128px 92px;
}

.staff-select option.leadership { background: #ff9ccc; color: #120d14; }
.staff-select option.investigation { background: var(--red); color: #120d14; }
.staff-select option.law { background: var(--blue); color: #120d14; }
.staff-select option.media { background: var(--green); color: #120d14; }

.logs-panel {
  width: min(880px, 100%);
  margin: 0 auto;
}

.logs-panel .table {
  table-layout: fixed;
}

.logs-panel td:first-child {
  width: 160px;
}

.logs-panel td:nth-child(2) {
  width: auto;
}

.logs-panel td:last-child {
  width: 170px;
  white-space: nowrap;
}

.logs-panel td {
  padding: 10px;
  overflow-wrap: anywhere;
  vertical-align: middle;
}

.notice {
  min-height: 22px;
  color: var(--danger);
  margin-top: 12px;
}

.login-form .notice {
  display: none;
  min-height: 0;
  margin-top: 2px;
  padding: 10px 12px;
  color: #ffd9dc;
  background: rgba(157,18,53,.24);
  border: 1px solid rgba(224,74,85,.42);
  border-radius: 8px;
}

.login-form .notice:not(:empty) {
  display: block;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(0,0,0,.68);
}

.modal {
  width: min(560px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 20px;
  border-radius: 8px;
}

.modal-form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}

.modal-form-actions .btn {
  width: 100%;
}

.copy-box {
  width: 100%;
  height: 118px;
  min-height: 118px;
  margin: 10px 0 14px;
}

.copy-card {
  width: 100%;
  min-height: 44px;
  max-height: 118px;
  padding: 12px 13px;
  color: var(--text);
  background: #0b080d;
  border: 1px solid rgba(245,210,138,.28);
  border-radius: 8px;
  font-family: inherit;
  font-size: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: hidden;
  outline: none;
  user-select: text;
}

.copy-click {
  cursor: pointer;
}

.copy-click.copied {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(163,239,184,.16);
}

@media (max-width: 820px) {
  .login-page, .grid.two, .admin-grid, .admin-forms {
    grid-template-columns: 1fr;
  }

  .case-card {
    grid-template-columns: 1fr;
  }

  .case-card .actions {
    justify-content: flex-start;
  }

  .strip-row,
  .users-section .strip-row {
    grid-template-columns: 1fr;
  }


  .content {
    padding: 20px 14px;
  }

  .login-logo {
    width: min(58vh, 92vw);
  }

  .login-form {
    top: calc(50% + 58px);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .modal-form-actions {
    grid-template-columns: 1fr;
  }
}
