@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap");

:root {
  --bg: #f6f6f2;
  --panel: #ffffff;
  --ink: #1f2d3d;
  --accent: #146c94;
  --border: #d9e2ec;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Poppins", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 10%, #d9edf7 0%, var(--bg) 35%);
  color: var(--ink);
}

.topbar {
  background: #ffffff;
  color: #1c2632;
  border-bottom: 1px solid #dde5ee;
  box-shadow: 0 4px 16px rgba(9, 26, 42, 0.05);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
}

.brand {
  color: #1c2632;
  text-decoration: none;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}

.brand-logo {
  width: 220px;
  max-width: 100%;
  height: auto;
}

.menu {
  display: flex;
  gap: 16px;
}

.menu a {
  color: #233142;
  text-decoration: none;
  font-weight: 600;
}

.menu a:hover {
  color: #e5252a;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334155;
}

.container {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 16px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.auth-wrap {
  max-width: 420px;
}

.auth-card {
  display: grid;
  gap: 10px;
}

.hidden-input {
  display: none;
}

.upload-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.upload-summary {
  margin: 8px 0;
  font-weight: 600;
}

.upload-list {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.upload-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fbfdff;
}

.remove-file {
  border: 1px solid #f1b9b9;
  border-radius: 8px;
  background: #fff1f1;
  color: var(--danger);
  padding: 6px 10px;
  cursor: pointer;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(10, 35, 66, 0.06);
}

h1 {
  margin-top: 0;
  font-size: 1.8rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 10px 8px;
  vertical-align: top;
}

input[type="text"],
input:not([type]),
input[type="file"],
input {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

button,
.link-button {
  display: inline-block;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.button-secondary {
  display: inline-block;
  border: 1px solid #d1dbe6;
  border-radius: 10px;
  padding: 10px 16px;
  background: #f8fafc;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.alert {
  border: 1px solid #f5c2c7;
  border-radius: 10px;
  padding: 12px;
  background: #fff5f5;
  color: var(--danger);
  margin-bottom: 16px;
}

.alert.success {
  border-color: #b8e7c6;
  background: #effcf3;
  color: #1d7a3b;
}

.alert-text {
  color: var(--danger);
  font-size: 0.92rem;
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}

.inline-form input {
  width: 140px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.filter-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.pagination-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}

.status-ok {
  background: #e9f8ef;
  color: #1f7a3a;
}

.status-no {
  background: #fff1f1;
  color: #b42318;
  border: 1px solid #f0c3c0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.log-box {
  max-height: 65vh;
  overflow: auto;
}

.log-box pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: "IBM Plex Mono", "Menlo", monospace;
  font-size: 0.84rem;
  padding: 2px 0;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(18, 27, 39, 0.5);
  display: grid;
  place-items: center;
  padding: 16px;
}

.busy-overlay.hidden {
  display: none;
}

.busy-card {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 18px 40px rgba(7, 19, 33, 0.2);
}

.busy-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.busy-message {
  margin-bottom: 12px;
  color: #3c4d63;
}

.busy-progress {
  height: 9px;
  border-radius: 999px;
  background: #e8eef5;
  overflow: hidden;
}

.busy-progress-bar {
  display: block;
  height: 100%;
  width: 45%;
  border-radius: inherit;
  background: linear-gradient(90deg, #146c94, #23a7d8);
  animation: busy-loading 1.1s ease-in-out infinite;
}

@keyframes busy-loading {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(260%);
  }
}

@media (max-width: 860px) {
  .container {
    margin: 18px auto;
    padding: 0 12px;
  }

  h1 {
    font-size: 1.45rem;
  }

  .topbar-inner {
    min-height: auto;
    padding: 10px 0;
    align-items: flex-start;
    flex-direction: column;
  }

  .menu {
    width: 100%;
    gap: 10px;
    flex-wrap: wrap;
  }

  .brand-logo {
    width: 184px;
  }

  .userbox {
    width: 100%;
    justify-content: space-between;
  }

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

  .upload-actions .button-secondary,
  .upload-actions button,
  .actions-row .button-secondary,
  .actions-row button,
  .actions-row .link-button {
    width: 100%;
    text-align: center;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form input {
    width: 100%;
  }

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

  .filter-actions {
    align-items: stretch;
  }

  .filter-actions button,
  .filter-actions .button-secondary {
    width: 100%;
    text-align: center;
  }

  .records-table {
    min-width: 720px;
  }

  .records-table .hide-mobile {
    display: none;
  }

  .pagination-row {
    justify-content: stretch;
  }

  .pagination-row .button-secondary {
    flex: 1;
    text-align: center;
  }

  .stack-table thead {
    display: none;
  }

  .stack-table tbody,
  .stack-table tr,
  .stack-table td {
    display: block;
    width: 100%;
  }

  .stack-table tr {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 10px;
    background: #fff;
  }

  .stack-table td {
    border: none;
    padding: 6px 0;
  }

  .stack-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.8rem;
    color: #5a6a7c;
    margin-bottom: 2px;
    font-weight: 600;
  }
}
