:root {
  --black: #111111;
  --white: #ffffff;
  --surface: #1b1b1b;
  --surface-raised: #222222;
  --gray-100: #f4f4f2;
  --gray-200: #e6e6e3;
  --gray-400: #b8b8b4;
  --gray-600: #8a8a86;
  --green: #25d366;
  --red: #e15554;
  --radius: 14px;
  --maxw: 560px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--black);
  color: var(--white);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Login screen ---------- */

#login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
  gap: 22px;
}

#login-screen img { width: 84px; height: 84px; }

#login-screen h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.02em;
}

#login-screen p.hint {
  margin: 0;
  color: var(--gray-400);
  font-size: 14px;
  max-width: 280px;
}

#login-form {
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.password-row {
  position: relative;
  width: 100%;
}

#login-form input {
  width: 100%;
  padding: 14px 44px 14px 16px;
  border-radius: var(--radius);
  border: 1px solid #333;
  background: var(--surface);
  color: var(--white);
  font-size: 16px;
  text-align: center;
  letter-spacing: 0.15em;
}

#login-form input:focus { outline: 2px solid var(--green); border-color: var(--green); }

#toggle-password {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.6;
  padding: 8px;
}

#toggle-password:active { opacity: 1; }

#login-form button {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: none;
  background: var(--white);
  color: var(--black);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

#login-form button:active { opacity: 0.8; }

#login-error {
  color: var(--red);
  font-size: 13px;
  min-height: 16px;
}

/* ---------- Dashboard ---------- */

#dashboard-screen {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 48px;
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

header.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

header.topbar img { width: 34px; height: 34px; }

header.topbar h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 700;
}

header.topbar .mes-ref {
  font-size: 11px;
  color: var(--gray-600);
  margin: 0;
}

#refresh-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid #333;
  background: var(--surface);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}

#refresh-btn.spinning svg { animation: spin 0.8s linear infinite; }

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

#status-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--gray-600);
  margin-bottom: 18px;
}

#status-bar .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

#status-bar.offline .dot { background: var(--red); }
#status-bar.offline #status-text { color: var(--red); }

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-600);
  margin: 22px 0 10px;
}

.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 92px;
  justify-content: center;
  transition: background 0.25s ease;
}

.card.wide { grid-column: 1 / -1; }

.card .label {
  font-size: 11.5px;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card .value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.card.wide .value { font-size: 26px; }

.card .sub {
  font-size: 12px;
  color: var(--gray-600);
}

.card .sub.positive { color: var(--green); }
.card .sub.negative { color: var(--red); }

.card.highlight {
  background: linear-gradient(155deg, #1e2e22, var(--surface));
  border: 1px solid rgba(37, 211, 102, 0.25);
}

.card.warning {
  background: linear-gradient(155deg, #2e1e1e, var(--surface));
  border: 1px solid rgba(225, 85, 84, 0.25);
}

.card.pulse { animation: pulse 0.6s ease; }

@keyframes pulse {
  0% { background: var(--surface-raised); }
  100% { background: var(--surface); }
}

.split-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

footer.app-footer {
  text-align: center;
  color: var(--gray-600);
  font-size: 11px;
  margin-top: 28px;
}
