body {
      font-family: Arial, sans-serif;
      margin: 0;
      background: #f4f4f4;
      color: #222;
    }

    .topbar {
      background: #343c47;
      color: white;
      padding: 16px 32px;
      display: flex;
      justify-content: center;
      align-items: center;
      text-align: center;
    }

    .topbar h1 {
      margin: 0;
      font-size: 22px;
    }

    .menu {
      position: fixed;
      inset: 0 auto 0 0;
      z-index: 1100;
      width: 220px;
      box-sizing: border-box;
      display: none;
      flex-direction: column;
      align-items: stretch;
      gap: 6px;
      padding: 34px 14px 18px;
      overflow-y: auto;
      background: #343c47;
      border-right: 1px solid rgba(255, 255, 255, 0.12);
    }

    .menu-logo-wrap {
      flex: 0 0 auto;
      display: flex;
      justify-content: center;
      align-items: center;
      min-height: 0;
      margin: 0 0 10px;
    }

    .menu-logo-wrap[hidden] {
      display: none;
    }

    .menu-logo {
      display: block;
      width: auto;
      height: auto;
      max-width: 176px;
      max-height: 110px;
      object-fit: contain;
    }

    .menu button {
      display: block;
      width: 100%;
      background: rgba(255, 255, 255, 0.10);
      color: white;
      border: 1px solid rgba(255, 255, 255, 0.22);
      padding: 10px 12px;
      border-radius: 8px;
      cursor: pointer;
      font-size: 15px;
      text-align: left;
    }

    .menu button:hover {
      background: rgba(255, 255, 255, 0.17);
    }

    .menu button.active {
      background: white;
      color: #1a73e8;
      font-weight: bold;
    }

    .menu-separator {
      flex: 0 0 14px;
      height: 14px;
    }

    #menuLogout {
      margin-top: auto;
    }

    body.app-authenticated .topbar,
    body.app-authenticated .userbar,
    body.app-authenticated .admin-simulation-bar {
      margin-left: 220px;
    }

    body.app-authenticated #appContainer {
      max-width: none;
      margin: 32px 32px 32px 252px;
    }

    .userbar {
      background: #fff;
      padding: 10px 32px;
      border-bottom: 1px solid #ddd;
      font-size: 14px;
      color: #555;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      flex-wrap: wrap;
    }

    .user-identity {
      overflow-wrap: anywhere;
    }

    .theme-toggle {
      width: auto;
      min-width: 132px;
      padding: 7px 11px;
      background: #eef3fd;
      color: #174ea6;
      border: 1px solid #a8c7fa;
      font-size: 13px;
      font-weight: 700;
    }

    .user-role-badge {
      display: inline-flex;
      align-items: center;
      width: fit-content;
      margin-left: 8px;
      padding: 3px 8px;
      border-radius: 999px;
      background: #fce8e6;
      color: #a50e0e;
      font-size: 12px;
      font-weight: 700;
    }

    .user-role-badge[hidden] {
      display: none !important;
    }

    .admin-simulation-bar {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      flex-wrap: wrap;
      padding: 10px 20px;
      border-bottom: 1px solid #f9ab00;
      background: #fff8e1;
      color: #5f4200;
    }

    .admin-simulation-bar[hidden] {
      display: none !important;
    }

    .admin-simulation-bar select,
    .admin-simulation-bar button {
      width: auto;
      min-width: 190px;
      padding: 8px 10px;
    }

    .admin-simulation-warning {
      flex: 1 0 100%;
      text-align: center;
      font-weight: 700;
      color: #b06000;
    }

    .container {
      max-width: 1200px;
      margin: 32px auto;
      background: #fff;
      padding: 24px;
      border-radius: 12px;
      box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
    }

    .login-card {
      max-width: 560px;
      text-align: center;
    }

    .login-button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      margin-top: 20px;
      padding: 12px 18px;
      border-radius: 8px;
      background: #1a73e8;
      color: white;
      text-decoration: none;
      font-weight: bold;
    }


    .steam-login-button {
      display: inline-block;
      padding: 0;
      border: 0;
      border-radius: 0;
      background: transparent;
      line-height: 0;
    }

    .steam-login-button:hover {
      background: transparent;
      opacity: 0.92;
    }

    .steam-login-button:focus-visible {
      outline: 3px solid #1a73e8;
      outline-offset: 4px;
    }

    .steam-login-button img {
      display: block;
      width: 180px;
      height: 35px;
      border: 0;
    }

    .login-form {
      display: grid;
      grid-template-columns: 1fr;
      gap: 10px;
      margin: 20px auto 12px;
      max-width: 420px;
      text-align: left;
    }

    .login-form .login-button {
      width: 100%;
      margin-top: 4px;
      border: none;
    }

    .stats-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 16px;
      margin-top: 18px;
    }

    .stat-card {
      border: 1px solid #ddd;
      border-radius: 12px;
      padding: 18px;
      background: #fafafa;
      min-height: 140px;
    }

    .stat-card h3 {
      margin: 0 0 10px 0;
      font-size: 16px;
    }

    .stat-number {
      font-size: 40px;
      font-weight: bold;
      color: #1a73e8;
      line-height: 1;
      margin-top: 18px;
    }

    .stat-list {
      margin: 10px 0 0 0;
      padding-left: 18px;
    }

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

    .stat-empty {
      margin-top: 10px;
      color: #666;
      font-size: 14px;
    }

    .stat-card-wide {
      grid-column: 1 / -1;
      min-height: 0;
    }

    .dashboard-measures-list {
      display: grid;
      gap: 9px;
      max-height: 420px;
      overflow-y: auto;
      padding-right: 4px;
    }

    .dashboard-measure-item {
      display: grid;
      grid-template-columns: minmax(180px, 1fr) auto;
      align-items: center;
      gap: 14px;
      padding: 12px;
      border: 1px solid #dfe3e8;
      border-radius: 10px;
      background: #fff;
    }

    .dashboard-measure-lines {
      display: grid;
      gap: 8px;
      min-width: 0;
    }

    .dashboard-measure-line {
      display: grid;
      grid-template-columns: 124px minmax(0, 1fr);
      align-items: flex-start;
      column-gap: 10px;
      min-width: 0;
    }

    .dashboard-measure-line .measure-badge {
      box-sizing: border-box;
      justify-content: center;
      width: 100%;
      margin-top: 1px;
    }

    .dashboard-measure-person {
      min-width: 0;
    }

    .dashboard-measure-person strong,
    .dashboard-measure-person span {
      display: block;
    }

    .dashboard-measure-person strong {
      overflow-wrap: anywhere;
    }

    .dashboard-measure-meta {
      margin-top: 3px;
      color: #666;
      font-size: 12px;
    }

    .dashboard-measure-record-meta {
      color: #666;
      font-size: 12px;
    }

    .dashboard-record-link {
      color: #1a73e8;
      font-size: 13px;
      font-weight: 700;
      white-space: nowrap;
      text-decoration: none;
    }

    .dashboard-record-link:hover {
      text-decoration: underline;
    }

    .page {
      display: none;
    }

    .page.active {
      display: block;
    }

    h2 {
      margin-top: 0;
    }

    h3 {
      margin-top: 24px;
    }

    label {
      display: block;
      margin-bottom: 4px;
      font-weight: bold;
    }

    .status {
      margin-bottom: 16px;
      font-weight: bold;
    }

    .error {
      color: #c5221f;
    }

    .success {
      color: #137333;
    }

    .small {
      margin-top: 4px;
      font-size: 13px;
      color: #666;
    }

    form {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 12px;
      margin-bottom: 24px;
    }

    input,
    textarea,
    select,
    button {
      font-size: 15px;
      padding: 10px;
      border-radius: 8px;
      border: 1px solid #ccc;
      box-sizing: border-box;
      width: 100%;
    }

    input[readonly] {
      background: #f1f3f4;
      color: #555;
    }

    input:disabled,
    textarea:disabled,
    select:disabled {
      background: #f1f3f4;
      color: #555;
      cursor: not-allowed;
      opacity: 1;
    }

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

    .record-longtext-field textarea {
      min-height: 320px;
    }

    .penalty-total-summary {
      margin-top: 10px;
      padding: 10px 12px;
      border: 1px solid #c7d7ef;
      border-radius: 8px;
      background: #f5f9ff;
      color: #20364f;
      font-weight: bold;
    }

    .penalty-total-summary[hidden] {
      display: none;
    }

    .full {
      grid-column: span 2;
    }

    button {
      cursor: pointer;
      border: none;
      background: #1a73e8;
      color: white;
    }

    button.secondary {
      background: #666;
    }

    button.danger {
      background: #c5221f;
    }

    button:disabled {
      opacity: 0.7;
      cursor: not-allowed;
    }

    .form-actions {
      display: flex;
      gap: 8px;
      grid-column: span 2;
      flex-wrap: wrap;
    }

    .edit-actions {
      align-items: center;
      flex-wrap: wrap;
    }

    .edit-actions button {
      width: auto;
      min-width: 118px;
      padding: 8px 12px;
      font-size: 13px;
      line-height: 1.2;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      text-align: center;
      white-space: nowrap;
    }

    .edit-actions .save-button {
      background: #188038;
    }

    .edit-actions .transfer-button {
      background: #a8c7fa;
      color: #174ea6;
    }

    .edit-actions .takeover-button {
      background: #e8f0fe;
      color: #174ea6;
      border: 1px solid #a8c7fa;
    }

    .edit-actions .assign-button,
    .assignee-control .assign-button {
      background: #a8c7fa;
      color: #174ea6;
      border: 1px solid #8ab4f8;
    }

    .edit-actions .delete-button {
      background: #c5221f;
      color: white;
      justify-content: center;
      text-align: center;
    }

    .assignee-control {
      display: flex;
      gap: 8px;
      align-items: center;
      flex-wrap: wrap;
    }

    .assignee-control input,
    .assignee-control select {
      flex: 1 1 260px;
      min-width: 220px;
    }

    .assignee-control button {
      width: auto;
      min-width: 170px;
      white-space: nowrap;
    }

    .case-access-box {
      display: flex;
      align-items: center;
      gap: 12px;
      flex-wrap: wrap;
      margin-top: 16px;
      padding: 12px;
      border: 1px solid #a8c7fa;
      border-radius: 8px;
      background: #f5f8ff;
    }

    .case-access-box[hidden] {
      display: none !important;
    }

    .case-access-box button {
      width: auto;
      min-width: 190px;
    }

    .case-access-link {
      color: #174ea6;
      font-weight: 600;
      overflow-wrap: anywhere;
    }

    .case-access-audit {
      flex: 1 0 100%;
      color: #4d5156;
    }

    .evidence-upload-box {
      display: grid;
      gap: 8px;
      margin-top: 8px;
      padding: 12px;
      border: 1px solid #d7dce3;
      border-radius: 8px;
      background: #fafafa;
    }

    .evidence-upload-controls {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }

    .evidence-upload-controls input[type="file"],
    .site-logo-upload-controls input[type="file"] {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }

    .pvt-file-picker-button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-height: 38px;
      padding: 8px 13px;
      border: 1px solid #c7ced8;
      border-radius: 7px;
      background: #f3f5f7;
      color: #202124;
      font: inherit;
      font-weight: 600;
      line-height: 1.2;
      cursor: pointer;
      user-select: none;
      white-space: nowrap;
    }

    .pvt-file-picker-button:hover {
      background: #e9edf2;
    }

    .pvt-file-selection {
      min-width: 150px;
      color: #5f6b7a;
      word-break: break-word;
    }

    .evidence-upload-controls button {
      width: auto;
      flex: 0 0 auto;
      white-space: nowrap;
    }

    .evidence-upload-status {
      min-height: 18px;
      margin: 0;
    }

    .evidence-links-label {
      margin-top: 12px;
    }

    .evidence-storage-field {
      display: none;
    }

    .evidence-gallery {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
      gap: 10px;
      margin-top: 8px;
    }

    .evidence-gallery-empty {
      grid-column: 1 / -1;
      padding: 12px;
      border: 1px dashed #c7cbd1;
      border-radius: 8px;
      color: #666;
      background: #fafafa;
    }

    .evidence-thumbnail {
      position: relative;
      width: 100%;
      aspect-ratio: 4 / 3;
      padding: 0;
      overflow: hidden;
      border: 1px solid #c7cbd1;
      border-radius: 8px;
      background: #eef1f4;
      color: #555;
    }

    .evidence-thumbnail:not(:disabled):hover {
      border-color: #1a73e8;
      box-shadow: 0 2px 8px rgba(26, 115, 232, 0.25);
    }

    .evidence-thumbnail img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .evidence-thumbnail span {
      display: grid;
      place-items: center;
      height: 100%;
      padding: 8px;
      font-size: 13px;
      box-sizing: border-box;
    }

    .evidence-modal {
      position: fixed;
      inset: 0;
      z-index: 10000;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 24px;
      background: rgba(0, 0, 0, 0.82);
      box-sizing: border-box;
    }

    .evidence-modal.active {
      display: flex;
    }

    .evidence-modal-content {
      display: grid;
      justify-items: center;
      gap: 10px;
      max-width: 96vw;
      max-height: 94vh;
      color: white;
    }

    .evidence-modal img {
      display: block;
      max-width: 94vw;
      max-height: 82vh;
      object-fit: contain;
      border-radius: 8px;
      background: #111;
    }

    .evidence-modal-close {
      position: absolute;
      top: 14px;
      right: 18px;
      width: 44px;
      height: 44px;
      padding: 0;
      border-radius: 50%;
      background: white;
      color: #222;
      font-size: 28px;
      line-height: 1;
    }

    .evidence-modal-caption {
      max-width: 90vw;
      overflow-wrap: anywhere;
      text-align: center;
    }

    .app-dialog {
      position: fixed;
      inset: 0;
      z-index: 11000;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 20px;
      background: rgba(0, 0, 0, 0.58);
      box-sizing: border-box;
    }

    .app-dialog.active {
      display: flex;
    }

    .app-dialog-card {
      width: min(460px, 100%);
      max-height: 90vh;
      overflow-y: auto;
      padding: 22px;
      border-radius: 12px;
      background: white;
      color: #222;
      box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
      box-sizing: border-box;
    }

    .app-dialog-card h3 {
      margin: 0 0 12px;
      font-size: 20px;
    }

    .app-dialog-message {
      margin-bottom: 20px;
      line-height: 1.5;
      overflow-wrap: anywhere;
      white-space: pre-line;
    }

    .app-dialog-input,
    .app-dialog-textarea {
      margin-bottom: 20px;
    }

    .app-dialog-textarea {
      min-height: 180px;
      resize: vertical;
    }

    .app-dialog-actions {
      display: flex;
      justify-content: flex-end;
      flex-wrap: wrap;
      gap: 10px;
    }

    .app-dialog-actions button {
      width: auto;
      min-width: 105px;
    }

    .app-dialog-confirm-danger {
      background: #c5221f;
    }

    .app-dialog-confirm-danger:hover {
      background: #a50e0e;
    }

    .toolbar {
      display: flex;
      gap: 12px;
      margin-bottom: 16px;
    }

    .records-toolbar {
      align-items: center;
      flex-wrap: wrap;
    }

    .records-toolbar input[type="text"] {
      flex: 1 1 320px;
    }

    .records-toolbar .record-search-button {
      width: auto;
      flex: 0 0 auto;
      align-self: center;
      padding: 8px 12px;
      font-size: 14px;
      white-space: nowrap;
    }

    .closed-toggle {
      width: auto;
      display: inline-flex;
      align-items: center;
      gap: 8px;
      margin: 0;
      padding: 8px 10px;
      border: 1px solid #ddd;
      border-radius: 8px;
      background: #fafafa;
      font-weight: normal;
      white-space: nowrap;
      cursor: pointer;
    }

    .closed-toggle input {
      width: auto;
      margin: 0;
    }

    .table-wrapper {
      overflow-x: auto;
    }

    .records-pagination {
      display: flex;
      justify-content: center;
      align-items: center;
      flex-wrap: wrap;
      gap: 12px;
      margin-top: 16px;
    }

    .records-pagination button {
      width: auto;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      min-width: 950px;
    }

    th,
    td {
      padding: 10px;
      border-bottom: 1px solid #ddd;
      text-align: left;
      vertical-align: top;
    }

    th {
      background: #f1f3f4;
      position: sticky;
      top: 0;
    }

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

    .edit-box {
      display: none;
      border: 1px solid #ddd;
      border-radius: 12px;
      padding: 18px;
      margin-bottom: 24px;
      background: #fafafa;
    }

    .edit-box.active {
      display: block;
    }

    .record-part {
      grid-column: 1 / -1;
      border: 1px solid #d8dee8;
      border-radius: 14px;
      background: #fff;
      overflow: hidden;
    }

    .record-part-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 12px;
      padding: 16px;
    }

    .record-part-grid > .full {
      grid-column: 1 / -1;
    }

    .record-part-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 12px 16px;
      border-bottom: 1px solid #d8dee8;
    }

    .record-part-title {
      font-size: 16px;
      font-weight: 700;
    }

    .record-part-description {
      font-size: 12px;
      color: #5f6368;
      text-align: right;
    }

    .record-part-police .record-part-header {
      background: #e8f0fe;
      border-left: 5px solid #1a73e8;
      color: #174ea6;
    }

    .record-part-justice {
      margin-top: 8px;
      border-color: #e4cf91;
    }

    .record-part-justice .record-part-header {
      background: #fff7dc;
      border-left: 5px solid #c58b00;
      border-bottom-color: #e4cf91;
      color: #6f4e00;
    }

    .hint {
      background: #eef3fd;
      border-left: 4px solid #1a73e8;
      padding: 12px;
      border-radius: 8px;
      margin-bottom: 18px;
      color: #333;
    }

    .checkbox-list {
      border: 1px solid #ccc;
      border-radius: 8px;
      padding: 8px;
      max-height: 180px;
      overflow-y: auto;
      background: white;
    }

    .checkbox-item {
      display: flex;
      align-items: center;
      gap: 8px;
      font-weight: normal;
      padding: 6px;
      border-radius: 6px;
      cursor: pointer;
    }

    .checkbox-item:hover {
      background: #f1f3f4;
    }

    .checkbox-item input {
      width: auto;
    }

    .fictional-documents-list {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      align-items: stretch;
      gap: 12px;
      border: 1px solid #ccc;
      border-radius: 8px;
      padding: 12px;
      background: white;
    }

    .fictional-document-section {
      display: grid;
      gap: 8px;
      padding: 10px;
      border: 1px solid #e1e4e8;
      border-radius: 8px;
      background: #fafafa;
      box-sizing: border-box;
      height: 100%;
    }

    .fictional-document-section textarea {
      box-sizing: border-box;
      height: 72px;
      min-height: 72px;
      margin-top: auto;
    }

    .fictional-scope-options {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }

    .fictional-scope-options .checkbox-item {
      flex: 0 1 auto;
      border: 1px solid #ddd;
      background: white;
    }

    .fictional-execution-status {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
      padding-top: 4px;
      border-top: 1px solid #e1e4e8;
    }

    .fictional-execution-status[hidden] {
      display: none;
    }

    .fictional-status-pill {
      display: inline-flex;
      align-items: center;
      min-height: 24px;
      padding: 3px 9px;
      border-radius: 999px;
      font-size: 12px;
      font-weight: 700;
      line-height: 1;
    }

    .fictional-status-pill.open {
      color: #7a4300;
      background: #fff3cd;
      border: 1px solid #e8c365;
    }

    .fictional-status-pill.completed {
      color: #155724;
      background: #d4edda;
      border: 1px solid #9bd0a8;
    }

    .fictional-execution-status .small {
      flex: 1 1 180px;
    }

    .fictional-execution-status button {
      width: auto;
      padding: 6px 10px;
      font-size: 13px;
      white-space: nowrap;
    }

    .law-selection-search {
      display: grid;
      gap: 6px;
      margin-bottom: 10px;
    }

    .law-selection-search input {
      margin: 0;
    }

    .law-selection-search-status {
      min-height: 18px;
    }

    .law-selection-list {
      display: grid;
      gap: 12px;
      margin-bottom: 10px;
      max-height: 320px;
      overflow-y: auto;
      overscroll-behavior: contain;
      padding-right: 6px;
      scrollbar-gutter: stable;
    }

    .law-selection-empty-search {
      margin-bottom: 10px;
    }

    .law-selection-category {
      border: 1px solid #d7dce3;
      border-radius: 10px;
      overflow: hidden;
      background: #fff;
    }

    .law-selection-category h4 {
      margin: 0;
      padding: 10px 12px;
      background: #f1f3f4;
    }

    .law-selection-item {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 10px 12px;
      border-top: 1px solid #eceff1;
      cursor: pointer;
      font-weight: normal;
    }

    .law-selection-item[hidden],
    .law-selection-category[hidden],
    .law-selection-empty-search[hidden] {
      display: none;
    }

    .law-selection-item:hover {
      background: #f8f9fa;
    }

    .law-selection-item input {
      width: auto;
      margin-top: 3px;
      flex: 0 0 auto;
    }

    .law-selection-description {
      display: grid;
      gap: 4px;
    }

    .law-selection-penalties {
      color: #5f6368;
      font-size: 12px;
    }

    .law-description-details {
      margin-top: 8px;
      max-width: 680px;
    }

    .law-description-details summary {
      width: fit-content;
      cursor: pointer;
      color: #174ea6;
      font-size: 13px;
      font-weight: 700;
    }

    .law-description-text {
      margin-top: 8px;
      padding: 10px 12px;
      border-left: 3px solid #1a73e8;
      border-radius: 6px;
      background: #f6f9fe;
      white-space: pre-wrap;
      overflow-wrap: anywhere;
    }

    .rank-order-actions {
      display: inline-flex;
      gap: 6px;
      align-items: center;
    }

    .rank-order-button {
      width: 34px !important;
      min-width: 34px;
      padding: 6px 8px !important;
    }

    .pre-line {
      white-space: pre-line;
    }

    .admin-select {
      min-width: 220px;
    }

    .closed-row td {
      background: #e0e0e0;
      color: #555;
    }

    .closed-row button {
      opacity: 0.75;
    }

    .fictional-documents-row td {
      background: #fff3cd;
    }

    .fictional-documents-row td:first-child {
      box-shadow: inset 4px 0 0 #f9ab00;
    }

    .closed-row.fictional-documents-row td {
      background: #e8dfbf;
    }

    #pageMembers button,
    #pageJusticeMembers button {
      width: auto;
      white-space: nowrap;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    #pageMembers .form-actions,
    #pageJusticeMembers .form-actions {
      justify-content: flex-start;
      align-items: flex-start;
    }

    #pageMembers .toolbar button,
    #pageJusticeMembers .toolbar button {
      flex: 0 0 auto;
    }

    #pageMembers .actions button,
    #pageJusticeMembers .actions button {
      width: auto;
    }


    .police-admin1-only[hidden],
    .police-admin2-only[hidden] {
      display: none !important;
    }

    .justice-admin1-only[hidden] {
      display: none !important;
    }

    .unified-role-cell {
      min-width: 210px;
    }

    .unified-role-details {
      display: grid;
      gap: 6px;
    }

    .unified-role-label {
      display: inline-block;
      width: fit-content;
      padding: 2px 7px;
      border-radius: 999px;
      background: #e8f0fe;
      color: #174ea6;
      font-size: 12px;
      font-weight: 700;
    }

    .unified-role-label.justice {
      background: #f3e8fd;
      color: #7627bb;
    }

    .unified-role-label.judge {
      background: #e6f4ea;
      color: #137333;
    }

    .unified-role-label.admin {
      background: #fce8e6;
      color: #a50e0e;
    }

    .judge-workflow-box {
      margin-top: 14px;
      padding: 14px;
      border: 1px solid #c7cbd1;
      border-radius: 8px;
      background: #f8f9fa;
    }

    .judge-workflow-box textarea {
      margin-top: 8px;
    }

    .judge-workflow-actions {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 10px;
      margin-top: 10px;
    }

    #judgeRequestStatus {
      min-height: 18px;
      font-weight: 700;
    }

    #judgeRequestStatus.error {
      color: #c5221f;
    }

    #judgeRequestStatus.success {
      color: #137333;
    }

    .judge-workflow-actions button {
      width: auto;
    }

    .unified-role-cell select {
      min-width: 185px;
    }

    .unified-member-name strong,
    .unified-member-name span {
      display: block;
    }

    .unified-member-name span {
      margin-top: 4px;
      overflow-wrap: anywhere;
    }

    .rank-admin-box,
    .member-admin-box {
      border: 1px solid #d7dce1;
      border-radius: 12px;
      padding: 18px;
      margin: 18px 0 24px 0;
      background: #fafafa;
    }

    .rank-admin-list {
      display: grid;
      gap: 10px;
      margin-top: 16px;
    }

    .rank-admin-row {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px;
      border: 1px solid #ddd;
      border-radius: 8px;
      background: white;
      flex-wrap: wrap;
    }

    .rank-admin-row strong {
      flex: 1 1 220px;
    }

    .rank-category-card {
      border: 1px solid #d7dce1;
      border-radius: 12px;
      margin: 18px 0;
      overflow: hidden;
      background: white;
    }

    .rank-category-header {
      padding: 14px 16px;
      background: #eef3f8;
      border-bottom: 1px solid #d7dce1;
    }

    .rank-category-header h3 {
      margin: 0;
    }

    .rank-category-count {
      color: #666;
      font-size: 13px;
      margin-top: 4px;
    }

    .rank-category-body {
      overflow-x: auto;
    }

    .rank-category-body table {
      margin: 0;
      min-width: 850px;
    }

    .rank-select-control {
      display: flex;
      gap: 8px;
      align-items: center;
      flex-wrap: wrap;
    }

    .rank-select-control select {
      min-width: 180px;
      flex: 1 1 180px;
    }

    .rank-select-control button {
      width: auto;
      white-space: nowrap;
    }

    .read-only-admin-level {
      white-space: nowrap;
    }

    .catalog-admin-box {
      border: 1px solid #d2e3fc;
      border-radius: 9px;
      padding: 10px 12px;
      background: #eef3fd;
      margin: 0;
    }

    .branding-options-box {
      margin-top: 14px;
    }

    .branding-options-box h3 {
      margin: 0 0 10px;
    }

    .branding-options-form {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
      gap: 12px;
      align-items: start;
    }

    .branding-options-form > div:not(.form-actions) {
      display: flex;
      flex-direction: column;
      align-self: start;
      min-width: 0;
      width: 100%;
    }

    .branding-options-form > div:not(.form-actions) .small {
      min-height: 34px;
    }

    .branding-options-form .form-actions {
      grid-column: 1 / -1;
    }

    .branding-options-form button {
      width: auto;
    }

    .site-logo-options {
      margin-top: 14px;
      padding-top: 14px;
      border-top: 1px solid #c6d7f3;
    }

    .site-logo-options h4 {
      margin: 0 0 10px;
    }

    .site-logo-preview {
      display: flex;
      align-items: center;
      justify-content: center;
      width: min(190px, 100%);
      min-height: 76px;
      margin-bottom: 10px;
      padding: 8px;
      border: 1px dashed #9eb9df;
      border-radius: 8px;
      background: rgba(255, 255, 255, 0.55);
    }

    .site-logo-preview img {
      display: block;
      max-width: 176px;
      max-height: 110px;
      width: auto;
      height: auto;
      object-fit: contain;
    }

    .site-logo-preview-empty {
      color: #64748b;
      text-align: center;
    }

    .site-logo-upload-controls {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }

    .site-logo-upload-controls button {
      width: auto;
    }

    .site-logo-upload-status {
      margin-top: 7px;
      min-height: 18px;
    }

    .justice-options-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
      gap: 10px;
      margin-top: 8px;
    }

    .justice-options-grid .small {
      margin-top: 4px;
      line-height: 1.35;
    }

    .catalog-admin-toggle {
      display: flex;
      align-items: center;
      gap: 7px;
      font-weight: bold;
      font-size: 14px;
      margin: 0;
      cursor: pointer;
    }

    .catalog-admin-toggle input {
      width: auto;
    }

    .law-editor-box {
      border: 1px solid #d7dce1;
      border-radius: 12px;
      padding: 18px;
      margin: 18px 0 24px 0;
      background: #fafafa;
    }

    .law-editor-box > h3:first-child {
      margin-top: 0;
    }

    .law-admin-only[hidden] {
      display: none !important;
    }

    #pageLaws button {
      width: auto;
      white-space: nowrap;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    #pageLaws .form-actions {
      justify-content: flex-start;
      align-items: flex-start;
    }

    #pageLaws .toolbar {
      align-items: center;
      flex-wrap: wrap;
    }

    #pageLaws .toolbar input[type="text"] {
      flex: 1 1 320px;
    }

    #pageLaws .toolbar button {
      flex: 0 0 auto;
    }

    .law-category-card {
      border: 1px solid #d7dce1;
      border-radius: 12px;
      margin: 18px 0;
      overflow: hidden;
      background: white;
    }

    .law-category-header {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      align-items: center;
      padding: 14px 16px;
      background: #eef3f8;
      border-bottom: 1px solid #d7dce1;
      flex-wrap: wrap;
    }

    .law-category-header h3 {
      margin: 0;
    }

    .law-category-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }

    .law-category-actions button,
    .law-actions button {
      width: auto;
      white-space: nowrap;
    }

    .law-order-button {
      min-width: 38px;
      padding-left: 10px;
      padding-right: 10px;
      font-weight: bold;
    }

    .law-category-body {
      overflow-x: auto;
      padding: 0;
    }

    .law-category-body table {
      margin: 0;
      min-width: 850px;
    }

    .law-category-body > .small {
      margin: 0;
      padding: 16px;
    }

    .law-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }

    .law-meta {
      color: #666;
      font-size: 12px;
      margin-top: 6px;
    }

    body.dark-mode {
      color-scheme: dark;
      background: #0d1117;
      color: #e6edf3;
    }

    body.dark-mode .topbar {
      background: #161b22;
      border-bottom: 1px solid #30363d;
    }

    body.dark-mode .menu {
      background: #161b22;
      border-right-color: #30363d;
    }

    body.dark-mode .menu button {
      background: rgba(255, 255, 255, 0.06);
      border-color: #4b5563;
      color: #f0f6fc;
    }

    body.dark-mode .menu button:hover {
      background: rgba(255, 255, 255, 0.12);
    }

    body.dark-mode .menu button.active {
      background: #e6edf3;
      color: #0969da;
    }

    body.dark-mode .userbar,
    body.dark-mode .container,
    body.dark-mode .app-dialog-card {
      background: #161b22;
      color: #e6edf3;
      border-color: #30363d;
    }

    body.dark-mode .container {
      box-shadow: 0 4px 22px rgba(0, 0, 0, 0.38);
    }

    body.dark-mode .theme-toggle {
      background: #253041;
      color: #f0c96b;
      border-color: #4b5563;
    }

    body.dark-mode .user-role-badge,
    body.dark-mode .unified-role-label.admin {
      background: #5a2323;
      color: #ffb4ab;
    }

    body.dark-mode .admin-simulation-bar {
      background: #3a321d;
      color: #f0e6bd;
      border-color: #8a6d1d;
    }

    body.dark-mode .admin-simulation-warning {
      color: #f0c96b;
    }

    body.dark-mode input,
    body.dark-mode textarea,
    body.dark-mode select {
      background: #0d1117;
      color: #e6edf3;
      border-color: #3d4652;
    }

    body.dark-mode input::placeholder,
    body.dark-mode textarea::placeholder {
      color: #7d8590;
    }

    body.dark-mode input[readonly],
    body.dark-mode input:disabled,
    body.dark-mode textarea:disabled,
    body.dark-mode select:disabled {
      background: #252b33;
      color: #9da7b3;
      border-color: #3d4652;
    }

    body.dark-mode input[type="checkbox"],
    body.dark-mode input[type="radio"] {
      accent-color: #58a6ff;
    }

    body.dark-mode input:focus,
    body.dark-mode textarea:focus,
    body.dark-mode select:focus,
    body.dark-mode button:focus-visible,
    body.dark-mode a:focus-visible {
      outline: 2px solid #58a6ff;
      outline-offset: 2px;
    }

    body.dark-mode .stat-card,
    body.dark-mode .edit-box,
    body.dark-mode .closed-toggle,
    body.dark-mode .evidence-upload-box,
    body.dark-mode .checkbox-list,
    body.dark-mode .fictional-documents-list,
    body.dark-mode .fictional-document-section,
    body.dark-mode .fictional-scope-options .checkbox-item,
    body.dark-mode .law-selection-category,
    body.dark-mode .judge-workflow-box,
    body.dark-mode .rank-admin-box,
    body.dark-mode .member-admin-box,
    body.dark-mode .rank-admin-row,
    body.dark-mode .rank-category-card,
    body.dark-mode .law-editor-box,
    body.dark-mode .law-category-card {
      background: #1c232d;
      color: #e6edf3;
      border-color: #30363d;
    }

    body.dark-mode .record-part {
      background: #161b22;
      border-color: #30363d;
    }

    body.dark-mode .record-part-police .record-part-header {
      background: #102a46;
      color: #9ecbff;
      border-color: #1f6feb;
    }

    body.dark-mode .record-part-justice {
      border-color: #6e5a1f;
    }

    body.dark-mode .record-part-justice .record-part-header {
      background: #352b12;
      color: #f2cc60;
      border-color: #9e6a03;
    }

    body.dark-mode .record-part-description {
      color: #9da7b3;
    }

    body.dark-mode .stat-number {
      color: #58a6ff;
    }

    body.dark-mode .small,
    body.dark-mode .stat-empty,
    body.dark-mode .law-meta,
    body.dark-mode .law-selection-penalties,
    body.dark-mode .rank-category-count,
    body.dark-mode .case-access-audit {
      color: #9da7b3;
    }

    body.dark-mode .error {
      color: #ff7b72;
    }

    body.dark-mode .success {
      color: #56d364;
    }

    body.dark-mode .hint,
    body.dark-mode .catalog-admin-box,
    body.dark-mode .case-access-box {
      background: #142238;
      color: #dbeafe;
      border-color: #315b8a;
    }

    body.dark-mode .penalty-total-summary {
      background: #142238;
      color: #dbeafe;
      border-color: #315b8a;
    }

    body.dark-mode .law-description-details summary {
      color: #79c0ff;
    }

    body.dark-mode .law-description-text {
      background: #142238;
      color: #dbeafe;
      border-left-color: #58a6ff;
    }

    body.dark-mode .case-access-link {
      color: #79c0ff;
    }

    body.dark-mode .checkbox-item:hover,
    body.dark-mode .law-selection-item:hover {
      background: #252d38;
    }

    body.dark-mode .law-selection-category h4,
    body.dark-mode .rank-category-header,
    body.dark-mode .law-category-header,
    body.dark-mode th {
      background: #252d38;
      color: #f0f6fc;
      border-color: #30363d;
    }

    body.dark-mode .law-selection-item,
    body.dark-mode th,
    body.dark-mode td {
      border-color: #30363d;
    }

    body.dark-mode .closed-row td {
      background: #242a32;
      color: #9da7b3;
    }

    body.dark-mode .fictional-documents-row td {
      background: #3a321d;
      color: #f0e6bd;
    }

    body.dark-mode .closed-row.fictional-documents-row td {
      background: #343026;
      color: #b8ad88;
    }

    body.dark-mode .evidence-gallery-empty {
      background: #1c232d;
      color: #9da7b3;
      border-color: #4b5563;
    }

    body.dark-mode .evidence-thumbnail {
      background: #252d38;
      color: #9da7b3;
      border-color: #4b5563;
    }

    body.dark-mode .evidence-modal-close {
      background: #e6edf3;
      color: #161b22;
    }

    body.dark-mode .unified-role-label {
      background: #1c3d5a;
      color: #79c0ff;
    }

    body.dark-mode .unified-role-label.justice {
      background: #3b2858;
      color: #d2a8ff;
    }

    body.dark-mode .unified-role-label.judge {
      background: #1e4620;
      color: #7ee787;
    }

    body.dark-mode button.secondary {
      background: #4b5563;
    }

    body.dark-mode .edit-actions .transfer-button,
    body.dark-mode .edit-actions .takeover-button,
    body.dark-mode .edit-actions .assign-button,
    body.dark-mode .assignee-control .assign-button {
      background: #1c3d5a;
      color: #79c0ff;
      border-color: #315b8a;
    }

    .personnel-file-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 18px;
      flex-wrap: wrap;
    }

    .personnel-summary-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
      gap: 12px;
      margin: 16px 0 22px;
    }

    .personnel-summary-card {
      border: 1px solid #d8dee8;
      border-radius: 12px;
      padding: 14px;
      background: #f8fafc;
      min-height: 86px;
    }

    .personnel-summary-card .label {
      display: block;
      color: #667085;
      font-size: 0.82rem;
      margin-bottom: 5px;
    }

    .personnel-summary-card strong {
      display: block;
      font-size: 1rem;
      word-break: break-word;
    }

    .personnel-section {
      border: 1px solid #d8dee8;
      border-radius: 12px;
      padding: 16px;
      background: #ffffff;
      margin-top: 16px;
    }

    .personnel-section > h3:first-child {
      margin-top: 0;
    }

    .personnel-timeline,
    .personnel-notes-list,
    .training-card-list {
      display: grid;
      gap: 10px;
    }

    .personnel-timeline-item,
    .personnel-note-card,
    .training-definition-card,
    .completed-training-card {
      border: 1px solid #d8dee8;
      border-radius: 10px;
      padding: 12px;
      background: #f8fafc;
    }

    .personnel-timeline-item strong,
    .training-definition-card strong,
    .completed-training-card strong {
      display: block;
      margin-bottom: 4px;
    }

    .personnel-note-text,
    .training-description-text {
      white-space: pre-wrap;
      word-break: break-word;
      margin: 6px 0;
    }

    .trainer-badge {
      display: inline-flex;
      align-items: center;
      width: fit-content;
      margin-left: 8px;
      padding: 2px 7px;
      border-radius: 999px;
      font-size: 0.75rem;
      font-weight: 700;
      background: #e0f2fe;
      color: #075985;
    }

    .trainer-control {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      white-space: nowrap;
      font-size: 0.84rem;
    }

    .record-measures {
      display: grid;
      justify-items: start;
      gap: 5px;
      min-width: 122px;
    }

    .measure-badge {
      display: inline-flex;
      align-items: center;
      width: fit-content;
      padding: 3px 8px;
      border-radius: 999px;
      font-size: 0.75rem;
      font-weight: 700;
      line-height: 1.2;
      white-space: nowrap;
    }

    .measure-badge.arrest {
      background: #fee2e2;
      color: #991b1b;
      border: 1px solid #fecaca;
    }

    .measure-badge.search {
      background: #ede9fe;
      color: #5b21b6;
      border: 1px solid #ddd6fe;
    }

    .training-form-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
      gap: 12px;
    }

    .training-form-grid .full,
    .training-form-grid .form-actions {
      grid-column: 1 / -1;
    }

    #pageTrainings button {
      width: auto;
      padding: 6px 10px;
      border-radius: 6px;
      font-size: 13px;
      line-height: 1.2;
      white-space: nowrap;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    #pageTrainings .form-actions {
      align-items: flex-start;
      justify-content: flex-start;
    }

    body.dark-mode .personnel-summary-card,
    body.dark-mode .personnel-section,
    body.dark-mode .personnel-timeline-item,
    body.dark-mode .personnel-note-card,
    body.dark-mode .training-definition-card,
    body.dark-mode .completed-training-card {
      background: #18212f;
      border-color: #334155;
    }

    body.dark-mode .personnel-summary-card .label {
      color: #94a3b8;
    }

    body.dark-mode .trainer-badge {
      background: #0c4a6e;
      color: #bae6fd;
    }

    body.dark-mode .measure-badge.arrest {
      background: #5f1d24;
      color: #fecaca;
      border-color: #7f1d1d;
    }

    body.dark-mode .measure-badge.search {
      background: #3b2563;
      color: #ddd6fe;
      border-color: #5b21b6;
    }

    body.dark-mode .dashboard-measure-item {
      background: #161b22;
      border-color: #30363d;
    }

    body.dark-mode .dashboard-measure-meta,
    body.dark-mode .dashboard-measure-record-meta {
      color: #9da7b3;
    }

    body.dark-mode .dashboard-record-link {
      color: #58a6ff;
    }

    body.dark-mode .site-logo-options {
      border-top-color: #334155;
    }

    body.dark-mode .site-logo-preview {
      background: #111827;
      border-color: #475569;
    }

    body.dark-mode .site-logo-preview-empty {
      color: #94a3b8;
    }

    @media (max-width: 800px) {
      .menu {
        width: 184px;
        padding: 26px 10px 14px;
      }

      .menu-logo {
        max-width: 154px;
        max-height: 96px;
      }

      .menu button {
        padding: 9px 10px;
        font-size: 14px;
      }

      body.app-authenticated .topbar,
      body.app-authenticated .userbar,
      body.app-authenticated .admin-simulation-bar {
        margin-left: 184px;
      }

      body.app-authenticated #appContainer {
        margin: 16px 16px 16px 200px;
      }

      .dashboard-measure-item {
        grid-template-columns: 1fr;
        align-items: start;
      }

      .dashboard-record-link {
        width: fit-content;
      }

      .topbar {
        padding: 16px;
      }

      .userbar {
        padding: 10px 16px;
      }

      .container {
        margin: 16px;
      }

      form {
        grid-template-columns: 1fr;
      }

      .record-part-grid {
        grid-template-columns: 1fr;
      }

      .record-part-grid > .full {
        grid-column: span 1;
      }

      .record-part-header {
        align-items: flex-start;
        flex-direction: column;
      }

      .record-part-description {
        text-align: left;
      }

      .stats-grid {
        grid-template-columns: 1fr;
      }

      .fictional-documents-list {
        grid-template-columns: 1fr;
      }

      .full,
      .form-actions {
        grid-column: span 1;
      }

      .toolbar {
        flex-direction: column;
      }

      .form-actions {
        flex-direction: column;
      }

      .edit-actions {
        flex-direction: row;
      }

      .edit-actions button {
        flex: 1 1 150px;
      }

      .actions {
        flex-direction: column;
      }
    }
