/* =========================================================================
   Sistema Info Turb — theme
   Official Solaris palette. Change only the tokens in :root to re-skin.
     Cerulean    #1A7D92  primary brand — headings, CTAs, accents
     Charcoal    #365663  logo color, secondary text
     Powder Blue #9EB5D6  backgrounds, borders, tints
     Aquamarine  #34EBC3  accent — highlights, CTAs
     Gunmetal    #202E3B  dark backgrounds — headers, footers, sidebar
   ========================================================================= */
:root {
    --cerulean:   #1A7D92;
    --cerulean-d: #14606f;
    --charcoal:   #365663;
    --powder:     #9EB5D6;
    --powder-l:   #eef2f8;
    --aqua:       #34EBC3;
    --aqua-d:     #17c7a3;
    --gunmetal:   #202E3B;

    --brand:      var(--cerulean);
    --brand-2:    var(--cerulean-d);
    --accent:     var(--aqua);
    --accent-2:   var(--aqua-d);

    --bg:         #e9eef4;
    --surface:    #ffffff;
    --surface-2:  var(--powder-l);
    --border:     #cdd9ea;
    --text:       var(--gunmetal);
    --text-muted: var(--charcoal);

    --ok:         #1f9d55;
    --warn:       #e08600;
    --danger:     #d23b3b;
    --info:       var(--cerulean);

    --radius:     10px;
    --shadow:     0 1px 3px rgba(32,46,59,.10), 0 1px 2px rgba(32,46,59,.06);
    --font:       system-ui, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.5; }
a { color: var(--cerulean); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .2rem; color: var(--text); }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin: 0 0 .75rem; color: var(--text-muted); }
hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* -------- layout -------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex-shrink: 0; background: var(--gunmetal); color: #cdd9e2;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: .5rem; padding: 1rem; font-weight: 700; color: #fff; }
.brand img { height: 26px; width: auto; }
.sidebar nav { display: flex; flex-direction: column; padding: .5rem; gap: 2px; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: .6rem; padding: .6rem .75rem;
    color: #b9c6d1; border-radius: 8px; font-weight: 500; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.sidebar nav a.active { background: var(--aqua); color: var(--gunmetal); }
.sidebar-foot { padding: 1rem; border-top: 1px solid rgba(255,255,255,.12); display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.sidebar-foot .u strong { display: block; color: #fff; font-size: .85rem; }
.sidebar-foot .u small { color: #8fa3af; }
.btn-link { background: none; border: none; color: #b9c6d1; cursor: pointer; text-decoration: underline; font: inherit; }

.content { flex: 1; padding: 1.5rem; max-width: 1280px; margin: 0 auto; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* -------- cards / grid -------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }

.kpi { display: flex; flex-direction: column; gap: .15rem; }
.kpi-label { color: var(--text-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.kpi-value { font-size: 1.6rem; font-weight: 700; color: var(--brand); }
.kpi-foot { color: var(--text-muted); font-size: .78rem; }
.kpi.accent { border-left: 4px solid var(--aqua); }

/* -------- tables -------- */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--text-muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover { background: var(--surface-2); }
.center { text-align: center; }

/* -------- badges / tags -------- */
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); }
.tag { display: inline-block; padding: .1rem .45rem; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: .78rem; margin: 0 .2rem .2rem 0; }
.b-open, .b-aberto              { background: #fdecec; border-color: #f3c3c3; color: #a52a2a; }
.b-in_progress, .b-andamento   { background: #fff3dd; border-color: #f0d59a; color: #8a5a00; }
.b-awaiting_parts, .b-aguardando_peca { background: var(--powder-l); border-color: var(--powder); color: var(--charcoal); }
.b-submitted, .b-enviado_supervisao   { background: #e2f9f3; border-color: #a9ead9; color: #0f7a63; }
.b-returned                   { background: #fde3cf; border-color: #f4c39a; color: #b45309; }
.b-closed, .b-concluido        { background: #e6f4ea; border-color: #b7dec4; color: #1f7a44; }
.age-fresh { background: #e6f4ea; border-color:#b7dec4; color:#1f7a44; }
.age-warn  { background: #fff3dd; border-color:#f0d59a; color:#8a5a00; }
.age-stale { background: #fdeced; border-color:#f3c3c3; color:#a52a2a; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700;
    min-width: 18px; height: 18px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; }
.sidebar nav a.active .nav-badge { background: var(--gunmetal); }
.c-low, .c-baixa      { background: #e6f4ea; color: #1f7a44; border-color:#b7dec4; }
.c-medium, .c-media, .c-observation, .c-observacao { background: #fff3dd; color: #8a5a00; border-color:#f0d59a; }
.c-high, .c-alta      { background: #fde3cf; color: #b45309; border-color:#f4c39a; }
.c-critical, .c-critica { background: #fdeced; color: #a52a2a; border-color:#f3c3c3; }
.life-ok      { background: #e6f4ea; color: #1f7a44; border-color:#b7dec4; }
.life-soon    { background: #fff3dd; color: #8a5a00; border-color:#f0d59a; }
.life-due     { background: #fde3cf; color: #b45309; border-color:#f4c39a; }
.life-overdue { background: #fdeced; color: #a52a2a; border-color:#f3c3c3; }

/* turbine operational state */
.st-running { background: #e6f4ea; color: #1f7a44; border-color:#b7dec4; }
.st-standby { background: #e4eefb; color: #1c5aa8; border-color:#b9d3f0; }
.st-stopped { background: var(--powder-l); color: var(--charcoal); border-color: var(--powder); }

/* shift-handover trend */
.trend-worse    { background: #fdeced; color: #a52a2a; border-color:#f3c3c3; }
.trend-same     { background: var(--powder-l); color: var(--charcoal); border-color: var(--powder); }
.trend-better   { background: #e2f9f3; color: #0f7a63; border-color:#a9ead9; }
.trend-resolved { background: #e4eefb; color: #1c5aa8; border-color:#b9d3f0; }
.trend-choice { display: flex; flex-wrap: wrap; gap: .6rem; margin: .5rem 0 1rem; }
.trend-choice label { display: flex; align-items: center; gap: .4rem; margin: 0; font-weight: 400; cursor: pointer; }
.trend-choice input { width: auto; margin: 0; }
.trend-choice .badge { font-size: .85rem; padding: .3rem .6rem; }

/* accordion sections */
details.acc > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem;
    margin-bottom: .75rem; user-select: none;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::before {
    content: "▸"; color: var(--text-muted); font-size: .9rem; transition: transform .15s;
}
details.acc[open] > summary::before { transform: rotate(90deg); }
details.acc > summary h3 { margin: 0; }
details.acc:not([open]) > summary { margin-bottom: 0; }

/* pager */
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; padding: .75rem 0 0; }

/* empty state */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty-state svg { color: var(--powder); }
.empty-state p { margin: .5rem 0 1rem; }

/* chart tooltip */
.chart-tip { position: fixed; z-index: 60; background: var(--gunmetal); color: #fff; font-size: .78rem;
    padding: .3rem .5rem; border-radius: 6px; pointer-events: none; white-space: nowrap; transform: translate(-50%, -130%); display: none; }

/* editable catalog rows */
.cat-list { display: flex; flex-direction: column; gap: .35rem; }
.cat-row { display: grid; grid-template-columns: 130px 1fr 90px 60px auto; gap: .6rem; align-items: center; }
.cat-row.cat-head { font-size: .75rem; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.cat-row input[type=text], .cat-row input[type=number] { width: 100%; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.cat-row label { margin: 0; }
.cat-actions { display: flex; gap: .5rem; align-items: center; }
@media (max-width: 700px) { .cat-row { grid-template-columns: 1fr 1fr; } .cat-row.cat-head { display: none; } }

/* notifications banner */
.notif { border-left: 4px solid var(--aqua); }
.notif-list { list-style: none; padding: 0; margin: .5rem 0 0; }
.notif-list li { padding: .6rem .5rem; border-bottom: 1px solid var(--border); }
.notif-list li:last-child { border-bottom: 0; }
.notif-list li:hover { background: var(--surface-2); }

/* component life bar */
.life-row { display: grid; grid-template-columns: 1fr auto; gap: .3rem .75rem; align-items: center; padding: .35rem 0; border-bottom: 1px dashed var(--border); }
.life-bar { grid-column: 1 / -1; height: 7px; border-radius: 4px; background: var(--powder-l); overflow: hidden; }
.life-bar > span { display: block; height: 100%; background: var(--cerulean); }
.life-bar.s-soon > span { background: var(--warn); }
.life-bar.s-due > span { background: #b45309; }
.life-bar.s-overdue > span { background: var(--danger); }

/* -------- forms -------- */
.form label { display: block; margin-bottom: .75rem; font-weight: 600; font-size: .85rem; }
.form input, .form select, .form textarea, .filters input, .filters select {
    width: 100%; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px;
    font: inherit; background: #fff; margin-top: .2rem; font-weight: 400; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--aqua); border-color: var(--aqua); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 1rem; padding: .75rem 1rem; }
legend { font-weight: 700; font-size: .85rem; padding: 0 .4rem; color: var(--charcoal); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .3rem; }
.check { display: flex; align-items: center; gap: .4rem; font-weight: 400; margin: 0; }
.check input { width: auto; margin: 0; }
.actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; min-width: 160px; }

/* -------- buttons -------- */
.btn { display: inline-block; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--cerulean); border-color: var(--cerulean); color: #fff; }
.btn-primary:hover { background: var(--cerulean-d); }
.btn-accent { background: var(--aqua); border-color: var(--aqua); color: var(--gunmetal); }
.btn-accent:hover { background: var(--aqua-d); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: .3rem .6rem; font-size: .82rem; }

/* -------- misc -------- */
.muted { color: var(--text-muted); }
.small { font-size: .8rem; }
.pad-xl { padding: 3rem 1rem; }
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash-success { background: #e6f4ea; border-color: #b7dec4; color: #1f7a44; }
.flash-error   { background: #fdeced; border-color: #f3c3c3; color: #a52a2a; }
.flash-warning { background: #fff3dd; border-color: #f0d59a; color: #8a5a00; }
.flash-info    { background: #e2f4f7; border-color: #b3dbe3; color: var(--cerulean-d); }
.dl { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem .75rem; margin: 0; }
.dl.compact { grid-template-columns: 1fr; }
.dl div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--border); padding: .2rem 0; }
.dl dt { color: var(--text-muted); }
.dl dd { margin: 0; font-weight: 600; text-align: right; }
.timeline { list-style: none; padding: 0; margin: 1rem 0 0; }
.timeline li { border-left: 2px solid var(--aqua); padding: .3rem 0 .6rem .75rem; margin-left: .3rem; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; margin-top: 1rem; }
.media img, .media video { width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.media figcaption { font-size: .8rem; color: var(--text-muted); }
.turbina-card { display: block; }
.tc-head { display: flex; justify-content: space-between; align-items: center; }

/* -------- login -------- */
.body-centered { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--gunmetal); }
.login-card { background: #fff; border-radius: 14px; padding: 2rem; width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.login-brand { text-align: center; margin-bottom: 1rem; }
.login-brand img { max-height: 54px; }
.login-card h1 { text-align: center; font-size: 1.2rem; }
.login-card .muted { text-align: center; }
.login-card form { margin-top: 1rem; }
.login-card label { display: block; font-weight: 600; margin-bottom: .6rem; font-size: .85rem; }
.login-card input { width: 100%; padding: .55rem .6rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; margin-top: .2rem; }

/* -------- 360 viewer -------- */
.grid-viewer { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .grid-viewer { grid-template-columns: 1fr; } }
.viewer360 { position: relative; background: var(--gunmetal); border-radius: 8px; overflow: hidden; cursor: grab; user-select: none; aspect-ratio: 16/10; touch-action: none; }
.viewer360 img, .v360pins { will-change: transform; }
.v360pin.queued { outline: 2px dashed #fff; }
.viewer360.dragging { cursor: grabbing; }
.viewer360 img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.v360-hint { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-size: .78rem; color: #cfe0f2; background: rgba(0,0,0,.35); padding: .3rem; }
.v360pins { position: absolute; inset: 0; pointer-events: none; }
.v360pin { position: absolute; transform: translate(-50%, -100%); pointer-events: auto; cursor: pointer;
    width: 22px; height: 22px; border-radius: 50% 50% 50% 0; background: var(--aqua); border: 2px solid #fff;
    rotate: -45deg; box-shadow: 0 2px 6px rgba(0,0,0,.4); display: grid; place-items: center; }
.v360pin span { rotate: 45deg; font-size: .7rem; font-weight: 700; color: var(--gunmetal); }
.v360pin.s-high, .v360pin.s-critical { background: var(--danger); }
.v360pin.s-low, .v360pin.s-observation { background: var(--cerulean); }
.viewer-controls { display: flex; align-items: center; gap: .6rem; margin-top: .6rem; }
.viewer-controls input[type=range] { flex: 1; accent-color: var(--cerulean); }
.pin-list { list-style: none; padding: 0; margin: .5rem 0 0; }
.pin-list li { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .6rem; margin-bottom: .5rem; cursor: pointer; }
.pin-list li:hover { background: var(--surface-2); }
.pin-list .pl-del { float: right; color: var(--danger); border: none; background: none; cursor: pointer; font-size: .8rem; }

/* -------- modal -------- */
.modal { position: fixed; inset: 0; background: rgba(32,46,59,.55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 12px; padding: 1.5rem; width: 420px; max-width: 92vw; }
.modal-box label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .75rem; }
.modal-box select, .modal-box textarea { width: 100%; padding: .5rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; margin-top: .2rem; }

/* -------- report / print -------- */
.body-print { background: #e9eef4; }
.print-toolbar { display: flex; justify-content: space-between; padding: 1rem; max-width: 900px; margin: 0 auto; }
.report { background: #fff; max-width: 900px; margin: 0 auto 2rem; padding: 2.5rem; box-shadow: var(--shadow); }
.report-head { display: flex; align-items: center; gap: 1rem; border-bottom: 3px solid var(--cerulean); padding-bottom: 1rem; margin-bottom: 1.5rem; }
.report-head h1 { color: var(--cerulean); }
.report-logo { height: 44px; }
.report-status { margin-left: auto; }
.report section { margin-bottom: 1.5rem; }
.report h2 { color: var(--charcoal); border-bottom: 1px solid var(--border); padding-bottom: .25rem; }
.kv { width: 100%; border-collapse: collapse; }
.kv th, .kv td { border: 1px solid var(--border); padding: .4rem .6rem; text-align: left; font-size: .88rem; }
.kv th { background: var(--surface-2); width: 22%; }
.kv.full th { width: auto; }
.pin-report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.pin-report { border: 1px solid var(--border); border-radius: 8px; padding: .6rem; display: grid; grid-template-columns: 120px 1fr; gap: .6rem; }
.pin-report-img { position: relative; }
.pin-report-img img { width: 100%; border-radius: 6px; }
.pin-dot { position: absolute; transform: translate(-50%, -50%); width: 20px; height: 20px; border-radius: 50%;
    background: var(--aqua); border: 2px solid #fff; display: grid; place-items: center; font-size: .7rem; font-weight: 700; color: var(--gunmetal); }
.pin-dot.s-high, .pin-dot.s-critical { background: var(--danger); color: #fff; }
.evi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.evi-grid img { width: 100%; border-radius: 6px; border: 1px solid var(--border); }
.report-foot { display: flex; gap: 3rem; margin-top: 3rem; }
.sign { flex: 1; text-align: center; }
.sign span { display: block; border-top: 1px solid var(--text); margin-bottom: .3rem; }

@media print {
    .no-print { display: none !important; }
    .body-print { background: #fff; }
    .report { box-shadow: none; margin: 0; padding: 0; max-width: none; }
    .pin-report-grid, .evi-grid { grid-template-columns: 1fr 1fr; }
    a { color: inherit; text-decoration: none; }
}

/* ================= dark mode ================= */
:root[data-theme="dark"] {
    --bg:         #161d24;
    --surface:    #1f2a34;
    --surface-2:  #26333f;
    --border:     #35434f;
    --text:       #e5edf5;
    --text-muted: #9db0c1;
    --brand:      #2ea6bd;
    --brand-2:    #4bbcd0;
    --shadow:     0 1px 3px rgba(0,0,0,.4);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:#161d24; --surface:#1f2a34; --surface-2:#26333f; --border:#35434f;
        --text:#e5edf5; --text-muted:#9db0c1; --brand:#2ea6bd; --brand-2:#4bbcd0;
        --shadow:0 1px 3px rgba(0,0,0,.4);
    }
}
:root[data-theme="dark"] .form input,
:root[data-theme="dark"] .form select,
:root[data-theme="dark"] .form textarea,
:root[data-theme="dark"] .filters input,
:root[data-theme="dark"] .filters select,
:root[data-theme="dark"] .cat-row input,
:root[data-theme="dark"] .modal-box select,
:root[data-theme="dark"] .modal-box textarea { background: #16202a; color: var(--text); }
:root[data-theme="dark"] .table tr.clickable:hover { background: #26333f; }
:root[data-theme="dark"] .body-print { background: #161d24; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .form input,
    :root:not([data-theme="light"]) .form select,
    :root:not([data-theme="light"]) .form textarea,
    :root:not([data-theme="light"]) .filters input,
    :root:not([data-theme="light"]) .filters select { background:#16202a; color:var(--text); }
}
.theme-toggle { background:none; border:none; color:#b9c6d1; cursor:pointer; font-size:1.1rem; padding:0 .3rem; }

/* offline banner */
#net-banner { position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; display: none;
    background: var(--warn); color: #1c2733; text-align: center; padding: .5rem; font-size: .85rem; font-weight: 600; }
