:root {
  --bg: #f3f7fb;
  --ink: #071a33;
  --muted: #516174;
  --line: #d4dde9;
  --panel: #ffffff;
  --accent: #2f64e8;
  --accent-dark: #244fbb;
  --danger: #c92a22;
  --focus: #7aa7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--bg);
  font-family: "Roboto", "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 12px 16px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(122, 167, 255, 0.45);
  outline-offset: 2px;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.login-view {
  position: relative;
  min-height: calc(100vh - 80px);
  display: grid;
  place-items: center;
}
.login-view::before {
  content: "";
  position: fixed;
  z-index: 0;
  inset: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(34, 64, 104, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 64, 104, 0.055) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  padding: 34px 34px 46px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(218, 226, 236, 0.9);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(42, 57, 78, 0.12);
}

.login-logo {
  display: block;
  width: min(282px, 88%);
  height: auto;
  margin: 0 auto 22px;
}

.login-title {
  margin: 0 0 24px;
  color: #304d91;
  font-family: "Roboto", "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
}

.login-card .access-code-label {
  color: #3f4650;
  font-family: "Roboto", "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 48px;
}

.login-card .password-toggle {
  position: absolute;
  top: 50%;
  right: 5px;
  display: grid;
  width: 38px;
  height: 34px;
  margin: 0;
  padding: 0;
  place-items: center;
  color: #596473;
  background: transparent;
  transform: translateY(-50%);
}

.password-toggle:hover {
  color: var(--accent-dark);
  background: #edf2fa;
}

.password-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.password-toggle .eye-closed,
.password-toggle.showing .eye-open {
  display: none;
}

.password-toggle.showing .eye-closed {
  display: block;
}

.login-card label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.login-card button {
  width: 100%;
  margin-top: 2px;
}

.login-card .form-message {
  text-align: center;
}

.tool-panel,
.files-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(20, 38, 51, 0.08);
}

.tool-panel h2,
.files-section h2 {
  margin: 0 0 18px;
  font-size: 22px;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
  font-weight: 700;
}

.form-message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
}

.form-message.error {
  color: var(--danger);
}

.storage-usage {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.storage-usage.warning {
  color: var(--danger);
  font-weight: 700;
}

.dashboard {
  display: grid;
  gap: 22px;
}

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

.topbar h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-weight: 700;
}

.ghost-button {
  color: var(--accent-dark);
  background: transparent;
  border: 1px solid var(--line);
}

.ghost-button:hover {
  color: #fff;
  background: var(--accent-dark);
}

.admin-panel {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 18px;
}

.history-menu {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.history-menu span {
  font-size: 19px;
  line-height: 1;
}

.history-modal {
  width: min(1040px, calc(100% - 32px));
  max-height: min(720px, calc(100vh - 48px));
  padding: 22px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(20, 38, 51, 0.22);
}

.history-modal::backdrop {
  background: rgba(18, 29, 43, 0.48);
}

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

.modal-heading h2 {
  margin: 0;
  font-size: 22px;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  font-size: 24px;
  line-height: 1;
}

.modal-close:hover {
  color: #fff;
  background: var(--accent-dark);
}

.audit-empty {
  padding: 16px 0;
  color: var(--muted);
}

.audit-list {
  display: grid;
  gap: 6px;
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.audit-row {
  display: grid;
  grid-template-columns: 88px minmax(110px, 0.8fr) minmax(180px, 1.5fr) minmax(100px, 0.8fr) 90px 140px;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
  font-size: 13px;
}

.audit-type {
  padding: 5px 8px;
  color: #fff;
  background: #2f64e8;
  border-radius: 4px;
  text-align: center;
  font-weight: 700;
}

.audit-type.upload {
  background: #087f5b;
}

.audit-type.deletion {
  background: var(--danger);
}

.audit-file,
.audit-user {
  overflow-wrap: anywhere;
  font-weight: 700;
}

.audit-group,
.audit-size,
.audit-date {
  color: var(--muted);
}

.tool-panel {
  padding: 22px;
}

.file-input-row,
.user-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.user-grid {
  grid-template-columns: 1fr auto 130px auto;
}

.user-grid input[name="name"] {
  grid-column: 1 / -1;
}

.user-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.user-row,
.file-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.file-meta,
.user-meta {
  display: grid;
  gap: 4px;
}

.file-name,
.user-name {
  overflow-wrap: anywhere;
  font-weight: 800;
}

.file-detail,
.user-role {
  color: var(--muted);
  font-size: 14px;
}

.files-section {
  padding: 22px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.files-list {
  display: grid;
  gap: 10px;
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover {
  background: #9f211b;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 24px, 1120px);
    padding: 24px 0;
  }

  .login-view,
  .admin-panel {
    grid-template-columns: 1fr;
  }

  .login-card {
    position: relative;
  z-index: 1;
  padding: 28px 24px 36px;
  }

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

  .topbar {
    width: 100%;
  }

  .history-modal {
    padding: 16px;
  }

  .modal-heading {
    align-items: flex-start;
  }

  .file-input-row,
  .user-grid,
  .file-row,
  .user-row,
  .audit-row {
    grid-template-columns: 1fr;
  }
}

.upload-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: center;
}

.upload-grid input[type="file"] {
  grid-column: 1;
}

.upload-grid button {
  grid-column: 1;
  justify-self: start;
}

.downloads-toolbar {
  margin: 0 0 14px;
}

.downloads-toolbar input {
  max-width: 460px;
}

.group-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.group-block + .group-block {
  margin-top: 10px;
}

.group-block > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  font-weight: 800;
}

.group-block > summary::-webkit-details-marker {
  display: none;
}

.group-block > summary {
  padding: 15px 16px;
  color: var(--ink);
  background: #f7fafc;
}

.group-block > summary span::before {
  content: ">";
  display: inline-block;
  width: 18px;
  color: var(--accent);
  transition: transform 0.18s ease;
}

.group-block[open] > summary span::before {
  transform: rotate(90deg);
}

.group-block summary small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.group-files {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #fff;
}

.group-files .file-row {
  border-radius: 6px;
}

@media (max-width: 820px) {
  .upload-grid,
  .upload-grid input[type="file"],
  .upload-grid button {
    grid-template-columns: 1fr;
    grid-column: auto;
  }

  .downloads-toolbar input {
    max-width: none;
  }
}
