*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Helvetica Neue', Arial, sans-serif; background: #f3f2f1; color: #0b0c0c; font-size: 14px; }
a { color: #1d70b8; }

/* Layout */
#header { background: #0b0c0c; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
#header-left { display: flex; align-items: center; gap: 12px; }
#header h1 { color: white; font-size: 16px; font-weight: 700; }
#header p { color: #b1b4b6; font-size: 12px; margin-top: 2px; }
#header-btns { display: flex; gap: 8px; }
#saved-drawer { background: #1d2d44; border-bottom: 2px solid #1d70b8; padding: 16px 20px; display: none; }
#saved-drawer.open { display: block; }
#main { display: grid; grid-template-columns: 340px 1fr; gap: 20px; padding: 24px 20px; max-width: 1200px; margin: 0 auto; align-items: start; }
#panel { background: white; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.1); overflow: hidden; position: sticky; top: 16px; }
#panel-header { background: #1d70b8; padding: 14px 20px; color: white; font-weight: 700; font-size: 15px; }
#results-col { min-width: 0; }

/* Sections */
.section-toggle { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: none; border: none; border-bottom: 1px solid #e8e8e8; cursor: pointer; text-align: left; font-size: 14px; font-weight: 600; color: #0b0c0c; font-family: inherit; }
.section-toggle .arrow { color: #505a5f; font-size: 12px; transition: transform .2s; display: inline-block; }
.section-toggle.collapsed .arrow { transform: rotate(-90deg); }
.section-toggle .badge { background: #1d70b8; color: white; border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700; margin-left: 6px; }
.section-body { padding: 4px 20px 16px; border-bottom: 1px solid #e8e8e8; }
.section-body.hidden { display: none; }
.panel-footer { padding: 12px 20px 16px; }

/* Form elements */
label.field-label { display: block; font-size: 13px; font-weight: 600; color: #0b0c0c; margin-bottom: 4px; margin-top: 10px; }
input[type=text], input[type=number], input[type=date], select { width: 100%; padding: 8px 10px; border: 1px solid #b1b4b6; border-radius: 3px; font-size: 14px; font-family: inherit; margin-bottom: 4px; }
input[type=text]:focus, input[type=number]:focus, input[type=date]:focus, select:focus { outline: 3px solid #ffdd00; outline-offset: 0; }
.checkbox-list { max-height: 180px; overflow-y: auto; border: 1px solid #b1b4b6; border-radius: 3px; padding: 6px 10px; }
.checkbox-list label { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-size: 13px; cursor: pointer; }
.hint { font-size: 12px; color: #505a5f; margin-top: 3px; line-height: 1.5; }
.row { display: flex; gap: 6px; align-items: flex-start; }
.row input { margin-bottom: 0; flex: 1; }

/* Buttons */
.btn { border: none; border-radius: 3px; cursor: pointer; font-family: inherit; font-weight: 600; }
.btn-primary { background: #1d70b8; color: white; padding: 8px 14px; font-size: 13px; }
.btn-primary:hover { background: #1561a0; }
.btn-success { background: #00703c; color: white; padding: 12px; font-size: 15px; width: 100%; }
.btn-success:hover { background: #005a30; }
.btn-danger { background: #d4351c; color: white; padding: 12px; font-size: 15px; width: 100%; }
.btn-danger:hover { background: #aa2a16; }
.btn-download { background: #1d70b8; color: white; padding: 10px 18px; font-size: 14px; }
.btn-dark { background: #2c2c2c; color: white; padding: 7px 14px; font-size: 13px; border: 1px solid #505a5f; }
.btn-dark:hover { background: #3c3c3c; }
.btn-link { background: none; border: none; cursor: pointer; font-family: inherit; text-decoration: underline; font-size: 12px; padding: 0; }

/* Export toggles */
#export-btns { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; }
#export-btns span { font-size: 13px; font-weight: 600; }
.export-btn { padding: 5px 10px; border-radius: 3px; border: 2px solid #b1b4b6; background: white; color: #0b0c0c; cursor: pointer; font-size: 13px; font-family: inherit; }
.export-btn.active { border-color: #1d70b8; background: #1d70b8; color: white; font-weight: 700; }

/* Tags */
.tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.tag { display: inline-flex; align-items: center; gap: 4px; border-radius: 3px; padding: 2px 8px; font-size: 13px; font-weight: 500; }
.tag-blue { background: #1d70b81a; color: #1d70b8; border: 1px solid #1d70b840; }
.tag-red { background: #d4351c1a; color: #d4351c; border: 1px solid #d4351c40; }
.tag-purple { background: #4c2c921a; color: #4c2c92; border: 1px solid #4c2c9240; }
.tag button { background: none; border: none; cursor: pointer; font-size: 14px; line-height: 1; padding: 0; margin-left: 2px; }
.tag-blue button { color: #1d70b8; }
.tag-red button { color: #d4351c; }
.tag-purple button { color: #4c2c92; }

/* Org autocomplete */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown { position: absolute; top: 100%; left: 0; right: 0; z-index: 100; background: white; border: 1px solid #b1b4b6; border-top: none; border-radius: 0 0 3px 3px; box-shadow: 0 4px 8px rgba(0,0,0,.1); max-height: 200px; overflow-y: auto; display: none; }
.autocomplete-dropdown.open { display: block; }
.autocomplete-item { display: flex; justify-content: space-between; width: 100%; padding: 8px 12px; background: none; border: none; border-bottom: 1px solid #f3f2f1; cursor: pointer; text-align: left; font-size: 13px; font-family: inherit; }
.autocomplete-item:hover { background: #f3f2f1; }
.autocomplete-item .slug { color: #505a5f; font-size: 12px; margin-left: 6px; }
.autocomplete-item .count { color: #505a5f; font-size: 12px; }

/* Cards */
.card { background: white; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.1); margin-bottom: 16px; overflow: hidden; }
.card-body { padding: 14px 20px; }
.card-header { padding: 12px 20px; border-bottom: 1px solid #e8e8e8; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }

/* Progress */
#progress-bar-wrap { background: #f3f2f1; border-radius: 20px; height: 10px; overflow: hidden; margin: 8px 0; }
#progress-bar { background: #1d70b8; height: 100%; width: 0; border-radius: 20px; transition: width .3s; }

/* Stats bar */
#stats-bar { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.stat-val { font-size: 22px; font-weight: 700; line-height: 1; }
.stat-lbl { font-size: 12px; color: #505a5f; margin-top: 2px; }
.stat-blue { color: #1d70b8; }
.stat-green { color: #00703c; }
.stat-purple { color: #4c2c92; }

/* Table */
#results-table-wrap { overflow-x: auto; }
#results-table { width: 100%; border-collapse: collapse; font-size: 13px; }
#results-table th { padding: 10px 12px; text-align: left; font-weight: 600; border-bottom: 2px solid #b1b4b6; white-space: nowrap; background: #f3f2f1; }
#results-table td { padding: 8px 12px; vertical-align: top; border-bottom: 1px solid #e8e8e8; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#results-table tr:nth-child(even) td { background: #fafafa; }

/* Empty state */
#empty-state { background: white; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.1); padding: 48px 32px; text-align: center; color: #505a5f; }
#empty-state h2 { font-size: 16px; color: #0b0c0c; margin-bottom: 8px; }
.tips { padding: 16px 20px; background: #f3f2f1; border-radius: 4px; text-align: left; font-size: 13px; line-height: 1.9; display: inline-block; max-width: 500px; margin-top: 16px; }
.tips ul { margin: 8px 0 0; padding-left: 20px; }

/* Saved drawer */
#saved-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
#saved-header span { color: white; font-weight: 700; font-size: 14px; }
#saved-list { display: flex; flex-wrap: wrap; gap: 8px; }
.saved-card { background: #2c3e5a; border: 1px solid #3d5a80; border-radius: 4px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; }
.saved-card-name { color: white; font-weight: 600; font-size: 13px; }
.saved-card-meta { color: #b1b4b6; font-size: 11px; }
#save-input-row { display: flex; gap: 8px; align-items: center; }
#save-input-row input { padding: 6px 10px; border: 1px solid #b1b4b6; border-radius: 3px; font-size: 13px; font-family: inherit; width: 220px; }

/* Misc */
.api-url-preview { margin-top: 10px; font-size: 11px; color: #505a5f; word-break: break-all; line-height: 1.5; }
.api-url-preview strong { font-weight: 600; }
#error-msg { color: #d4351c; font-weight: 600; font-size: 14px; }
.table-footer { padding: 10px 20px; background: #f3f2f1; font-size: 13px; color: #505a5f; text-align: center; }
.include-withdrawn { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; margin-bottom: 10px; }
.field-actions { margin-top: 8px; display: flex; gap: 8px; }
.hidden { display: none !important; }
