:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #eef2f5;
  --text: #1f2933;
  --muted: #66788a;
  --line: #d8e0e7;
  --accent: #416faf;
  --accent-strong: #31588f;
  --warn: #9a5b00;
  --shadow: 0 18px 42px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.site-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 34px clamp(18px, 4vw, 56px);
  background: var(--accent);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.logo-frame {
  display: grid;
  place-items: center;
  width: clamp(240px, 26vw, 320px);
  min-height: 88px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 32px rgba(29, 55, 90, 0.18);
  overflow: hidden;
}

.logo-frame img {
  display: block;
  width: 100%;
  max-height: 92px;
  object-fit: contain;
  padding: 16px 20px;
}

.logo-frame img[hidden] {
  display: none;
}

.logo-frame span {
  color: var(--accent-strong);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0;
  padding: 18px 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #dbe7f7;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.65rem, 3vw, 2.8rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.status-card {
  align-self: center;
  min-width: 170px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  text-align: right;
}

.status-card span {
  display: block;
  font-size: 2rem;
  font-weight: 800;
}

.status-card small {
  color: #d7e1e8;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 48px;
}

.controls,
.content-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(160px, 1fr));
  gap: 14px;
  padding: 18px;
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus {
  outline: 3px solid rgba(65, 111, 175, 0.2);
  border-color: var(--accent);
}

.content-panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin-bottom: 4px;
  font-size: 1.2rem;
}

.panel-header p {
  margin-bottom: 0;
  color: var(--muted);
}

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

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

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-muted);
  color: #405162;
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  color: #263442;
}

.file-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
}

.file-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 7px;
  background: #e8eef8;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.file-name {
  display: block;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.path-note {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  background: #edf3f8;
  color: #32485a;
  font-weight: 800;
}

.access-note {
  color: var(--warn);
  font-size: 0.86rem;
  font-weight: 700;
}

.empty-state {
  display: grid;
  gap: 6px;
  padding: 46px 18px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  color: var(--text);
  font-size: 1.05rem;
}

@media (max-width: 820px) {
  .site-header {
    flex-direction: column;
    padding-top: 26px;
    padding-bottom: 26px;
  }

  .brand {
    align-items: flex-start;
  }

  .status-card {
    width: 100%;
    text-align: left;
  }

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

@media (max-width: 520px) {
  .brand {
    flex-direction: column;
  }

  .logo-frame {
    width: min(100%, 300px);
    min-height: 76px;
  }

  .logo-frame img {
    max-height: 82px;
    padding: 14px 16px;
  }
}

.login-panel {
  display: grid;
  place-items: center;
  min-height: 55vh;
}

.login-card {
  width: min(460px, 100%);
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.login-card h2 {
  margin-top: 0;
}

.login-card form {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.login-card input {
  width: 100%;
}

.login-card button,
.user-bar button {
  cursor: pointer;
}

.login-message {
  min-height: 22px;
  color: #9f1239;
  font-weight: 600;
}

.user-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  padding: 14px 18px;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 14px;
}

#userBadge {
  font-weight: 700;
}

[hidden] {
  display: none !important;
}

.r3m-dev-mark {
  position: fixed;
  right: clamp(18px, 3vw, 34px);
  bottom: clamp(16px, 3vw, 28px);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 15px 10px 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(10px);
  user-select: none;
}

body:has(#appShell:not([hidden])) .r3m-dev-mark {
  display: none;
}

.r3m-dev-mark::before {
  content: "";
  width: 3px;
  height: 42px;
  border-radius: 999px;
  background: linear-gradient(180deg, #5aa145, #7fb85e);
}

.r3m-dev-mark__text {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
  color: #6b7280;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.r3m-dev-mark__text strong {
  margin-top: 3px;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: none;
}

.r3m-dev-mark img {
  display: block;
  width: 86px;
  height: auto;
}

@media (max-width: 720px) {
  .r3m-dev-mark {
    right: 16px;
    bottom: 14px;
    padding: 9px 12px;
  }

  .r3m-dev-mark__text {
    display: none;
  }

  .r3m-dev-mark img {
    width: 76px;
  }
}

.admin-panel {
  margin: 22px 0;
  padding: 22px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 22px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.admin-form {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr 1fr auto;
  gap: 14px;
  align-items: end;
  margin: 18px 0 10px;
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  color: #475569;
  font-weight: 600;
}

.admin-form input {
  height: 42px;
  border: 1px solid rgba(100, 116, 139, 0.35);
  border-radius: 12px;
  padding: 0 12px;
  font-size: 14px;
  background: #fff;
}

.admin-form button,
.admin-actions button {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  font-weight: 700;
  cursor: pointer;
  background: #1f6f43;
  color: #fff;
}

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

.admin-actions button {
  background: #334155;
  padding: 8px 10px;
  font-size: 12px;
}

.admin-actions button.danger {
  background: #b42318;
}

.admin-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.badge-ok {
  background: #dcfce7;
  color: #166534;
}

.badge-muted {
  background: #f1f5f9;
  color: #64748b;
}

.admin-table-wrap {
  margin-top: 16px;
}

@media (max-width: 900px) {
  .admin-form {
    grid-template-columns: 1fr;
  }

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