:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #102a43;
  --muted: #627d98;
  --primary: #0b7285;
  --primary-dark: #095c6b;
  --danger: #b02a37;
  --success: #1b7f4a;
  --border: #d9e2ec;
  --shadow: 0 10px 35px rgba(16, 42, 67, 0.08);
}

html,
body {
  min-height: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  min-height: 100vh;
  background-color: #edf4f8;
  background-image: linear-gradient(170deg, #edf4f8 0%, #f7fafc 60%, #e7f2f8 100%);
  background-attachment: fixed;
  color: var(--text);
}

i.fa-solid {
  font-size: 0.85em;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.2rem;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0;
  font-size: 1.32rem;
}

.auth-card-redesign {
  padding: 1.35rem;
}

.auth-hero {
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.auth-icon-wrap {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #ddf0f5;
  color: #0b7285;
  display: grid;
  place-items: center;
}

.auth-form,
.stack-form,
.sort-form {
  display: grid;
  gap: 0.75rem;
}

input,
select,
button {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
}

button {
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease;
}

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

.layout-shell {
  max-width: 1780px;
  margin: 0.9rem auto;
  padding: 0 0.9rem 1.5rem;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 0.9rem;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 0.9rem;
}

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

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.8rem;
  margin-bottom: 0.8rem;
}

.upload-group {
  display: grid;
  gap: 0.8rem;
}

.upload-group h3 {
  margin: 0 0 0.1rem;
}

.children-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.child-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.55rem;
  margin: 0;
  min-width: 0;
}

.inline-section {
  margin-top: -0.1rem;
}

.upload-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.83rem;
  color: var(--muted);
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #cfd8e3;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.is-uploading {
  opacity: 0.9;
}

.hidden {
  display: none;
}

.upload-mode-switch {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  background: #f8fbfd;
}

.upload-mode-switch label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.84rem;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.5rem;
  align-items: center;
}

h2,
h3 {
  margin-top: 0;
}

h2 {
  font-size: 1.02rem;
}

h3 {
  font-size: 0.92rem;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 0.38rem 0.42rem;
  vertical-align: middle;
  font-size: 0.83rem;
}

th {
  background: #f8fafc;
  white-space: nowrap;
}

td code {
  white-space: normal;
  word-break: break-all;
}

.actions {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.ghost-btn,
.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  padding: 0.34rem 0.45rem;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 28px;
}

.ghost-btn:hover,
.icon-btn:hover {
  background: #f2f7fb;
}

.danger-outline {
  border: 1px solid #d87a84;
  color: var(--danger);
  background: #fff;
}

.danger-outline:hover {
  background: #fdecef;
}

.logout-btn {
  width: 100%;
}

.alert {
  padding: 0.75rem;
  border-radius: 10px;
  margin-bottom: 0.75rem;
}

.alert.success {
  background: #e8f8ef;
  border: 1px solid #9ed9b7;
  color: var(--success);
}

.alert.error {
  background: #feeff1;
  border: 1px solid #efb2ba;
  color: var(--danger);
}

.muted {
  color: var(--muted);
}

.hint {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.changelog-open-btn {
  width: 100%;
}

.log-content {
  max-height: 65vh;
  overflow: auto;
  background: #0e1b2a;
  color: #d8e5f2;
  border-radius: 12px;
  padding: 1rem;
}

.base-model > summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  margin-bottom: 0.5rem;
}

.base-model > summary::-webkit-details-marker {
  display: none;
}

.base-model > summary h2 {
  margin: 0;
}

.base-model > summary .fa-chevron-down {
  transition: transform 0.2s ease;
}

.base-model[open] > summary .fa-chevron-down {
  transform: rotate(180deg);
}

.sort-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.col-size {
  width: 96px;
}

.col-time {
  width: 176px;
}

.col-actions {
  width: 112px;
}

.changelog-modal {
  width: min(980px, 92vw);
  border: none;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 25px 60px rgba(16, 42, 67, 0.25);
}

.changelog-modal::backdrop {
  background: rgba(15, 25, 35, 0.55);
}

.changelog-modal-body {
  background: #fff;
  border-radius: 12px;
}

.changelog-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.changelog-modal-header h2 {
  margin: 0;
}

.changelog-modal-content {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 420px;
}

.changelog-modal-list {
  border-right: 1px solid var(--border);
  padding: 0.6rem;
  overflow: auto;
}

.changelog-item-btn {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  color: var(--text);
  text-align: left;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.45rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.changelog-item-btn small {
  font-size: 0.74rem;
}

.changelog-modal-view {
  padding: 0.8rem;
  overflow: auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 720px) {
  .actions {
    flex-direction: column;
    align-items: flex-start;
  }

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

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

  .sidebar {
    position: static;
  }

  .changelog-modal-content {
    grid-template-columns: 1fr;
  }

  .changelog-modal-list {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 180px;
  }
}
