:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --line: #dfe5ea;
  --line-strong: #c8d2da;
  --text: #1d252d;
  --muted: #65717d;
  --faint: #8a96a3;
  --primary: #2f6f8f;
  --primary-dark: #21556f;
  --primary-soft: #e7f2f6;
  --danger: #b84b45;
  --danger-soft: #faeceb;
  --success: #2f7d56;
  --success-soft: #e9f5ee;
  --warning: #a96f1f;
  --warning-soft: #fff3df;
  --shadow: 0 18px 45px rgba(28, 42, 56, 0.12);
  font-family: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(47, 111, 143, 0.14), rgba(228, 237, 232, 0.35)),
    var(--bg);
}

.login-panel {
  width: min(100%, 440px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-mark,
.brand-mark {
  display: grid;
  place-items: center;
  border: 1px solid rgba(47, 111, 143, 0.34);
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.login-mark {
  width: 58px;
  height: 58px;
  margin-bottom: 22px;
  font-size: 20px;
}

.eyebrow,
.topbar p,
.modal-header p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-panel h1,
.topbar h1,
.modal-header h2,
.table-toolbar h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1 {
  margin-top: 8px;
  font-size: 28px;
  line-height: 1.2;
}

.login-copy {
  margin: 10px 0 26px;
  color: var(--muted);
  line-height: 1.7;
}

.login-form,
.filter-form,
.cert-form,
.import-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

label span,
legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 143, 0.14);
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  transition: transform 0.16s ease, border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease;
}

.button {
  gap: 7px;
  padding: 0 13px;
  font-size: 13px;
  white-space: nowrap;
}

.button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.row-actions button:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}

.button-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  color: #fff;
}

.button-danger {
  border-color: rgba(184, 75, 69, 0.35);
  color: var(--danger);
}

.button-danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: rgba(184, 75, 69, 0.6);
}

.button-wide {
  width: 100%;
}

.icon {
  width: 18px;
  min-width: 18px;
  text-align: center;
  font-size: 16px;
  line-height: 1;
}

.inline-error,
.inline-success {
  margin: 0;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
}

.inline-error {
  border: 1px solid rgba(184, 75, 69, 0.22);
  background: var(--danger-soft);
  color: var(--danger);
}

.inline-success {
  border: 1px solid rgba(47, 125, 86, 0.22);
  background: var(--success-soft);
  color: var(--success);
}

.admin-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #17222c;
  color: #eaf1f6;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 800;
}

.brand-mark {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 13px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 22px;
}

.nav a {
  padding: 11px 12px;
  border-radius: 6px;
  color: rgba(234, 241, 246, 0.72);
  font-size: 14px;
  font-weight: 700;
}

.nav a:hover,
.nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar-meta {
  margin-top: auto;
  padding: 14px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-meta span {
  display: block;
  color: rgba(234, 241, 246, 0.6);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.sidebar-meta strong {
  display: block;
  margin-top: 6px;
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

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

.topbar h1 {
  margin-top: 5px;
  font-size: 28px;
  line-height: 1.2;
}

.topbar-actions,
.toolbar-actions,
.filter-actions,
.pagination div,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.summary article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  line-height: 1;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(28, 42, 56, 0.04);
}

.filter-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px auto;
  align-items: end;
  gap: 14px;
  padding: 16px;
}

.table-panel {
  position: relative;
  margin-top: 16px;
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.table-toolbar h2 {
  font-size: 18px;
}

.table-toolbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1060px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

td {
  color: #34414d;
}

.checkbox-cell {
  width: 44px;
  text-align: center;
}

.checkbox-cell input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
}

.cert-no {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-enabled {
  background: var(--success-soft);
  color: var(--success);
}

.status-disabled {
  background: var(--warning-soft);
  color: var(--warning);
}

.row-actions {
  min-width: 168px;
}

.row-actions button {
  min-height: 28px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.row-actions button:last-child {
  color: var(--danger);
}

.empty,
.loading {
  margin: 18px;
  padding: 30px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: center;
}

.empty strong {
  display: block;
  font-size: 16px;
}

.empty p,
.loading {
  color: var(--muted);
}

.empty p {
  margin: 6px 0 0;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  color: var(--muted);
  font-size: 13px;
}

.pagination select {
  width: 108px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 24, 32, 0.46);
}

.modal-panel {
  width: min(100%, 620px);
  max-height: min(92vh, 900px);
  overflow: auto;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-panel-form {
  width: min(100%, 980px);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.modal-header h2 {
  margin-top: 4px;
  font-size: 20px;
}

.icon-button {
  width: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.cert-form {
  gap: 0;
}

.form-section {
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.form-section h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

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

.form-title-row h3 {
  margin: 0;
}

.tabs {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.tabs button {
  min-width: 48px;
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tabs button.active {
  background: var(--primary);
  color: #fff;
}

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

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

fieldset {
  min-width: 0;
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

fieldset:last-child {
  margin-bottom: 0;
}

legend {
  padding: 0 6px;
}

.form-hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.modal-footer {
  position: sticky;
  bottom: 0;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.import-form {
  padding: 20px;
}

.upload-zone {
  width: 100%;
  min-height: 150px;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
}

.upload-zone strong {
  color: var(--text);
  font-size: 16px;
}

.upload-zone span:last-child {
  max-width: 430px;
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: 7px;
  background: #17222c;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 14px;
}

@media (max-width: 1060px) {
  .admin-page {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    display: block;
    padding: 16px;
  }

  .sidebar-brand {
    border-bottom: 0;
    padding-bottom: 12px;
  }

  .nav {
    flex-direction: row;
    padding-top: 8px;
  }

  .sidebar-meta {
    margin-top: 12px;
  }
}

@media (max-width: 780px) {
  .workspace {
    padding: 18px;
  }

  .topbar,
  .table-toolbar,
  .pagination,
  .form-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .summary,
  .filter-form,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .filter-actions,
  .topbar-actions,
  .toolbar-actions,
  .pagination div {
    flex-wrap: wrap;
  }

  .modal {
    padding: 12px;
  }

  .modal-header,
  .modal-footer,
  .form-section,
  .import-form {
    padding: 16px;
  }
}
