:root {
  --a-bg: #FAF7F4;
  --a-bg-deep: #F0EBE5;
  --a-surface: rgba(255, 255, 255, 0.94);
  --a-surface-strong: #ffffff;
  --a-surface-soft: #FBF8F5;
  --a-accent: #C94400;
  --a-accent-dark: #A83800;
  --a-accent-soft: rgba(201, 68, 0, 0.08);
  --a-gold: #8B5E34;
  --a-gold-soft: rgba(139, 94, 52, 0.08);
  --a-text: #1A1209;
  --a-text-2: #3D2E1F;
  --a-text-3: #7A6152;
  --a-text-4: #AFA09A;
  --a-border: rgba(60, 30, 10, 0.09);
  --a-border-strong: rgba(60, 30, 10, 0.16);
  --a-shadow-lg: 0 18px 42px rgba(80, 40, 10, 0.1);
  --a-shadow-md: 0 10px 24px rgba(80, 40, 10, 0.07);
  --a-shadow-sm: 0 4px 12px rgba(80, 40, 10, 0.05);
  --a-r-sm: 8px;
  --a-r: 12px;
  --a-r-lg: 16px;
  --a-font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
}

html {
  height: 100%;
}

body {
  min-height: 100%;
  font-family: var(--a-font);
  font-size: 14px;
  color: var(--a-text);
  background: var(--a-bg);
  -webkit-font-smoothing: antialiased;
}

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

.hidden {
  display: none !important;
}

/* ── LOGIN ─────────────────────────────────── */

.a-login-screen {
  min-height: 100vh;
  padding: 24px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #FDF9F5 0%, #F5EDE3 100%);
}

.a-login-shell {
  width: 100%;
  max-width: 420px;
}

.a-login-brand {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--a-text-3);
}

.a-login-panel {
  margin-top: 12px;
  padding: 36px;
  border-radius: var(--a-r-lg);
  border: 1px solid var(--a-border);
  background: var(--a-surface-strong);
  box-shadow: var(--a-shadow-lg);
}

.a-login-header {
  margin-bottom: 28px;
  display: grid;
  gap: 8px;
}

.a-ll-title {
  font-size: 26px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--a-text);
}

.a-login-form-area {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.a-lr-form {
  display: grid;
  gap: 16px;
}

.a-field {
  display: grid;
  gap: 8px;
}

.a-field-label,
.a-label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--a-text-3);
  font-weight: 500;
}

.a-label-gap {
  margin-top: 6px;
}

.a-input,
.a-input-sm,
.a-textarea {
  width: 100%;
  border-radius: var(--a-r);
  border: 1px solid var(--a-border);
  background: var(--a-surface-strong);
  color: var(--a-text);
  transition: border-color 0.18s, box-shadow 0.18s;
}

.a-input,
.a-input-sm {
  min-height: 48px;
  padding: 0 16px;
}

.a-input-sm {
  min-height: 42px;
}

.a-textarea {
  min-height: 80px;
  padding: 10px 14px;
  resize: vertical;
}

.a-input:focus,
.a-input-sm:focus,
.a-textarea:focus {
  outline: none;
  border-color: rgba(201, 68, 0, 0.35);
  box-shadow: 0 0 0 3px rgba(201, 68, 0, 0.09);
}

select.a-input {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d7b6d' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

.a-btn-login,
.a-btn-primary,
.a-btn-upload {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: var(--a-r);
  color: #fff;
  background: var(--a-accent);
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: background 0.18s, transform 0.18s, opacity 0.18s;
}

.a-btn-login:hover,
.a-btn-primary:hover,
.a-btn-upload:hover {
  background: var(--a-accent-dark);
  transform: translateY(-1px);
}

.a-btn-login:disabled,
.a-btn-primary:disabled,
.a-btn-upload:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.a-btn-primary {
  width: auto;
  min-width: 80px;
}

.a-message {
  min-height: 20px;
  margin-top: 14px;
  text-align: center;
  color: var(--a-accent-dark);
  font-size: 13px;
}

.a-message.is-error {
  color: #bf3f32;
}

.a-back-link-login {
  display: inline-flex;
  align-items: center;
  margin-top: 16px;
  color: var(--a-text-3);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.18s;
}

.a-back-link-login:hover {
  color: var(--a-accent-dark);
}

/* ── APP SHELL ─────────────────────────────── */

.a-app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 64px 48px minmax(0, 1fr);
}

.a-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: rgba(250, 247, 244, 0.92);
  border-bottom: 1px solid var(--a-border);
  backdrop-filter: blur(12px);
}

.a-topbar-left,
.a-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.a-top-mark {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--a-accent);
}

.a-top-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.a-top-brand {
  font-size: 17px;
  font-weight: 700;
  color: var(--a-text);
}

.a-top-section {
  font-size: 12px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--a-text-3);
}

.a-back-btn {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--a-r-sm);
  border: 1px solid var(--a-border);
  background: var(--a-surface-strong);
  color: var(--a-text-2);
  text-decoration: none;
  font-size: 13px;
  transition: background 0.18s, border-color 0.18s;
}

.a-back-btn:hover {
  background: var(--a-surface-soft);
  border-color: var(--a-border-strong);
}

.a-btn-out {
  width: 38px;
  height: 38px;
  border: 1px solid var(--a-border);
  border-radius: var(--a-r-sm);
  background: var(--a-surface-strong);
  color: var(--a-text-3);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}

.a-btn-out:hover {
  color: var(--a-accent-dark);
  border-color: rgba(201, 68, 0, 0.22);
  background: rgba(201, 68, 0, 0.05);
}

.a-btn-out svg {
  width: 17px;
  height: 17px;
}

.a-tabnav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 24px;
  border-bottom: 1px solid var(--a-border);
  background: rgba(250, 247, 244, 0.7);
}

.admin-tab {
  min-height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--a-text-3);
  font-size: 14px;
  cursor: pointer;
  transition: color 0.18s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.admin-tab:hover {
  color: var(--a-text);
}

.admin-tab.active {
  color: var(--a-text);
  font-weight: 600;
  border-bottom-color: var(--a-accent);
}

/* ── PANEL ─────────────────────────────────── */

.a-panel {
  min-height: 0;
  padding: 18px 20px 20px;
}

.a-pkg-layout {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
}

.a-sidebar,
.a-preview,
.a-table-layout,
.a-dialog {
  border-radius: var(--a-r-lg);
  background: var(--a-surface-strong);
  border: 1px solid var(--a-border);
  box-shadow: var(--a-shadow-sm);
}

.a-sidebar {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.a-sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.a-sidebar-top {
  padding: 14px 14px 12px;
  display: grid;
  gap: 10px;
  border-bottom: 1px solid var(--a-border);
  flex-shrink: 0;
}

.a-search-box {
  position: relative;
}

.a-search-ico {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--a-text-4);
  pointer-events: none;
}

.a-search-ico svg {
  width: 16px;
  height: 16px;
}

.a-search {
  width: 100%;
  min-height: 42px;
  padding: 0 14px 0 42px;
  border-radius: var(--a-r-sm);
  border: 1px solid var(--a-border);
  background: var(--a-surface-soft);
  color: var(--a-text);
  transition: border-color 0.18s, box-shadow 0.18s;
}

.a-search:focus {
  outline: none;
  border-color: rgba(139, 94, 52, 0.3);
  box-shadow: 0 0 0 3px rgba(139, 94, 52, 0.1);
}

.a-sidebar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.a-count {
  font-size: 12px;
  color: var(--a-text-3);
  padding: 0 4px;
}

.a-icon-btn,
.ghost-btn,
.a-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--a-r-sm);
  border: 1px solid var(--a-border);
  background: var(--a-surface-strong);
  color: var(--a-text-2);
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}

.a-icon-btn {
  width: 36px;
  padding: 0;
}

.a-icon-btn svg {
  width: 15px;
  height: 15px;
}

.ghost-btn:hover,
.a-icon-btn:hover,
.a-link-btn:hover {
  border-color: var(--a-border-strong);
  background: var(--a-surface-soft);
}

.ghost-btn.compact {
  min-height: 34px;
}

.a-link-btn.accent {
  color: #fff;
  border: 0;
  background: var(--a-accent);
}

.a-link-btn.accent:hover {
  background: var(--a-accent-dark);
  border: 0;
}

/* ── PAGE LIST ─────────────────────────────── */

.a-list {
  list-style: none;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.page-item {
  padding: 12px 14px;
  border-radius: var(--a-r);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.page-item:hover {
  background: var(--a-surface-soft);
  border-color: var(--a-border);
}

.page-item.active {
  background: #FFF5ED;
  border-color: rgba(201, 68, 0, 0.22);
}

.page-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.page-title-wrap {
  min-width: 0;
  flex: 1;
}

.page-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--a-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-path {
  margin-top: 4px;
  font-size: 12px;
  color: var(--a-text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scope-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(201, 68, 0, 0.09);
  color: var(--a-accent-dark);
  white-space: nowrap;
  flex-shrink: 0;
}

.page-meta-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.page-owner {
  font-size: 12px;
  color: var(--a-text-4);
}

/* ── INLINE ACTIONS ────────────────────────── */

.page-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.page-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--a-text-4);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.page-action-btn:hover {
  color: var(--a-accent);
  background: var(--a-accent-soft);
  border-color: rgba(201, 68, 0, 0.15);
}

.page-action-btn svg {
  width: 13px;
  height: 13px;
}

.page-action-btn--danger:hover {
  color: #c0392b;
  background: rgba(192, 57, 43, 0.08);
  border-color: rgba(192, 57, 43, 0.2);
}

/* ── SIDEBAR BOTTOM ────────────────────────── */

.a-sidebar-bottom {
  padding: 0 10px 10px;
  border-top: 1px solid var(--a-border);
  flex-shrink: 0;
}

.a-collapse {
  border: 0;
}

.a-collapse-trigger {
  display: flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
  color: var(--a-text-2);
  font-size: 13px;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.a-collapse-trigger::-webkit-details-marker {
  display: none;
}

.a-collapse-trigger::before {
  content: "›";
  margin-right: 8px;
  font-size: 17px;
  transition: transform 0.18s;
}

details[open] > .a-collapse-trigger::before {
  transform: rotate(90deg);
}

.a-collapse-body {
  display: grid;
  gap: 8px;
  padding-bottom: 6px;
}

.a-upload-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.a-progress {
  height: 3px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(139, 94, 52, 0.12);
}

.a-progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--a-accent), var(--a-gold));
  transition: width 0.25s;
}

.a-upload-msg,
.a-hint,
.empty-hint {
  font-size: 12px;
  line-height: 1.7;
  color: var(--a-text-3);
}

.a-upload-msg.is-error {
  color: #bf3f32;
}

.a-xlsx-panel {
  display: grid;
  gap: 12px;
  max-width: 520px;
  padding: 20px;
}

/* ── PREVIEW ───────────────────────────────── */

.a-preview {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.a-preview-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--a-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.a-preview-info {
  min-width: 0;
}

.a-preview-title {
  font-size: 20px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--a-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.a-preview-path {
  margin-top: 4px;
  font-size: 12px;
  color: var(--a-text-3);
}

.a-preview-meta {
  margin-top: 3px;
  font-size: 12px;
  color: var(--a-text-4);
}

.a-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: start;
  flex-shrink: 0;
}

.a-preview-wrap {
  position: relative;
  min-height: 0;
  background: #F7F2ED;
}

.a-preview-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.a-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--a-text-4);
  font-size: 13px;
}

/* ── TABLES ────────────────────────────────── */

.a-table-layout {
  padding: 22px;
}

.a-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.a-table-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--a-text);
}

.a-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: var(--a-r);
  border: 1px solid var(--a-border);
}

.a-table th,
.a-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--a-border);
  text-align: left;
  vertical-align: middle;
}

.a-table th {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--a-text-3);
  font-weight: 600;
  background: var(--a-surface-soft);
}

.a-table tr:last-child td {
  border-bottom: 0;
}

.a-entity-cell {
  display: grid;
  gap: 3px;
}

.a-entity-main {
  font-weight: 600;
  color: var(--a-text);
}

.a-entity-sub {
  font-size: 12px;
  color: var(--a-text-4);
}

.role-badge,
.group-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
}

.role-badge {
  background: rgba(201, 68, 0, 0.09);
  color: var(--a-accent-dark);
}

.role-badge.is-user {
  background: var(--a-gold-soft);
  color: var(--a-text-2);
}

.group-badge {
  margin: 2px 4px 2px 0;
  background: var(--a-gold-soft);
  color: var(--a-text-2);
}

.a-empty-inline {
  font-size: 12px;
  color: var(--a-text-4);
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.danger-btn {
  color: #fff;
  border-color: transparent;
  background: #C0392B;
}

.danger-btn:hover {
  border-color: transparent;
  background: #A93224;
}

/* ── DIALOGS ───────────────────────────────── */

.a-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(30, 15, 5, 0.38);
  backdrop-filter: blur(6px);
}

.a-dialog {
  width: min(480px, 100%);
  padding: 24px;
}

.a-dialog--wide {
  width: min(560px, 100%);
}

.a-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.a-dialog-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--a-text);
}

.a-dialog-x {
  width: 32px;
  height: 32px;
  border: 1px solid var(--a-border);
  border-radius: var(--a-r-sm);
  background: transparent;
  color: var(--a-text-3);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.a-dialog-x:hover {
  color: var(--a-text);
  background: var(--a-surface-soft);
}

.a-dialog-x svg {
  width: 15px;
  height: 15px;
}

.a-dialog-section {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--a-border);
}

.a-dialog-form {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.a-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.a-checkbox-group {
  max-height: 160px;
  padding: 10px 12px;
  display: grid;
  gap: 8px;
  overflow-y: auto;
  border-radius: var(--a-r-sm);
  background: var(--a-surface-soft);
  border: 1px solid var(--a-border);
  font-size: 13px;
}

.a-checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* ── RESPONSIVE ────────────────────────────── */

@media (max-width: 1100px) {
  .a-pkg-layout {
    grid-template-columns: 300px minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .a-pkg-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(400px, 1fr);
  }

  .a-sidebar {
    max-height: 380px;
  }
}

@media (max-width: 760px) {
  .a-login-screen,
  .a-panel {
    padding: 12px;
  }

  .a-login-panel {
    padding: 24px;
  }

  .a-topbar {
    padding: 0 14px;
  }

  .a-tabnav {
    padding: 0 14px;
    overflow-x: auto;
  }

  .a-preview-head,
  .a-table-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .a-upload-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .a-ll-title,
  .a-table-header h2,
  .a-preview-title {
    font-size: 20px;
  }

  .a-back-btn {
    display: none;
  }

  .a-topbar {
    min-height: 60px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
