:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #dbe3ec;
  --text: #17212b;
  --muted: #5f6b76;
  --brand: #145fd2;
  --brand-strong: #0f4fb0;
  --brand-soft: #e9f1ff;
  --ok: #158a59;
  --ok-soft: #e7f7ef;
  --danger: #bf4343;
  --danger-soft: #fdeeee;
  --radius: 14px;
  --shadow: 0 10px 28px rgba(16, 31, 48, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% -10%, #dce9ff 0%, transparent 40%),
    radial-gradient(circle at 95% -20%, #d7efe7 0%, transparent 35%),
    var(--bg);
  line-height: 1.45;
}

a {
  color: var(--brand);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244, 246, 248, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0.78rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  text-decoration: none;
  color: var(--text);
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
}

.brand-mark {
  font-size: 1.08rem;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.9rem;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
}

.nav-link:hover {
  color: var(--text);
  background: #ecf1f7;
}

.container {
  max-width: 1140px;
  margin: 1.1rem auto 2.2rem;
  padding: 0 1rem;
}

.page-head {
  margin-bottom: 0.9rem;
}

.page-head h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  letter-spacing: -0.01em;
}

.page-head p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.card + .card,
.card + section,
section + .card,
section + section {
  margin-top: 0.9rem;
}

.card-head {
  margin-bottom: 0.75rem;
}

.card-head h1,
.card-head h2,
.card-head h3 {
  margin: 0;
}

.card-head p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.9rem;
  align-items: start;
}

.stack {
  display: grid;
  gap: 0.72rem;
}

.visually-hidden {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.dropzone {
  min-height: 148px;
  border: 1px dashed #9fb2c6;
  border-radius: 12px;
  background: linear-gradient(180deg, #f7fbff, #f2f6fb);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.36rem;
  text-align: center;
  padding: 1rem;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.dropzone strong {
  font-size: 1.03rem;
}

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

.dropzone:hover,
.dropzone:focus {
  border-color: var(--brand);
  background: #eef5ff;
}

.dropzone.is-dragover {
  border-color: var(--brand);
  background: #e7f1ff;
}

.file-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.file-hint.warn {
  color: #9b5f11;
}

.upload-progress-panel {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
  padding: 0.72rem;
  display: grid;
  gap: 0.58rem;
}

.upload-progress-panel.done {
  border-color: #90d0b4;
  background: var(--ok-soft);
}

.upload-progress-panel.error {
  border-color: #e5b1b1;
  background: var(--danger-soft);
}

.upload-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.upload-progress-head strong {
  font-size: 1.08rem;
}

.upload-progress-head span {
  color: var(--muted);
  font-size: 0.9rem;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: #e2eaf2;
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #4a8eff);
  transition: width 120ms linear;
}

.upload-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.upload-metrics div {
  background: #f1f5f9;
  border: 1px solid #e0e8f0;
  border-radius: 10px;
  padding: 0.5rem;
  display: grid;
  gap: 0.18rem;
}

.upload-metrics span {
  color: var(--muted);
  font-size: 0.79rem;
}

.upload-metrics strong {
  font-size: 0.9rem;
}

#uploadResult {
  display: grid;
  gap: 0.55rem;
}

.upload-result {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 0.68rem 0.75rem;
}

.upload-result.success {
  border-color: #90d0b4;
  background: var(--ok-soft);
}

.upload-result.error {
  border-color: #e5b1b1;
  background: var(--danger-soft);
}

.upload-result p {
  margin: 0;
}

.upload-actions {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.meta-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.meta-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  border-bottom: 1px solid #eef2f7;
  padding: 0.4rem 0;
}

.meta-list li span {
  color: var(--muted);
}

.meter {
  margin-top: 0.7rem;
  height: 8px;
  border-radius: 999px;
  background: #e5ebf2;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #2d8bff, #2fbf89);
}

.meter-label {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.helper-links {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.plan-inline {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.45rem;
}

.plan-inline article {
  border: 1px solid #e7edf4;
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  background: #fafcfe;
}

.plan-inline h3 {
  margin: 0;
  font-size: 0.92rem;
}

.plan-inline p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.72rem;
}

.stat-card p {
  margin: 0 0 0.3rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.stat-card h3 {
  margin: 0;
  font-size: 1.25rem;
}

.empty-state {
  border: 1px dashed #c8d5e1;
  border-radius: 11px;
  padding: 1rem;
  text-align: center;
  background: #fafcff;
}

.empty-state h3 {
  margin: 0 0 0.3rem;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.simple-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
}

.simple-list li + li {
  margin-top: 0.33rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
}

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

thead {
  background: #f4f7fb;
}

th,
td {
  text-align: left;
  padding: 0.6rem 0.48rem;
  border-bottom: 1px solid #edf2f7;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.truncate {
  max-width: 17rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-shell {
  max-width: 520px;
  margin: 1.8rem auto 0;
}

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

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

label {
  display: grid;
  gap: 0.34rem;
  color: var(--muted);
  font-size: 0.92rem;
}

input[type="text"],
input[type="password"],
input[type="file"],
select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: #ffffff;
  border: 1px solid #cfd9e4;
  border-radius: 10px;
  padding: 0.58rem 0.64rem;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.btn,
button {
  font: inherit;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--brand);
  color: #ffffff;
  padding: 0.56rem 0.82rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.btn:hover,
button:hover {
  background: var(--brand-strong);
}

.btn.wide,
button.wide {
  width: 100%;
}

.btn.tiny,
button.tiny {
  padding: 0.32rem 0.56rem;
  font-size: 0.85rem;
}

.btn.ghost,
button.ghost {
  background: #ffffff;
  color: var(--text);
  border-color: #cfd9e4;
}

.btn.ghost:hover,
button.ghost:hover {
  background: #f3f7fc;
}

.btn.danger,
button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.btn.danger:hover,
button.danger:hover {
  background: #a93737;
}

.btn:disabled,
button:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
}

.inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.flash {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
  padding: 0.75rem 0.82rem;
  margin-bottom: 0.85rem;
}

.flash.success {
  border-color: #90d0b4;
  background: var(--ok-soft);
}

.flash.error {
  border-color: #e5b1b1;
  background: var(--danger-soft);
}

.flash-actions {
  margin-top: 0.52rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.user-pill {
  border: 1px solid #d5dfea;
  border-radius: 999px;
  padding: 0.24rem 0.6rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.user-pill em {
  color: var(--text);
  font-style: normal;
}

@media (max-width: 980px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upload-metrics {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .main-nav {
    width: 100%;
    flex-wrap: wrap;
  }

  .stats-strip {
    grid-template-columns: 1fr;
  }
}
