:root {
  --navy: #0b1f3a;
  --navy-2: #132a4a;
  --blue: #1d4ed8;
  --blue-btn: #2563eb;
  --red: #dc2626;
  --red-soft: #fecaca;
  --warn: #fef3c7;
  --warn-border: #f59e0b;
  --ok: #16a34a;
  --bg: #eef2f7;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.45;
}

.wrap {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 14px;
  padding: 28px 26px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
  border: 1px solid var(--line);
}
.login-card h1 {
  font-size: 1.35rem;
  margin-bottom: 6px;
}
.login-card .sub {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 18px;
}
.login-card label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.login-card input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 1rem;
  margin-bottom: 14px;
}
.login-error {
  color: var(--red);
  font-size: 0.9rem;
  margin-bottom: 10px;
  min-height: 1.2em;
}

/* Header */
.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.top h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--navy);
}
.top .meta {
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 4px;
}
.top .meta strong { color: var(--ink); }
.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #fff;
  background: var(--navy);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-navy { background: var(--navy-2); }
.btn-red { background: var(--red); }
.btn-outline {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
.btn-blue { background: var(--blue-btn); }
.btn-soft-red {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}
.btn-lg {
  padding: 14px 18px;
  font-size: 1rem;
  width: 100%;
  justify-content: center;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  background: #dbe3ee;
  border-radius: 10px 10px 0 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-bottom: none;
}
.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 14px 12px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 2px 0 var(--blue);
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0 0 12px 12px;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}
.panel.hidden { display: none; }

.warn {
  color: var(--red);
  font-weight: 800;
  margin-bottom: 8px;
}
.flow {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 18px;
}

.field-label {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 8px;
  display: block;
}

.upload-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 16px;
}
.file-btn {
  position: relative;
  overflow: hidden;
}
.file-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.file-name {
  margin-top: 6px;
  font-size: 0.88rem;
  color: var(--muted);
  min-height: 1.2em;
}

.import-progress {
  margin-top: 16px;
  padding: 16px 16px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}
.import-progress.hidden { display: none; }
.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}
.progress-head strong {
  color: var(--navy);
  font-size: 0.95rem;
}
#progress-percent {
  font-weight: 800;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}
.progress-track {
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2563eb, #0ea5e9);
  border-radius: 999px;
  transition: width 0.25s ease;
}
.progress-track.indeterminate .progress-fill {
  width: 36% !important;
  animation: progress-slide 1.1s ease-in-out infinite;
}
@keyframes progress-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 0.86rem;
  color: var(--muted);
}
#progress-current {
  color: var(--ink);
  font-family: ui-monospace, Consolas, monospace;
  word-break: break-all;
  max-width: 100%;
}
#progress-counts {
  white-space: nowrap;
  font-weight: 700;
  color: var(--navy-2);
}
.progress-log {
  list-style: none;
  margin-top: 12px;
  max-height: 180px;
  overflow: auto;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}
.progress-log li {
  font-size: 0.8rem;
  font-family: ui-monospace, Consolas, monospace;
  padding: 3px 0;
  color: #334155;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.progress-log .tag {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 6px;
  border-radius: 4px;
}
.progress-log .tag-ok { background: #dcfce7; color: #166534; }
.progress-log .tag-skip { background: #fef3c7; color: #92400e; }
.progress-log .tag-info { background: #dbeafe; color: #1e40af; }
.progress-log .tag-err { background: #fee2e2; color: #991b1b; }

.box {
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 14px;
  font-size: 0.92rem;
}
.box-warn {
  background: var(--warn);
  border: 1px solid var(--warn-border);
  color: #78350f;
}
.box-info {
  background: #f1f5f9;
  border: 1px solid var(--line);
  color: #334155;
}
.box ul {
  margin: 8px 0 0 18px;
}
.box li { margin: 4px 0; }

.result {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 600;
  display: none;
}
.result.show { display: block; }
.result.ok {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}
.result.err {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.history {
  margin-top: 28px;
}
.history h2 {
  font-size: 1.1rem;
  margin-bottom: 12px;
}
.history-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.history-item .left { color: var(--ink); font-size: 0.92rem; }
.history-item .right {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.badge-ok {
  color: var(--ok);
  font-weight: 800;
}
.badge-err {
  color: var(--red);
  font-weight: 800;
}

.maint-grid {
  display: grid;
  gap: 14px;
  max-width: 480px;
}
.maint-grid input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 1rem;
}

.hidden { display: none !important; }

@media (max-width: 720px) {
  .upload-row { grid-template-columns: 1fr; }
  .tabs { flex-direction: column; }
}
