* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  background: #f3f5f8;
  color: #1f2937;
}

.hidden {
  display: none !important;
}

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.boot-card {
  width: min(100%, 420px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  padding: 28px 24px;
  text-align: center;
}

.boot-card h1 {
  margin: 0 0 12px;
  font-size: 32px;
}

.boot-card p {
  margin: 0;
  color: #64748b;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 460px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  padding: 24px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.app-shell.share-mode {
  grid-template-columns: minmax(0, 1fr);
}

.app-shell.share-mode .sidebar {
  display: none;
}

.app-shell.share-mode #create-share-button {
  display: none;
}

.sidebar {
  background: #0f172a;
  color: #e2e8f0;
  padding: 24px 16px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
}

.sidebar-header h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.sidebar-header p {
  margin: 0;
  color: #94a3b8;
  word-break: break-word;
}

.menu {
  display: grid;
  gap: 10px;
  align-content: start;
}

.menu-button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.menu-button.active {
  background: #2563eb;
  border-color: #2563eb;
}

.sidebar-actions {
  display: grid;
  gap: 10px;
}

.content {
  padding: 24px;
  display: grid;
  gap: 16px;
  position: relative;
  align-content: start;
}

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

.content-header h1 {
  margin: 0 0 8px;
}

.content-header p {
  margin: 0;
  color: #6b7280;
}

.content-section {
  display: none;
}

.content-section.active {
  display: block;
  align-self: start;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 16px 48px;
  display: grid;
  gap: 16px;
}

.card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  padding: 20px;
}

.card-header h1,
.card-header h2 {
  margin: 0 0 8px;
}

.card-header p {
  margin: 0;
  color: #6b7280;
}

.subsection {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.card > .subsection:first-child {
  margin-top: 0;
}

.apps-toolbar-section {
  margin-bottom: 18px;
}

.apps-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.apps-toolbar .info-panel {
  flex: 1;
}

.apps-toolbar-actions {
  flex-shrink: 0;
}

.share-toolbar {
  display: flex;
  justify-content: flex-start;
  align-items: end;
  gap: 16px;
}

.share-filter-field {
  max-width: 220px;
}

.share-expire-input {
  width: 100%;
  min-width: 180px;
}

.subsection-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.subsection-description {
  margin: 0;
  color: #6b7280;
}

.info-panel {
  border: 1px solid #dbeafe;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 12px;
  padding: 14px 16px;
}

.form {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.compact-form {
  margin-top: 0;
}

.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

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

.field span {
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  background: #fff;
}

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

button {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
}

button.secondary {
  background: #475569;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.panel {
  margin: 18px 0 0;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  overflow: auto;
  min-height: 140px;
  white-space: pre-wrap;
  word-break: break-word;
}

.compact-panel {
  margin-top: 0;
  min-height: 96px;
}

.manager-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.manager-grid-wide {
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
}

.tag-management-layout {
  align-items: start;
}

.tag-management-layout .manager-card {
  display: flex;
  flex-direction: column;
  align-self: start;
}

.tag-management-layout .list-panel {
  align-content: start;
}

.tag-management-layout #tag-types-view,
.tag-management-layout #tags-view {
  min-height: 320px;
  max-height: 320px;
  overflow: auto;
}

.template-binding-layout {
  align-items: start;
}

.template-binding-layout .manager-card {
  display: flex;
  flex-direction: column;
  align-self: start;
}

.batch-template-layout {
  align-items: start;
}

.batch-template-layout .manager-card {
  display: flex;
  flex-direction: column;
  align-self: start;
}

.manager-card {
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 16px;
  background: #f8fafc;
  display: grid;
  gap: 14px;
}

.manager-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

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

.template-list-panel {
  max-height: 420px;
  overflow: auto;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.template-binding-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.batch-template-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr) minmax(260px, 320px);
  gap: 12px;
  align-items: end;
  margin-top: 18px;
}

.batch-template-software-field,
.batch-template-search-field {
  margin: 0;
}

.list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #dbe2ea;
  border-radius: 12px;
  background: #fff;
}

.list-item.active {
  border-color: #2563eb;
  box-shadow: inset 0 0 0 1px #2563eb;
}

.list-item-main {
  border: none;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  display: grid;
  gap: 4px;
}

.list-item-main.static {
  cursor: default;
}

.list-item-title {
  font-weight: 700;
  color: #111827;
}

.list-item-meta {
  font-size: 13px;
  color: #6b7280;
}

.list-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ghost-button {
  background: #e2e8f0;
  color: #0f172a;
  padding: 8px 12px;
}

.danger-button {
  background: #fee2e2;
  color: #b91c1c;
}

.selected-template-card {
  border: 1px solid #dbe2ea;
  border-radius: 12px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.selected-template-title {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
}

.selected-template-meta {
  font-size: 13px;
  color: #6b7280;
}

.batch-template-actions {
  display: grid;
  grid-template-columns: minmax(140px, 180px) 1fr;
  gap: 12px;
  align-items: end;
}

.inline-field {
  margin: 0;
}

.batch-quantity-field {
  max-width: 180px;
}

.batch-result-actions {
  justify-content: flex-start;
}

.tag-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 600;
}

.muted-text {
  color: #6b7280;
  font-size: 13px;
}

.binding-groups {
  display: grid;
  gap: 14px;
}

.binding-group {
  border: 1px solid #dbe2ea;
  border-radius: 12px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.binding-group h4 {
  margin: 0;
  font-size: 15px;
}

.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  align-items: center;
}

.checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
  font-size: 14px;
  color: #1f2937;
}

.panels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.history-card {
  display: grid;
  gap: 12px;
}

.history-table-wrap {
  overflow: auto;
  border: 1px solid #dbe2ea;
  border-radius: 12px;
  background: #fff;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

.history-table th,
.history-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

.history-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

.history-table tbody tr {
  cursor: pointer;
}

.history-table tbody tr:hover {
  background: #f8fafc;
}

.history-table tbody tr.active {
  background: #eff6ff;
}

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

.history-empty {
  color: #6b7280;
}

.subheading {
  margin: 0 0 10px;
  font-size: 16px;
}

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

#business-message {
  margin-top: 0;
  position: fixed;
  top: 24px;
  right: 24px;
  max-width: min(280px, calc(100% - 48px));
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
  z-index: 30;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
}

#business-message.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.message.info {
  background: #dbeafe;
  color: #1d4ed8;
}

.message.success {
  background: #dcfce7;
  color: #15803d;
}

.message.error {
  background: #fee2e2;
  color: #b91c1c;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-rows: auto auto auto;
  }

  .content-header {
    flex-direction: column;
  }

  .subsection-header {
    flex-direction: column;
  }

  .apps-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .apps-toolbar-actions {
    width: 100%;
  }

  .manager-grid-wide {
    grid-template-columns: 1fr;
  }

  .batch-template-toolbar {
    grid-template-columns: 1fr;
  }

  .template-binding-toolbar {
    grid-template-columns: 1fr;
  }

  .batch-template-actions {
    grid-template-columns: 1fr;
  }

  .list-item {
    grid-template-columns: 1fr;
  }
}
