:root {
  --bg: linear-gradient(140deg, #081327 0%, #11363c 55%, #0f5a42 100%);
  --card: rgba(5, 16, 32, 0.82);
  --text: #ecf4ff;
  --muted: #b5c9df;
  --action: #34d399;
  --action-hover: #10b981;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.container {
  min-height: 100vh;
  display: block;
  padding: 18px 24px;
}

.card {
  width: min(1500px, 98vw);
  min-height: calc(100vh - 36px);
  margin: 0 auto;
  border-radius: 18px;
  background: var(--card);
  padding: 24px;
  backdrop-filter: blur(8px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.34);
}

.broker-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 14px;
}

.broker-sidebar {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.24);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-user {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-menu {
  display: grid;
  gap: 8px;
}

.menu-btn {
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.menu-btn.is-active {
  background: var(--action);
  color: #032116;
  border-color: transparent;
}

.sidebar-logout {
  margin-top: auto;
}

.broker-content {
  min-width: 0;
}

.broker-view {
  margin-bottom: 0;
}

.user-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.summary-item {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.summary-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

h1 {
  margin: 0 0 10px;
}

.subtitle {
  margin: 0 0 20px;
  color: var(--muted);
}

.panel {
  margin-bottom: 16px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

.panel h2,
.panel h3 {
  margin-top: 0;
}

.hidden {
  display: none !important;
}

.login-form-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 100%;
  margin-bottom: 14px;
}

.login-form-stack input,
.login-form-stack button {
  width: 100%;
}

.status-message {
  margin: 0 0 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

#status-message-text {
  flex: 1;
}

.status-close {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.28);
  padding: 0;
  line-height: 1;
  font-size: 16px;
}

.status-close:hover {
  background: rgba(255, 255, 255, 0.24);
}

.status-message.error {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.18);
}

.status-message.success {
  border-color: rgba(52, 211, 153, 0.5);
  background: rgba(52, 211, 153, 0.18);
}

#auth-panel {
  width: min(520px, 100%);
  margin: 28px auto;
}

.form-row,
.upload-row,
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

input,
select,
button {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 10px 12px;
  font-size: 14px;
}

input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

select {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

select option {
  background: #eef4ff;
  color: #0b162b;
}

button {
  background: var(--action);
  color: #032116;
  font-weight: 700;
  border: 0;
  cursor: pointer;
}

button:hover {
  background: var(--action-hover);
}

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

.secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

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

pre {
  min-height: 180px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.32);
  border-radius: 12px;
  padding: 14px;
}

.session-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
}

.session-state {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 4px 8px;
  margin-left: 8px;
}

.role-standard {
  background: #1d4ed8;
  color: #dbeafe;
}

.role-admin {
  background: #a16207;
  color: #fef3c7;
}

.role-owner {
  background: #7c2d12;
  color: #ffedd5;
}

.users-editor-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

#view-admin {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#view-admin .form-row,
#view-admin .users-editor-list {
  width: 100%;
}

#refresh-users {
  align-self: flex-start;
  margin-bottom: 0;
}

.user-editor-item {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 10px;
  background: rgba(2, 8, 18, 0.4);
}

.user-editor-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.user-email {
  word-break: break-all;
}

.user-editor-controls {
  margin-bottom: 0;
}

.user-editor-controls select,
.user-editor-controls input {
  min-width: 140px;
}

.files-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
}

.files-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

.files-table th,
.files-table td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 13px;
}

.files-table th {
  color: var(--muted);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.03);
}

.files-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.files-table a {
  color: #99f6e4;
  font-weight: 700;
  text-decoration: none;
}

.files-table a:hover {
  text-decoration: underline;
}

.file-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.table-action-btn {
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.table-action-download {
  background: #22c55e;
  color: #032116;
}

.table-action-download:hover {
  background: #16a34a;
}

.table-action-delete {
  background: #ef4444;
  color: #fff;
}

.table-action-delete:hover {
  background: #dc2626;
}

@media (max-width: 700px) {
  .card {
    padding: 16px;
    width: 100%;
    min-height: auto;
  }

  .broker-shell {
    grid-template-columns: 1fr;
  }

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

  .user-summary-grid {
    grid-template-columns: 1fr;
  }
}
