* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1100px;
  background: #f5f7fb;
  color: #172033;
  font-family: "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  height: 36px;
  padding: 0 14px;
  border: 1px solid #d8dee9;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

input,
select {
  height: 36px;
  min-width: 160px;
  padding: 0 10px;
  border: 1px solid #d8dee9;
  border-radius: 6px;
  background: #fff;
}

.primary {
  border-color: #1d6fff;
  background: #1d6fff;
  color: #fff;
}

.primary.blue {
  background: #1677ff;
}

.danger {
  border-color: #ff6b6b;
  color: #ff3b3b;
}

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

.login-card {
  width: 380px;
  padding: 32px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(20, 30, 55, 0.12);
}

.login-card h1 {
  margin: 0 0 8px;
}

.login-card p {
  margin: 0 0 22px;
  color: #77839a;
}

.login-card label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.login-card input,
.login-card button {
  width: 100%;
}

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

.sidebar {
  padding: 24px 16px;
  background: #121826;
  color: #d9e2f2;
}

.brand {
  margin-bottom: 26px;
  font-size: 20px;
  font-weight: 700;
}

.sidebar a,
.logout-form button {
  display: flex;
  align-items: center;
  width: 100%;
  height: 42px;
  margin-bottom: 8px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #aeb8cc;
  text-decoration: none;
}

.sidebar a.active {
  background: #1f6fff;
  color: #fff;
}

.logout-form {
  margin-top: 30px;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0 0 6px;
}

.topbar p {
  margin: 0;
  color: #77839a;
}

.card {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid #e7ebf2;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(25, 35, 55, 0.05);
}

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

.inline-form,
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.inline-form label {
  display: grid;
  gap: 6px;
  color: #66728a;
  font-size: 13px;
}

.filters {
  margin-bottom: 16px;
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  color: #66728a;
  font-size: 14px;
}

.select-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.select-all input,
.select-col input {
  width: 16px;
  min-width: 16px;
  height: 16px;
  padding: 0;
}

.table-wrap {
  overflow-x: visible;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 8px;
  border-bottom: 1px solid #edf0f5;
  text-align: left;
  vertical-align: top;
  white-space: normal;
}

th {
  color: #344057;
  font-weight: 700;
}

code {
  font-family: Consolas, monospace;
  color: #1d2c48;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 700;
}

.badge.unused {
  background: #ffe8e8;
  color: #e33d3d;
}

.badge.active {
  background: #e7f8df;
  color: #36a420;
}

.badge.disabled,
.badge.expired {
  background: #eef1f5;
  color: #697386;
}

.actions {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px;
  width: 230px;
  white-space: normal;
}

.actions form {
  display: inline;
}

.actions button,
.actions summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 32px;
  padding: 0;
  line-height: 1;
}

.select-col {
  width: 36px;
}

.code-col {
  width: 230px;
}

.remark-col {
  width: 100px;
  overflow-wrap: anywhere;
}

th:nth-child(2),
td:nth-child(2) {
  width: 48px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 78px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 82px;
}

th:nth-child(6),
td:nth-child(6),
th:nth-child(7),
td:nth-child(7) {
  width: 140px;
}

th:nth-child(10),
td:nth-child(10) {
  width: 240px;
}

details {
  position: relative;
}

summary {
  border: 1px solid #d8dee9;
  border-radius: 6px;
  background: #fff;
  list-style: none;
  cursor: pointer;
}

.edit-form {
  position: absolute;
  z-index: 10;
  right: 0;
  display: grid !important;
  gap: 8px;
  width: 280px;
  margin-top: 8px;
  padding: 14px;
  border: 1px solid #d8dee9;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(20, 30, 55, 0.16);
}

.edit-form label {
  display: grid;
  gap: 5px;
  color: #66728a;
  font-size: 13px;
}

.edit-form input,
.edit-form select,
.edit-form button {
  width: 100%;
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 6px;
  background: #e9f4ff;
  color: #13589d;
}

.alert.error {
  background: #ffecec;
  color: #d93030;
}

.empty {
  padding: 42px;
  color: #8893a8;
  text-align: center;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.pagination a {
  min-width: 34px;
  padding: 7px 10px;
  border: 1px solid #d8dee9;
  border-radius: 6px;
  color: #344057;
  text-align: center;
  text-decoration: none;
}

.pagination a.active {
  border-color: #1d6fff;
  background: #1d6fff;
  color: #fff;
}

.pagination a.disabled {
  pointer-events: none;
  opacity: 0.45;
}

/* Compact license table */
.table-wrap {
  overflow: hidden;
}

table {
  table-layout: fixed;
  font-size: 13px;
}

.col-select {
  width: 34px;
}

.col-id {
  width: 44px;
}

.col-code {
  width: 180px;
}

.col-duration {
  width: 66px;
}

.col-status {
  width: 72px;
}

.col-time {
  width: 132px;
}

.col-remark {
  width: 80px;
}

.col-actions {
  width: 142px;
}

th,
td {
  height: 46px;
  padding: 8px 7px;
  overflow: hidden;
  vertical-align: middle;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  font-size: 13px;
}

code {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  min-height: 22px;
  padding: 0 7px;
  font-size: 12px;
}

.actions {
  display: table-cell !important;
  width: auto;
  max-width: none;
  white-space: nowrap;
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(2, 42px);
  gap: 5px;
  align-items: center;
  justify-content: start;
}

.action-buttons form,
.action-buttons details {
  display: block;
  margin: 0;
}

.action-buttons button,
.action-buttons summary {
  width: 42px;
  height: 28px;
  padding: 0;
  border-radius: 5px;
  font-size: 12px;
  line-height: 28px;
  text-align: center;
  white-space: nowrap;
}

.edit-form {
  right: auto;
  left: -170px;
}

.remark-cell {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.remark-cell span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.remark-editor {
  position: relative;
  flex: 0 0 auto;
}

.remark-editor summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #d8dee9;
  border-radius: 5px;
  color: #1d6fff;
  line-height: 1;
}

.remark-form {
  position: absolute;
  z-index: 20;
  right: 0;
  display: grid;
  grid-template-columns: 180px 48px;
  gap: 8px;
  width: 244px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid #d8dee9;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(20, 30, 55, 0.14);
}

.remark-form input {
  min-width: 0;
  width: 100%;
  height: 32px;
}

.remark-form button {
  width: 48px;
  height: 32px;
  padding: 0;
}

.table-toolbar {
  min-height: 34px;
  margin-bottom: 8px;
  font-size: 13px;
}

.select-all input,
.select-col input {
  width: 15px;
  min-width: 15px;
  height: 15px;
}

.pagination {
  margin-top: 12px;
}

.pagination a {
  min-width: 30px;
  padding: 5px 9px;
  font-size: 13px;
}

th:nth-child(n),
td:nth-child(n) {
  width: auto;
}

/* Final license list layout */
.table-wrap {
  overflow: visible;
}

table {
  width: 100%;
  table-layout: fixed;
  font-size: 13px;
}

.col-select {
  width: 34px;
}

.col-id {
  width: 44px;
}

.col-code {
  width: 320px;
}

.col-duration {
  width: 64px;
}

.col-status {
  width: 72px;
}

.col-time {
  width: 136px;
}

.col-remark {
  width: 150px;
}

.col-actions {
  width: 112px;
}

.col-detail {
  width: 68px;
}

th,
td {
  height: 48px;
  padding: 8px 8px;
  overflow: hidden;
  vertical-align: middle;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.actions,
td.remark-col {
  overflow: visible;
}

.code-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.code-cell code {
  flex: 1;
  min-width: 0;
  overflow: visible;
  color: #172033;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}

.copy-button,
.detail-button {
  height: 28px;
  padding: 0 9px;
  border-color: #cfe0ff;
  color: #1d6fff;
  font-size: 12px;
  white-space: nowrap;
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(2, 48px);
  gap: 6px;
  align-items: center;
  justify-content: start;
}

.action-buttons button,
.action-buttons summary {
  width: 48px;
  height: 28px;
  padding: 0;
  border-radius: 5px;
  font-size: 12px;
  line-height: 28px;
}

.remark-cell {
  max-width: 100%;
}

.remark-cell span {
  flex: 1;
}

.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.38);
}

.detail-modal.hidden {
  display: none;
}

.detail-card {
  width: min(680px, 92vw);
  max-height: 82vh;
  overflow: auto;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(20, 30, 55, 0.22);
}

.detail-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #edf0f5;
}

.detail-card-header button {
  height: 30px;
}

.detail-list {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 0;
  margin: 0;
  padding: 8px 18px 18px;
}

.detail-list dt,
.detail-list dd {
  min-height: 42px;
  margin: 0;
  padding: 11px 0;
  border-bottom: 1px solid #edf0f5;
  line-height: 1.55;
}

.detail-list dt {
  color: #66728a;
}

.detail-list dd {
  overflow-wrap: anywhere;
  color: #172033;
}

td.remark-col {
  display: table-cell !important;
  vertical-align: middle;
}

.remark-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.remark-cell span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
