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

:root {
  --bg: #fafafa;
  --surface: #fff;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #666;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

header { margin-bottom: 2rem; }
h1 { font-size: 1.5rem; font-weight: 600; }
.subtitle { color: var(--text-muted); font-size: 0.875rem; }
h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.75rem; }

.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  transition: border-color 0.2s, background 0.2s;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--accent);
  background: #eff6ff;
}
.upload-icon { font-size: 2rem; line-height: 1; }

#files-section { margin-top: 2rem; }
#files-list { list-style: none; }
#files-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
#files-list li:hover { border-color: var(--accent); }
.file-name { font-weight: 500; }
.file-meta { font-size: 0.8rem; color: var(--text-muted); }
.file-actions { display: flex; gap: 0.5rem; }

button, .btn {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.15s;
}
button:hover { background: #f0f0f0; }
#back-btn { margin-bottom: 1.5rem; }

/* Declaration view */
.decl-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.decl-header h3 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.decl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem 1.5rem;
}
.decl-field label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}
.decl-field span {
  font-size: 0.9rem;
}

.decl-parties {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.party-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.party-card h4 { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.03em; }
.party-card .name { font-weight: 600; margin-bottom: 0.25rem; }
.party-card .addr { font-size: 0.85rem; color: var(--text-muted); }

.goods-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.85rem;
}
.goods-table th {
  background: #f5f5f5;
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.goods-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
}
.goods-table tr:last-child td { border-bottom: none; }
.goods-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.goods-table tfoot td {
  font-weight: 600;
  border-top: 2px solid var(--border);
  background: #f9f9f9;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}
