/* === 深色現代風（跟用戶端 App 同調性）=== */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "Microsoft JhengHei", BlinkMacSystemFont,
                "PingFang TC", "Segoe UI", sans-serif;
  background: #0F0F10;
  color: #E8E8EA;
  min-height: 100vh;
  padding: 24px;
}

.hidden { display: none !important; }
.muted { color: #6E7681; font-size: 13px; }
.err { color: #FF6B6B; font-size: 13px; margin-top: 8px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace; }

button {
  background: #1F2233;
  color: #E8E8EA;
  border: 1px solid #2A2E47;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}
button:hover { background: #2A2E47; }
button.primary {
  background: #4A8FE7;
  color: #fff;
  border-color: #4A8FE7;
}
button.primary:hover { background: #5B9FF7; }
button.danger {
  background: transparent;
  color: #FF6B6B;
  border-color: #FF6B6B;
}
button.danger:hover { background: rgba(255,107,107,0.1); }
button.small {
  padding: 4px 10px;
  font-size: 12px;
}

input, select, textarea {
  width: 100%;
  background: #15171F;
  color: #E8E8EA;
  border: 1px solid #2A2E47;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 12px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #4A8FE7;
}
textarea { resize: vertical; }
label {
  display: block;
  font-size: 12px;
  color: #8B92AE;
  margin-bottom: 4px;
}

/* === 登入畫面 === */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}
.login-box {
  background: #15171F;
  border-radius: 16px;
  padding: 32px;
  width: 360px;
}
.login-box h1 {
  font-size: 20px;
  margin-bottom: 8px;
}
.login-box p {
  margin-bottom: 16px;
}
.login-box button {
  width: 100%;
  margin-top: 8px;
  background: #4A8FE7;
  border-color: #4A8FE7;
  color: #fff;
}

/* === 主畫面 === */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #2A2E47;
}
header h1 { font-size: 20px; }
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* === 統計卡 === */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: #15171F;
  border-radius: 12px;
  padding: 16px 18px;
}
.stat-label {
  font-size: 12px;
  color: #8B92AE;
  margin-bottom: 8px;
}
.stat-num {
  font-size: 28px;
  font-weight: 600;
  color: #E8E8EA;
}
.stat-num.green { color: #4ADE80; }
.stat-num.blue { color: #6FA6E7; }
.stat-num.red { color: #FF8B8B; }

/* === 動作列 === */
.actions {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.search-input {
  width: 320px;
  margin-bottom: 0;
  background: #1A1D2A;
}

/* === 表格 === */
.table-wrap {
  background: #15171F;
  border-radius: 12px;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead th {
  text-align: left;
  padding: 12px 14px;
  background: #1A1D2A;
  color: #8B92AE;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #2A2E47;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #1F2233;
}
tbody tr:hover { background: #1A1D2A; }
tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}
.badge.active { background: rgba(74,222,128,0.15); color: #4ADE80; }
.badge.unused { background: rgba(143,156,184,0.15); color: #8B92AE; }
.badge.disabled { background: rgba(255,139,139,0.15); color: #FF8B8B; }
.badge.expired { background: rgba(255,180,80,0.15); color: #FFB450; }

.online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4A4F5F;
  margin-right: 6px;
  vertical-align: middle;
}
.online-dot.on { background: #4ADE80; box-shadow: 0 0 6px #4ADE80; }

.serial-cell {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
  font-size: 12px;
  color: #B5BCD5;
}

select.quick-extend {
  width: auto;
  min-width: 130px;
  margin-bottom: 0;
  font-size: 11px;
  padding: 5px 8px;
  background: #1A1D2A;
  border-color: #2A2E47;
  cursor: pointer;
}
select.quick-extend:hover {
  border-color: #4A8FE7;
}

/* 授權/到期欄：左邊日期 + 右邊快速更改 */
.auth-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.auth-info {
  flex: 1;
  min-width: 0;
}
.auth-action {
  flex-shrink: 0;
}

/* 置頂按鈕 */
.pin-btn {
  background: transparent;
  border: none;
  padding: 2px 4px;
  font-size: 14px;
  opacity: 0.25;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  filter: grayscale(100%);
}
.pin-btn:hover {
  opacity: 0.7;
  background: transparent;
}
.pin-btn.pinned {
  opacity: 1;
  filter: none;
  transform: rotate(-15deg);
}

/* 置頂的整列高亮 */
tbody tr.pinned-row {
  background: rgba(74,143,231,0.05);
}
tbody tr.pinned-row:hover {
  background: rgba(74,143,231,0.10);
}

/* === Modal === */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-box {
  background: #15171F;
  border-radius: 16px;
  padding: 24px;
  width: 480px;
  max-width: 90vw;
}
.modal-box h2 {
  font-size: 18px;
  margin-bottom: 16px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #15171F;
  border: 1px solid #4A8FE7;
  padding: 12px 18px;
  border-radius: 10px;
  z-index: 200;
}
.toast.err { border-color: #FF6B6B; }
