:root {
  --bg: #0d1117;
  --bg-elevated: #161b22;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #2ea043;
  --accent-hover: #3fb950;
  --accent-active: #238636;
  --danger: #f85149;
  --success: #3fb950;
  --warning: #d29922;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  padding-bottom: var(--safe-bottom);
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 4px);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
  border-bottom: 1px solid #21262d;
  flex-shrink: 0;
  min-height: 0;
}

.status-bar__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.status-bar--online {
  color: var(--success);
  background: rgba(63, 185, 80, 0.08);
}

.status-bar--online .status-bar__dot {
  background: var(--success);
  box-shadow: 0 0 8px rgba(63, 185, 80, 0.6);
}

.status-bar--portao-offline {
  color: var(--warning);
  background: rgba(210, 153, 34, 0.1);
}

.status-bar--portao-offline .status-bar__dot {
  background: var(--warning);
}

.status-bar--offline {
  color: var(--danger);
  background: rgba(248, 81, 73, 0.1);
}

.status-bar--offline .status-bar__dot {
  background: var(--danger);
}

.status-bar--checking {
  color: var(--text-muted);
  background: var(--bg-elevated);
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.screen[hidden] {
  display: none !important;
}

.header {
  text-align: center;
  margin-bottom: 32px;
}

.header--compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  margin-bottom: 8px;
}

.title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.title--small {
  font-size: 1.25rem;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 24px;
}

.remember {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}

.remember__input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.remember__label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.login-hint {
  margin: 12px 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-muted);
  text-align: center;
}

.login-hint strong {
  color: var(--text);
  font-weight: 600;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.field__input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid #30363d;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.field__input:focus {
  border-color: var(--accent);
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 16px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  margin-top: 8px;
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 8px;
  cursor: pointer;
}

.control-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 0 48px;
}

.open-btn {
  position: relative;
  width: min(72vw, 280px);
  height: min(72vw, 280px);
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, var(--accent-hover), var(--accent-active));
  color: #fff;
  cursor: pointer;
  box-shadow:
    0 0 0 8px rgba(46, 160, 67, 0.15),
    0 12px 40px rgba(46, 160, 67, 0.35);
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
  -webkit-user-select: none;
  user-select: none;
}

.open-btn:hover:not(:disabled) {
  transform: scale(1.02);
  box-shadow:
    0 0 0 10px rgba(46, 160, 67, 0.2),
    0 16px 48px rgba(46, 160, 67, 0.45);
}

.open-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.open-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: 0 0 0 6px rgba(46, 160, 67, 0.08);
}

.open-btn__ring {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 2px solid rgba(63, 185, 80, 0.25);
  pointer-events: none;
}

.open-btn__label {
  position: relative;
  z-index: 1;
  display: block;
  font-size: clamp(1.1rem, 4.5vw, 1.35rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.04em;
}

.open-btn.is-loading .open-btn__label {
  opacity: 0.4;
}

.feedback {
  text-align: center;
  min-height: 1.5em;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0;
  padding: 0 12px;
}

.feedback--success {
  color: var(--success);
}

.feedback--error {
  color: var(--danger);
}

.feedback--warning {
  color: var(--warning);
}

.loader {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.loader[hidden] {
  display: none !important;
}

.loader__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .open-btn,
  .btn,
  .loader__spinner {
    transition: none;
    animation: none;
  }
}
