@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
}
@font-face {
  font-family: "Inter Tight";
  src: url("/assets/fonts/inter-tight-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --ink: #202020;
  --steel: #4d4d4d;
  --slate: #6b6b6b;
  --line: #dedbd6;
  --ash: #efefef;
  --fog: #f5f5f5;
  --ivory: #ebe6dd;
  --paper: #fff;
  --ember: #ff682c;
  --brass: #816729;
  --font-body: "Inter", Arial, sans-serif;
  --font-display: "Inter Tight", Arial, sans-serif;
  --font-data: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--paper); }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--paper); color: var(--ink); font: 400 14px/1.5 var(--font-body); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, dl, dt, dd { margin: 0; }
button, input, select { font: inherit; }
a { color: inherit; text-underline-offset: 3px; }
button { cursor: pointer; }
::selection { background: var(--ivory); color: var(--ink); }
:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--fog); }
::-webkit-scrollbar-thumb { background: #a9a6a0; border: 3px solid var(--fog); border-radius: 10px; }
.hidden { display: none !important; }
.muted, .loading, .empty { color: var(--slate); }

/* Shared frame */
.app-header { background: var(--paper); border-bottom: 1px solid var(--line); }
.header-inner { width: min(100%, 1300px); min-height: 82px; margin: auto; padding: 0 clamp(20px, 3.5vw, 48px); display: flex; align-items: center; gap: clamp(24px, 4vw, 60px); }
.brand { display: inline-flex; align-items: center; gap: 12px; flex: none; text-decoration: none; }
.brand-icon { width: 38px; height: 38px; border: 1px solid var(--ink); border-radius: 50%; display: grid; place-items: center; color: var(--ink); }
.brand-icon svg { width: 18px; height: 18px; }
.brand-text { display: grid; gap: 2px; }
.brand-title { font: 400 22px/1 var(--font-display); letter-spacing: -.02em; }
.brand-subtitle { color: var(--slate); font-size: 10px; }
.nav-links { display: flex; align-items: center; gap: 2px; background: var(--ash); border-radius: 200px; padding: 5px; }
.nav-item { display: inline-flex; align-items: center; gap: 8px; border-radius: 200px; padding: 9px 15px; text-decoration: none; color: var(--steel); font: 400 14px/1 var(--font-display); letter-spacing: -.02em; white-space: nowrap; transition: color .18s, background .18s; }
.nav-item:hover, .nav-item.active { color: var(--ink); background: var(--paper); }
.nav-item svg { width: 15px; height: 15px; stroke-width: 1.7; }
.user-profile { margin-left: auto; display: flex; align-items: center; gap: 22px; }
.user-meta { display: grid; gap: 2px; text-align: right; }
.user-name { font-size: 12px; font-weight: 600; }
.user-role-badge, .user-role-badge.administrador, .user-role-badge.tomero { padding: 0; background: none; color: var(--slate); font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; }
.btn-logout { display: inline-flex; align-items: center; gap: 7px; padding: 6px 0; border-bottom: 1px solid var(--ink); text-decoration: none; font-size: 12px; white-space: nowrap; }
.btn-logout:hover { border-color: var(--ember); }
.main-content { width: min(100%, 1300px); margin: 0 auto; padding: 52px clamp(20px, 3.5vw, 48px) 94px; flex: 1; }
.app-footer { border-top: 1px solid var(--line); color: var(--slate); }
.footer-inner { width: min(100%, 1300px); margin: auto; padding: 24px clamp(20px, 3.5vw, 48px); display: flex; align-items: center; justify-content: space-between; gap: 20px; font-size: 11px; }

/* Work-area introduction */
.page-head, .dashboard-header { display: flex; justify-content: space-between; align-items: end; gap: 32px; margin-bottom: 36px; }
.system-tag, .context-tag { display: none; }
.page-head h1, .dashboard-header h1 { max-width: 20ch; font: 400 clamp(36px, 4vw, 52px)/1.04 var(--font-display); letter-spacing: -.02em; text-wrap: balance; }
.page-head p, .dashboard-header p { max-width: 65ch; margin-top: 13px; color: var(--steel); font-size: 14px; }
.connection-status { display: flex; align-items: center; justify-content: flex-end; gap: 16px; flex-wrap: wrap; padding-bottom: 4px; }
.live-pill { display: inline-flex; align-items: center; gap: 8px; color: var(--steel); font-size: 11px; white-space: nowrap; }
.live-pill i { display: block; width: 6px; height: 6px; border-radius: 50%; background: var(--brass); }
.live-pill[data-state="online"] i { background: var(--ink); }
.live-pill[data-state="offline"] i { background: var(--ember); }
.live-pill[data-state="offline"] { color: var(--ink); }

/* A continuous index of system readings, not separate KPI cards */
.notification-controls { display: flex; align-items: center; gap: 14px 22px; flex-wrap: wrap; margin: -12px 0 28px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.notification-actions { display: flex; gap: 8px; flex-wrap: wrap; flex: 0 1 auto; min-width: 0; max-width: 100%; }
.notification-actions .button { min-height: 44px; padding: 10px 13px; font-size: 12px; }
.notification-actions .button:disabled { color: var(--slate); cursor: not-allowed; }
.notification-actions [aria-pressed="true"] { background: var(--ivory); }
.notification-actions #mute-alarm:not(:disabled) { border-color: #a04422; color: #913b1d; background: var(--ivory); }
.notification-controls p { flex: 1; min-width: min(100%, 240px); max-width: 75ch; color: var(--steel); font-size: 12px; line-height: 1.6; }
.notification-toasts { position: fixed; z-index: 50; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 36px)); max-height: calc(100dvh - 36px); overflow-y: auto; }
.notification-toast { flex: none; padding: 17px 18px 14px; background: var(--ivory); color: var(--ink); border: 1px solid #a04422; overflow-wrap: anywhere; }
.notification-toast strong { display: block; color: #913b1d; font-size: 15px; line-height: 1.35; }
.notification-toast p { margin-top: 7px; font-size: 13px; line-height: 1.55; }
.notification-toast[data-test="true"] { border-color: var(--slate); background: var(--paper); }
.notification-toast[data-test="true"] strong { color: var(--ink); }
.notification-dismiss { display: block; margin-top: 12px; padding: 5px 0; border: 0; border-bottom: 1px solid currentColor; background: transparent; color: var(--ink); cursor: pointer; font-size: 12px; }
.summary { display: grid; grid-template-columns: 1fr 1.7fr 1.1fr 1.15fr; background: var(--ash); margin-bottom: 44px; }
.summary article { min-width: 0; padding: 23px 24px 21px; display: flex; flex-direction: column; border-right: 1px solid #d3d3d3; }
.summary article:last-child { border-right: 0; }
.summary span { color: var(--steel); font-size: 11px; font-weight: 500; }
.summary strong { margin-top: 8px; font: 400 clamp(24px, 2.7vw, 37px)/1.05 var(--font-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.summary small { margin-top: 9px; color: var(--slate); font-size: 10px; line-height: 1.35; }
.summary article.has-critical strong { color: #a13f1d; }
.summary article.has-critical { background: var(--ivory); }

/* Three physical tanks are the center of the operating screen */
.tank-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.tank-grid > .loading { grid-column: 1 / -1; padding: 80px 20px; text-align: center; background: var(--fog); }
.tank-card { min-width: 0; display: flex; flex-direction: column; gap: 0; padding: clamp(22px, 2.8vw, 36px); background: var(--fog); }
.tank-card[data-status="low"], .tank-card[data-status="high"] { background: #f2efea; }
.tank-header { display: flex; justify-content: space-between; align-items: start; gap: 14px; }
.tank-code { display: block; margin-bottom: 8px; font: 500 11px/1 var(--font-data); letter-spacing: .08em; }
.tank-card h2 { font: 400 clamp(23px, 2vw, 29px)/1.12 var(--font-display); letter-spacing: -.02em; }
.status-badge { position: relative; display: inline-flex; align-items: center; gap: 7px; padding-top: 3px; color: var(--steel); font-size: 11px; text-align: right; white-space: nowrap; }
.status-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--slate); flex: none; }
.tank-card[data-status="low"] .status-badge, .tank-card[data-status="high"] .status-badge { color: #9a3e1d; }
.tank-card[data-status="low"] .status-badge::before, .tank-card[data-status="high"] .status-badge::before { background: var(--ember); }
.tank-card[data-status="offline"] .status-badge { color: var(--slate); }

/* A restrained physical vessel, with the live waterline as the signature mark */
.tank-visual { display: grid; place-items: center; padding: 29px 0 22px; }
.tank-body { position: relative; width: 152px; height: 178px; overflow: hidden; background: var(--paper); border: 2px solid #9e9b96; border-radius: 18px 18px 22px 22px; }
.tank-body::before { content: ""; position: absolute; z-index: 5; top: 8px; left: 9px; right: 9px; height: 7px; border: 1px solid #c9c6bf; border-radius: 50%; pointer-events: none; }
.tank-body::after { content: ""; position: absolute; z-index: 4; left: 10px; right: 10px; bottom: 7px; height: 1px; background: #b9b4ac; pointer-events: none; }
.water { --water-fill: #bfc5c0; --water-line: var(--brass); --water-motion: paused; position: absolute; z-index: 1; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(to bottom, transparent 4px, var(--water-fill) 4px); transition: height .7s cubic-bezier(.18,.8,.24,1); }
/* The wave averages the measured waterline; only the surface moves, not the value. */
.water::before, .water::after { content: ""; position: absolute; top: -4px; left: 0; width: calc(100% + 144px); height: 8px; pointer-events: none; mask-repeat: repeat-x; mask-size: 144px 8px; animation: water-surface 6.5s linear infinite; animation-delay: var(--water-phase, 0s); animation-play-state: var(--water-motion); }
.water::before { background: var(--water-fill); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='144' height='8' viewBox='0 0 144 8'%3E%3Cpath d='M0 4 Q18 0 36 4 T72 4 T108 4 T144 4 V8 H0Z' fill='black'/%3E%3C/svg%3E"); }
.water::after { background: var(--water-line); opacity: .65; mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='144' height='8' viewBox='0 0 144 8'%3E%3Cpath d='M0 4 Q36 1 72 4 T144 4' fill='none' stroke='black' stroke-width='1'/%3E%3C/svg%3E"); animation-duration: 8.5s; animation-delay: var(--water-ripple-phase, 0s); animation-direction: reverse; }
.tank-card[data-water-motion="running"] .water { --water-motion: running; }
.water[data-band="red"] { --water-fill: #dc7168; --water-line: #a83930; }
.water[data-band="amber"] { --water-fill: #e5c463; --water-line: #8c681b; }
.water[data-band="blue"] { --water-fill: #78b5d4; --water-line: #286a91; }
.tank-card[data-status="offline"] .water { --water-fill: #e1e0dc; --water-line: #aaa7a1; --water-motion: paused; }
.water[data-empty="true"] { background: none; }
.water[data-empty="true"]::before, .water[data-empty="true"]::after { content: none; }
@keyframes water-surface { from { transform: translateX(0); } to { transform: translateX(-144px); } }
.level-value { position: absolute; z-index: 7; top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 4px 7px; background: rgba(255,255,255,.96); color: var(--ink); font: 400 28px/1 var(--font-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tank-ticks { position: absolute; z-index: 6; top: 0; right: 6px; bottom: 0; padding: 8px 0 10px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.tick { padding: 1px 3px; color: var(--steel); background: rgba(255,255,255,.94); font: 500 9px/1 var(--font-data); }
.volume-container { text-align: center; }
.volume-main { display: flex; justify-content: center; align-items: baseline; gap: 8px; }
.volume-liters { font: 400 29px/1.1 var(--font-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.volume-percent-badge { color: var(--steel); font: 500 11px var(--font-data); }
.volume-sub { display: block; margin-top: 4px; color: var(--slate); font-size: 11px; }
.operational-banner { min-height: 57px; display: flex; align-items: start; gap: 8px; margin-top: 25px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--steel); font-size: 12px; line-height: 1.45; }
.operational-banner[data-action="low"], .operational-banner[data-action="high"] { color: #913b1d; }
.banner-icon { display: flex; flex: none; padding-top: 1px; }
.banner-icon svg { width: 14px; height: 14px; stroke-width: 1.8; }
.metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px; margin: 20px 0 18px; }
.metrics div { min-width: 0; }
.metrics dt { color: var(--slate); font-size: 10px; }
.metrics dd { margin-top: 5px; color: var(--ink); font: 500 10px/1.4 var(--font-data); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tank-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; }
.updated { color: var(--slate); font-size: 10px; }
.request-measurement { min-height: 34px; padding: 7px 11px; font-size: 11px; white-space: nowrap; }
.request-measurement[data-state="success"] { background: var(--ivory); }
.request-measurement:disabled { opacity: .55; cursor: wait; }

/* Alerts read like a chronological record */
.alerts-panel { margin-top: 68px; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.section-title h2 { font: 400 clamp(28px, 3vw, 38px)/1.1 var(--font-display); letter-spacing: -.02em; }
.section-desc { margin-top: 7px; color: var(--steel); font-size: 13px; }
.section-title a { border-bottom: 1px solid var(--ember); text-decoration: none; font-size: 12px; white-space: nowrap; }
.alerts-list { border-top: 1px solid var(--line); }
.alert-row { display: grid; grid-template-columns: 8px minmax(0,1fr) auto; align-items: center; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.alert-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brass); }
.alert-row.high .alert-dot, .alert-row.low .alert-dot { background: var(--ember); }
.alert-details strong { font-size: 13px; font-weight: 600; }
.alert-details p { margin-top: 3px; color: var(--steel); font-size: 12px; }
.alert-right { display: flex; align-items: center; gap: 18px; }
.alert-right time { color: var(--slate); font: 500 11px var(--font-data); white-space: nowrap; }
.ack-badge { color: var(--slate); font-size: 11px; }
.btn-ack { padding: 6px 0; background: none; border: 0; border-bottom: 1px solid var(--ink); color: var(--ink); font-size: 11px; font-weight: 500; }
.btn-ack:disabled { opacity: .5; cursor: wait; }

/* Controls and browser states */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 18px; border: 1px solid var(--ink); border-radius: 0; background: none; color: var(--ink); text-decoration: none; font: 400 13px/1 var(--font-display); letter-spacing: -.02em; transition: color .16s, background .16s; }
.button.primary { background: var(--ink); color: var(--paper); }
.button.primary:hover { background: var(--steel); }
.button.secondary:hover { background: var(--ash); }
.button svg { stroke-width: 1.6; }
.alert, .notice-banner { padding: 14px 16px; margin: 16px 0; background: var(--ivory); color: var(--ink); font-size: 12px; }
.alert.danger, .notice-danger { border-bottom: 2px solid var(--ember); }
.loading, .empty-state { padding: 34px 18px; text-align: center; color: var(--slate); }
label { display: block; margin-bottom: 7px; color: var(--steel); font-size: 11px; font-weight: 600; }
input, select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #bdbab5; border-radius: 0; background: var(--paper); color: var(--ink); caret-color: var(--ember); outline: none; font-size: 13px; }
input::placeholder { color: var(--slate); }
input:focus, select:focus { border-color: var(--ink); outline: 1px solid var(--ink); outline-offset: 2px; }

/* Access */
.login-shell { min-height: calc(100vh - 250px); display: grid; grid-template-columns: minmax(0,1.2fr) minmax(330px,.8fr); align-items: center; gap: clamp(50px, 8vw, 150px); }
.login-copy { padding: 50px 0; }
.login-copy h1 { max-width: 720px; font: 400 clamp(43px, 5.4vw, 69px)/1.05 var(--font-display); letter-spacing: -.02em; text-wrap: balance; }
.login-copy h1 em { font-style: normal; color: var(--ink); }
.login-copy p { max-width: 50ch; margin-top: 25px; color: var(--steel); font-size: 16px; line-height: 1.5; }
.network-line { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 53px; color: var(--slate); font: 500 10px var(--font-data); }
.network-line i { width: 2px; height: 2px; border-radius: 50%; background: var(--ember); }
.login-card { padding: clamp(28px, 3.5vw, 48px); background: var(--ash); border-radius: 6px 0 0 0; }
.login-card h2 { font: 400 31px/1.15 var(--font-display); letter-spacing: -.02em; }
.login-card > p { max-width: 35ch; margin-top: 9px; color: var(--steel); font-size: 12px; }
.login-card .form-group:first-of-type { margin-top: 28px; }
.form-group { margin-bottom: 19px; }
.login-card .button { width: 100%; margin-top: 2px; }
.login-card > p:last-child { color: var(--slate) !important; line-height: 1.4; }

/* History */
.dashboard-header { margin-bottom: 30px; }
.filter-form { display: flex; align-items: end; gap: 12px; padding: 20px 24px; margin-bottom: 25px; background: var(--ash); }
.filter-group { width: min(100%, 360px); }
.table-wrapper { overflow-x: auto; border-top: 1px solid var(--ink); }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 15px 13px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.data-table th { color: var(--steel); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.data-table td { color: var(--ink); }
.data-table td strong { font-weight: 600; }
.data-table td span, .data-table td small { color: var(--slate) !important; font-size: 10px; }
.data-table tbody tr:hover td { background: var(--fog); }

/* Footer and adaptation */
@media (max-width: 1050px) {
  .tank-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .summary { grid-template-columns: repeat(2,1fr); }
  .summary article:nth-child(2) { border-right: 0; }
  .summary article:nth-child(-n+2) { border-bottom: 1px solid #d3d3d3; }
}
@media (max-width: 780px) {
  .header-inner { min-height: 76px; flex-wrap: wrap; gap: 8px 14px; padding-top: 12px; padding-bottom: 12px; }
  .nav-links { order: 3; width: 100%; justify-content: center; }
  .user-profile { margin-left: auto; }
  .page-head, .dashboard-header { align-items: start; flex-direction: column; }
  .connection-status { justify-content: start; }
  .tank-grid { grid-template-columns: 1fr; }
  .tank-card { padding: 30px; }
  .login-shell { min-height: 0; grid-template-columns: 1fr; gap: 35px; }
  .login-card { order: 1; }
  .login-copy { order: 2; padding: 0; }
  .login-copy h1 { font-size: clamp(37px, 7vw, 52px); }
  .login-copy p { margin-top: 16px; font-size: 14px; }
  .network-line { margin-top: 24px; }
}
@media (max-width: 540px) {
  .main-content { padding-top: 33px; padding-bottom: 60px; }
  .header-inner { min-height: 66px; }
  .brand-subtitle { display: none; }
  .brand-title { font-size: 19px; }
  .brand-icon { width: 32px; height: 32px; }
  .user-name { max-width: 82px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .btn-logout span { display: none; }
  .nav-links { padding: 4px; }
  .nav-item { flex: 1; justify-content: center; padding: 10px 8px; font-size: 13px; }
  .page-head h1, .dashboard-header h1 { font-size: 36px; }
  .summary article { padding: 17px 14px; }
  .summary strong { font-size: 25px; white-space: normal; overflow-wrap: anywhere; }
  .summary small { font-size: 9px; }
  .tank-card { padding: 26px 22px; }
  .tank-card h2 { font-size: 24px; }
  .tank-body { height: 170px; }
  .section-title { align-items: start; flex-direction: column; }
  .alert-row { grid-template-columns: 7px minmax(0,1fr); }
  .alert-right { grid-column: 2; justify-content: space-between; }
  .filter-form { flex-direction: column; align-items: stretch; padding: 18px; }
  .filter-group { width: 100%; }
  .filter-form .button { width: 100% !important; }
  .footer-inner { flex-direction: column; align-items: start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .water::before, .water::after { animation: none; }
}
