* {
  box-sizing: border-box;
}
:root {
  color-scheme: light;
  --page-bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-brand: #f5f1ed;
  --text: #1f2933;
  --muted: #667085;
  --border: rgba(16, 24, 40, 0.1);
  --border-strong: rgba(107, 87, 72, 0.28);
  --brand: #6b5748;
  --brand-hover: #594638;
  --brand-text: #513f33;
  --shadow: rgba(16, 24, 40, 0.08);
}
[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #11100f;
  --surface: #191715;
  --surface-soft: #211f1d;
  --surface-brand: #2b2520;
  --text: #f5f1ed;
  --muted: #b9afa6;
  --border: rgba(245, 241, 237, 0.12);
  --border-strong: rgba(205, 190, 166, 0.34);
  --brand: #c8b99d;
  --brand-hover: #b6a789;
  --brand-text: #f5ead8;
  --shadow: rgba(0, 0, 0, 0.35);
}
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--page-bg);
  color: var(--text);
}
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.brand {
  margin-bottom: 1rem;
}
.brand-logo {
  width: 118px;
  height: auto;
}
.menu {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}
.sidebar-user {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(16, 24, 40, 0.12);
}
.user-name {
  font-weight: 700;
  margin: 0.2rem 0 0.6rem;
}
.menu-link {
  text-decoration: none;
  color: var(--text);
  padding: 0.68rem 0.78rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
}
.menu-link:hover {
  background: var(--surface-soft);
  border-color: rgba(107, 87, 72, 0.18);
}
.menu-link.active {
  background: var(--surface-brand);
  border-color: var(--border-strong);
  color: var(--brand-text);
  font-weight: 600;
}
.sidebar-footer {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 0.55rem;
  margin-top: 1rem;
  padding-top: 1rem;
}
.sidebar-footer-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.theme-tabs {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0.2rem;
}
.theme-tab {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-weight: 700;
  margin: 0;
  padding: 0.45rem 0.55rem;
}
.theme-tab.active {
  background: var(--brand);
  color: #ffffff;
}
.content {
  padding: 1.5rem;
  min-width: 0;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
  margin-bottom: 1rem;
}
.user-profile,
.auth-links {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.auth-links .btn-primary {
  margin-top: 0;
}
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #6b5748;
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
}
.profile-text {
  display: grid;
  line-height: 1.1;
  color: var(--text);
  text-decoration: none;
}
.profile-label {
  color: var(--muted);
  font-size: 0.75rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}
.grid-two .full {
  grid-column: 1 / -1;
}
input,
select,
textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 0.25rem;
  background: var(--surface);
  color: var(--text);
}
input[type="checkbox"] {
  width: auto;
  margin-top: 0;
}
.btn,
.btn-primary,
button {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  padding: 0.45rem 0.7rem;
  display: inline-block;
  cursor: pointer;
}
.btn-primary {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
  margin-top: 0.8rem;
}
.btn-primary:hover,
.btn-primary:focus {
  background: var(--brand-hover);
  color: #ffffff;
}
.btn.danger {
  border-color: #c24141;
  color: #c24141;
}
.muted {
  color: var(--muted);
}
.messages {
  margin-bottom: 1rem;
}
.message {
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  margin-bottom: 0.4rem;
  background: #eef2ff;
}
.message.error {
  background: #fee2e2;
}
.message.success {
  background: #dcfce7;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0.8rem 0;
}
.metrics div {
  background: var(--surface-soft);
  padding: 0.7rem;
  border-radius: 8px;
}
.metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}
.metrics strong {
  font-size: 1.1rem;
}
.downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  border: 1px solid rgba(16, 24, 40, 0.1);
  padding: 0.45rem;
  text-align: left;
  font-size: 0.9rem;
}
.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.file-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(16, 24, 40, 0.08);
  gap: 0.75rem;
}
.actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}
.actions form {
  margin: 0;
}
.inline-form {
  margin: 0;
}
.row-actions {
  margin-top: 0.75rem;
}
.export-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.55rem;
}
.results-action-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid rgba(107, 87, 72, 0.18);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 10px 24px var(--shadow);
}
.results-action-bar > div:first-child {
  display: grid;
  gap: 0.15rem;
}
.results-action-bar .btn-primary {
  margin-top: 0;
}
.selected-counter {
  white-space: nowrap;
}
.select-column {
  width: 92px;
}
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.row-checkbox,
#selectAllRows {
  width: 18px;
  height: 18px;
  accent-color: #6b5748;
  cursor: pointer;
}
.selectable-row {
  cursor: pointer;
}
.selectable-row:hover {
  background: #fbf8f5;
}
.selected-row {
  background: var(--surface-brand);
}
.selected-row:hover {
  background: #efe7df;
}
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}
.section-header h2,
.section-header p {
  margin-top: 0;
}
.compact-table {
  max-height: 320px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.form-errors {
  margin-top: 0.8rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: #fee2e2;
  color: #7f1d1d;
}
.form-errors ul {
  margin: 0.25rem 0;
}
.profile-card {
  max-width: 780px;
}
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem;
}
.auth-note {
  margin-bottom: 0;
}
.auth-note a {
  color: var(--brand);
  font-weight: 700;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.8rem;
}
.form-actions .btn-primary {
  margin-top: 0;
}
.processing-overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(15, 23, 42, 0.32);
  z-index: 20;
}
.processing-overlay.show {
  display: grid;
}
.processing-panel {
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  width: min(340px, calc(100vw - 2rem));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.2rem;
  box-shadow: 0 20px 60px var(--shadow);
}
.processing-panel span {
  color: var(--muted);
  text-align: center;
}
.role-form {
  margin: 0;
}
.role-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 0.45rem;
  align-items: end;
}
.role-controls select,
.role-controls .btn-primary {
  margin-top: 0;
}
.role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}
.role-grid > div {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem;
}
.access-denied {
  max-width: 620px;
}
.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid #e5e7eb;
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .theme-tab.active {
  color: #191715;
}
[data-theme="dark"] th,
[data-theme="dark"] td,
[data-theme="dark"] .file-list li {
  border-color: var(--border);
}
[data-theme="dark"] .selectable-row:hover,
[data-theme="dark"] .selected-row:hover {
  background: #332b24;
}
[data-theme="dark"] .message {
  background: #252c45;
}
[data-theme="dark"] .message.success {
  background: #193a2b;
}
[data-theme="dark"] .message.error,
[data-theme="dark"] .form-errors {
  background: #442121;
  color: #ffd8d8;
}
[data-theme="dark"] .avatar {
  background: var(--brand);
  color: #191715;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(16, 24, 40, 0.1);
  }
  .grid-two {
    grid-template-columns: 1fr;
  }
  .role-grid,
  .role-controls {
    grid-template-columns: 1fr;
  }
  .results-action-bar {
    position: static;
    display: grid;
  }
  .section-header {
    display: grid;
  }
}
