:root {
    --bg: #f4f6f4;
    --card: #ffffff;
    --text: #1d2a24;
    --muted: #5d6b64;
    --border: #d5ddd8;
    --accent: #2e7d4f;
    --accent-text: #ffffff;
    --error: #c0392b;
    --warning: #d68910;
    --ok-bg: #e6f4ea;
    --err-bg: #fdecea;
    --heading: #ffd400;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16201b;
        --card: #1f2c25;
        --text: #e6efe9;
        --muted: #9db0a5;
        --border: #34463c;
        --accent: #3fa56a;
        --ok-bg: #1d3a2a;
        --err-bg: #3d2320;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    /* GreenSwamp1.jpg behind every page: the whole image centered on black (as on the Home page);
       stays put while the content scrolls. */
    background: #000 url("images/GreenSwamp1.jpg") center / contain no-repeat fixed;
    color: var(--text);
    line-height: 1.5;
}

h1 { margin: 0 0 .5rem; font-size: 1.8rem; }
h2 { margin: 0 0 .75rem; font-size: 1.15rem; }
h1, h2, h3, h4, h5, h6 { color: var(--heading); text-shadow: 0 1px 3px rgba(0, 0, 0, .9); }

/* Text placed directly on the background image (outside cards) needs to stay readable. */
.app-main > p { color: #f0f0f0; text-shadow: 0 1px 3px rgba(0, 0, 0, .9); }
a { color: var(--accent); }
code { background: var(--bg); padding: 0 .3em; border-radius: 4px; }

.app-header {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .75rem 1.5rem; background: var(--accent); color: var(--accent-text);
}
.app-header a { color: var(--accent-text); text-decoration: none; }
.app-header .brand { font-weight: 700; font-size: 1.15rem; }

/* Main menu select box */
.nav-menu-select {
    min-width: 11rem; padding: .35rem .6rem; border: 1px solid rgba(255, 255, 255, .18); border-radius: 6px;
    background: rgba(12, 22, 17, .68); color: #e6efe9; font: inherit; cursor: pointer;
    color-scheme: dark; /* dark native drop-down list and arrow */
}
.nav-menu-select option { background: #14201a; color: #e6efe9; }

.app-shell { display: flex; flex-direction: column; min-height: 100vh; }
.app-main { flex: 1 0 auto; width: 100%; max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

/* Home page: the app title centered over the page background image. */
.app-main:has(> .home-hero) { display: flex; max-width: none; padding: 0; }
.home-hero { flex: 1; display: grid; place-items: center; min-height: 20rem; padding: 1.5rem; }
.home-title {
    margin: 0; text-align: center; color: var(--heading);
    font-size: clamp(2.5rem, 8vw, 6rem); font-weight: 800; line-height: 1.1;
    text-shadow: 0 2px 12px rgba(0, 0, 0, .85);
}
.home-content { display: flex; flex-direction: column; align-items: center; gap: 1.5rem; }
.home-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; }
    .home-actions .btn {
        font-size: 1.1rem;
        padding: .7rem 1.5rem;
        justify-content: center;
    }

.lead { color: var(--muted); margin-top: 0; }
.hint { color: var(--muted); font-size: .9rem; }

/* Cards (and the Log Analysis tiles) are semi-transparent dark panels over the background image.
   The theme colors are redefined here so everything inside switches to light-on-dark in both themes. */
.card, .menu-tile {
    --card: rgba(12, 22, 17, .68);
    --bg: rgba(0, 0, 0, .35);
    --text: #e6efe9;
    --muted: #b4c4ba;
    --border: rgba(255, 255, 255, .18);
    --accent: #3fa56a;
    --ok-bg: rgba(29, 58, 42, .85);
    --err-bg: rgba(61, 35, 32, .85);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.card {
    background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
    padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
}

/* Main menu */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.menu-tile {
    display: flex; flex-direction: column; gap: .35rem; text-align: left; cursor: pointer;
    padding: 1.25rem; border-radius: 10px; border: 1px solid var(--border);
    background: var(--card); color: var(--text); font: inherit;
}
.menu-tile:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.menu-title { font-size: 1.25rem; font-weight: 600; color: var(--accent); }
.menu-desc { color: var(--muted); }

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }
.btn {
    /* Same semi-transparent dark look as the cards, wherever the button sits. */
    --card: rgba(12, 22, 17, .68);
    --text: #e6efe9;
    --border: rgba(255, 255, 255, .18);
    display: inline-block; padding: .55rem 1.1rem; border-radius: 6px; cursor: pointer;
    border: 1px solid var(--border); background: var(--card); color: var(--text);
    font: inherit; text-decoration: none;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* Drag & drop area: a transparent <input type=file> covers the whole zone, so the browser's own
   drag-and-drop file handling works without any JavaScript. */
.dropzone {
    position: relative; min-height: 130px; border: 2px dashed rgba(255, 255, 255, .25); border-radius: 10px;
    display: flex; align-items: center; justify-content: center; text-align: center;
    background: rgba(0, 0, 0, .35); color: #e6efe9;
    transition: background .15s, border-color .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: #3fa56a; background: rgba(29, 58, 42, .85); }
.dropzone.has-file { border-style: solid; }
.dropzone-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone-content { display: flex; flex-direction: column; gap: .25rem; pointer-events: none; padding: 1rem; }
.dropzone-content span { color: #b4c4ba; }

.steps { margin: 0; padding-left: 1.25rem; }
.steps li { margin-bottom: .35rem; }

/* Alerts */
.alert { padding: .65rem 1rem; border-radius: 6px; margin: 1rem 0; }
.alert-error { background: var(--err-bg); color: var(--error); }
.alert-ok { background: var(--ok-bg); color: var(--accent); }
ul.alert { padding-left: 2rem; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin: 1rem 0; }
.stat { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; display: flex; flex-direction: column; }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-error .stat-value { color: var(--error); }
.stat-warning .stat-value { color: var(--warning); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th.num, td.num { text-align: right; white-space: nowrap; }

/* PHD2 "Pulse Finish Times Grouped" row colors (thresholds in Rules/Phd2Rules.cs). */
tr.band-green td  { background: rgba(46, 160, 67, .28); }
tr.band-yellow td { background: rgba(230, 190, 20, .35); }
tr.band-red td    { background: rgba(210, 50, 40, .30); }
.sig { font-weight: 600; }
pre.detail { margin: .3rem 0 0; font-size: .8rem; color: var(--muted); white-space: pre-wrap; }

.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; color: #fff; background: #7f8c8d; }
.badge-Critical { background: #7b241c; }
.badge-Error { background: var(--error); }
.badge-Warning { background: var(--warning); }
.badge-Info { background: #2980b9; }

.filters { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-bottom: .75rem; }
.filters select { margin-left: .35rem; padding: .25rem; }

/* Timeline */
.tl-row { display: grid; grid-template-columns: 110px 1fr 110px; gap: .6rem; align-items: center; font-size: .85rem; margin: .15rem 0; }
.tl-track { display: flex; height: 14px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.tl-bar { display: block; height: 100%; }
.tl-error { background: var(--error); }
.tl-warning { background: var(--warning); }
.tl-count { color: var(--muted); text-align: right; }
.legend { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; vertical-align: middle; margin: 0 .2rem 0 .6rem; }
.legend-error { background: var(--error); }
.legend-warning { background: var(--warning); }

/* Settings form */
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .9rem; }
.field > span { font-size: .9rem; color: var(--muted); }
/* Input boxes: dark, matching the cards (same look inside or outside a card). */
.field input[type=text], .field input[type=number], .field input[type=password], .field textarea, .filters select {
    border: 1px solid rgba(255, 255, 255, .18); border-radius: 6px;
    background: rgba(0, 0, 0, .35); color: #e6efe9; font: inherit;
    color-scheme: dark; /* dark number spinners and drop-down lists */
}
.field input[type=text], .field input[type=number], .field input[type=password], .field textarea { padding: .45rem .6rem; }
.field input[readonly] { opacity: .75; }
.filters select option { background: #14201a; color: #e6efe9; }
.field textarea { font-family: Consolas, "Cascadia Mono", monospace; font-size: .85rem; }
.field-inline { flex-direction: row; align-items: center; gap: .5rem; }

details summary { cursor: pointer; font-weight: 600; }

#blazor-error-ui {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
    background: #fff3cd; color: #333; padding: .6rem 1.25rem; box-shadow: 0 -1px 4px rgba(0,0,0,.2);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .75rem; }
