:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-hover: #fafafa;
  --border: #e8eaed;
  --border-strong: #d1d5db;
  --text: #0f1419;
  --text-secondary: #5f6368;
  --text-muted: #80868b;
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --primary-soft: #e8f0fe;
  --danger: #d93025;
  --danger-soft: #fce8e6;
  --success: #137333;
  --success-soft: #e6f4ea;
  --warning: #b06000;
  --warning-soft: #fef7e0;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --header-h: 56px;
  --max-w: 1040px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* App shell */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.app-header__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.app-brand {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.app-brand:hover {
  text-decoration: none;
  color: var(--primary);
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 13px;
  min-width: 0;
  flex: 1;
}

.app-nav__link {
  color: var(--text-secondary);
  text-decoration: none;
}

.app-nav__link:hover {
  color: var(--text);
}

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

.app-nav__current {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header__actions {
  margin-left: auto;
  flex-shrink: 0;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

.app-main--narrow {
  max-width: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-h));
  padding-top: 2rem;
  padding-bottom: 2rem;
}

/* Page header */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-header__title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.page-header__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.page-title {
  margin: 0 0 1.5rem;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

/* Panels & cards */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
  overflow: hidden;
}

.panel__head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.panel__title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.panel__body {
  padding: 1.25rem;
}

.panel__body--flush {
  padding: 0;
}

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

.card--auth {
  width: 100%;
}

/* Layout */
.layout-split {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 768px) {
  .layout-split {
    grid-template-columns: 1fr;
  }
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

/* Typography */
.muted {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}

.muted + .form,
.muted + form {
  margin-top: 1rem;
}

.lead {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0.25rem 0 0;
}

h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Forms */
.form label {
  display: block;
  margin-bottom: 1rem;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form label:last-of-type {
  margin-bottom: 1.25rem;
}

.form input[type='text'],
.form input[type='email'],
.form input[type='password'],
.form select,
.select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

.select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat {
  padding: 0.65rem 0.75rem;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.stat__label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat__value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.file-drop {
  display: block;
  margin-top: 0.35rem;
  padding: 1rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.file-drop input[type='file'] {
  width: 100%;
  font-size: 13px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--surface-hover);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.btn-link {
  border: none;
  background: none;
  color: var(--primary);
  padding: 0;
  font-weight: 500;
}

.btn-link.danger {
  color: var(--danger);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  padding: 0.65rem 1.25rem;
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-hover);
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td {
  background: var(--surface-hover);
}

.table .cell-name {
  font-weight: 500;
  color: var(--text);
}

.table .cell-actions {
  text-align: right;
  white-space: nowrap;
}

/* Project list (dashboard) */
.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.project-list__item {
  border-bottom: 1px solid var(--border);
}

.project-list__item:last-child {
  border-bottom: none;
}

.project-list__link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  color: inherit;
  text-decoration: none;
  transition: background 0.12s;
}

.project-list__link:hover {
  background: var(--surface-hover);
  text-decoration: none;
}

.project-list__main {
  flex: 1;
  min-width: 0;
}

.project-list__name {
  font-weight: 500;
  font-size: 14px;
  margin: 0;
}

.project-list__date {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0.15rem 0 0;
}

.project-list__aside {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: #eef0f3;
  color: var(--text-secondary);
}

.badge-completed {
  background: var(--success-soft);
  color: var(--success);
}

.badge-failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-processing,
.badge-validating,
.badge-uploading {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-draft,
.badge-uploaded {
  background: #eef0f3;
  color: var(--text-secondary);
}

.panel-narrow {
  max-width: 480px;
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 13px;
}

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

.alert-warning {
  background: var(--warning-soft);
  color: var(--warning);
  border: 1px solid #fde293;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}

.empty-state__title {
  margin: 0 0 0.35rem;
  font-size: 15px;
  font-weight: 600;
}

.empty-state__text {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 13px;
}

/* Output downloads */
.download-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.validation-list {
  margin: 0.5rem 0 0;
  padding-left: 1.15rem;
  font-size: 13px;
  color: var(--text-secondary);
}

.validation-list li {
  margin-bottom: 0.35rem;
}

/* Processing indicator */
.processing-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--primary);
}

.processing-note::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* Login */
.auth-logo {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}
