* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: #eef2f7;
  color: #1f2937;
}

.page-header {
  padding: 16px 24px;
  background: #111827;
  color: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-header h1 {
  margin: 0;
  font-size: 24px;
}

.page-header p {
  margin: 6px 0 0;
  color: #d1d5db;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.layout {
  max-width: 1360px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}

.sidebar {
  display: grid;
  gap: 16px;
  position: static;
  align-content: start;
  min-width: 0;
}

.content {
  display: grid;
  gap: 16px;
}

.stats-stack {
  display: grid;
  gap: 12px;
}

.panel {
  background: #fff;
  border: 1px solid #dbe2ea;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.panel h2 {
  margin-top: 0;
}
.panel h3 {
  margin: 0 0 8px;
}

.hint {
  font-size: 13px;
  color: #6b7280;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.stat {
  background: #fff;
  border: 1px solid #dbe2ea;
  border-radius: 10px;
  padding: 12px;
}

.stat span {
  display: block;
  font-size: 12px;
  color: #6b7280;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr auto 120px;
  gap: 8px;
  margin-top: 8px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

input,
select,
button {
  height: 38px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 14px;
}

button {
  background: #2563eb;
  color: #fff;
  border: none;
  cursor: pointer;
}

button:hover {
  background: #1d4ed8;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-size: 14px;
}

.checkbox input {
  width: 16px;
  height: 16px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
  margin: 0;
}

.search-input-wrap {
  position: relative;
}

.search-input-wrap input {
  width: 100%;
  padding-right: 40px;
}

.filter-icon-btn {
  background: #f8fafc;
  color: #334155;
  border: 1px solid #cbd5e1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.filter-icon-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.filter-icon-btn.active {
  background: #e2e8f0;
}

.search-icon-inside {
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  border: 1px solid #cbd5e1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-icon-inside:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.search-icon-inside:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}

.search-icon-inside svg {
  pointer-events: none;
}

.search-icon-btn {
  background: #2563eb;
  color: #ffffff;
  border: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ghost-btn {
  background: #1f2937;
  border: 1px solid #4b5563;
  color: #f9fafb;
}

.ghost-btn:hover {
  background: #374151;
}

.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}

.table-head h2 {
  margin: 0;
  flex: 0 0 auto;
}

.table-search-inline {
  flex: 1 1 auto;
  max-width: 560px;
}

.table-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pager {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.pager button {
  height: 30px;
  padding: 0 8px;
  font-size: 13px;
}

.pager span {
  font-size: 13px;
  color: #475569;
}

.table-wrap {
  overflow-x: auto;
}

.table-main {
  max-height: 420px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 14px;
}

th {
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
}

.muted {
  color: #6b7280;
}

.hidden {
  display: none !important;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.list li {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  font-size: 14px;
  background: #f8fafc;
}

.danger {
  color: #b91c1c;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-error {
  background: #fee2e2;
  color: #991b1b;
}

.link-btn {
  background: #0f766e;
  height: 32px;
  padding: 0 8px;
  font-size: 13px;
}

.link-btn:hover {
  background: #0d9488;
}

.imports-wrap {
  max-height: 280px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #ffffff;
  max-width: 100%;
}

.compact-table {
  min-width: 100%;
  table-layout: fixed;
}

.compact-table th,
.compact-table td {
  font-size: 12px;
  padding: 8px;
  vertical-align: top;
}

.compact-table th:nth-child(1),
.compact-table td:nth-child(1) {
  width: 88px;
}

.compact-table th:nth-child(3),
.compact-table td:nth-child(3) {
  width: 86px;
}

.file-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.error-text {
  display: block;
  margin-top: 2px;
  color: #991b1b;
}

.quick-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 2px;
}

.qa-btn {
  min-width: 156px;
  height: 34px;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  border: 1px solid #cbd5e1;
  font-size: 13px;
}

.qa-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.side-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 40;
  display: flex;
  justify-content: flex-end;
  padding: 16px;
}

.side-modal-card {
  width: 520px;
  max-width: 100%;
  height: 100%;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #dbe2ea;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
  padding: 16px;
  overflow: auto;
}

.side-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

body.auth-locked .layout {
  grid-template-columns: 1fr;
  max-width: 560px;
  min-height: calc(100vh - 90px);
  align-items: center;
}

body.auth-locked .sidebar {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
}

body.auth-locked #contentArea,
body.auth-locked #quickActions,
body.auth-locked #statsPanel {
  display: none !important;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .stats-stack {
    grid-template-columns: 1fr 1fr;
  }
  .filters {
    grid-template-columns: 1fr 1fr;
  }
  .search-row {
    grid-template-columns: 1fr 40px;
  }
  .table-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .table-search-inline {
    order: 3;
    width: 100%;
    max-width: none;
  }
  .table-meta {
    margin-left: auto;
  }
  .auth-form {
    grid-template-columns: 1fr;
  }
  .split {
    grid-template-columns: 1fr;
  }
  .quick-actions {
    justify-content: stretch;
  }
  .qa-btn {
    min-width: 0;
    flex: 1;
  }
  .side-modal {
    padding: 8px;
  }
  .side-modal-card {
    width: 100%;
    border-radius: 10px;
  }
  body.auth-locked .layout {
    max-width: 100%;
    min-height: auto;
  }
}
