/* The Aytict AYT brand kit (v1.3.0), not AytOS's console theme -- this
   supersedes an earlier pass that deliberately matched AytOS's own
   #9d4ae8 purple so a TSF window opened from the AytOS console would read
   as the same appliance. That tradeoff is superseded now that TSF has its
   own brand kit to apply directly: --primary-color is the kit's actual
   "Main brand color" (#C000C0), --dark-bg is the kit's specified
   background (#000000), and --text-primary is its specified "Text on
   dark" (#CCCCCC) -- every one of these is a real value from the kit's
   README/color-palette.html, not a derived or approximated one.

   --success/--warning/--error stay semantic (green/amber/red) rather than
   brand colors on purpose: the kit's own palette is magenta/purple/blue/
   green with no designated warning-amber or alarm-red, and a status
   indicator needs to read unambiguously as "danger" or "caution" before
   it reads as "on-brand" -- --success does use the kit's own green family
   (#00BB00, listed under "Medium shades for secondary text") since the
   kit happens to already cover that case.

   Spacing/radii/shadow tokens are unchanged from the prior density pass --
   this is a color swap, not a layout redesign. */
:root {
    --primary-color: #c000c0;
    --primary-hover: #ff00ff;
    --primary-active: #990099;
    --primary-tint: rgba(192, 0, 192, 0.10);
    --primary-tint-strong: rgba(192, 0, 192, 0.18);
    --on-primary: #ffffff;
    --secondary-color: #1a0033;
    --dark-bg: #000000;
    --card-bg: #14001f;
    --card-bg-raised: #1f0030;
    --border-color: #330066;
    --border-color-strong: #4400aa;
    --text-primary: #cccccc;
    --text-secondary: #a98cc4;
    --success: #00bb00;
    --warning: #ffa500;
    --error: #ff4d4f;

    /* Added for this pass, referenced by everything below instead of a mix
       of hand-picked pixel values -- one scale keeps corners and elevation
       consistent app-wide instead of per-component (4px/8px/8px/none, as
       it was before). */
    --radius-sm: 4px;
    --radius-md: 6px;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-raised: 0 6px 20px rgba(0, 0, 0, 0.35);
    --shadow-focus: 0 0 0 3px var(--primary-tint-strong);
}

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

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    background-color: var(--dark-bg);
    color: var(--text-primary);
    line-height: 1.5;
}

/* A visible focus ring everywhere, instead of relying on each control's own
   hover/border-color change (which most controls below had, but focus --
   the state that actually matters for keyboard use -- had none at all). */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* A slim scrollbar reads as a deliberately built interface; the fat
   platform-default one is the single most obvious "this is unstyled" tell
   on a dark UI, especially inside the fixed-height panels below
   (.logs-container, .timeline-list, .check-list, #editor-container). */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color-strong);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color-strong) transparent;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#app.hidden {
    display: none;
}

.session-info {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.session-info #logged-in-user {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.session-info .btn {
    width: auto;
    margin-bottom: 0;
    padding: 0.4rem 0.9rem;
}

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 15% 15%, var(--primary-tint), transparent 45%),
        var(--dark-bg);
}

.login-screen.hidden {
    display: none;
}

.login-box {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-raised);
    padding: 2rem 2.25rem;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-box h1 {
    color: var(--primary-color);
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.login-box h1 .brand-mark {
    height: 1.4rem;
    width: auto;
}

.login-box .subtitle {
    display: block;
    margin-bottom: 1.5rem;
}

.login-box form {
    text-align: left;
}

.login-error {
    color: var(--error);
    font-size: 0.82rem;
    margin-bottom: 0.85rem;
    text-align: center;
}

.login-error.hidden {
    display: none;
}

.login-certificate {
    background: var(--card-bg-raised);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    text-align: left;
}

.login-certificate-status {
    color: var(--text-primary);
    font-size: 0.88rem;
    margin: 0;
}

.login-certificate.is-ok .login-certificate-status { color: var(--success); }
.login-certificate.is-bad .login-certificate-status { color: var(--warning); }

.login-certificate-details {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.2rem 0.75rem;
    margin: 0.65rem 0 0;
    font-size: 0.78rem;
}

.login-certificate-details.hidden {
    display: none;
}

.login-certificate-details dt {
    color: var(--text-secondary);
}

.login-certificate-details dd {
    margin: 0;
    color: var(--text-primary);
    font-family: monospace;
    overflow-wrap: anywhere;
}

.login-box #login-button {
    width: 100%;
}

.login-help {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin: 1rem 0 0;
    line-height: 1.45;
}

.tsf-header {
    background: var(--secondary-color);
    padding: 0.6rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    white-space: nowrap;
}

.logo h1 {
    color: var(--primary-color);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.logo .brand-mark {
    height: 1.15rem;
    width: auto;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    flex: 1;
}

.nav-item {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: background-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--on-primary);
    background: var(--primary-color);
}

.tsf-main {
    display: flex;
    flex: 1;
    min-height: 0;
}

.sidebar {
    width: 210px;
    flex: 0 0 auto;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    padding: 1.1rem 1rem;
}

.sidebar-section {
    margin-bottom: 1.5rem;
}

.sidebar-section h3 {
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.sidebar-section ul {
    list-style: none;
}

.sidebar-section ul li {
    margin-bottom: 0.15rem;
}

.sidebar-section ul li a {
    color: var(--text-primary);
    text-decoration: none;
    display: block;
    font-size: 0.86rem;
    padding: 0.4rem 0.55rem;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-section ul li a:hover {
    background: var(--primary-tint);
    color: var(--primary-hover);
}

.sidebar-section ul li a.active {
    background: var(--primary-color);
    color: var(--on-primary);
}

.content {
    flex: 1;
    padding: 1.5rem 1.75rem;
    overflow-y: auto;
    min-width: 0;
}

.content h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 0.9rem;
}

.content h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.content h4 {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 1rem 0 0.5rem;
}

.recent-activity {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.1rem;
    margin-top: 1.25rem;
}

.recent-activity h3 {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 0.65rem;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.9rem;
    margin: 0 0 1.5rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    padding: 1rem 1.1rem;
    border-radius: var(--radius-md);
}

.stat-card h3 {
    color: var(--text-secondary);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 0.3rem;
}

.stat-value {
    color: var(--primary-color);
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.analytics-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    border-radius: var(--radius-md);
    padding: 1.1rem 1.2rem;
    margin-bottom: 1.1rem;
}

.analytics-section h3 {
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.an-chart { min-height: 2rem; }

.an-empty {
    color: var(--text-secondary);
    font-size: 0.86rem;
}

.an-bar-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.45rem;
}

.an-bar-label {
    flex: 0 0 170px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.an-bar-track {
    flex: 1 1 auto;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    height: 0.7rem;
    overflow: hidden;
}

.an-bar-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: var(--radius-sm);
    min-width: 2px;
}

.an-bar-count {
    flex: 0 0 2.3rem;
    text-align: right;
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 600;
}

.an-timeline {
    display: flex;
    align-items: flex-end;
    gap: 0.35rem;
    height: 120px;
    padding-top: 0.85rem;
}

.an-timeline-col {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
}

.an-timeline-bar {
    width: 100%;
    max-width: 26px;
    background: var(--primary-color);
    border-radius: 2px 2px 0 0;
    min-height: 2px;
}

.an-timeline-label {
    margin-top: 0.35rem;
    font-size: 0.62rem;
    color: var(--text-secondary);
    white-space: nowrap;
    transform: rotate(-40deg);
    transform-origin: top center;
}

/* Every progress bar in the app (batch scans, imports, anything long-
   running) used this class already but it had no rule at all -- the track
   rendered with no background/border and the fill bar came from an inline
   style hardcoding the old theme's neon green (#00ff41), a leftover from
   before this palette. Fixed at the source in advanced-features.ajs; this
   is the track + fill the inline width:%/background now pairs with. */
.progress-bar {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    height: 1.1rem;
    overflow: hidden;
    margin: 0.5rem 0;
}

.progress-bar > div {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.2s ease;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--primary-color);
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    width: 100%;
    margin-bottom: 0.5rem;
}

.btn:hover {
    background: var(--primary-tint);
    border-color: var(--primary-hover);
    color: var(--primary-hover);
}

.btn:active {
    background: var(--primary-tint-strong);
}

/* The one filled/solid button style -- used everywhere in the app (Execute,
   Run, Save, Create *, Send, Start *) as the primary action of its form or
   card, but had never had a rule of its own: every "btn-primary" button in
   TSF rendered as a plain outlined .btn, indistinguishable from a Cancel or
   Refresh button next to it. This is the one visual hierarchy fix in this
   pass that changes more than spacing/radius -- everything else here was
   already a real (if unstyled) class doing what its name says. */
.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--on-primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: var(--on-primary);
}

.btn-primary:active {
    background: var(--primary-active);
    border-color: var(--primary-active);
}

.btn-secondary {
    border-color: var(--border-color-strong);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* For irreversible actions (e.g. Crawler's "Purge All Crawled Data") --
   same --error color .sev-high/the session-expired border already use, so
   this reads as consistently "destructive" with the rest of the app. */
.btn-danger {
    border-color: var(--error);
    color: var(--error);
}

.btn-danger:hover {
    background: var(--error);
    color: var(--on-primary);
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.tool-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    padding: 1.1rem 1.2rem;
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.tool-card:hover {
    border-color: var(--border-color-strong);
    box-shadow: var(--shadow-raised);
    transform: translateY(-1px);
}

.tool-card h3 {
    color: var(--primary-color);
    font-size: 0.98rem;
    margin-bottom: 0.35rem;
}

.tool-category {
    color: var(--text-secondary);
    font-size: 0.78rem;
    margin-bottom: 0.75rem;
}

.badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    letter-spacing: 0.03em;
    vertical-align: middle;
}

.badge-warning {
    background: var(--warning);
    color: #1a1a1a;
}

p.badge-warning, p.badge-muted {
    display: block;
    padding: 0.4rem 0.7rem;
    margin-bottom: 0.7rem;
}

.script-editor {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border-color);
}

/* These four were plain unstyled <button> elements (no .btn class at all)
   -- the only buttons left in the app that skipped it -- so they rendered
   as bare browser-default rectangles next to everything else's themed
   buttons. Now that they carry .btn/.btn-primary, this keeps them inline
   and compact instead of taking .btn's block-level 100%-width default,
   the same override .view-toolbar/.session-info already needed. */
.editor-toolbar .btn {
    width: auto;
    margin-bottom: 0;
    padding: 0.4rem 0.85rem;
}

.script-editor #editor-container {
    height: 420px;
    overflow: hidden;
}

.script-filename-label {
    margin-left: auto;
    align-self: center;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

#script-run-result {
    padding: 0 0.8rem 0.8rem;
}

#script-run-result pre {
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.7rem;
    overflow-x: auto;
    white-space: pre-wrap;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.82rem;
}

.logs-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    max-height: 600px;
    overflow-y: auto;
}

.log-entry {
    padding: 0.4rem 0.6rem;
    border-left: 3px solid;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.02);
}

.log-entry.INFO {
    border-color: var(--success);
}

.log-entry.WARN {
    border-color: var(--warning);
}

.log-entry.ERROR {
    border-color: var(--error);
}

.log-user {
    color: var(--text-secondary);
    font-size: 0.76rem;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(6, 8, 11, 0.72);
    backdrop-filter: blur(1px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--card-bg);
    border: 1px solid var(--border-color-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-raised);
    min-width: 460px;
    max-width: 800px;
    max-height: 88vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: flex-end;
    padding: 0.6rem 0.7rem 0;
    position: sticky;
    top: 0;
    background: var(--card-bg);
}

.modal-close {
    width: 1.6rem;
    height: 1.6rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.modal-body {
    padding: 0 1.2rem 1.2rem;
}

.modal-body h3:first-child {
    font-size: 1.05rem;
    margin-bottom: 0.9rem;
}

.tsf-footer {
    background: var(--secondary-color);
    border-top: 1px solid var(--border-color);
    padding: 0.7rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.form-group {
    margin-bottom: 1.1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
}

/* Every <select> in the app, styled once here instead of per-container:
   before this, only the ones inside .view-toolbar or .form-group got a dark
   background, so a plain <select> anywhere else (e.g. Tools' own category
   filter, inside .tools-filter, which never had a select rule) rendered
   with the browser's native white dropdown -- the single most visible
   "unstyled" tell against a dark theme. appearance:none plus this arrow
   keeps every one of them looking like the same widget across Chrome,
   Firefox and Safari instead of three different native pickers. */
select {
    appearance: none;
    -webkit-appearance: none;
    background-color: var(--card-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%239aa7b4' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 10px 7px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.5rem 1.7rem 0.5rem 0.65rem;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

select:hover {
    border-color: var(--border-color-strong);
}

select:focus {
    border-color: var(--primary-color);
}

select option {
    background: var(--card-bg);
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5rem 0.65rem;
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    transition: border-color 0.15s ease;
}

.form-group select {
    padding-right: 1.7rem;
}

.form-group input:hover,
.form-group select:hover {
    border-color: var(--border-color-strong);
}

.tool-options-fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option-field label {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
}

.option-field select,
.option-field input[type="text"] {
    width: 100%;
    padding: 0.5rem 0.65rem;
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
}

.option-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
}

.option-checkbox,
.option-checkbox-inline {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 400;
    cursor: pointer;
}

.option-checkbox input,
.option-checkbox-inline input {
    width: auto;
    cursor: pointer;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary-color);
}

.tools-filter,
.logs-filter {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.logs-filter .btn {
    width: auto;
    margin-bottom: 0;
}

.tools-filter input {
    flex: 1;
    padding: 0.5rem 0.65rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.88rem;
}

.view-subtitle {
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin: 0.35rem 0 0.9rem;
}

.view-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.1rem;
}

.view-toolbar .btn,
.view-toolbar select {
    width: auto;
    margin-bottom: 0;
}

.view-toolbar select {
    padding: 0.5rem 0.65rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
}

.inline-check {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    margin-bottom: 0;
}

.inline-check input {
    width: auto;
}

.check-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.65rem;
}

.check-list .inline-check {
    margin-bottom: 0.4rem;
}

.badge-success {
    background: var(--success);
    color: var(--dark-bg);
}

.badge-error {
    background: var(--error);
    color: #fff;
}

.badge-danger {
    background: var(--error);
    color: #fff;
    font-weight: 700;
}

.annie-report-action {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.75rem 0;
}

.annie-report-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.annie-report-status.annie-report-ok {
    color: var(--success);
}

.annie-report-status.annie-report-fail {
    color: var(--text-secondary);
}

.annie-report-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.9rem 1rem;
    margin: 0.5rem 0 1rem;
}

.annie-report-card h4 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.annie-report-card ul {
    margin: 0.5rem 0 0 1.1rem;
    padding: 0;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.annie-report-card li {
    margin-bottom: 0.3rem;
}

.annie-report-card h5 {
    margin: 1rem 0 0.4rem;
    color: var(--primary-color);
    font-size: 0.92rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25rem;
}

/* The "Recommended action" callout -- deliberately the one element on the
   card styled to stand out at a glance, since it's meant to answer "what's
   the one thing I should do" without reading the rest. */
.annie-callout {
    background: rgba(192, 0, 192, 0.08);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.9rem;
    margin: 0.6rem 0;
}

.annie-callout strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.annie-callout p {
    margin: 0;
    font-size: 0.9rem;
}

.annie-findings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin: 0.4rem 0;
}

.annie-findings-table th, .annie-findings-table td {
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.5rem;
    text-align: left;
    vertical-align: top;
}

.annie-findings-table th {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.annie-code-block {
    background: #0a0a0a;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.82rem;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
}

/* The Annie console (public/js/annie-console.ajs) -- a terminal, not a
   chat widget, so it gets its own high-contrast black/monospace look
   rather than the app's usual card styling. */
.annie-terminal {
    display: flex;
    flex-direction: column;
    background: #000;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    height: 60vh;
    min-height: 320px;
    overflow: hidden;
}

.annie-terminal-output {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.9rem;
}

.annie-line {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}

.annie-line-user {
    color: var(--text-primary);
}

.annie-line-annie {
    color: var(--primary-color);
}

.annie-line-system {
    color: var(--text-secondary);
    font-style: italic;
}

.annie-line-error {
    color: #ff3366;
}

.annie-terminal-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--border-color);
    background: #0a0a0a;
}

.annie-terminal-prompt {
    color: var(--primary-color);
    font-family: 'Consolas', 'Courier New', monospace;
    font-weight: bold;
}

.annie-terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.9rem;
}

.badge-muted {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.sev-critical {
    background: #ff0033;
    color: #fff;
}

.sev-high {
    background: var(--error);
    color: #fff;
}

.sev-medium {
    background: var(--warning);
    color: #1a1a1a;
}

.sev-low {
    background: #3b82f6;
    color: #fff;
}

.sev-info {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.finding-card select {
    width: auto;
    padding: 0.35rem 0.5rem;
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
}

.timeline-list {
    max-height: 420px;
    overflow-y: auto;
}

.timeline-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.86rem;
}

.timeline-time {
    color: var(--text-secondary);
    margin-right: 0.7rem;
    font-size: 0.78rem;
}

/* ── Defense view (ACSP) ──────────────────────────────────────────────────
   ACSP reports genuinely tabular data -- a ban list, an event log, a
   firewall ruleset -- so the Defense view renders tables, which nothing
   else in TSF needed until now. `.error` is styled here too: it was
   already used by app.ajs and campaign-management.ajs but had no rule,
   so a failed load rendered as ordinary body text. */

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.85rem 0;
    font-size: 0.85rem;
}

.data-table th,
.data-table td {
    padding: 0.5rem 0.65rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.data-table th {
    color: var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* An event detail is a description of traffic somebody sent at this host;
   it can be long and it can be junk, so it wraps instead of stretching
   the table off the side of the page. */
.data-table td {
    word-break: break-word;
    max-width: 32rem;
}

.error {
    color: var(--error);
}

/* A smaller stat value: the Defense tiles carry words ("enforce",
   "nftables", "3d 4h"), not the two-digit counts .stat-value was sized for. */
.stat-value-sm {
    font-size: 1.25rem;
}

/* A text setting and its Save button on one line -- used by the Settings
   view for non-boolean settings and by the Defense view's detection check. */
.setting-text-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.35rem;
}

.setting-text-row input[type="text"] {
    flex: 1 1 18rem;
}

.setting-saved {
    color: var(--success);
    font-size: 0.82rem;
}

/* ---- Display mode switcher + per-mode tool suggestion ----
   Mirror of app.css's display modes for the legacy (.ajs) UI, which loads
   main.css rather than app.css. The AHL app and this UI share the same
   data-mode values and the same localStorage key (tsf_mode), so an
   operator's mode choice is consistent across both front-ends. */
.mode-switch { display: inline-flex; border: 1px solid var(--border-color-strong); border-radius: 999px; overflow: hidden; }
.mode-btn { background: transparent; border: 0; color: var(--text-secondary); padding: 5px 13px; font-size: 12px; font-weight: 600; cursor: pointer; transition: color .12s, background .12s; }
.mode-btn + .mode-btn { border-left: 1px solid var(--border-color); }
.mode-btn:hover { color: var(--text-primary); }
.mode-btn.active { background: var(--primary-color); color: var(--on-primary); }

/* The Tools view's "Show all" override and its suggestion note. */
.tools-filter .btn { width: auto; margin-bottom: 0; }
#tools-mode-note.dim, .dim { color: var(--text-secondary); font-size: 0.82rem; }

/* data-mode wins over the base :root palette by specificity (the attribute
   selector on the same element), so source order does not matter. Only the
   palette tokens are redefined; every component already reads them. */
:root[data-mode="defensive"] {
    color-scheme: dark;
    --primary-color: #00c8f5;        /* Ayt blue (deepened for contrast) */
    --primary-hover: #4dd8ff;
    --primary-active: #0088b0;
    --primary-tint: rgba(0, 200, 245, 0.10);
    --primary-tint-strong: rgba(0, 200, 245, 0.18);
    --secondary-color: #06121f;
    --dark-bg: #000000;
    --card-bg: #070b14;
    --card-bg-raised: #0c1322;
    --border-color: #123047;
    --border-color-strong: #1e4e74;
    --text-primary: #d6ecff;
    --text-secondary: #8fb4d4;
}

:root[data-mode="offensive"] {
    color-scheme: dark;
    --primary-color: #ff2f52;        /* Ayt red */
    --primary-hover: #ff6076;
    --primary-active: #a01228;
    --primary-tint: rgba(255, 47, 82, 0.10);
    --primary-tint-strong: rgba(255, 47, 82, 0.18);
    --secondary-color: #1b0b11;
    --dark-bg: #000000;
    --card-bg: #120609;
    --card-bg-raised: #1b0b11;
    --border-color: #3a1622;
    --border-color-strong: #6a2030;
    --text-primary: #ffdfe4;
    --text-secondary: #d59aa6;
}

/* ---- Narrower screens (tablets, foldables, phones) ----
   The header keeps one row on a wide desktop. Below that, the logo and the
   mode/log-out controls share the top row and the menu gets a full-width
   row of its own that scrolls sideways, instead of wrapping into a block
   that pushes the page halfway down the screen. */
@media (max-width: 1700px) {
    .tsf-header {
        flex-wrap: wrap;
        row-gap: 0.45rem;
        padding: 0.5rem 0.9rem;
    }
    .main-nav {
        order: 3;
        flex: 1 1 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        margin: 0 -0.9rem;
        padding: 0 0.9rem 0.1rem;
    }
    .main-nav::-webkit-scrollbar { display: none; }
    .nav-item { flex: 0 0 auto; }
    .session-info { gap: 0.6rem; }
}

@media (max-width: 760px) {
    .mode-btn { padding: 5px 10px; }
}

/* Phone width: the sidebar moves above the content, and each of its lists
   becomes one sideways-scrolling row so it stays a strip, not a block. */
@media (max-width: 560px) {
    .tsf-main { flex-direction: column; }
    .sidebar {
        width: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border-color);
        padding: 0.6rem 0.7rem;
    }
    .sidebar-section { margin-bottom: 0.5rem; }
    .sidebar-section:last-child { margin-bottom: 0; }
    .sidebar-section h3 { margin-bottom: 0.35rem; }
    .sidebar-section ul {
        display: flex;
        gap: 0.35rem;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .sidebar-section ul::-webkit-scrollbar { display: none; }
    .sidebar-section ul li { margin-bottom: 0; flex: 0 0 auto; }
    .sidebar-section ul li a { white-space: nowrap; }
    .sidebar-section .btn { width: auto; display: inline-block; margin: 0 0.35rem 0 0; }
}

@media (max-width: 460px) {
    /* No room beside the controls: the name goes under the logo instead. */
    .logo { flex-direction: column; align-items: flex-start; gap: 0; }
    .subtitle { font-size: 0.66rem; }
    .tsf-header { padding: 0.45rem 0.7rem; }
    .main-nav { margin: 0 -0.7rem; padding: 0 0.7rem 0.1rem; }
    .session-info { gap: 0.4rem; }
    .session-info .btn { padding: 0.35rem 0.6rem; }
    .mode-btn { padding: 4px 8px; font-size: 11px; }
}

/* Tab-like buttons (Settings: General / Appliances). */
.view-toolbar .btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--on-primary);
}
