/* ── Form ── */

.submit-btn {
    padding: 0.65rem 1.4rem;
    background: var(--accent-blue);
    color: var(--text-heading2);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.submit-btn:hover:not(:disabled) { background: var(--accent-blue-hover); }
.submit-btn:disabled { opacity: 0.65; cursor: not-allowed; }

.spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: var(--text-heading2);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Alerts ── */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.1rem;
    border-radius: 0.6rem;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid;
}

.alert-error { background: var(--error-bg);  border-color: var(--error-border);  color: var(--error-text); }
.alert-warn  { background: var(--warn-bg, #1c1400); border-color: var(--warn-border, #92400e); color: var(--warn-text, #fbbf24); }

/* ── Stat cards ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.65rem;
    margin-bottom: 1.1rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: 0.6rem;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.stat-card .stat-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dimmed);
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', monospace;
    line-height: 1.1;
    color: var(--accent-blue-dim);
}

.stat-card .stat-value.green { color: var(--accent-green); }
.stat-card .stat-value.muted { color: var(--text-muted); }
.stat-card .stat-value.red   { color: var(--error-text); }
.stat-card .stat-value.amber { color: #f59e0b; }

/* ── Analytics row ── */
.analytics-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    margin-bottom: 1.1rem;
}

@media (max-width: 680px) { .analytics-row { grid-template-columns: 1fr; } }

.analytics-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: 0.6rem;
    padding: 0.9rem 1rem;
}

.panel-title {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-dimmed);
    margin-bottom: 0.7rem;
}

.analytics-list { list-style: none; display: flex; flex-direction: column; gap: 0.55rem; }

.analytics-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    row-gap: 0.2rem;
}

.analytics-item .item-name {
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.analytics-item .item-bar-wrap {
    grid-column: 1 / -1;
    height: 3px;
    background: var(--bg-panel, #0f172a);
    border-radius: 2px;
    overflow: hidden;
}

.analytics-item .item-bar {
    height: 100%;
    background: var(--accent-blue);
    border-radius: 2px;
}

.analytics-item .item-count {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.77rem;
    color: var(--text-muted);
}

.analytics-item .item-pct {
    font-size: 0.72rem;
    color: var(--text-dimmed);
    min-width: 3rem;
    text-align: right;
}

/* ── Map ── */
.map-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: 0.75rem;
    overflow: hidden;
    margin-bottom: 1.1rem;
}

.map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-strong);
    gap: 1rem;
    flex-wrap: wrap;
}

.map-header .map-title {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-dimmed);
}

.map-header .map-attr {
    font-size: 0.7rem;
    color: var(--text-dimmed);
}

.map-header .map-attr a { color: var(--text-dimmed); text-decoration: none; }
.map-header .map-attr a:hover { color: var(--text-muted); }

#bulk-map {
    width: 100%;
    height: 360px;
    background: var(--bg-panel);
}

/* ── Table controls ── */
.table-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}

.table-search {
    flex: 1;
    min-width: 160px;
    padding: 0.48rem 0.85rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: 0.4rem;
    color: var(--input-text);
    font-size: 0.84rem;
    outline: none;
    transition: border-color 0.2s;
}

.table-search:focus { border-color: var(--accent-blue); }
.table-search::placeholder { color: var(--text-dimmed); }

.ctrl-btn {
    padding: 0.48rem 0.85rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.ctrl-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.ctrl-btn:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
.ctrl-btn:active, .ctrl-btn[aria-expanded="true"] { background: var(--results-row-alt); color: var(--text-primary); border-color: var(--accent-blue); }
.ctrl-btn--icon { display: inline-flex; align-items: center; justify-content: center; width: 2.3rem; height: 2.3rem; padding: 0; }

.table-count {
    font-size: 0.77rem;
    color: var(--text-dimmed);
    white-space: nowrap;
}

/* Count on the left, Export CSV on the right, directly under the table and as wide as it. */
.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 0 0.9rem;
}

/* ── Results table ── */
.table-wrapper {
    overflow-x: auto;
    border-radius: 0.65rem;
    border: 1px solid var(--border-strong);
    background: var(--bg-surface);
    -webkit-overflow-scrolling: touch;
    margin-bottom: 0.75rem;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.results-table thead tr {
    background: var(--results-row-alt);
    border-bottom: 1px solid var(--border-strong);
}

.results-table th {
    padding: 0.6rem 0.85rem;
    text-align: left;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    user-select: none;
}

.results-table th.sortable { cursor: pointer; }
.results-table th.sortable:hover { color: var(--text-primary); }
.results-table th .sort-icon { display: inline-block; margin-left: 3px; opacity: 0.35; font-size: 0.6rem; }
.results-table th.sort-asc  .sort-icon,
.results-table th.sort-desc .sort-icon { opacity: 1; }

.results-table tbody tr {
    border-bottom: 1px solid var(--results-row-alt);
    transition: background 0.1s;
}

.results-table tbody tr:last-child  { border-bottom: none; }
.results-table tbody tr:nth-child(odd)  { background: var(--results-row-alt); }
.results-table tbody tr:nth-child(even) { background: var(--bg-surface); }
.results-table tbody tr:hover           { background: var(--info-bg); }
.results-table tbody tr.row-hidden      { display: none; }

.results-table td {
    padding: 0.52rem 0.85rem;
    color: var(--text-primary);
    vertical-align: middle;
    word-break: break-word;
}

.results-table td.ip-cell {
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--accent-blue-dim);
    font-weight: 500;
    white-space: nowrap;
}

.results-table td.mono   { font-family: 'SF Mono', 'Fira Code', monospace; white-space: nowrap; }
.results-table td.muted  { color: var(--text-dimmed); font-style: italic; }
.results-table td.err    { color: var(--error-text); font-size: 0.8rem; }

/* ── Bulk table: values stay on one line, the wrapper scrolls sideways when the table is wider ── */
.wdois-workspace .tool-page table.result-table--bulk { table-layout: auto; width: max-content; min-width: 100%; }
.wdois-workspace .tool-page table.result-table--bulk :is(th, td) { white-space: nowrap; overflow-wrap: normal; padding: 0.5rem 0.8rem; vertical-align: middle; max-width: none; }
.wdois-workspace .tool-page table.result-table--bulk td[data-colkey="org"] { white-space: normal; overflow-wrap: anywhere; min-width: 14rem; max-width: 24rem; }
.wdois-workspace .tool-page table.result-table--bulk :is(th, td)[data-colkey="ip"] { min-width: 42ch; }
.wdois-workspace .tool-page table.result-table--bulk :is(th, td)[data-colkey="asn"] { min-width: 6.5rem; }
.wdois-workspace .tool-page table.result-table--bulk :is(th, td)[data-colkey="country"] { min-width: 9.5rem; }
.wdois-workspace .tool-page table.result-table--bulk :is(th, td)[data-colkey="continent"] { min-width: 9.5rem; }
.wdois-workspace .tool-page table.result-table--bulk :is(th, td)[data-colkey="timezone"] { min-width: 11rem; }
.wdois-workspace .tool-page table.result-table--bulk :is(th, td)[data-colkey="outcome"] { min-width: 12rem; }
.wdois-workspace .tool-page table.result-table--bulk td.err { white-space: nowrap; }
.th-inner { display: inline-flex; align-items: center; gap: 0.25rem; white-space: nowrap; }
.th-inner .sort-icon { margin-left: 0; }
.result-table--bulk[data-hide~="asn"] [data-colkey="asn"],
.result-table--bulk[data-hide~="org"] [data-colkey="org"],
.result-table--bulk[data-hide~="city"] [data-colkey="city"],
.result-table--bulk[data-hide~="region"] [data-colkey="region"],
.result-table--bulk[data-hide~="country"] [data-colkey="country"],
.result-table--bulk[data-hide~="continent"] [data-colkey="continent"],
.result-table--bulk[data-hide~="timezone"] [data-colkey="timezone"],
.result-table--bulk[data-hide~="outcome"] [data-colkey="outcome"] { display: none; }

/* ── Columns menu ── */
.col-menu { position: relative; }
.col-panel {
    position: absolute; right: 0; top: calc(100% + 0.3rem); z-index: 20; min-width: 14rem;
    padding: 0.6rem 0.75rem; background: var(--bg-surface); border: 1px solid var(--border-strong);
    border-radius: 0.5rem; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.col-panel__title { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.35rem; }
.col-option { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; font-size: 0.84rem; color: var(--text-primary); cursor: pointer; }
.col-option input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--accent-blue); }
.col-option input:disabled { cursor: not-allowed; }
.col-note { font-size: 0.72rem; color: var(--text-dimmed); }

/* ── Empty / no-match state ── */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-dimmed);
    font-size: 0.88rem;
}

/* ── Responsive ── */
@media (max-width: 640px) {

    .submit-btn, .clear-btn { flex: 1; justify-content: center; }
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 400px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
