:root {
  color-scheme: dark;
  --bg: #141416;
  --bg-elevated: #1f1f22;
  --bg-card: #252528;
  --border: #3a3a40;
  --text: #f2f2f4;
  --text-muted: #a8a8b3;
  --accent: #5b8def;
  --accent-hover: #7aa3f5;
  --success: #3ecf8e;
  --danger: #f07178;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(91, 141, 239, 0.15), transparent),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(31, 31, 34, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
}

.subtitle {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.status {
  margin-bottom: 1.5rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.status:empty {
  display: none;
}

.status.error {
  border-color: rgba(240, 113, 120, 0.5);
  color: #ffc9cc;
}

.status.loading {
  color: var(--text-muted);
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.app-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow);
}

.app-card-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.app-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.app-name {
  margin: 0;
  font-size: 1.1rem;
}

.app-description {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.platform-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.platform-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid transparent;
  font-size: 0.88rem;
}

.platform-chip strong {
  font-weight: 600;
}

.platform-chip .version {
  color: var(--success);
  font-variant-numeric: tabular-nums;
}

.platform-chip .date {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.card-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: auto;
}

.card-actions .btn {
  flex: 1;
}

.history-panel {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.history-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.history-table th,
.history-table td {
  padding: 0.4rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.history-table th {
  color: var(--text-muted);
  font-weight: 500;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge.active {
  background: rgba(62, 207, 142, 0.15);
  color: var(--success);
}

.badge.mandatory {
  background: rgba(240, 113, 120, 0.15);
  color: var(--danger);
}

.btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:not(:disabled):active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:not(:disabled):hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:not(:disabled):hover {
  border-color: #555;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.dialog {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 0;
  width: min(480px, calc(100vw - 2rem));
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.dialog-form {
  display: flex;
  flex-direction: column;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1.25rem 1.25rem 0;
}

.dialog-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.dialog-subtitle {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.icon-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
}

.dialog-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.field span {
  color: var(--text-muted);
}

.field input,
.field select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(91, 141, 239, 0.5);
  outline-offset: 1px;
}

.otp-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.hint.success {
  color: var(--success);
}

.error {
  margin: 0;
  color: #ffc9cc;
  font-size: 0.88rem;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0 1.25rem 1.25rem;
}

@media (max-width: 600px) {
  .card-actions {
    flex-direction: column;
  }

  .platform-chip {
    flex-direction: column;
    align-items: flex-start;
  }
}
