:root {
  --bg: #0f1216;
  --surface: #161b22;
  --surface-2: #1f242c;
  --border: #2a313b;
  --text: #e6e9ee;
  --muted: #8a93a3;
  --accent: #6ea8ff;
  --accent-soft: #2c4775;
  --green: #4ec07c;
  --red: #e26565;
  --grey: #8a93a3;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

body {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.muted { color: var(--muted); font-size: 12px; }

/* ---- Sidebar ---- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 18px;
  overflow-y: auto;
}

.sidebar-header h1 {
  font-size: 18px;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.sidebar-header .subtitle {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 12px;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px 12px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  text-align: center;
}
.dropzone:hover, .dropzone.is-dragging, .dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--surface-2);
  outline: none;
}
.dropzone-icon { font-size: 22px; color: var(--accent); }
.dropzone-text strong { display: block; font-size: 13px; }
.dropzone-text span { color: var(--muted); font-size: 12px; }

.upload-status {
  margin-top: 10px;
  padding: 8px 10px;
  font-size: 12px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
}
.upload-status.is-error { color: var(--red); }
.upload-status.is-success { color: var(--green); }

.section-label {
  margin: 22px 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.lease-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lease-list .empty { color: var(--muted); font-size: 12px; padding: 8px 0; }

.lease-item {
  padding: 10px 10px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.lease-item:hover {
  border-color: var(--accent-soft);
  background: #232a35;
}
.lease-item .name {
  font-weight: 500;
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lease-item .meta { display: flex; align-items: center; gap: 8px; }
.lease-item .date { font-size: 11px; color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  font-size: 10.5px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge.processing { color: var(--grey); }
.badge.complete { color: var(--green); border-color: rgba(78, 192, 124, 0.35); }
.badge.failed { color: var(--red); border-color: rgba(226, 101, 101, 0.35); }

.spinner {
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Main ---- */
.main { padding: 28px 32px; overflow: auto; }
.main-header { display: flex; align-items: baseline; gap: 16px; margin-bottom: 18px; }
.main-header h2 { margin: 0; font-size: 18px; font-weight: 600; }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: calc(100vh - 110px);
  box-shadow: var(--shadow);
}

.lease-table { width: 100%; border-collapse: collapse; min-width: 2600px; font-size: 13px; }
.lease-table thead th {
  background: var(--surface-2);
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.lease-table thead tr.thead-groups th {
  position: sticky; top: 0; z-index: 2;
  background: #1a212b;
  color: var(--accent);
  font-size: 10.5px;
  border-right: 1px solid var(--border);
  padding: 6px 12px;
}
.lease-table thead tr.thead-groups th:last-child { border-right: none; }
.lease-table thead tr.thead-fields th {
  position: sticky; top: 28px; z-index: 1;
}
.lease-table thead tr.thead-fields th.th-primary { color: var(--text); }
.lease-table .cell-type-currency,
.lease-table .cell-type-percent,
.lease-table .cell-type-integer { font-variant-numeric: tabular-nums; }
.lease-table tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  max-width: 240px;
}
.lease-table tbody tr:last-child td { border-bottom: none; }
.lease-table tbody tr:hover { background: var(--surface-2); }
.lease-table .cell-team { font-weight: 600; }
.lease-table .cell-clickable { cursor: pointer; }
.lease-table .cell-clickable:hover { color: var(--accent); }
.lease-table .cell-null { color: var(--muted); }
.lease-table .empty-row td { color: var(--muted); padding: 28px 14px; }

/* ---- Drawer ---- */
.drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  width: 340px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.22s ease;
  box-shadow: var(--shadow);
  z-index: 20;
  display: flex;
  flex-direction: column;
}
.drawer.is-open { transform: translateX(0); }
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 15;
}
.drawer-overlay.is-open { opacity: 1; pointer-events: auto; }
.drawer-close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none;
  color: var(--muted);
  font-size: 22px; cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 4px;
}
.drawer-close:hover { background: var(--surface-2); color: var(--text); }
.drawer-body { padding: 28px 24px; overflow-y: auto; }
.drawer-eyebrow {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.drawer-field { margin: 4px 0 6px; font-size: 13px; color: var(--muted); }
.drawer-value { font-size: 22px; font-weight: 600; line-height: 1.25; margin-bottom: 22px; word-break: break-word; }
.confidence { margin-bottom: 22px; }
.confidence-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.confidence-bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.confidence-fill { height: 100%; background: var(--accent); width: 0; transition: width 0.3s ease; }
.drawer-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 8px; }
.drawer-quote {
  margin: 0 0 8px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 6px 6px 0;
  font-style: italic;
  font-size: 13px;
  white-space: pre-wrap;
}
.drawer-page { font-size: 11px; }

@media (max-width: 880px) {
  body { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .drawer { width: 100%; }
}
