/* EcoSensorNetwork
 *
 * Carries over the established identity: the misty conifer banner, the teal
 * (#426e74) navigation bar and the chevron breadcrumb trail. Rewritten from
 * clean.css to drop the dead rules and the w3.css dependency, but the visual
 * result is intended to match.
 */

:root {
    --teal:          #426e74;
    --teal-dark:     #35585d;
    --teal-light:    #5b8b91;
    --ink:           #222;
    --ink-soft:      #555;
    --rule:          #ccc;
    --panel:         #fff;
    --panel-alt:     #f5f5f5;
    --page:          #fff;
    --crumb:         #ddd;
    --crumb-light:   #f5f5f5;
    --danger:        #8a463b;
    --ok:            #3f7d52;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: sans-serif;
    font-size: 20px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--page);
    padding: 10px;
    margin: 0;
}

/* ---- banner ------------------------------------------------------------ */

.logo_banner {
    width: 100%;
    margin: 0 0 4px;
    padding: 0;
    border-radius: 5px;
    text-align: right;
    background-image: url("/images/header_v2.png");
    background-repeat: no-repeat;
    background-size: 100%;
    background-position: center;
    overflow: hidden;
}

.logo_banner img {
    max-width: 100%;
    height: auto;
    padding-bottom: 20px;
    border: 0;
}

/* ---- top navigation ---------------------------------------------------- */

.top_nav {
    list-style-type: none;
    margin: 0;
    padding: 1px;
    border-radius: 5px;
    background: var(--teal);
    font-weight: bold;
    /* flow-root contains the float-right items without clipping the admin
       dropdown, which overflow:auto used to cut off. */
    display: flow-root;
}

.top_nav li {
    display: inline-block;
    margin: 3px;
    padding: 5px 13px;
    border: 2px solid var(--teal);
    border-radius: 3px;
    background-color: var(--teal);
}

.top_nav li.right {
    float: right;
}

.top_nav a {
    color: #fff;
    text-decoration: none;
}

.top_nav li:hover,
.top_nav li:focus-within {
    background-color: var(--teal-light);
    border-color: var(--teal-light);
}

.top_nav a:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ---- breadcrumbs ------------------------------------------------------- */

#breadcrumbs-one {
    background: #eee;
    border: 1px solid;
    border-color: var(--crumb-light) #e5e5e5 var(--rule);
    border-radius: 5px;
    box-shadow: 0 0 2px rgba(0, 0, 0, .2);
    overflow: hidden;
    width: 100%;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
    font-size: 16px;
}

#breadcrumbs-one li {
    float: left;
}

#breadcrumbs-one a {
    position: relative;
    float: left;
    padding: .7em 1em .7em 2em;
    color: #444;
    text-decoration: none;
    text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
    background-color: var(--crumb);
    background-image: linear-gradient(to right, var(--crumb-light), var(--crumb));
}

#breadcrumbs-one li:first-child a {
    padding-left: 1em;
    border-radius: 5px 0 0 5px;
}

#breadcrumbs-one a:hover {
    background: #fff;
}

#breadcrumbs-one a::after,
#breadcrumbs-one a::before {
    content: "";
    position: absolute;
    top: 50%;
    right: -1em;
    margin-top: -1.5em;
    border-top: 1.5em solid transparent;
    border-bottom: 1.5em solid transparent;
    border-left: 1em solid;
}

#breadcrumbs-one a::after {
    z-index: 2;
    border-left-color: var(--crumb);
}

#breadcrumbs-one a::before {
    z-index: 1;
    right: -1.1em;
    border-left-color: var(--rule);
}

#breadcrumbs-one a:hover::after {
    border-left-color: #fff;
}

#breadcrumbs-one .current {
    position: relative;
    float: left;
    /* 2em left clears the point of the preceding chevron, matching the links. */
    padding: .7em 1em .7em 2em;
    font-weight: bold;
    color: var(--teal-dark);
}

#breadcrumbs-one .current::after,
#breadcrumbs-one .current::before {
    content: normal;
}

/* ---- content ----------------------------------------------------------- */

main {
    /* Breathing room for the workspace; the banner, nav and breadcrumbs
       above stay full width. Scales with the window, 16px-64px a side. */
    padding: 8px clamp(16px, 4vw, 64px) 40px;
}

h1, h2, h3 {
    color: var(--teal-dark);
    line-height: 1.2;
    margin: 0 0 .4em;
}

h1 { font-size: 32px; }
h2 { font-size: 26px; }
h3 { font-size: 21px; }

a {
    color: var(--teal);
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 17px;
}

table.data th {
    text-align: left;
    padding: 8px 10px;
    background: var(--panel-alt);
    border-bottom: 2px solid var(--rule);
}

table.data td {
    padding: 8px 10px;
    border-bottom: 1px solid #e5e5e5;
}

table.data td.num {
    font-variant-numeric: tabular-nums;
}

.table-scroll {
    overflow-x: auto;
}

.notice {
    padding: 10px 14px;
    border-radius: 5px;
    border-left: 4px solid var(--teal);
    background: var(--panel-alt);
    font-size: 17px;
}

footer.site {
    margin-top: 40px;
    padding-top: 12px;
    border-top: 1px solid var(--rule);
    font-size: 14px;
    color: var(--ink-soft);
    text-align: right;
}

/* Company mark, small and right-aligned, opening hisescientific.com in a new tab. */
footer.site .footer-logo {
    display: inline-block;
    line-height: 0; /* no descender gap beneath the image */
}

footer.site .footer-logo img {
    height: 24px;   /* 708×75 source → ~226px wide */
    width: auto;
    opacity: 0.85;
    transition: opacity 0.15s;
}

footer.site .footer-logo:hover img,
footer.site .footer-logo:focus-visible img {
    opacity: 1;
}

@media (max-width: 640px) {
    body { font-size: 17px; }
    .top_nav li { padding: 5px 9px; }
    .top_nav li.right { float: none; }
}

/* ---- forms and messages ------------------------------------------------ */

.stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 16px 0 24px;
}

.stack.narrow { max-width: 26rem; }

.stack label {
    font-size: 16px;
    font-weight: bold;
    color: var(--ink-soft);
    margin-top: 8px;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
    font: inherit;
    font-size: 17px;
    padding: 8px 10px;
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: var(--panel);
    color: var(--ink);
    width: 100%;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 1px;
    border-color: var(--teal);
}

button {
    font: inherit;
    font-size: 17px;
    font-weight: bold;
    padding: 8px 18px;
    border: 2px solid var(--teal);
    border-radius: 3px;
    background: var(--teal);
    color: #fff;
    cursor: pointer;
}

button:hover { background: var(--teal-light); border-color: var(--teal-light); }
button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
button.danger { background: var(--danger); border-color: var(--danger); }

button.linkish {
    background: none;
    border: none;
    padding: 0;
    color: var(--teal);
    font-weight: normal;
    text-decoration: underline;
}

button.linkish.danger { background: none; color: var(--danger); }

.inline-form { display: inline; margin: 0 10px 0 0; }

.top_nav .inline-form button.linkish { color: #fff; }

.flash {
    padding: 10px 14px;
    margin: 0 clamp(16px, 4vw, 64px) 12px;
    border-radius: 4px;
    font-size: 17px;
    border-left: 4px solid;
}

.flash-success { background: #eaf3ec; border-color: var(--ok); color: #24512f; }
.flash-error   { background: #f7ebe9; border-color: var(--danger); color: #6d352c; }

.errors {
    margin: 0 0 16px;
    padding: 10px 14px 10px 32px;
    border-left: 4px solid var(--danger);
    border-radius: 4px;
    background: #f7ebe9;
    color: #6d352c;
    font-size: 17px;
}

.hint, .muted { color: var(--ink-soft); font-size: 16px; }
.hint { margin: 2px 0 0; }

.tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 3px;
    background: var(--panel-alt);
    border: 1px solid var(--rule);
    font-size: 14px;
    color: var(--ink-soft);
}

ul.plain { list-style: none; padding: 0; font-size: 17px; }
ul.plain li { padding: 3px 0; }

code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85em; }

/* ---- landing page ------------------------------------------------------ */

.lead {
    font-size: 21px;
    max-width: 46rem;
    color: var(--ink-soft);
}

.cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 8px 32px;
    margin: 28px 0;
}

.cols h2 { font-size: 20px; margin-bottom: .2em; }
.cols p { font-size: 17px; color: var(--ink-soft); margin-top: 0; }

.cta { margin-top: 8px; }

.button-link {
    display: inline-block;
    padding: 9px 20px;
    margin-right: 10px;
    border: 2px solid var(--teal);
    border-radius: 3px;
    background: var(--teal);
    color: #fff;
    font-weight: bold;
    text-decoration: none;
}

.button-link:hover { background: var(--teal-light); border-color: var(--teal-light); }
.button-link:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.tag.error { background: #f7ebe9; border-color: var(--danger); color: var(--danger); }

/* ---- add-source dialog ------------------------------------------------- */

.page-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

dialog {
    border: 1px solid var(--rule);
    border-radius: 6px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
    padding: 20px 24px;
    width: min(30rem, 92vw);
    background: var(--panel);
    color: var(--ink);
}

dialog::backdrop {
    background: rgba(28, 36, 32, .45);
}

.dialog-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.dialog-head h2 { margin: 0; font-size: 22px; }

#type-list { display: grid; gap: 10px; }

.type-choice {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--panel);
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 12px 14px;
    font-weight: normal;
    cursor: pointer;
}

.type-choice:hover { border-color: var(--teal); background: var(--panel-alt); }
.type-choice strong { display: block; color: var(--teal-dark); }
.type-choice span { font-size: 15px; color: var(--ink-soft); }

.dialog-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.new-cred { display: flex; flex-direction: column; gap: 6px; }

/* The hidden attribute must always win, whatever display a class sets. */
[hidden] { display: none !important; }

/* ---- weather station finder -------------------------------------------- */

.station-finder { display: flex; flex-direction: column; gap: 6px; }

.station-results {
    max-height: 12rem;
    overflow-y: auto;
    border: 1px solid var(--rule);
    border-radius: 4px;
    font-size: 15px;
}

.station-option {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--panel);
    color: var(--ink);
    border: none;
    border-bottom: 1px solid var(--rule);
    padding: 7px 10px;
    font-weight: normal;
    cursor: pointer;
}

.station-option:last-child { border-bottom: none; }
.station-option:hover { background: var(--panel-alt); color: var(--teal-dark); }

/* ---- station page columns ---------------------------------------------- */

.station-columns {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 4fr);
    gap: 12px 40px;
    align-items: start;
    margin-bottom: 24px;
}

.station-edit .stack { margin-top: 0; margin-bottom: 0; max-width: 26rem; }
.station-edit .stack label:first-of-type { margin-top: 0; }
/* Read-only details align to the channel table's top edge too. */
.station-edit dl.details { margin-top: 0; }

dl.details {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 18px;
    font-size: 17px;
    margin: 12px 0;
}

dl.details dt { font-weight: bold; color: var(--ink-soft); }
dl.details dd { margin: 0; }

@media (max-width: 800px) {
    .station-columns { grid-template-columns: 1fr; }
}

/* ---- station page tabs -------------------------------------------------- */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--teal);
    margin: 18px 0 20px;
    flex-wrap: wrap;
}

.tabs [role="tab"] {
    background: var(--panel-alt);
    color: var(--teal-dark);
    border: 1px solid var(--rule);
    border-bottom: none;
    border-radius: 5px 5px 0 0;
    padding: 8px 20px;
    font-weight: bold;
}

.tabs [role="tab"]:hover { background: #eaeeea; }

.tabs [role="tab"][aria-selected="true"] {
    background: var(--teal);
    border-color: var(--teal);
    color: #fff;
}

/* The bar above the graph: options toggle left, download right. */
.data-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 16px;
}
.data-bar #data-toggle { font-weight: bold; padding: 6px 0; }
.data-bar .button-link { padding: 7px 16px; margin-right: 0; }

/* The options panel: the range cluster on the left, the display settings
   stacked on the right. Hidden until the toggle opens it. */
.data-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid var(--rule);
    border-radius: 5px;
    background: var(--panel-alt);
    font-size: 16px;
}

/* Left: a label|picker grid — From, To, then Apply under the pickers. */
.data-range {
    display: grid;
    grid-template-columns: max-content max-content;
    gap: 6px 10px;
    align-items: center;
}
.data-range #data-apply { justify-self: start; }

/* Right: three settings stacked. */
.data-display {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}
.data-scale-row { display: flex; align-items: center; gap: 8px; }

.data-controls label { font-weight: bold; color: var(--ink-soft); white-space: nowrap; }
.data-controls input[type="datetime-local"] {
    font: inherit;
    font-size: 16px;
    padding: 6px 8px;
    border: 1px solid var(--rule);
    border-radius: 4px;
    width: auto;
}
.data-controls .checkline { font-weight: normal; }
.data-controls .checkline input { margin-right: 4px; }

#station-graph { min-height: 420px; }

#station-map {
    height: 460px;
    border: 1px solid var(--rule);
    border-radius: 5px;
}

/* ---- threshold cell inputs --------------------------------------------- */
.cell-input { width: 8rem !important; padding: 5px 8px; font-size: 16px; }

.data-controls select { width: auto; font-size: 16px; padding: 6px 8px; }

.channel-list { display: flex; flex-direction: column; gap: 4px; max-height: 20rem; overflow-y: auto; }
.channel-list label { font-size: 16px; font-weight: normal; }
.channel-list input { margin-right: 8px; }

/* ---- dashboard tiles ---------------------------------------------------- */

.tile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 14px;
}

/* Masonry packing (masonry.js): fine implicit rows, the row gutter carried
   inside each tile's span so half tiles slide up into the holes. */
[data-masonry].masonry-on {
    grid-auto-rows: 1px;
    row-gap: 0;
    align-items: start;
}

@media (max-width: 900px) {
    .tile-grid { grid-template-columns: 1fr; }
    .tile-full { grid-column: auto; }
}

.tile {
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: 5px;
    padding: 12px 16px;
    min-width: 0;
}

.tile-full { grid-column: span 2; }
.tile-dragging { opacity: 0.5; }

.tile-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    cursor: grab;
    user-select: none;
}

.tile-head:active { cursor: grabbing; }
.tile-head h2 { margin: 0; font-size: 20px; }
.tile-sub { display: block; font-size: 14px; font-weight: normal; }

.tile-body table.data { font-size: 15px; }
.tile-body table.data th, .tile-body table.data td { padding: 6px 8px; }

.tile-map { height: 320px; border: 1px solid var(--rule); border-radius: 4px; }

/* ---- add-tile placeholder ---------------------------------------------- */

.tile-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 7.5rem;
    background: none;
    border: 2px dashed var(--rule);
    border-radius: 5px;
    color: var(--ink-soft);
    cursor: pointer;
    font-size: 16px;
    font-weight: normal;
}

.tile-add:hover { border-color: var(--teal); color: var(--teal); }
.tile-add-plus { font-size: 2.4rem; line-height: 1; }

/* ---- favourite stars ---------------------------------------------------- */

.star-toggle {
    background: none;
    border: none;
    padding: 0 6px 0 0;
    font-size: 1.1em;
    line-height: 1;
    cursor: pointer;
    color: var(--rule);
    font-weight: normal;
}

.star-toggle.is-favorite { color: #e6b422; }
.star-toggle:hover { color: #cfa01d; }
.star-toggle:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 3px; }

h1.with-star { display: flex; align-items: center; gap: 8px; }
h1.with-star .star-toggle { font-size: 26px; padding: 0; }

table.data td .star-toggle { font-size: 20px; }

.star-static { color: #e6b422; margin-right: 4px; }
.tag.error { background: #f7ebe9; border-color: var(--danger); color: var(--danger); text-decoration: none; }

/* ---- field notes -------------------------------------------------------- */

.notes-columns {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 12px 40px;
    align-items: start;
}
@media (max-width: 800px) { .notes-columns { grid-template-columns: 1fr; } }

.field-notes { list-style: none; padding: 0; margin: 16px 0; }
.field-notes li { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.field-note-body { font-size: 17px; white-space: pre-wrap; }
.field-note-meta { font-size: 14px; margin-top: 3px; }

.field-qr { max-width: 260px; }
.field-qr svg { width: 100%; height: auto; display: block; }
.qr-actions { margin: 10px 0; }

/* Public field page: a narrow, centered column for phones */
body.field-page { max-width: 40rem; margin: 0 auto; }
.field-main { padding: 8px 6px 40px; }

/* ---- site page: station list + map ------------------------------------- */

.site-columns {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 16px 32px;
    align-items: start;
}

@media (max-width: 800px) { .site-columns { grid-template-columns: 1fr; } }

#site-map {
    height: 420px;
    border: 1px solid var(--rule);
    border-radius: 5px;
}

/* ---- attention field notes ---------------------------------------------- */
.note-attention { border-left: 3px solid var(--danger); padding-left: 10px; }
.field-note-meta .inline-form { margin-left: 8px; }

/* ---- settings page ------------------------------------------------------ */
.settings-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    gap: 8px 48px;
    align-items: start;
}

/* ---- subscriptions ------------------------------------------------------ */
.tag.ok { background: #eaf3ec; border-color: var(--ok); color: #24512f; }
.sub-actions { margin-top: 14px; }

/* ---- admin subscription panel ------------------------------------------ */
.admin-sub-panel {
    margin-top: 20px;
    padding: 12px 16px;
    border: 1px solid var(--rule);
    border-radius: 5px;
    background: var(--panel-alt);
}
.admin-sub-panel h2 { margin-top: 0; font-size: 20px; }

/* ---- nav dropdown (admin menu) ----------------------------------------- */

/* Slightly tighter items so a full bar stays on one row at ~1280+. */
.top_nav { font-size: 17px; }

.top_nav li.has-menu { position: relative; }

.top_nav .menu-label {
    background: none;
    border: none;
    color: #fff;
    font: inherit;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
}

.top_nav .submenu {
    position: absolute;
    left: 0;
    top: 100%;
    margin: 4px 0 0;
    padding: 4px;
    list-style: none;
    background: var(--teal);
    border-radius: 4px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
    min-width: 12rem;
    display: none;
    z-index: 20;
}

/* Open on hover and on keyboard/touch focus within the group. */
.top_nav li.has-menu:hover .submenu,
.top_nav li.has-menu:focus-within .submenu {
    display: block;
}

.top_nav .submenu li { display: block; margin: 0; border: none; background: none; }
.top_nav .submenu a { display: block; padding: 7px 12px; border-radius: 3px; }
.top_nav .submenu a:hover { background: var(--teal-light); }

/* ---- login split layout ------------------------------------------------- */

.login-split {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: 24px 48px;
    align-items: start;
    margin-top: 12px;
}

.login-intro .lead {
    font-size: 19px;
    color: var(--ink-soft);
    max-width: 42rem;
}

.login-preview {
    width: 100%;
    height: auto;
    margin-top: 12px;
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(28, 36, 32, .14);
}

.login-panel {
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 20px 24px 24px;
    box-shadow: 0 2px 10px rgba(28, 36, 32, .06);
}

.login-panel h2 { margin-top: 0; }
.login-panel .stack { max-width: none; }
.login-signup { margin-bottom: 0; }

@media (max-width: 760px) {
    .login-split { grid-template-columns: 1fr; }
    /* On a phone, the sign-in panel comes first; the pitch follows. */
    .login-panel { order: -1; }
}

/* ---- field visits ------------------------------------------------------- */
.visit-devices { list-style: none; padding: 0; margin: 16px 0; }
.visit-device { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.visit-device.has-issues { border-left: 3px solid var(--danger); padding-left: 12px; }
.visit-device-head { display: flex; align-items: baseline; gap: 10px; font-size: 18px; }
.visit-issue { margin: 6px 0 0 6px; font-size: 16px; }
.visit-issue .inline-form { margin-left: 8px; }
.visit-actions { margin-top: 20px; display: flex; gap: 20px; align-items: center; }

/* ---- stacking: keep Leaflet maps beneath the nav dropdown ---------------- */
/* Leaflet gives its panes z-index 400 and its controls 1000. Without a
   stacking context on the map box those escape to the page and paint over
   the admin submenu (z-index 20), so the menu opens behind a plot map.
   Isolate every map at z-index 0, and lift the nav above Leaflet's ceiling
   regardless. <dialog> modals live in the browser's top layer, so they are
   unaffected by either rule. */
.tile-map,
#site-map,
#station-map,
.leaflet-container {
    position: relative;
    z-index: 0;
}

.top_nav {
    position: relative;
    z-index: 1100;
}

