/* ---- Global ---- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 15px;
  color: #333;
  background: #f0f2f5;
}

a { color: #4a7cff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Top navigation ---- */
.navbar {
  background: #fff;
  border-bottom: 1px solid #dde0e4;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.navbar b { font-size: 16px; color: #222; }
.navbar a {
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 6px;
  transition: background .15s;
}
.navbar a:hover { background: #f0f2f5; text-decoration: none; }
.navbar .spacer { flex: 1; }

/* ---- Flash messages ---- */
.flash-messages {
  max-width: 640px;
  margin: 16px auto;
  padding: 0 24px;
  list-style: none;
}
.flash-messages li {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 8px;
  font-size: 14px;
}

/* ---- Login page ---- */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 56px);
  padding: 24px;
}
.login-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  padding: 40px 36px 32px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 24px;
  color: #222;
}
.login-card label {
  display: block;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}
.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccd0d5;
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 16px;
  transition: border-color .15s;
  outline: none;
}
.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus {
  border-color: #4a7cff;
  box-shadow: 0 0 0 3px rgba(74,124,255,.15);
}
.login-buttons {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.login-card .logo-container {
  margin: 28px auto 0;
  width: 140px;
}
.login-card .logo { width: 100%; height: auto; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary {
  background: #4a7cff;
  color: #fff;
  flex: 1;
}
.btn-primary:hover:not(:disabled) { background: #3a66dd; }
.btn-secondary {
  background: #f0f2f5;
  color: #333;
  border: 1px solid #ccd0d5;
  flex: 1;
}
.btn-secondary:hover:not(:disabled) { background: #e4e6ea; }
.btn-small {
  padding: 7px 16px;
  font-size: 13px;
}

/* ---- Status / error messages ---- */
.status-msg { color: #4a7cff; font-size: 13px; margin-top: 12px; min-height: 18px; }
.error-msg { color: #d9534f; font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ---- Portal page ---- */
.portal-wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}
.portal-wrapper h2 {
  font-size: 20px;
  font-weight: 600;
  color: #222;
  margin-bottom: 20px;
}

/* ---- App tiles (Kacheln) ---- */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}
.kachel {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e4e6ea;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: box-shadow .15s, transform .15s;
  cursor: pointer;
}
.kachel:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  transform: translateY(-2px);
}
.kachel img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-bottom: 12px;
  border-radius: 8px;
}
.kachel .app-name {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
  word-break: break-word;
}
.kachel .btn {
  margin-top: auto;
  width: 100%;
}

/* ---- Security key section ---- */
.security-section {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e4e6ea;
  padding: 24px;
}
.security-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: #222;
  margin-bottom: 14px;
}

/* ---- Deploy page ---- */
.deploy-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  padding: 40px 36px 32px;
  width: 100%;
  max-width: 480px;
  text-align: center;
}
.deploy-card h1 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #222;
}
.deploy-desc {
  font-size: 14px;
  color: #555;
  margin-bottom: 24px;
  line-height: 1.5;
}
.deploy-hint {
  font-size: 13px;
  color: #666;
  margin: 16px 0;
  line-height: 1.5;
  text-align: left;
}
.qr-container {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}
.qr-container img {
  width: 300px;
  height: 300px;
  background: white;
  border-radius: 8px;
}
.deploy-info {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 12px 0;
  text-align: left;
}
.info-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.info-row:last-child { margin-bottom: 0; }
.info-label {
  font-size: 13px;
  font-weight: 600;
  color: #555;
  min-width: 50px;
}
.info-value {
  font-size: 14px;
  color: #222;
  background: #e9ecef;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
}
.info-secret {
  font-size: 11px;
  word-break: break-all;
}
.deploy-card label {
  display: block;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}
.deploy-card input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccd0d5;
  border-radius: 8px;
  font-size: 18px;
  letter-spacing: 4px;
  text-align: center;
  margin-bottom: 14px;
  outline: none;
  transition: border-color .15s;
}
.deploy-card input[type="text"]:focus {
  border-color: #4a7cff;
  box-shadow: 0 0 0 3px rgba(74,124,255,.15);
}

.token-choice {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.token-choice-btn {
  width: 100%;
  padding: 14px 20px;
  font-size: 15px;
}

/* ---- Settings page ---- */
.settings-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e4e6ea;
  padding: 24px 28px;
  margin-bottom: 20px;
}
.settings-card h3 {
  font-size: 16px;
  font-weight: 600;
  color: #222;
  margin-bottom: 16px;
}
.settings-desc {
  font-size: 13px;
  color: #666;
  margin-bottom: 14px;
  line-height: 1.5;
}
.settings-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}
.settings-form input[type="password"] {
  width: 100%;
  max-width: 360px;
  padding: 10px 12px;
  border: 1px solid #ccd0d5;
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 14px;
  outline: none;
  transition: border-color .15s;
}
.settings-form input[type="password"]:focus {
  border-color: #4a7cff;
  box-shadow: 0 0 0 3px rgba(74,124,255,.15);
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .login-card { padding: 28px 20px 24px; }
  .login-buttons { flex-direction: column; }
  .app-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .portal-wrapper { padding: 20px 12px; }
}
