﻿:root {
  --bg-0: #0b0f14;
  --bg-1: #101722;
  --bg-2: #1a2638;
  --panel: rgba(19, 27, 40, 0.92);
  --text: #e8eef8;
  --muted: #9ca9bd;
  --line: #2a3a53;
  --accent: #2fc6c9;
  --accent-2: #f18f01;
  --danger: #f04e4e;
  --ok: #2ed573;
  --warn: #f5c542;
  --bad: #ff6b6b;
  --radius: 14px;
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(1000px 480px at -10% -10%, #21406a 0%, transparent 65%),
    radial-gradient(900px 440px at 110% 0%, #2e405e 0%, transparent 58%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 55%, var(--bg-2));
  background-attachment: fixed;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

.auth-shell,
.page-shell {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem;
}

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.auth-panel {
  width: 100%;
  margin-top: 1rem;
}

.subtitle {
  margin-top: 0.3rem;
  color: var(--muted);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  background: rgba(8, 12, 18, 0.85);
}

.top-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.top-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

.menu-toggle {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #182334;
  color: var(--text);
  font-size: 1.3rem;
}

.menu {
  position: fixed;
  top: 65px;
  left: 1rem;
  right: 1rem;
  z-index: 25;
  background: rgba(15, 23, 35, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.45rem;
  display: grid;
  gap: 0.4rem;
}

.menu-link {
  display: block;
  width: 100%;
  border: 0;
  background: #182338;
  color: var(--text);
  padding: 0.85rem 0.9rem;
  border-radius: 10px;
  text-decoration: none;
  text-align: left;
  font-size: 1rem;
}

.menu-button {
  cursor: pointer;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-top: 1rem;
}

.panel h2 {
  margin-bottom: 0.8rem;
  font-size: 1.1rem;
}

.stack-form {
  display: grid;
  gap: 0.55rem;
}

label,
.label-inline {
  color: var(--muted);
  font-size: 0.95rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #101826;
  color: var(--text);
  padding: 0.7rem 0.8rem;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(47, 198, 201, 0.4);
  outline-offset: 1px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-row input {
  width: auto;
  min-height: auto;
}

.btn {
  min-height: 50px;
  border: 0;
  border-radius: 12px;
  padding: 0.8rem 1rem;
  font-weight: 700;
  color: #04111a;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #4be0ab);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-danger {
  background: linear-gradient(135deg, #ef5350, #ff8a65);
  color: #200;
}

.message {
  min-height: 1.2em;
  margin-top: 0.45rem;
  color: var(--accent-2);
}

.message.error {
  color: var(--bad);
}

.message.success {
  color: var(--ok);
}

.loading-status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.65rem;
  color: var(--accent);
  font-weight: 700;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(47, 198, 201, 0.35);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.last-frame-banner {
  margin-top: 1rem;
  border-radius: var(--radius);
  padding: 0.95rem;
  text-align: center;
  font-size: 1.28rem;
  font-weight: 900;
}

.last-frame-banner.banner-ok {
  border: 2px solid #4be0ab;
  color: #f7fffd;
  background: linear-gradient(135deg, rgba(47, 198, 201, 0.24), rgba(75, 224, 171, 0.18));
  box-shadow: 0 10px 22px rgba(20, 130, 113, 0.28);
}

.last-frame-banner.banner-error {
  border: 2px solid #ff6b6b;
  color: #ffecec;
  background: linear-gradient(135deg, rgba(240, 78, 78, 0.32), rgba(157, 42, 42, 0.24));
  box-shadow: 0 10px 22px rgba(158, 46, 46, 0.32);
}

.local-time-note {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.range-grid {
  display: grid;
  gap: 0.5rem;
}

.range-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f1a29;
  padding: 0.6rem 0.75rem;
}

.range-option input {
  width: auto;
  min-height: auto;
}

.summary-grid {
  display: grid;
  gap: 0.6rem;
}

.signal-pill {
  display: inline-block;
  min-width: 82px;
  text-align: center;
  border-radius: 999px;
  padding: 0.26rem 0.65rem;
  font-weight: 700;
  color: #091018;
}

.signal-green {
  background: var(--ok);
}

.signal-yellow {
  background: var(--warn);
}

.signal-red {
  background: var(--bad);
}

.history-list {
  display: grid;
  gap: 0.7rem;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  background: #0f1724;
  display: grid;
  gap: 0.4rem;
}

.history-item p {
  font-size: 0.95rem;
}

.config-box {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
}

.inline-form {
  grid-template-columns: 1fr;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.7rem;
}

.logs-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.logs-controls select {
  width: auto;
  min-width: 90px;
}

.log-details {
  max-width: 360px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  font-size: 0.86rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 0.58rem 0.4rem;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
}

td button,
td select {
  min-height: 38px;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  margin-right: 0.2rem;
}

td button {
  border: 0;
  background: #1f334e;
  color: var(--text);
}

td .danger {
  background: #592f35;
}

@media (min-width: 640px) {
  .auth-shell,
  .page-shell {
    padding: 1.5rem;
  }

  .range-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inline-form {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
  }

  #userForm.inline-form {
    grid-template-columns: 1fr 1fr 140px auto;
  }

  .menu {
    left: auto;
    right: 1.5rem;
    width: 280px;
  }
}
