* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f5f5f5; color: #333; }

.header { background: #1a1a2e; color: white; padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; }
.header h1 { font-size: 20px; font-weight: 600; }
.header .sub { font-size: 13px; opacity: 0.75; margin-left: 10px; }
.controls { display: flex; gap: 12px; align-items: center; }
.controls a { color: white; text-decoration: none; font-size: 13px; padding: 6px 14px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.3); }
.controls a:hover { background: rgba(255,255,255,0.1); }
.controls button { background: none; border: 1px solid rgba(255,255,255,0.3); color: white; padding: 6px 14px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.controls button:hover { background: rgba(255,255,255,0.1); }

.container { max-width: 1400px; margin: 0 auto; padding: 20px; }
.stats { font-size: 14px; color: #666; margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
thead { background: #16213e; color: white; }
th { padding: 12px 14px; text-align: left; font-size: 13px; font-weight: 600; white-space: nowrap; }
td { padding: 10px 14px; font-size: 13px; border-bottom: 1px solid #eee; vertical-align: middle; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #e8f0fe; }
tr.done td { background: #f1f8e9; }
.done-cell { text-align: center; width: 56px; }
.done-cell input { width: 18px; height: 18px; cursor: pointer; }

.status { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; background: #eee; color: #333; }

.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; justify-content: center; align-items: center; }
.overlay.active { display: flex; }
.modal { background: white; border-radius: 12px; padding: 28px; width: 620px; max-width: 90vw; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal h2 { font-size: 18px; margin-bottom: 20px; color: #1a1a2e; }
.modal .close { float: right; cursor: pointer; font-size: 22px; color: #999; background: none; border: none; }
.modal .close:hover { color: #333; }

.detail-grid { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; }
.detail-grid dt { font-weight: 600; font-size: 13px; color: #666; }
.detail-grid dd { font-size: 13px; word-break: break-word; }
.detail-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid #eee; }
.detail-section h3 { font-size: 14px; font-weight: 600; color: #1a1a2e; margin-bottom: 12px; }
.address-box { background: #f8f9fa; padding: 14px; border-radius: 8px; font-size: 14px; line-height: 1.6; }

.completion-box { background: #fff8e1; padding: 14px; border-radius: 8px; }
.completion-box label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.completion-box textarea { width: 100%; min-height: 70px; padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; font-family: inherit; resize: vertical; }
.completion-box .meta { font-size: 12px; color: #666; margin-top: 8px; }
.completion-box .actions { margin-top: 10px; display: flex; gap: 8px; justify-content: flex-end; }
.completion-box button { padding: 8px 16px; border: none; border-radius: 6px; font-size: 13px; cursor: pointer; }
.btn-primary { background: #1a1a2e; color: white; }
.btn-primary:hover { background: #16213e; }
.btn-secondary { background: #eee; color: #333; }
.btn-danger { background: #c62828; color: white; }
.btn-danger:hover { background: #a31818; }

.loading { text-align: center; padding: 60px; color: #999; }

.login-screen { display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.login-box { background: white; padding: 32px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); width: 360px; }
.login-box h2 { margin-bottom: 20px; color: #1a1a2e; font-size: 20px; }
.login-box input { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; margin-bottom: 12px; }
.login-box button { width: 100%; padding: 10px; background: #1a1a2e; color: white; border: none; border-radius: 6px; font-size: 14px; cursor: pointer; }
.login-box button:hover { background: #16213e; }
.login-box .error { color: #d32f2f; font-size: 13px; margin-bottom: 10px; display: none; }
.app { display: none; }
.app.active { display: block; }

.admin-section { background: white; border-radius: 8px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.admin-section h2 { font-size: 16px; margin-bottom: 14px; color: #1a1a2e; }
.admin-section table { box-shadow: none; }
.form-row { display: grid; grid-template-columns: 140px 1fr; gap: 10px 14px; align-items: center; margin-bottom: 10px; }
.form-row label { font-size: 13px; font-weight: 600; color: #555; }
.form-row input, .form-row select, .form-row textarea { width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; font-family: inherit; }
.form-row textarea { min-height: 110px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.row-actions { display: flex; gap: 6px; }
.row-actions button { padding: 4px 10px; font-size: 12px; border: 1px solid #ccc; background: white; border-radius: 4px; cursor: pointer; }
.row-actions button:hover { background: #f0f0f0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #e3f2fd; color: #1565c0; padding: 3px 8px; border-radius: 4px; font-size: 12px; }

/* Drag-and-drop column picker */
.col-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.col-pane { border: 1px solid #e0e0e0; border-radius: 8px; padding: 10px; background: #fafafa; min-height: 180px; display: flex; flex-direction: column; }
.col-pane h4 { font-size: 12px; font-weight: 600; color: #555; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.col-list { display: flex; flex-direction: column; gap: 4px; min-height: 120px; flex: 1; }
.col-list.drop-active { background: #e8f0fe; border-radius: 6px; outline: 2px dashed #1565c0; outline-offset: -2px; }
.col-item { background: white; border: 1px solid #ddd; border-radius: 6px; padding: 6px 10px; font-size: 13px; cursor: grab; display: flex; align-items: center; gap: 8px; user-select: none; }
.col-item:hover { background: #f0f7ff; border-color: #1565c0; }
.col-item.dragging { opacity: 0.4; }
.col-item .drag-handle { color: #999; font-size: 14px; line-height: 1; cursor: grab; }
.col-item.selected { background: #e3f2fd; border-color: #1565c0; }

/* Predicate editor */
.pred-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.pred-row { display: grid; grid-template-columns: 16px 1fr 110px 1.4fr 24px; gap: 6px; align-items: center; background: white; border: 1px solid #ddd; border-radius: 6px; padding: 6px 8px; }
.pred-row.dragging { opacity: 0.4; }
.pred-row .drag-handle { color: #999; cursor: grab; user-select: none; }
.pred-row select, .pred-row input { font-size: 13px; padding: 5px 8px; border: 1px solid #ddd; border-radius: 4px; width: 100%; }
.pred-row button { background: none; border: none; color: #c62828; cursor: pointer; font-size: 18px; line-height: 1; }
.pred-add { background: #e8f5e9; color: #2e7d32; border: 1px dashed #81c784; border-radius: 6px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.pred-add:hover { background: #d4edda; }

/* Impersonation banner */
.impersonation-banner { background: #fff3e0; color: #e65100; padding: 8px 16px; text-align: center; font-size: 13px; border-bottom: 1px solid #ffb74d; }
.impersonation-banner strong { font-weight: 600; }
