:root {
  --bg: #eef3f8;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #dbe3ef;
  --blue: #1d4ed8;
  --blue-soft: #eff6ff;
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;
  --nav: #172233;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Microsoft YaHei UI", "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: inherit; text-decoration: none; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 54px;
  display: grid;
  grid-template-columns: auto auto minmax(420px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 7px 14px;
  background: linear-gradient(90deg, #111827 0%, #1e3a5f 52%, #155e75 100%);
  color: white;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .18);
}
.logo { display: inline-flex; align-items: center; gap: 9px; min-width: 226px; }
.logo-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #38bdf8, #22c55e);
  color: #06223a;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 8px 20px rgba(34,197,94,.28);
}
.logo strong { display: block; letter-spacing: 0; font-size: 17px; line-height: 17px; white-space: nowrap; }
.logo small { display: block; color: #c7d2fe; font-size: 11px; margin-top: 2px; }
.top-nav { display: flex; align-items: center; gap: 6px; }
.top-nav a {
  color: #dbeafe;
  padding: 7px 11px;
  border-radius: 7px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.top-nav a.active, .top-nav a:hover, .top-nav a.verified {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.16);
  color: white;
}
.top-nav a.verified { color: #bbf7d0; }
.header-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.header-search { display: grid; grid-template-columns: minmax(180px, 330px) auto; gap: 7px; min-width: 0; }
.header-search input {
  height: 34px;
  color: #0f172a;
  border-color: rgba(255,255,255,.34);
  box-shadow: 0 1px 0 rgba(255,255,255,.08);
}
.userbar { display: flex; align-items: center; gap: 12px; color: #dbeafe; font-size: 13px; }
.userbar a { color: white; background: rgba(255,255,255,.12); padding: 7px 11px; border-radius: 7px; }
.main { padding: 8px 12px 14px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
h1 { margin: 0; font-size: 20px; }
h2 { margin: 0 0 12px; font-size: 16px; }
p { color: var(--muted); margin: 3px 0 0; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.search { display: flex; gap: 8px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; background: white; }
textarea { resize: vertical; }
.btn { border: 1px solid var(--line); background: white; padding: 6px 10px; border-radius: 7px; cursor: pointer; font: inherit; white-space: nowrap; }
.btn.primary { background: linear-gradient(135deg, #2563eb, #0891b2); border-color: transparent; color: white; box-shadow: 0 8px 18px rgba(37,99,235,.18); }
.btn.compact { height: 34px; padding: 5px 12px; }
.btn.full { width: 100%; }
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; margin-bottom: 8px; }
.stats div { background: var(--panel); border: 1px solid rgba(148,163,184,.28); border-radius: 8px; padding: 7px 10px; box-shadow: 0 6px 18px rgba(15,23,42,.04); }
.stats span { color: var(--muted); display: block; margin-bottom: 2px; font-size: 12px; }
.stats b { font-size: 16px; }
.panel { background: var(--panel); border: 1px solid rgba(148,163,184,.32); border-radius: 8px; padding: 8px; box-shadow: 0 10px 28px rgba(15,23,42,.05); }
.filters, .bulkbar { display: flex; gap: 7px; align-items: center; margin-bottom: 7px; }
.filters .multi-select { flex: 1 1 0; min-width: 180px; }
.multi-select { position: relative; }
.multi-trigger {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 0 30px 0 10px;
  text-align: left;
  font: inherit;
  cursor: pointer;
  color: #111827;
  position: relative;
  overflow: hidden;
}
.multi-trigger span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.multi-trigger::after {
  content: "";
  position: absolute;
  right: 11px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 2px solid #64748b;
  border-bottom: 2px solid #64748b;
  transform: translateY(-65%) rotate(45deg);
}
.multi-menu {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 5px);
  z-index: 12;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 14px 32px rgba(15,23,42,.15);
}
.multi-select.open .multi-menu { display: grid; gap: 2px; }
.multi-menu label {
  display: flex;
  grid-template-columns: none;
  flex-direction: row;
  align-items: center;
  gap: 7px;
  padding: 6px 7px;
  border-radius: 6px;
  cursor: pointer;
  color: #1f2937;
}
.multi-menu label:hover { background: #f1f5f9; }
.multi-menu input { width: auto; }
.bulkbar label { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.bulkbar input[type=checkbox] { width: auto; }
.months { width: 64px; padding: 5px 7px; height: 32px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; max-height: calc(100vh - 210px); }
table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1080px; }
th, td { border-bottom: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; background: #f8fafc; color: #475569; font-weight: 700; }
.server-col { width: 210px; }
.note-col { width: 230px; }
td small { display: block; color: var(--muted); margin-top: 2px; font-size: 12px; }
tbody tr:hover { background: #f8fbff; }
tr.soon { background: #fff7ed; }
tr.expired { background: #fef2f2; }
.badge { display: inline-block; border-radius: 999px; padding: 2px 7px; font-size: 12px; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.danger-text { color: var(--red); }
.warn-text { color: var(--amber); }
.ok-text { color: var(--green); }
.alert { border-radius: 6px; padding: 9px 11px; margin-bottom: 10px; background: #e0f2fe; color: #075985; }
.alert.danger { background: #fee2e2; color: #991b1b; }
.alert.success { background: #dcfce7; color: #166534; }
.login-bg { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #1f2937, #0f766e); }
.login-card, .install-card { width: min(480px, calc(100vw - 32px)); background: white; border-radius: 10px; padding: 22px; box-shadow: 0 22px 60px rgba(0,0,0,.24); }
.install-card { width: min(760px, calc(100vw - 32px)); }
.login-card form, .form-grid { display: grid; gap: 10px; margin-top: 14px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
label { display: grid; gap: 4px; color: #374151; font-size: 13px; }
.two-col { display: grid; grid-template-columns: 420px 1fr; gap: 24px; }
.server-cell {
  display: grid;
  grid-template-columns: 136px 42px;
  align-items: center;
  column-gap: 8px;
  min-width: 0;
  max-width: 210px;
}
.server-cell strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  min-width: 42px;
  height: 18px;
  padding: 0 5px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  letter-spacing: 0;
  border: 1px solid transparent;
  flex: 0 0 auto;
}
.type-badge.ssh { color: #0369a1; background: #e0f2fe; border-color: #bae6fd; }
.type-badge.rdp { color: #166534; background: #dcfce7; border-color: #bbf7d0; }
.actions { display: flex; gap: 5px; align-items: center; min-width: 98px; }
.actions a, .actions button { cursor: pointer; font: inherit; }
.actions form { margin: 0; }
.row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  background: #eff6ff;
  font-size: 13px;
  padding: 0;
}
.row-action.delete {
  border-color: #fecaca;
  color: #dc2626;
  background: #fff1f2;
}
.row-action:hover { filter: brightness(.98); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.inline-edit { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-edit input { min-width: 180px; }
.note-cell { max-width: 230px; color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-popover {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, .28);
}
.date-popover[hidden] { display: none; }
.date-card {
  width: min(360px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid rgba(148,163,184,.38);
  border-radius: 10px;
  background: white;
  box-shadow: 0 24px 70px rgba(15,23,42,.24);
}
.date-title { font-weight: 800; margin-bottom: 10px; }
.date-card input { height: 38px; }
.date-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(15, 23, 42, .18);
}
.modal-shell[hidden] { display: none; }
.modal-card {
  width: min(520px, calc(100vw - 56px));
  max-height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: 46px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(148,163,184,.55);
  border-radius: 12px;
  background: white;
  box-shadow: 0 24px 80px rgba(15,23,42,.28);
}
.modal-card.modal-small { width: min(460px, calc(100vw - 56px)); }
.modal-card.modal-medium { width: min(620px, calc(100vw - 56px)); }
.modal-card.modal-large { width: min(860px, calc(100vw - 56px)); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.modal-heading { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.modal-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: white;
  background: linear-gradient(135deg, #2563eb, #0891b2);
  font-weight: 900;
}
.modal-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: #64748b;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.modal-card iframe { width: 100%; height: min(440px, calc(100vh - 102px)); border: 0; background: white; }
.modal-card.modal-small iframe { height: min(290px, calc(100vh - 102px)); }
.modal-card.modal-large iframe { height: min(600px, calc(100vh - 102px)); }
.modal-page { background: white; }
.modal-page .app-header, .modal-page .topbar { display: none; }
.modal-page .main { padding: 12px; }
.modal-page .panel { border: 0; box-shadow: none; padding: 0; }
.modal-page .two-col { grid-template-columns: minmax(260px, 340px) minmax(300px, 1fr); gap: 12px; }
.modal-page .form-grid { margin-top: 0; grid-template-columns: 1fr; gap: 7px; }
.modal-page .form-grid .wide { grid-column: 1; }
.modal-page input, .modal-page select, .modal-page textarea { padding: 5px 8px; }
.modal-page textarea { min-height: 54px; }
.modal-page label { gap: 3px; }
.modal-page .form-actions { margin-top: 4px; }
.modal-page h2 { margin-top: 0; }
.modal-page table { min-width: 0; }
.modal-page th, .modal-page td { padding: 5px 7px; }
.modal-page .inline-edit input { min-width: 0; }
.modal-page .actions { min-width: 92px; }
.modal-page .row-action { width: 40px; height: 23px; font-size: 12px; }
.checkbox-panel {
  max-height: 132px;
  overflow: auto;
  display: grid;
  gap: 4px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdff;
}
.checkbox-panel label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #374151;
}
.checkbox-panel input { width: auto; }
.field-tip { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
@media (max-width: 760px) {
  .modal-page .two-col { grid-template-columns: 1fr; }
}
.verify-panel { max-width: 460px; margin: 36px auto; }
.verify-form { display: grid; gap: 12px; margin-top: 14px; }
@media (max-width: 1100px) {
  .app-header { grid-template-columns: auto 1fr; }
  .header-tools { grid-column: 1 / -1; justify-content: flex-start; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-header { height: auto; grid-template-columns: 1fr; gap: 10px; padding: 12px; }
  .logo { min-width: 0; }
  .top-nav, .userbar, .header-tools { flex-wrap: wrap; }
  .header-search { grid-template-columns: 1fr auto; width: 100%; }
  .main { padding: 12px; }
  .topbar, .filters, .bulkbar, .top-actions { flex-direction: column; align-items: stretch; }
  .stats, .form-grid { grid-template-columns: 1fr; }
}
