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

:root {
  --bg: #ffffff;
  --surface: #f5f5f5;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-secondary: #666;
  --primary: #0078d4;
  --primary-hover: #106ebe;
  --success: #107c10;
  --warn: #ff8c00;
  --err: #d13438;
  --radius: 6px;
}

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

.app {
  padding: 12px;
  max-width: 100%;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.env-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: #e6f3ff;
  color: var(--primary);
}

.search-area { margin-bottom: 12px; }

.input-group {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.input-group input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.btn-primary {
  padding: 7px 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.hint {
  font-size: 11px;
  color: var(--text-secondary);
}

.status {
  padding: 8px 12px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-size: 12px;
}

.status.loading { background: #e6f3ff; color: var(--primary); }
.status.error   { background: #fde7e9; color: var(--err); }
.status.success { background: #dff6dd; color: var(--success); }

.hidden { display: none; }

/* Scan chips */
.scan-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.ref-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  cursor: pointer;
  transition: opacity 0.15s;
  border: 1px solid transparent;
}

.ref-chip:hover { opacity: 0.8; }

.chip-green {
  background: #dff6dd;
  color: #107c10;
  border-color: #b7dfb7;
}

.chip-green .chip-label {
  font-size: 9px;
  text-transform: uppercase;
  font-weight: 600;
  opacity: 0.7;
}

.chip-green .chip-val {
  font-weight: 600;
  font-family: "Consolas", "SF Mono", monospace;
}

.chip-gray {
  background: #f3f3f3;
  color: #666;
  border-color: #ddd;
}

.chip-gray .chip-label {
  font-size: 9px;
  text-transform: uppercase;
  font-weight: 600;
  opacity: 0.7;
}

.chip-gray .chip-val {
  font-weight: 500;
  font-family: "Consolas", "SF Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  .chip-green {
    background: #1a3d1a;
    color: #6fcf6f;
    border-color: #2d5a2d;
  }
  .chip-gray {
    background: #333;
    color: #999;
    border-color: #444;
  }
}

.result {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.result-header {
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.result-header .tag {
  font-size: 11px;
}

.result-header .tag strong {
  color: var(--text-secondary);
  font-weight: 500;
  margin-right: 4px;
}

.result-body { padding: 10px 12px; }

.section {
  margin-bottom: 10px;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 3px;
}

.kv-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 3px 8px;
  font-size: 12px;
}

.kv-grid .kv-label { color: var(--text-secondary); }
.kv-grid .kv-value { color: var(--text); font-weight: 500; }

.table-wrap {
  overflow-x: auto;
  margin: 4px 0;
}

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

.table-wrap th {
  background: var(--surface);
  padding: 5px 8px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.table-wrap td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

.milestone-list {
  list-style: none;
  font-size: 11px;
}

.milestone-list li {
  padding: 3px 0;
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.milestone-list .ms-code {
  font-weight: 600;
  color: var(--primary);
  min-width: 38px;
}

.milestone-list .ms-desc { flex: 1; }
.milestone-list .ms-date {
  color: var(--text-secondary);
  font-size: 10px;
  white-space: nowrap;
}

.party-card {
  font-size: 11px;
  padding: 6px 8px;
  margin: 3px 0;
  background: var(--surface);
  border-radius: 4px;
}

.party-card .party-type {
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.party-card .party-name {
  font-weight: 500;
  margin-bottom: 1px;
}

.party-card .party-addr {
  color: var(--text-secondary);
}

.notes-block {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  max-height: 150px;
  overflow-y: auto;
  background: var(--surface);
  padding: 8px;
  border-radius: var(--radius);
  line-height: 1.5;
}

/* dark mode support for Outlook dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1e1e;
    --surface: #2d2d2d;
    --border: #404040;
    --text: #e0e0e0;
    --text-secondary: #a0a0a0;
  }
  .header { border-color: var(--border); }
  .input-group input {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
  }
  .result { border-color: var(--border); }
  .table-wrap th { background: var(--surface); }
  .party-card { background: var(--surface); }
  .notes-block { background: var(--surface); }
  .status.loading { background: #1a3a5c; color: #6cb6ff; }
  .status.error   { background: #3d1e20; color: #f0888e; }
}
