:root {
  --bg: #f8f9fa;
  --surface: #fff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --red: #dc2626;
  --amber: #d97706;
  --green: #16a34a;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

#app { display: flex; min-height: 100vh; }

#sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex-shrink: 0;
}

.sidebar-header { display: flex; align-items: center; gap: 10px; }
.sidebar-header h1 { font-size: 18px; font-weight: 700; color: var(--accent); }
.sidebar-header .subtitle { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.sidebar-logo { width: 32px; height: 32px; background: var(--accent); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: #fff; }
.sidebar-logo .icon-logo { width: 18px; height: 18px; }

.section-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }

#project-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
#project-list li { padding: 8px 12px; border-radius: var(--radius); cursor: pointer; font-size: 13px; color: var(--text); transition: background 0.15s; }
#project-list li:hover { background: var(--bg); }
#project-list li.active { background: var(--accent); color: #fff; font-weight: 500; }

.btn-ghost { background: none; border: none; color: var(--text-muted); font-size: 12px; cursor: pointer; padding: 6px 0; text-align: left; }
.btn-ghost:hover { color: var(--text); }

#main { flex: 1; padding: 32px 40px; overflow-y: auto; }

.view.hidden { display: none; }
.empty-state { display: flex; align-items: center; justify-content: center; min-height: 400px; color: var(--text-muted); font-size: 15px; }

.project-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.project-header h2 { font-size: 22px; font-weight: 700; }
.project-actions { display: flex; gap: 8px; }

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: var(--accent-hover); }
.btn-outline { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }

.stats-row { display: flex; gap: 24px; margin-bottom: 20px; }
.stat { display: flex; flex-direction: column; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 24px; font-weight: 700; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th { text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); background: var(--bg); }
td { padding: 10px 14px; font-size: 13px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr.row-total td { background: #f0f4ff; font-weight: 600; }
tr.row-manufactured td { color: var(--amber); }
tr.row-closed td { color: var(--green); }
tr.row-need td { color: var(--red); }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-need { background: var(--red); }
.status-partial { background: var(--amber); }
.status-closed { background: var(--green); }
.status-manufactured { background: var(--amber); border: 1px solid var(--amber); background: transparent; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.3); display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: 12px; width: 90%; max-width: 720px; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal.hidden { display: none; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); padding: 0 4px; }

.drop-zone {
  margin: 20px 24px; padding: 48px; border: 2px dashed var(--border); border-radius: var(--radius); text-align: center; color: var(--text-muted); cursor: pointer; transition: border 0.15s;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); color: var(--accent); }

#import-preview { padding: 20px 24px; }
#import-actions { padding: 16px 24px; display: flex; gap: 8px; border-top: 1px solid var(--border); }

.invoice-preview { display: flex; gap: 20px; padding: 20px 24px; }
.invoice-left { flex: 1; max-width: 350px; }
.invoice-left img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.invoice-right { flex: 1; }
.invoice-field { margin-bottom: 12px; }
.invoice-field label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 2px; }
.invoice-field span, .invoice-field li { font-size: 13px; }
.invoice-actions { padding: 16px 24px; display: flex; gap: 8px; border-top: 1px solid var(--border); }

#invoice-loading { padding: 48px; text-align: center; }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.order-card {
  background: var(--surface); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow); transition: box-shadow 0.15s; display: flex; justify-content: space-between; align-items: center;
}
.order-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.order-card-name { font-weight: 500; }
.order-card-meta { font-size: 12px; color: var(--text-muted); }

.icon-xs { width: 12px; height: 12px; }
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; }
.icon-md { width: 18px; height: 18px; }
.icon-lg { width: 32px; height: 32px; }
.icon-empty { width: 48px; height: 48px; color: var(--text-muted); opacity: 0.3; }

.btn i, .btn-ghost i { vertical-align: -2px; }
.drop-zone i.icon-lg { display: block; margin: 0 auto 12px; color: var(--text-muted); }
.invoice-field label i { vertical-align: -2px; margin-right: 2px; }
.btn .icon-sm { margin-right: 4px; }

.empty-state { flex-direction: column; gap: 12px; }
.empty-state .icon-empty { margin-bottom: 4px; }

.drop-hint { display: block; font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.preview-order { margin-bottom: 16px; }
.preview-order h4 { font-size: 14px; font-weight: 600; margin-bottom: 6px; padding: 0 24px; }
.preview-table { width: calc(100% - 48px); margin: 0 24px 12px; font-size: 12px; }
.preview-table th, .preview-table td { padding: 6px 10px; }

.hidden { display: none; }
