:root {
  --bg: #eef4ff;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-border: rgba(117, 141, 198, 0.18);
  --text: #14203c;
  --muted: #66718f;
  --primary: #3157ff;
  --primary-deep: #1d37b8;
  --accent: #11b4a3;
  --danger: #d94e59;
  --shadow: 0 24px 60px rgba(38, 64, 134, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Outfit', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(49, 87, 255, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(17, 180, 163, 0.18), transparent 24%),
    linear-gradient(180deg, #f9fbff 0%, var(--bg) 100%);
}

button,
input,
select {
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
  transform: none !important;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 32px auto;
}

.auth-shell,
.workspace-shell {
  display: grid;
  gap: 24px;
}

.auth-shell {
  grid-template-columns: 1.15fr 0.85fr;
  align-items: stretch;
}

.auth-hero,
.auth-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: 28px;
}

.auth-hero,
.auth-panel,
.panel {
  padding: 28px;
}

.hero-pill,
.panel-kicker,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-pill,
.panel-kicker {
  color: var(--primary-deep);
  background: rgba(49, 87, 255, 0.08);
  padding: 9px 12px;
}

.auth-hero h1,
.workspace-title {
  margin: 18px 0 14px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.auth-hero p,
.workspace-subtitle,
.auth-form p,
.auth-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.hero-grid,
.stats-grid,
.result-grid,
.latest-grid {
  display: grid;
  gap: 14px;
}

.hero-grid {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 28px;
}

.hero-card,
.stat-card,
.latest-card,
.progress-card,
.result-card,
.drop-zone,
.file-chip,
.history-item {
  border: 1px solid rgba(117, 141, 198, 0.14);
  background: rgba(255, 255, 255, 0.8);
  border-radius: 22px;
}

.hero-card,
.latest-card,
.progress-card,
.result-card,
.history-item {
  padding: 18px;
}

.hero-card strong,
.panel h2,
.auth-form h2 {
  display: block;
  margin-bottom: 8px;
}

.auth-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.auth-tab,
.secondary-btn,
.icon-btn,
.btn-link {
  border: 0;
  background: rgba(49, 87, 255, 0.08);
  color: var(--primary-deep);
  cursor: pointer;
}

.auth-tab,
.secondary-btn,
.primary-btn,
.icon-btn {
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.auth-tab {
  padding: 12px 16px;
  border-radius: 16px;
  font-weight: 700;
  flex: 1;
}

.auth-tab.is-active {
  background: linear-gradient(135deg, var(--primary) 0%, #5f7cff 100%);
  color: white;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  border: 1px solid rgba(117, 141, 198, 0.2);
  background: rgba(247, 250, 255, 0.95);
  color: var(--text);
  border-radius: 16px;
  padding: 14px 15px;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(49, 87, 255, 0.18);
  border-color: rgba(49, 87, 255, 0.36);
}

.primary-btn,
.secondary-btn {
  padding: 14px 18px;
  border-radius: 16px;
  font-weight: 700;
}

.primary-btn {
  border: 0;
  color: white;
  background: linear-gradient(135deg, var(--primary) 0%, #6080ff 100%);
  box-shadow: 0 14px 30px rgba(49, 87, 255, 0.24);
  cursor: pointer;
}

.secondary-btn:hover,
.primary-btn:hover,
.auth-tab:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.auth-note {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(17, 180, 163, 0.1);
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 24px;
}

.workspace-user {
  display: flex;
  gap: 14px;
  align-items: center;
}

.user-badge {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  min-width: 240px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--panel-border);
}

.user-badge-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 22px;
}

.history-panel {
  grid-column: 1 / -1;
}

.panel-head,
.latest-head,
.progress-head,
.result-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.panel h2 {
  margin: 6px 0 0;
  font-size: 28px;
}

.status-pill {
  padding: 9px 12px;
  background: rgba(17, 180, 163, 0.1);
  color: #0c8578;
}

.drop-zone {
  padding: 28px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
  border-style: dashed;
  margin-bottom: 18px;
  transition: border-color 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.drop-zone.drag-over {
  border-color: rgba(49, 87, 255, 0.46);
  background: rgba(49, 87, 255, 0.06);
  transform: translateY(-2px);
}

.drop-icon {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(49, 87, 255, 0.12), rgba(17, 180, 163, 0.14));
  color: var(--primary-deep);
  font-weight: 800;
}

.file-chip {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.icon-btn {
  padding: 10px 12px;
  border-radius: 12px;
}

.progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(49, 87, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--primary));
}

.progress-steps {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.progress-step {
  font-size: 12px;
  text-align: center;
  color: var(--muted);
  padding: 8px;
  border-radius: 12px;
  background: rgba(49, 87, 255, 0.06);
}

.progress-step.active {
  color: white;
  background: linear-gradient(135deg, var(--primary), #5f7cff);
}

.result-badge {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(17, 180, 163, 0.12);
  color: #0c8578;
  font-size: 22px;
  font-weight: 800;
}

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

.result-grid div,
.latest-grid div {
  display: grid;
  gap: 6px;
}

.result-grid span,
.latest-grid span,
.stat-card span,
.history-meta span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stats-grid {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 18px;
}

.stat-card {
  padding: 18px;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
}

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

.history-list {
  display: grid;
  gap: 14px;
}

.history-item {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.history-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.history-main {
  display: grid;
  gap: 8px;
}

.history-main strong {
  font-size: 20px;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.history-side {
  display: grid;
  gap: 10px;
  justify-items: end;
  text-align: right;
}

.history-side .status-pill {
  justify-self: end;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: white;
  animation: spin 0.9s linear infinite;
}

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

.app-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 18px;
  color: white;
  box-shadow: 0 16px 32px rgba(20, 32, 60, 0.24);
  transform: translateY(12px);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.app-toast-info,
.app-toast-success {
  background: linear-gradient(135deg, #0c8578, #11b4a3);
}

.app-toast-error {
  background: linear-gradient(135deg, #b93c56, #e15a67);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 11, 26, 0.52);
}

.modal-card {
  position: relative;
  width: min(960px, 92vw);
  max-height: 90vh;
  background: #ffffff;
  border-radius: 18px;
  padding: 22px 22px 18px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: hidden;
  z-index: 1;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.detail-grid span {
  font-size: 13px;
  color: #5b6477;
}

.detail-grid strong {
  display: block;
  margin-top: 2px;
}

.detail-section {
  border-top: 1px solid #eef1f6;
  padding-top: 10px;
}

.detail-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.line-items {
  display: grid;
  gap: 10px;
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}

.line-item {
  display: grid;
  grid-template-columns: 2fr 0.6fr 0.8fr 0.8fr;
  gap: 8px;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid #eef1f6;
  border-radius: 10px;
  background: #f9fafc;
}

.line-item span {
  color: #4b5563;
}

.ghost-btn {
  border: 1px solid #d5d9e3;
  background: #fff;
  color: #111827;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.ghost-btn:hover {
  background: #f3f4f6;
  border-color: #cbd5e1;
}

@media (max-width: 980px) {
  .auth-shell,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .hero-grid,
  .stats-grid,
  .result-grid,
  .latest-grid {
    grid-template-columns: 1fr;
  }

  .workspace-header,
  .workspace-user,
  .panel-head,
  .latest-head,
  .progress-head,
  .result-head {
    flex-direction: column;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .history-side {
    justify-items: start;
    text-align: left;
  }
}
