@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;600&family=Geist:wght@400;500;600&display=swap');

:root {
  --bg:          #f0f4fa;
  --surface:     #ffffff;
  --surface2:    #f8f9fc;
  --border:      #e2e8f0;
  --border2:     #cbd5e1;
  --accent:      #005A9D;
  --accent-lt:   #e8f2fb;
  --accent-bd:   #99c4e8;
  --ok:          #15803d;
  --ok-lt:       #f0fdf4;
  --ok-bar:      #22c55e;
  --warn:        #b45309;
  --warn-lt:     #fffbeb;
  --warn-bar:    #f59e0b;
  --danger:      #b91c1c;
  --danger-lt:   #fef2f2;
  --danger-bar:  #ef4444;
  --info:        #0369a1;
  --info-lt:     #f0f9ff;
  --info-bd:     #bae6fd;
  --text:        #374151;
  --muted:       #94a3b8;
  --heading:     #0f172a;
  --mono:        'Geist Mono', 'Courier New', monospace;
  --sans:        'Geist', system-ui, sans-serif;
  --r:           8px;
  --sh:          0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --sh-md:       0 4px 16px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  padding-bottom: 60px;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 40px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--sh);
}
.topbar-brand { display: flex; align-items: center; }
.topbar-name {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 22px;
  font-weight: normal;
  color: var(--accent);
  letter-spacing: 0.04em;
  line-height: 1;
}
.topbar-right { display: flex; align-items: center; gap: 20px; }
.topbar-time {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

.btn-login, .btn-logout {
  display: flex; align-items: center; gap: 6px;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.btn-login  { background: var(--danger-bar); color: #fff; border: 1px solid var(--danger); }
.btn-login:hover  { background: var(--danger); }
.btn-logout { background: var(--accent-lt); color: var(--accent); border: 1px solid var(--accent-bd); }
.btn-logout:hover { background: #dbeafe; }

.wrap { max-width: 1400px; margin: 0 auto; padding: 0 40px; }

.statsbar { display: flex; gap: 14px; flex-wrap: wrap; padding-top: 28px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--sh);
  min-width: 150px;
}
.stat-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--accent-lt);
  border: 1px solid var(--accent-bd);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.green { background: var(--ok-lt);    border-color: #bbf7d0; color: var(--ok); }
.stat-icon.red   { background: var(--danger-lt); border-color: #fecaca; color: var(--danger); }
.stat-value { font-family: var(--mono); font-size: 22px; font-weight: 600; color: var(--heading); line-height: 1; }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-top: 3px; }

.toolbar { display: flex; align-items: center; gap: 12px; padding-top: 24px; }
.lease-filter {
  flex: 0 1 340px;
  padding: 8px 12px;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
}
.lease-filter:focus { outline: none; border-color: var(--accent-bd); box-shadow: 0 0 0 3px var(--accent-lt); }
.toolbar .count { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.alert-block {
  margin-top: 20px;
  padding: 13px 16px;
  border-radius: var(--r);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 13px;
}
.alert-error { background: var(--danger-lt); border: 1px solid #fecaca; color: var(--danger); }
.alert-info  { background: var(--info-lt);   border: 1px solid var(--info-bd);  color: var(--info); }
.alert-warn  { background: var(--warn-lt);   border: 1px solid #fde68a;         color: var(--warn); }
.alert-icon svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-block ul { margin-left: 18px; margin-top: 5px; }
.alert-block li { margin-top: 3px; }
.alert-block code { font-family: var(--mono); font-size: 12px; }

.notice {
  max-width: 520px;
  margin: 72px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh-md);
  padding: 36px 32px;
  text-align: center;
}
.notice-icon {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--ok-lt); border: 1px solid #bbf7d0; color: var(--ok);
}
.notice-icon svg { width: 28px; height: 28px; }
.notice h2 { font-size: 18px; color: var(--heading); margin-bottom: 6px; font-family: var(--sans); font-weight: 600; }
.notice p { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.notice .btn-login,
.notice .btn-logout { display: inline-flex; margin-top: 8px; }

.hosting-section { margin-top: 28px; }
.hosting-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.hosting-title { display: flex; align-items: center; gap: 9px; }
.icon-server { width: 17px; height: 17px; color: var(--accent); flex-shrink: 0; }
.hosting-title h2 {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--heading);
  letter-spacing: .03em;
}
.hosting-meta { display: flex; align-items: center; gap: 10px; }
.badge {
  background: var(--accent-lt);
  color: var(--accent);
  border: 1px solid var(--accent-bd);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 600;
}
.collected { font-size: 11px; color: var(--muted); font-family: var(--mono); }

.table-wrap {
  overflow-x: auto;
  border-radius: var(--r);
  border: 1px solid var(--border);
  box-shadow: var(--sh-md);
}
table { width: 100%; border-collapse: collapse; background: var(--surface); }
thead tr { background: var(--surface2); border-bottom: 1px solid var(--border2); }
th {
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  white-space: nowrap;
}
th[onclick] { cursor: pointer; user-select: none; }
th[onclick]:hover { color: var(--accent); }
td { padding: 8px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8faff; }

.col-idx    { color: var(--muted); font-family: var(--mono); font-size: 12px; width: 36px; text-align: right; padding-right: 8px; }
.col-user   { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--heading); white-space: nowrap; }
.col-mono   { font-family: var(--mono); font-size: 12px; color: var(--text); white-space: nowrap; }
.col-domain { font-size: 13px; color: #6b7280; white-space: nowrap; }
.col-pct    { white-space: nowrap; text-align: right; }
.text-danger { color: var(--danger) !important; font-weight: 600; }

.pct {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
}
.pct-ok      { color: var(--ok);     background: var(--ok-lt);     border: 1px solid #bbf7d0; }
.pct-warning { color: var(--warn);   background: var(--warn-lt);   border: 1px solid #fde68a; }
.pct-danger  { color: var(--danger); background: var(--danger-lt); border: 1px solid #fecaca; }
.pct-na      { color: var(--muted);  background: var(--surface2);  border: 1px solid var(--border); }

.empty { text-align: center; color: var(--muted); font-style: italic; padding: 24px; }

.footer { text-align: center; margin-top: 48px; font-size: 11px; color: var(--muted); font-family: var(--mono); }

@media (max-width: 700px) {
  .topbar, .wrap { padding-left: 16px; padding-right: 16px; }
}

.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-top: 10px;
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.pager-left, .pager-right { display: flex; align-items: center; gap: 8px; }
.pager select {
  font-family: var(--mono); font-size: 12px;
  border: 1px solid var(--border2); border-radius: 6px;
  padding: 4px 6px; background: var(--surface); color: var(--text);
}
.pager button {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  background: var(--surface); color: var(--accent);
  border: 1px solid var(--border2); border-radius: 6px;
  padding: 5px 10px; cursor: pointer; transition: background .15s;
}
.pager button:hover:not(:disabled) { background: var(--accent-lt); }
.pager button:disabled { color: var(--muted); opacity: .5; cursor: default; }
.pager .info { white-space: nowrap; color: var(--text); }

.notice-icon.red { background: var(--danger-lt); border-color: #fecaca; color: var(--danger); }

.btn-dl {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  background: var(--accent-lt); color: var(--accent);
  border: 1px solid var(--accent-bd); border-radius: 6px;
  padding: 4px 10px; text-decoration: none; transition: background .15s;
}
.btn-dl:hover { background: #dbeafe; }

.col-dl { text-align: right; white-space: nowrap; }

.topbar-right { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.topbar-right form { display: contents; }
.topbar-name { overflow-wrap: anywhere; }
button.btn-logout, button.btn-login { font-family: var(--mono); }
button.btn-logout:disabled { opacity: .5; cursor: not-allowed; }

.stat-value.stat-text { font-size: 16px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.countdown.expired { color: var(--danger); }

.alert-detail { margin-top: 6px; }
.alert-detail code { word-break: break-word; }

td.col-val { min-width: 280px; }
.val-str { font-family: var(--mono); font-size: 12px; color: var(--heading); word-break: break-word; }
.ts-human { display: block; font-family: var(--sans); font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font-family: var(--mono); font-size: 11px; color: var(--accent);
  background: var(--accent-lt); border: 1px solid var(--accent-bd);
  border-radius: 5px; padding: 1px 7px;
}
.val-json {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.45; color: var(--heading);
  background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; max-height: 280px; overflow: auto; white-space: pre;
}
.val-json.tall { max-height: 520px; }
.val-per-src { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }
.src-tag {
  font-family: var(--mono); font-size: 10px; font-weight: 600; color: var(--warn);
  background: var(--warn-lt); border: 1px solid #fde68a; border-radius: 4px; padding: 1px 5px; flex-shrink: 0;
}
th.src, td.src { text-align: center; width: 48px; }
tr.row-proto .col-user { color: #64748b; font-weight: 400; }

table.kv td.col-key { width: 38%; font-size: 12px; color: #64748b; white-space: nowrap; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }

details.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--sh); margin-top: 10px;
}
details.panel > summary {
  padding: 10px 14px; cursor: pointer;
  font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--heading);
}
details.panel > summary:hover { color: var(--accent); }
details.panel[open] > summary { border-bottom: 1px solid var(--border); }
.panel-body { padding: 14px; position: relative; }
.panel-body > .btn-login { display: inline-flex; margin-top: 12px; }

.copy-btn {
  position: absolute; top: 20px; right: 22px; z-index: 1;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  background: var(--surface); color: var(--accent);
  border: 1px solid var(--border2); border-radius: 5px; padding: 3px 9px; cursor: pointer;
}
.copy-btn:hover { background: var(--accent-lt); }
.raw-token {
  font-family: var(--mono); font-size: 11px; color: var(--heading); word-break: break-all;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; padding-right: 90px; max-height: 180px; overflow: auto;
}

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text); font-family: var(--mono); }
.form-grid input, .form-grid select {
  padding: 7px 10px; border: 1px solid var(--border2); border-radius: 6px;
  background: var(--surface); color: var(--text); font-family: var(--sans); font-size: 13px;
}
.form-grid input:focus, .form-grid select:focus { outline: none; border-color: var(--accent-bd); box-shadow: 0 0 0 3px var(--accent-lt); }
.hint { font-size: 12px; color: #64748b; margin-top: 10px; }
.hint code { font-family: var(--mono); font-size: 11.5px; }

a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
