:root {
  color-scheme: light;
  --bg: #f7f5f1;
  --panel: #ffffff;
  --muted-panel: #f0ede8;
  --text: #191817;
  --muted: #746f69;
  --line: #ded9d2;
  --accent: #111111;
  --danger: #d63a3f;
  --danger-bg: #fff1f1;
  --danger-line: #ffd1d1;
  --row-panel: #ffffff;
  --row-panel-soft: #fbfaf8;
  --input-panel: #ffffff;
  --success: #20a36b;
  --shadow: 0 18px 48px rgba(34, 30, 24, 0.1);
  --soft-shadow: 0 24px 70px rgba(34, 30, 24, 0.12);
  --orange: #f5a400;
}

body.dark {
  color-scheme: dark;
  --bg: #141412;
  --panel: #20201d;
  --muted-panel: #292823;
  --text: #f4f1eb;
  --muted: #b4aea5;
  --line: #3d3932;
  --accent: #f4f1eb;
  --danger-bg: #3a2020;
  --danger-line: #744040;
  --row-panel: #181815;
  --row-panel-soft: #1f1e1a;
  --input-panel: #181815;
  --success: #5fd49d;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
  --soft-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 255, 255, 0.8), transparent 28%),
    linear-gradient(180deg, #fbfaf8 0%, var(--bg) 48%, #f1eee9 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
}

body.dark {
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 255, 255, 0.06), transparent 28%),
    linear-gradient(180deg, #181715 0%, var(--bg) 58%, #11110f 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.admin-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

body:has(#loginView:not([hidden])) .admin-shell {
  width: min(420px, calc(100vw - 32px));
  display: grid;
  place-items: center;
  padding: 0;
}

.login-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.login-card {
  min-height: 338px;
  position: relative;
  overflow: hidden;
  width: min(420px, 100%);
  margin: 0;
  padding: 34px 28px 26px;
}

.login-card::after {
  content: "";
  position: absolute;
  inset: auto -34px -48px auto;
  width: 142px;
  height: 142px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--orange) 18%, transparent);
  pointer-events: none;
}

.login-card > * {
  position: relative;
  z-index: 1;
}

.login-card h1 {
  margin: 30px 0 22px;
  font-size: 1.95rem;
}

.login-index {
  position: absolute;
  top: 20px;
  right: 22px;
  color: #b8b0a7;
  font-size: 0.78rem;
  font-weight: 950;
}

.login-mark {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border-radius: 14px;
  background: #191817;
  overflow: hidden;
  box-shadow: 0 12px 26px rgba(20, 18, 16, 0.16);
}

.login-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

input,
select,
textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--input-panel);
  color: var(--text);
  padding: 11px 12px;
}

input[type="file"] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

input[type="file"]::file-selector-button {
  min-height: 30px;
  margin-right: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--muted-panel);
  color: var(--text);
  font-weight: 750;
}

body.dark input,
body.dark select,
body.dark textarea {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  background: var(--accent);
  color: var(--bg);
}

.secondary-button {
  background: var(--panel);
  color: var(--muted);
  border-color: var(--line);
}

.danger-button {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-line);
}

body.dark .danger-button {
  color: #ff9a9d;
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
}

.admin-toast {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 80;
  width: min(360px, calc(100vw - 32px));
  display: grid;
  gap: 4px;
  padding: 15px 17px 15px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
  color: var(--text);
  overflow: hidden;
}

.admin-toast[hidden] {
  display: none;
}

.admin-toast::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--success);
}

.admin-toast.error::before {
  background: var(--danger);
}

.admin-toast strong {
  font-size: 0.9rem;
}

.admin-toast span {
  color: var(--muted);
  line-height: 1.4;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 22px;
}

.admin-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 6px 14px rgba(20, 18, 16, 0.06);
}

.login-theme-button {
  position: fixed;
  top: 34px;
  right: 44px;
  z-index: 30;
}

body:has(#adminView:not([hidden])) .login-theme-button {
  display: none;
}

.profile-menu {
  position: relative;
  z-index: 20;
}

.profile-menu summary {
  list-style: none;
}

.profile-menu summary::-webkit-details-marker {
  display: none;
}

.profile-trigger::marker {
  content: "";
  font-size: 0;
}

.profile-trigger {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  cursor: pointer;
  box-shadow: var(--shadow);
}

.profile-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #4f4b46);
  color: #fff;
  font-weight: 950;
}

body.dark .profile-avatar {
  background: linear-gradient(135deg, #f4f1eb, #777168);
  color: #181815;
}

.profile-avatar.has-image {
  background-position: center;
  background-size: cover;
  color: transparent;
}

.profile-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.profile-popover span {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 4px;
}

.admin-header p {
  margin: 0 0 4px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.76rem;
}

.admin-header h1 {
  margin: 0;
  overflow-wrap: anywhere;
}

.admin-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 16px;
  background: var(--muted-panel);
}

.admin-tab {
  min-height: 38px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.admin-tab.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(20, 18, 16, 0.06);
}

.admin-panel-view[hidden] {
  display: none !important;
}

.panel {
  padding: 24px;
  margin-bottom: 18px;
}

.panel h2 {
  margin: 0 0 16px;
}

.panel-help {
  max-width: 760px;
  margin: -8px 0 16px;
  color: var(--muted);
  line-height: 1.45;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.panel-title h2 {
  margin: 0;
}

.panel-title select {
  max-width: 260px;
}

.app-type-slider {
  width: min(100%, 640px);
  min-height: 46px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 0 0 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--muted-panel) 72%, var(--panel));
}

.app-type-slider button {
  min-width: 0;
  min-height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-type-slider button.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 8px 18px rgba(20, 18, 16, 0.08);
}

.settings-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  min-height: 46px;
  margin: 0 0 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--muted-panel) 72%, var(--panel));
}

.settings-tabs button {
  min-width: 0;
  min-height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-tabs button.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 8px 18px rgba(20, 18, 16, 0.08);
}

body.dark .app-type-slider button.active,
body.dark .settings-tabs button.active {
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.inline-form {
  grid-template-columns: minmax(170px, 0.32fr) minmax(160px, 0.22fr) minmax(240px, 0.46fr) minmax(280px, 1fr) 110px auto;
  align-items: start;
}

.inline-form .primary-button,
.inline-form .secondary-button,
.inline-form .danger-button {
  white-space: nowrap;
}

#appForm {
  grid-template-columns: minmax(160px, 0.9fr) minmax(150px, 0.7fr) minmax(210px, 1.1fr) minmax(220px, 1.35fr) minmax(96px, auto);
}

#appForm .primary-button {
  grid-column: 1 / -1;
  justify-self: end;
  min-width: 124px;
}

.inline-form textarea {
  min-height: 44px;
}

.roadmap-release-admin {
  display: grid;
  gap: 14px;
  margin: 18px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--muted-panel) 62%, var(--panel));
}

.roadmap-release-admin .panel-title {
  margin-bottom: 0;
}

.roadmap-release-admin h3 {
  margin: 0;
}

.roadmap-release-form {
  margin: 0;
}

.roadmap-release-row p {
  margin: 6px 0 0;
  color: var(--muted);
}

.roadmap-release-row {
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 16px;
}

.roadmap-release-main {
  min-width: 0;
  width: 100%;
  display: grid;
  gap: 12px;
}

.roadmap-release-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.roadmap-release-fields {
  display: grid;
  grid-template-columns: minmax(120px, 0.55fr) minmax(220px, 1.4fr) minmax(150px, 0.65fr) minmax(150px, 0.65fr);
  gap: 12px;
}

.roadmap-release-fields label {
  min-width: 0;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.roadmap-release-fields textarea {
  grid-column: 1 / -1;
  min-height: 88px;
  line-height: 1.45;
  resize: vertical;
}

.roadmap-release-fields .release-field-title {
  grid-column: span 2;
}

.roadmap-release-fields .release-field-full,
.roadmap-release-fields .wide-field {
  grid-column: 1 / -1;
}

.roadmap-release-fields .release-field-full textarea,
.roadmap-release-fields .wide-field textarea {
  min-height: 112px;
}

.roadmap-release-fields [data-action="release-body"] {
  min-height: 170px;
}

.roadmap-release-fields [data-action="release-items"] {
  min-height: 120px;
}

.roadmap-release-row .feedback-admin-actions {
  justify-content: flex-end;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.inline-checkbox {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.inline-checkbox input {
  width: 18px;
  height: 18px;
}

.inline-checkbox.compact {
  justify-content: center;
}

.grid-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
}

.feedback-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.feedback-tools {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.feedback-tools a {
  text-align: center;
}

.form-field {
  min-width: 0;
  display: grid;
  gap: 6px;
  align-content: start;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.form-field > span,
.feedback-admin-controls label > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.form-field small {
  min-height: 32px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.35;
}

.form-field textarea {
  grid-column: auto;
}

.feedback-form .wide-field {
  grid-column: span 2;
}

.feedback-public-toggle {
  align-self: start;
  padding-top: 24px;
}

.grid-form textarea {
  grid-column: span 2;
}

.feedback-form textarea {
  grid-column: span 2;
}

.backup-form {
  grid-template-columns: minmax(260px, 0.42fr) minmax(240px, 1fr);
  align-items: end;
  margin-bottom: 12px;
}

.app-store-form {
  grid-template-columns: minmax(280px, 1fr) minmax(150px, 0.25fr) auto auto;
  align-items: end;
  margin-bottom: 12px;
}

.openai-settings-form {
  grid-template-columns: minmax(280px, 1fr) auto;
  align-items: center;
  margin-bottom: 8px;
}

.mail-settings-form {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.mail-settings-form input,
.mail-settings-form select,
.mail-settings-form label {
  grid-column: span 2;
}

.mail-settings-form .wide-field {
  grid-column: span 3;
}

.mail-settings-form button {
  grid-column: span 3;
}

.legal-settings-form label {
  align-content: start;
}

.legal-settings-form small {
  display: block;
  min-height: 34px;
  margin-top: -4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.35;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.legal-settings-actions {
  padding-top: 4px;
}

.legal-settings-actions .secondary-button {
  min-width: 260px;
}

.mail-templates-form {
  display: grid;
  gap: 14px;
}

.mail-template-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--row-panel-soft);
}

.mail-template-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 6px;
}

.mail-template-head > div {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.mail-template-head strong {
  font-size: 1rem;
}

.mail-template-head span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.mail-template-head code {
  display: inline-flex;
  margin: 2px 4px 2px 0;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--muted-panel);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
}

.mail-template-head .secondary-button {
  flex: 0 0 auto;
}

.mail-template-card textarea {
  min-height: 160px;
  line-height: 1.45;
  resize: vertical;
}

.mail-templates-form > .secondary-button {
  justify-self: end;
  min-width: 260px;
}

.settings-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-grid,
.split-grid {
  display: grid;
  gap: 12px;
}

.dashboard-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

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

.dashboard-sections {
  align-items: stretch;
}

.dashboard-section {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.dashboard-section h3 {
  margin: 0;
}

.dashboard-section .table-list {
  min-height: 0;
  align-content: start;
  grid-auto-rows: auto;
  margin-top: 0;
}

.dashboard-section .empty-row {
  box-sizing: border-box;
  height: 72px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  text-align: center;
}

.stat-card,
.mini-entry {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--muted-panel);
}

.stat-card span,
.mini-entry span {
  color: var(--muted);
  font-size: 0.86rem;
}

.stat-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.7rem;
}

.compact-row {
  grid-template-columns: 1fr auto;
}

.row.compact-row {
  box-sizing: border-box;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 72px;
  padding: 14px;
}

.row.compact-row > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.row.compact-row strong,
.row.compact-row span {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.row.compact-row .secondary-button {
  flex: 0 0 auto;
  justify-self: end;
}

.feedback-detail-card {
  width: min(1120px, calc(100vw - 32px));
  max-height: min(900px, calc(100vh - 24px));
  overflow: auto;
}

.detail-body {
  display: grid;
  gap: 16px;
}

.feedback-detail-card .detail-body {
  gap: 18px;
}

.feedback-detail-card .split-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.feedback-detail-card textarea {
  min-height: 126px;
  line-height: 1.5;
}

.detail-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--muted-panel);
}

.detail-section p {
  line-height: 1.55;
}

dialog {
  border: 0;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(25, 24, 23, 0.28);
  backdrop-filter: blur(3px);
}

.dialog-card {
  width: min(520px, calc(100vw - 32px));
  display: grid;
  gap: 14px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.dialog-card h2 {
  margin: 0 0 4px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.dialog-actions .secondary-button,
.dialog-actions .primary-button {
  min-width: 128px;
}

.two-factor-box {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--muted-panel);
}

.two-factor-box > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.two-factor-box strong {
  color: var(--text);
}

.two-factor-box span,
.two-factor-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.two-factor-setup {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.two-factor-setup[hidden] {
  display: none;
}

.recovery-codes-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--success) 24%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--success) 10%, var(--panel));
}

.recovery-codes-box[hidden] {
  display: none;
}

.recovery-codes-box textarea {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  letter-spacing: 0.04em;
}

.two-factor-setup img {
  width: 220px;
  height: 220px;
  justify-self: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 10px;
}

.two-factor-disable {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.two-factor-disable .danger-button {
  grid-column: 1 / -1;
}

.app-admin-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.app-admin-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--row-panel), var(--row-panel-soft));
}

.app-admin-empty {
  display: grid;
  gap: 6px;
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--muted-panel) 72%, var(--panel));
}

.app-admin-empty strong {
  color: var(--text);
}

.app-admin-empty span {
  color: var(--muted);
  line-height: 1.45;
}

.app-admin-side {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 10px;
  padding-right: 14px;
  border-right: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
}

.reorder-controls {
  display: grid;
  gap: 4px;
}

.icon-button.mini {
  width: 32px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
  font-weight: 900;
}

.icon-button.mini:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.app-admin-row strong {
  display: block;
}

.app-admin-row span {
  color: var(--muted);
  font-size: 0.88rem;
}

.app-position {
  text-align: center;
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1.2;
}

.app-admin-main {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.app-admin-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.app-admin-summary .inline-checkbox {
  flex: 0 0 auto;
}

.app-admin-fields {
  display: grid;
  grid-template-columns: minmax(200px, 0.28fr) minmax(180px, 0.22fr) minmax(240px, 0.5fr);
  gap: 12px;
  align-items: start;
}

.app-admin-fields label {
  min-width: 0;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.app-admin-fields textarea {
  grid-column: 1 / -1;
  min-height: 118px;
  line-height: 1.45;
  resize: vertical;
}

.app-admin-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.table-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.row {
  display: grid;
  grid-template-columns: 1.4fr 110px 120px 90px 120px 120px auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--row-panel);
}

.feedback-admin-row {
  grid-template-columns: 26px minmax(220px, 0.9fr) minmax(460px, 1.1fr);
  grid-template-areas:
    "select main controls"
    "select meta actions";
  align-items: start;
}

.feedback-admin-row .feedback-select {
  grid-area: select;
  margin-top: 6px;
}

.feedback-admin-main {
  grid-area: main;
  min-width: 0;
  display: grid;
  gap: 4px;
}

.feedback-admin-main strong {
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.feedback-admin-main span {
  line-height: 1.35;
}

.feedback-admin-controls {
  grid-area: controls;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(98px, 0.72fr) minmax(112px, 0.82fr);
  gap: 8px;
}

.feedback-admin-controls label {
  min-width: 0;
  display: grid;
  gap: 5px;
  align-content: start;
}

.feedback-admin-controls input,
.feedback-admin-controls select {
  width: 100%;
}

.feedback-admin-controls .feedback-control-wide {
  grid-column: 1 / -1;
}

.feedback-admin-controls .feedback-control-wide + .feedback-control-wide {
  grid-column: span 2;
}

.feedback-admin-controls [data-action="plannedFor"] {
  min-width: 0;
}

.feedback-admin-meta {
  grid-area: meta;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.feedback-admin-actions {
  grid-area: actions;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.feedback-admin-actions .secondary-button,
.feedback-admin-actions .danger-button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 11px;
  font-size: 0.88rem;
}

.feedback-select {
  width: 18px;
  height: 18px;
  padding: 0;
}

.detail-image {
  max-width: min(520px, 100%);
  max-height: 320px;
  display: block;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  object-fit: contain;
}

.audit-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) minmax(150px, auto);
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--row-panel), var(--row-panel-soft));
}

.audit-badge {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--muted-panel);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.audit-badge.success {
  border-color: color-mix(in srgb, var(--success) 28%, var(--line));
  background: color-mix(in srgb, var(--success) 12%, var(--panel));
  color: color-mix(in srgb, var(--success) 72%, var(--text));
}

.audit-badge.warning {
  border-color: color-mix(in srgb, var(--orange) 34%, var(--line));
  background: color-mix(in srgb, var(--orange) 13%, var(--panel));
  color: color-mix(in srgb, var(--orange) 72%, var(--text));
}

.audit-badge.danger {
  border-color: var(--danger-line);
  background: var(--danger-bg);
  color: var(--danger);
}

.audit-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.audit-main strong {
  color: var(--text);
}

.audit-main span,
.audit-ip {
  color: var(--muted);
  font-size: 0.9rem;
}

.audit-ip {
  justify-self: end;
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

body.dark .app-admin-row,
body.dark .row,
body.dark .audit-row,
body.dark .login-card,
body.dark .panel,
body.dark .dialog-card,
body.dark .profile-popover,
body.dark .admin-toast {
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

body.dark .app-admin-row strong,
body.dark .row strong,
body.dark .audit-main strong {
  color: var(--text);
}

body.dark .app-admin-row span,
body.dark .row span,
body.dark .audit-main span,
body.dark .audit-ip,
body.dark .empty-row {
  color: var(--muted);
}

.empty-row {
  color: var(--muted);
}

.comment-admin-row {
  grid-template-columns: 1fr 120px auto;
  align-items: start;
}

.comment-admin-row p {
  margin: 8px 0 0;
  color: var(--text);
}

.comment-admin-row img {
  max-width: 260px;
  max-height: 180px;
  display: block;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  object-fit: contain;
}

.backup-row {
  grid-template-columns: minmax(260px, 1fr) 82px auto auto auto;
  gap: 8px;
}

.backup-row .secondary-button,
.backup-row .danger-button {
  min-height: 34px;
  min-width: 0;
  padding: 0 12px;
  border-radius: 11px;
  font-size: 0.88rem;
  white-space: nowrap;
}

.app-store-row {
  grid-template-columns: 1fr 110px 130px 90px;
}

.app-meta-footer {
  width: 100%;
  min-height: 58px;
  margin: 0;
  padding: 14px 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: color-mix(in srgb, var(--muted-panel) 74%, var(--bg));
  border-top: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.app-meta-footer strong {
  color: var(--text);
}

.app-meta-dot {
  opacity: 0.45;
}

.env-badge {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--muted-panel);
  color: var(--muted);
}

.env-badge.dev {
  background: #ffe4e4;
  color: #d63a3f;
}

body.dark .env-badge.dev {
  background: #3a2020;
  color: #ff9a9d;
}

.changelog-editor {
  display: grid;
  gap: 18px;
}

.editor-section {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--row-panel-soft);
}

.editor-section h3,
.editor-section h4 {
  margin: 0;
}

.editor-section .panel-help {
  margin: 6px 0 0;
}

.grid-form label {
  display: grid;
  gap: 7px;
}

.grid-form label > span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.wide-field {
  grid-column: 1 / -1;
}

.changelog-assignment-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.ticket-admin-list {
  display: grid;
  gap: 10px;
}

.ticket-admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.ticket-admin-row strong {
  display: block;
}

.ticket-admin-row span {
  color: var(--muted);
  font-size: 0.88rem;
}

.row.changelog {
  grid-template-columns: 120px 1fr 130px auto auto;
}

.row.changelog.is-selected {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.row strong {
  display: block;
}

.row span {
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 820px) {
  .admin-shell {
    width: min(100% - 20px, 1120px);
    padding: 18px 0 48px;
  }

  .admin-header {
    align-items: flex-start;
  }

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

  .app-type-slider,
  .settings-tabs {
    grid-template-columns: 1fr;
  }

  .inline-form,
  .grid-form,
  .feedback-tools,
  .backup-form,
  .app-store-form,
  .openai-settings-form,
  .mail-settings-form,
  .app-admin-row,
  .app-admin-fields,
  .roadmap-release-row,
  .roadmap-release-fields,
  .row,
  .backup-row,
  .app-store-row,
  .row.changelog,
  .changelog-assignment-grid,
  .ticket-admin-row,
  .dashboard-grid,
  .split-grid,
  .compact-row,
  .audit-row {
    grid-template-columns: 1fr;
  }

  .audit-row {
    align-items: start;
  }

  .feedback-admin-row {
    grid-template-columns: 26px minmax(0, 1fr);
    grid-template-areas:
      "select main"
      "controls controls"
      "meta meta"
      "actions actions";
  }

  .feedback-admin-controls {
    grid-template-columns: 1fr;
  }

  .feedback-admin-controls .feedback-control-wide,
  .feedback-admin-controls .feedback-control-wide + .feedback-control-wide {
    grid-column: 1 / -1;
  }

  .feedback-admin-actions {
    justify-content: stretch;
  }

  .feedback-admin-actions .secondary-button,
  .feedback-admin-actions .danger-button {
    flex: 1 1 140px;
  }

  .roadmap-release-summary {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions {
    justify-content: stretch;
  }

  .legal-settings-actions .secondary-button {
    width: 100%;
    min-width: 0;
  }

  .two-factor-disable,
  .two-factor-box > div:first-child {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .audit-badge {
    justify-self: start;
  }

  .audit-ip {
    justify-self: start;
    max-width: 100%;
  }

  .grid-form textarea {
    grid-column: auto;
  }

  .app-admin-side {
    justify-items: start;
    padding: 0 0 14px;
    border-right: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  }

  .app-position {
    text-align: left;
  }

  .app-admin-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .app-admin-actions {
    justify-content: stretch;
  }

  .app-admin-actions .secondary-button,
  .app-admin-actions .danger-button {
    flex: 1 1 160px;
  }

  .mail-settings-form input,
  .mail-settings-form .wide-field,
  .mail-settings-form button {
    grid-column: auto;
  }

  .mail-templates-form > .secondary-button {
    justify-self: stretch;
    min-width: 0;
  }

  .mail-template-head {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-title {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-title select {
    max-width: none;
  }
}

@media (max-width: 520px) {
  body:has(#loginView:not([hidden])) .admin-shell {
    width: min(100% - 18px, 420px);
    min-height: 100vh;
    padding: 18px 0;
  }

  .login-theme-button {
    top: 12px;
    right: 12px;
  }

  .login-card {
    min-height: auto;
    padding: 28px 22px 24px;
  }

  .login-card h1 {
    margin-top: 26px;
    font-size: 1.75rem;
  }

  .admin-header {
    flex-direction: column;
    gap: 14px;
  }

  .admin-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .profile-popover {
    left: 0;
    right: auto;
    min-width: min(260px, calc(100vw - 36px));
  }

  .admin-tabs {
    grid-template-columns: 1fr;
  }

  .panel,
  .dialog-card {
    padding: 22px 18px;
  }

  .dialog-card,
  .feedback-detail-card {
    width: min(100vw - 18px, 1120px);
    max-height: calc(100vh - 18px);
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions .secondary-button,
  .dialog-actions .primary-button,
  .dialog-actions .danger-button {
    width: 100%;
  }

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

  .two-factor-setup img {
    width: min(220px, 100%);
    height: auto;
  }

  .app-admin-row,
  .row,
  .audit-row {
    padding: 14px 12px;
  }

  .backup-row .secondary-button,
  .backup-row .danger-button,
  .row .secondary-button,
  .row .danger-button {
    width: 100%;
  }
}
