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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: #0071e3; text-decoration: none; }
a:hover { text-decoration: underline; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid #e5e5ea;
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-weight: 700;
  font-size: 18px;
  color: #1d1d1f;
  text-decoration: none;
}

.panel-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-user { color: #86868b; font-size: 14px; }

.nav-primary {
  background: #0071e3;
  color: #fff !important;
  padding: 6px 14px;
  border-radius: 980px;
  text-decoration: none !important;
}

.panel-main {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.panel-shell {
  display: flex;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  gap: 20px;
  align-items: flex-start;
}

.panel-sidebar {
  width: 180px;
  flex-shrink: 0;
  background: #fff;
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 1px 8px rgba(0,0,0,.04);
  position: sticky;
  top: 72px;
}

.sidebar-item {
  display: block;
  padding: 12px 16px;
  border-radius: 10px;
  color: #424245;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
}

.sidebar-item:last-child { margin-bottom: 0; }

.sidebar-item:hover {
  background: #f5f5f7;
  text-decoration: none;
}

.sidebar-item.active {
  background: #f0f7ff;
  color: #0071e3;
}

.panel-content {
  flex: 1;
  min-width: 0;
}

.panel-announcement {
  overflow: hidden;
  margin: 0 0 20px;
  padding: 10px 0;
  background: #fff7f7;
  border: 1px solid #ffd6d6;
  border-radius: 12px;
}

.panel-announcement-track {
  display: flex;
  width: max-content;
  animation: panel-announcement-scroll 18s linear infinite;
}

.panel-announcement-text {
  flex: 0 0 auto;
  padding-right: 48px;
  white-space: nowrap;
  color: #d70015;
  font-size: 14px;
  font-weight: 600;
}

.panel-announcement-preview {
  margin: 0;
}

@keyframes panel-announcement-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .panel-announcement-track {
    animation: none;
    width: auto;
  }

  .panel-announcement-text:last-child {
    display: none;
  }
}

@media (max-width: 720px) {
  .panel-shell {
    flex-direction: column;
    padding-top: 16px;
  }

  .panel-sidebar {
    width: 100%;
    position: static;
    display: flex;
    gap: 8px;
    padding: 8px;
  }

  .sidebar-item {
    flex: 1;
    text-align: center;
    padding: 10px 8px;
    font-size: 13px;
    margin-bottom: 0;
  }
}

.password-card { max-width: 420px; }

.panel-page .page-head { margin-bottom: 24px; }
.panel-page h1 { font-size: 28px; font-weight: 700; margin-bottom: 6px; }
.muted { color: #86868b; font-size: 14px; }

.auth-card {
  max-width: 400px;
  margin: 40px auto;
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 2px 16px rgba(0,0,0,.06);
}

.auth-card h1 { font-size: 24px; margin-bottom: 8px; }
.auth-switch { margin-top: 20px; text-align: center; font-size: 14px; color: #86868b; }

.captcha-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.captcha-row input[type="text"] {
  flex: 1;
  min-width: 0;
}

.captcha-img {
  flex-shrink: 0;
  width: 120px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid #d2d2d7;
  cursor: pointer;
  background: #f5f5f7;
}

.captcha-hint {
  margin: -4px 0 8px;
  text-align: right;
}

.captcha-refresh {
  border: none;
  background: none;
  color: #0071e3;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

.captcha-refresh:hover {
  text-decoration: underline;
}

.card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 8px rgba(0,0,0,.04);
}

.card h2 { font-size: 18px; margin-bottom: 16px; }

.form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 12px 0 6px;
  color: #424245;
}

.form input[type="text"],
.form input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d2d2d7;
  border-radius: 10px;
  font-size: 16px;
  outline: none;
}

.form input:focus {
  border-color: #0071e3;
  box-shadow: 0 0 0 3px rgba(0,113,227,.15);
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border: none;
  border-radius: 980px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn-primary { background: #0071e3; color: #fff; }
.btn-primary:hover { background: #0077ed; }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-block { width: 100%; margin-top: 20px; }
.btn-small { padding: 8px 14px; font-size: 13px; }
.btn-outline {
  background: transparent;
  border: 1px solid #d2d2d7;
  color: #1d1d1f;
}

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-error { background: #fff2f2; color: #d70015; border: 1px solid #ffd6d6; }
.alert-success { background: #f0fff4; color: #248a3d; border: 1px solid #c6f6d5; }

.upload-zone {
  position: relative;
  border: 2px dashed #d2d2d7;
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: #0071e3;
  background: #f0f7ff;
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-hint { color: #86868b; font-size: 15px; }
.upload-limit { margin-top: 6px; font-size: 13px; }
.upload-name { margin-top: 8px; font-weight: 600; font-size: 14px; word-break: break-all; }
.upload-status { margin-top: 12px; font-size: 14px; color: #86868b; min-height: 20px; }

.upload-zone.is-uploading {
  pointer-events: none;
  opacity: .65;
  border-color: #0071e3;
  background: #f0f7ff;
}

.upload-progress {
  margin-top: 16px;
}

.upload-progress-track {
  height: 8px;
  background: #e5e5ea;
  border-radius: 999px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #0071e3, #34aadc);
  border-radius: 999px;
  transition: width .15s ease;
}

.upload-progress-text {
  margin-top: 8px;
  font-size: 13px;
  color: #424245;
  text-align: center;
}

.upload-card .btn-primary { margin-top: 16px; }

.card-apps { padding: 20px; }

.ipa-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ipa-card {
  padding: 14px 16px;
  background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
  border: 1px solid #ececef;
  border-radius: 14px;
  transition: border-color .2s, box-shadow .2s;
}

.ipa-card:hover {
  border-color: #d8d8de;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .06);
}

.card-apps .panel-app-row {
  padding: 0;
  background: #fff;
  overflow: hidden;
  border: 1px solid #0071e3;
  box-shadow: 0 2px 10px rgba(0, 113, 227, 0.08);
}

.card-apps .panel-app-row:hover {
  border-color: #0077ed;
  box-shadow: 0 4px 16px rgba(0, 113, 227, 0.14);
}

.panel-app-card-head {
  padding: 14px 16px 12px;
}

.panel-app-card-foot {
  background: linear-gradient(180deg, #f7f8fc 0%, #f1f3f8 100%);
  border-top: 1px solid #e8eaf0;
  padding: 12px 16px 14px;
}

.panel-app-card-foot .ipa-link-row {
  margin-top: 0;
  margin-bottom: 10px;
}

.panel-app-card-foot .ipa-link {
  margin-top: 0;
  color: #d70015;
  font-weight: 500;
}

.card-apps .panel-app-toolbar {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.ipa-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ipa-identity {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ipa-seq {
  width: 18px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: #aeaeb2;
  flex-shrink: 0;
  user-select: none;
  line-height: 1;
}

.ipa-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  object-fit: cover;
  background: #f0f0f5;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
  flex-shrink: 0;
}

.ipa-info {
  flex: 1;
  min-width: 0;
}

.ipa-name {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
  word-break: break-all;
  color: #1d1d1f;
}

.ipa-meta {
  font-size: 12px;
  color: #86868b;
  margin-top: 3px;
  line-height: 1.4;
}

.ipa-link-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
}

.ipa-link-row .ipa-link {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}

.refresh-link-btn {
  flex-shrink: 0;
  margin-top: 0;
}

.ipa-link {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.45;
  color: #6e6e73;
  word-break: break-all;
  user-select: text;
}

.ipa-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #ececef;
}

.ipa-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ipa-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  background: #f5f5f7;
  font-size: 13px;
  font-weight: 600;
  color: #1d1d1f;
  user-select: none;
}

.ipa-chip em {
  font-style: normal;
  font-size: 11px;
  font-weight: 500;
  color: #86868b;
}

.ipa-chip.chip-on { background: #edf8f0; color: #248a3d; }
.ipa-chip.chip-on em { color: #5dab6e; }
.ipa-chip.chip-off { background: #fff2f2; color: #d70015; }
.ipa-chip.chip-off em { color: #e06c6c; }

.ipa-toolbar-btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.ipa-toolbar-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.admin-app-toolbar {
  align-items: flex-end;
}

.ipa-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 68px;
}

.ipa-field-label {
  font-size: 11px;
  color: #86868b;
  line-height: 1;
}

.quota-input,
.status-select,
.add-quota-input,
.expires-days-input,
.cert-type-select {
  padding: 6px 8px;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  color: #1d1d1f;
  outline: none;
  min-width: 68px;
}

.quota-input { width: 68px; }
.add-quota-input { width: 56px; }
.expires-days-input { width: 72px; }
.cert-type-select { width: 108px; min-width: 108px; }

.ipa-field-expires {
  min-width: 72px;
}

.ipa-field-cert-type {
  min-width: 108px;
}

.ipa-field-hint {
  align-self: flex-end;
  font-size: 11px;
  color: #86868b;
  padding-bottom: 8px;
  white-space: nowrap;
}

.quota-input:focus,
.status-select:focus,
.add-quota-input:focus,
.expires-days-input:focus,
.cert-type-select:focus {
  border-color: #0071e3;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, .1);
}

.ipa-field.is-saving .ipa-field-label { color: #0071e3; }
.ipa-field.is-saved .ipa-field-label { color: #248a3d; }
.ipa-field.is-error .ipa-field-label { color: #d70015; }

.ipa-stat {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  min-width: 56px;
  user-select: none;
  pointer-events: none;
  cursor: default;
}

.ipa-stat-label {
  font-size: 11px;
  color: #86868b;
  line-height: 1;
}

.ipa-stat-value {
  font-size: 13px;
  font-weight: 600;
  color: #1d1d1f;
  line-height: 1.2;
}

.ipa-stat-value.stat-on { color: #248a3d; }
.ipa-stat-value.stat-off { color: #d70015; }

.empty { color: #86868b; padding: 20px 0; text-align: center; }

.copy-btn.copied { background: #248a3d; color: #fff; border-color: #248a3d; }

.btn-danger {
  background: transparent;
  border: 1px solid #ff3b30;
  color: #ff3b30;
}

.btn-danger:hover { background: #fff2f2; }
.btn-danger:disabled { opacity: .55; cursor: not-allowed; }

.ipa-card.removing,
.ipa-row.removing {
  opacity: .45;
  pointer-events: none;
}

@media (max-width: 640px) {
  .ipa-toolbar-btns {
    width: 100%;
    margin-left: 0;
  }

  .ipa-toolbar-btns .btn {
    flex: 1;
    min-width: 0;
  }
}

.update-app-meta {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f5f5f7;
  font-size: 13px;
  line-height: 1.7;
  color: #1d1d1f;
}

.update-app-meta strong {
  color: #86868b;
  font-weight: 600;
  margin-right: 4px;
}

.update-modal .upload-zone {
  margin-top: 0;
}

.records-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.records-modal[hidden] {
  display: none;
}

.records-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
}

.records-modal-box {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.records-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #ececef;
}

.records-modal-head h3 {
  font-size: 17px;
  font-weight: 600;
}

.records-modal-close {
  border: none;
  background: none;
  font-size: 24px;
  line-height: 1;
  color: #86868b;
  cursor: pointer;
  padding: 0 4px;
}

.records-modal-body {
  padding: 12px 16px 16px;
  overflow: auto;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.records-table th,
.records-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #f0f0f5;
  vertical-align: top;
}

.records-table th {
  font-size: 12px;
  color: #86868b;
  font-weight: 600;
  white-space: nowrap;
}

.records-table td.records-udid {
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #424245;
}

.records-table tbody tr:last-child td {
  border-bottom: none;
}
