:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --panel: #ffffff;
  --border: #d9d9de;
  --text: #1c1c1e;
  --muted: #6e6e73;
  --accent: #0071e3;
  --danger: #d70015;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-box h1 {
  margin: 0 0 8px;
  font-size: 20px;
  text-align: center;
}

.login-box label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.login-box input,
.license-form input,
.license-form select,
.license-form textarea {
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
}

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #fff;
}

button:hover { opacity: 0.9; }

.error { color: var(--danger); font-size: 13px; margin: 0; }

.layout {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.search { padding: 12px; }
.search input {
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.app-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.app-list li a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  text-decoration: none;
  color: var(--text);
}

.app-list li.active a { background: var(--accent); color: #fff; }
.app-list li.active .app-version { color: rgba(255,255,255,0.8); }
.app-list li.empty { padding: 12px; color: var(--muted); font-size: 13px; }

.app-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}
.app-icon.placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  font-size: 12px;
}

.app-name { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-version { font-size: 11px; color: var(--muted); }

.add-btn {
  display: block;
  text-align: center;
  padding: 10px;
  border-top: 1px solid var(--border);
  text-decoration: none;
  color: var(--accent);
  font-size: 13px;
}

.logout-form { padding: 10px; border-top: 1px solid var(--border); }
.logout-form button { width: 100%; background: transparent; color: var(--muted); border: 1px solid var(--border); }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
}

.placeholder-panel {
  color: var(--muted);
  text-align: center;
  margin-top: 80px;
}

.license-form h2 {
  font-size: 15px;
  margin: 28px 0 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.license-form h2:first-child { margin-top: 0; }

.row {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  min-width: 200px;
}

.row label.full { flex-basis: 100%; }
.row label.inline { flex-direction: row; align-items: center; gap: 8px; flex: none; }

.icon-preview {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  align-self: flex-end;
}

.actions { margin-top: 20px; }

.subform {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.attachments { margin-top: 32px; }
.attachments ul { list-style: none; padding: 0; margin: 0 0 12px; }
.attachments li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.attachments li.empty { color: var(--muted); border: none; }

.inline-form { display: inline; }
.link-btn { background: none; border: none; color: var(--danger); padding: 0; font-size: 12px; }

.danger-zone { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--border); }
.danger-btn { background: var(--danger); }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --panel: #2c2c2e;
    --border: #3a3a3c;
    --text: #f5f5f7;
    --muted: #9a9a9e;
  }
}
