* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    min-height: 100vh;
    margin: 0;
    background: var(--page);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px max(24px, calc((100% - var(--content-width)) / 2));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-title { color: var(--primary-text); font-size: 19px; font-weight: 700; letter-spacing: -.15px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.brand-logo { display: block; }
.brand-logo img { display: block; width: 100%; height: auto; }
.brand-logo-dark { display: none !important; }
.header-logo { width: 112px; height: auto; }
.user-name { color: var(--text-muted); font-weight: 600; }
.logout-form { margin: 0; }

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    background: var(--surface);
    color: var(--text);
    padding: 7px 9px;
    cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-muted); }

.primary-nav {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    padding: 0 max(24px, calc((100% - var(--content-width)) / 2));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.nav-tab { position: relative; flex: 0 0 auto; color: var(--text-muted); font-size: 13px; font-weight: 600; padding: 12px 16px 11px; transition: background-color .16s ease, color .16s ease; }
.nav-tab:hover { background: var(--surface-muted); color: var(--text); text-decoration: none; }
.nav-tab.active { background: color-mix(in srgb, var(--primary) 82%, var(--surface)); color: var(--primary-on); box-shadow: inset 0 -3px 0 #8db5ff; }

.page-shell { max-width: var(--content-width); margin: 0 auto; padding: 32px 24px 48px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
.page-heading h1, .form-section h2, .section-heading h2, .error-page h1 { margin: 0; color: var(--text); font-size: 26px; line-height: 1.2; font-weight: 700; }
.page-heading p:not(.eyebrow), .section-heading p { margin: 6px 0 0; color: var(--text-muted); }
.eyebrow { margin: 0 0 4px; color: var(--primary-text); font-size: 11px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: var(--radius-small);
    padding: 7px 13px;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
    text-decoration: none;
}
.button:hover { text-decoration: none; }
.button-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-on); }
.button-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.button-secondary:hover { background: var(--surface-muted); }
.button-quiet { color: var(--primary-text); background: transparent; }
.button-quiet:hover { background: var(--surface-muted); }
.button-small { min-height: 30px; padding: 5px 10px; font-size: 12px; }

.messages { margin-bottom: 20px; }
.message { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; padding: 10px 12px; border: 1px solid var(--border); border-left-width: 4px; background: var(--surface); box-shadow: var(--shadow); }
.message-success { border-left-color: var(--success); }.message-error { border-left-color: var(--danger); }.message-warning { border-left-color: var(--warning); }.message-info { border-left-color: var(--primary); }
.message-close { border: 0; background: transparent; color: var(--text-muted); font-size: 20px; cursor: pointer; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-areas: "plants inverters healthy faulty" "unused unused unused unused" "report report mail mail"; gap: 16px; }
.metric-card { min-height: 148px; display: flex; flex-direction: column; justify-content: space-between; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--primary); box-shadow: var(--shadow); color: var(--text); transition: border-color .16s ease, transform .16s ease, background-color .16s ease; }.metric-card:hover { border-color: var(--border-strong); background: var(--surface-muted); text-decoration: none; transform: translateY(-1px); }
.metric-card span { color: var(--text-muted); font-size: 13px; font-weight: 600; }.metric-card .metric-icon { color: var(--primary-text); font-size: 17px; line-height: 1; }.metric-card strong { color: var(--text); font-size: 29px; font-weight: 700; }.metric-card small { color: var(--text-muted); }.metric-plants { grid-area: plants; }.metric-inverters { grid-area: inverters; }.metric-healthy { grid-area: healthy; }.metric-faulty { grid-area: faulty; }.metric-unused { grid-area: unused; }.metric-report { grid-area: report; }.metric-mail { grid-area: mail; }
.status-line { display: flex; align-items: center; gap: 9px; font-size: 18px !important; }.status-dot { display: inline-block; width: 16px; height: 16px; flex: 0 0 16px; border: 2px solid var(--primary-on); border-radius: 50%; box-shadow: 0 0 0 1px var(--border-strong); }.status-success { background: var(--success); }.status-failed { background: var(--danger); }

.filter-bar { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 18px; padding: 16px; background: var(--surface); border: 1px solid var(--border); }.filter-field { min-width: 160px; }.filter-search { width: min(100%, 360px); flex: 1; }.filter-actions { display: flex; gap: 4px; }.filter-bar-simple { max-width: 620px; }
.table-panel, .content-form { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }.table-scroll { overflow-x: auto; }.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); color: var(--text-muted); }.pagination-links { display: flex; gap: 16px; min-width: 132px; }.pagination-links:last-child { justify-content: flex-end; }.pagination a { font-weight: 600; }

.content-form { max-width: 1060px; }.form-section { padding: 24px; border-bottom: 1px solid var(--border); }.form-section h2 { font-size: 18px; }.section-note { margin: 6px 0 18px; color: var(--text-muted); }.form-grid { display: grid; gap: 18px; margin-top: 20px; }.form-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }.form-grid-four { grid-template-columns: repeat(4, minmax(0, 1fr)); }.form-actions { display: flex; gap: 8px; padding: 18px 24px; }.compact-form { max-width: 760px; }.compact-form .form-field + .form-field { margin-top: 16px; }

.page-heading-controls { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }.mail-status { display: inline-flex; align-items: center; gap: 9px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }.list-section { margin-top: 30px; }.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 14px; }.section-heading h2 { font-size: 19px; }.inline-search { display: flex; gap: 6px; }.log-status { display: inline-block; min-width: 62px; padding: 2px 6px; text-align: center; border-radius: var(--radius-small); font-size: 12px; font-weight: 700; }.log-status-success { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); }.log-status-failed { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }.log-status-skipped { color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, transparent); }

.error-page { max-width: 520px; margin: 72px auto; padding: 36px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }.error-page p:not(.eyebrow) { margin: 12px 0 24px; color: var(--text-muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.form-grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check-field { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; }.check-field input { accent-color: var(--primary); }
.toast-region { position: fixed; z-index: 1000; top: 18px; right: 18px; display: grid; width: min(360px, calc(100% - 36px)); gap: 10px; }.toast { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-left: 4px solid var(--primary); background: var(--surface); color: var(--text); box-shadow: 0 12px 30px rgb(0 0 0 / 18%); animation: toast-in .2s ease-out; }.toast-success { border-left-color: var(--success); }.toast-error { border-left-color: var(--danger); }.toast-warning { border-left-color: var(--warning); }.toast-info { border-left-color: var(--primary-text); }.toast button { border: 0; background: transparent; color: var(--text-muted); font-size: 20px; cursor: pointer; }.is-loading { position: relative; pointer-events: none; opacity: .68; }.is-loading::after { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 78%, transparent); color: var(--primary-text); content: "Loading…"; font-weight: 700; }
@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }

html[data-theme="dark"] .brand-logo-light { display: none !important; }
html[data-theme="dark"] .brand-logo-dark { display: block !important; filter: brightness(1.25) saturate(.9) drop-shadow(0 1px 2px rgb(0 0 0 / 40%)); }

@media (prefers-color-scheme: dark) {
    html:not([data-theme-preference]) .brand-logo-light { display: none !important; }
    html:not([data-theme-preference]) .brand-logo-dark { display: block !important; filter: brightness(1.25) saturate(.9) drop-shadow(0 1px 2px rgb(0 0 0 / 40%)); }
}
