/* CloudSilly · 简洁白色主题 */
:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #1f2937;
  --text-soft: #6b7280;
  --muted: #9ca3af;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 600; color: var(--text); }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; color: var(--text-soft); }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #fff; border-right: 1px solid var(--border);
  padding: 20px 0; flex-shrink: 0;
}
.sidebar .brand {
  font-size: 18px; font-weight: 700; padding: 0 20px 20px;
  border-bottom: 1px solid var(--border); margin-bottom: 12px;
  color: var(--text);
}
.sidebar .brand small { display:block; font-size:12px; color:var(--muted); font-weight:400; margin-top:2px;}
.sidebar nav a {
  display: block; padding: 10px 20px; color: var(--text-soft);
  border-left: 3px solid transparent; cursor: pointer;
}
.sidebar nav a:hover { background: var(--bg); color: var(--text); }
.sidebar nav a.active {
  color: var(--primary); border-left-color: var(--primary);
  background: #eff6ff; font-weight: 500;
}
.main { flex: 1; min-width: 0; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 14px 24px; display: flex; align-items: center; justify-content: space-between;
}
.topbar .title { font-size: 16px; font-weight: 600; }
.topbar .user-info { color: var(--text-soft); font-size: 13px; }
.content { padding: 24px; }

/* Card */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-title {
  font-size: 15px; font-weight: 600; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
}

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.stat .label { color: var(--text-soft); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--text); }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 14px; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 13px; cursor: pointer;
  transition: all .15s; font-family: inherit;
}
.btn:hover { border-color: var(--text-soft); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-soft); padding: 4px 8px; }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text); }
.input, .select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; background: #fff; color: var(--text);
  font-family: inherit; transition: border-color .15s;
}
.input:focus, .select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }
.form-help { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.table th { background: #fafbfc; color: var(--text-soft); font-weight: 500; font-size: 12px; }
.table tr:hover td { background: #fafbfc; }
.table .actions { display: flex; gap: 6px; }
.table-empty { text-align: center; padding: 40px; color: var(--muted); }
.table-wrap { overflow-x: auto; }

/* Tags / status */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 12px; font-weight: 500; background: #f3f4f6; color: var(--text-soft);
}
.tag-success { background: #dcfce7; color: #15803d; }
.tag-danger { background: #fee2e2; color: var(--danger); }
.tag-warning { background: #fef3c7; color: #b45309; }
.tag-info { background: #dbeafe; color: var(--primary); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-online { background: var(--success); }
.dot-offline { background: var(--muted); }

/* Login page */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
  background-color: #0f172a;
  background-image: url('/assets/login-desktop.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  isolation: isolate;
}
@media (max-width: 768px), (orientation: portrait) {
  .login-page {
    background-image: url('/assets/login-mobile.png');
    background-attachment: scroll;
  }
}
.login-card {
  width: 100%; max-width: 380px;
  background: rgba(255, 255, 255, 0.30);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 30px 80px -10px rgba(15, 23, 42, 0.55),
              0 8px 24px -6px rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  position: relative; z-index: 1;
  color: #0f172a;
}
.login-card h1 { text-align: center; margin-bottom: 4px; font-size: 22px;}
.login-card .sub { text-align: center; color: var(--text-soft); margin-bottom: 28px; font-size: 13px;}
.login-tabs { display: flex; margin-bottom: 24px; border-bottom: 1px solid rgba(255,255,255,0.4); }
.login-tabs button {
  flex: 1; background: none; border: none; padding: 10px;
  font-size: 14px; cursor: pointer; color: var(--text-soft);
  border-bottom: 2px solid transparent; font-family: inherit;
}
.login-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500;}

/* Modal */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 480px;
  max-height: 90vh; overflow: auto; box-shadow: 0 10px 30px rgba(0,0,0,.15);
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); padding: 0; line-height: 1; }

/* Toast */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 2000; }
.toast {
  background: #fff; border: 1px solid var(--border); border-left: 3px solid var(--primary);
  padding: 12px 16px; border-radius: 6px; margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.08); font-size: 13px;
  min-width: 240px; animation: slideIn .2s ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1;} }

/* Utilities */
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px;}
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.text-soft { color: var(--text-soft); } .text-muted { color: var(--muted); }
.text-success { color: var(--success); } .text-danger { color: var(--danger); }
.text-sm { font-size: 12px; } .text-mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.center { text-align: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-family: ui-monospace, Consolas, monospace; font-size: 12px;}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .brand { font-size: 0; padding: 0 0 12px; text-align: center; }
  .sidebar .brand::first-letter { font-size: 20px; }
  .sidebar nav a { padding: 12px; text-align: center; font-size: 11px; }
  .content { padding: 14px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-row { flex-direction: column; }
}

/* === Instance card grid (user console) === */
.inst-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.inst-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.inst-card:hover { box-shadow: 0 12px 28px -10px rgba(15,23,42,.18); border-color: #cbd5e1; }
.inst-card .inst-head { display: flex; align-items: center; gap: 10px; }
.inst-card .inst-logo { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.inst-card .inst-name { font-size: 16px; font-weight: 600; color: var(--text); flex: 1; min-width: 0; word-break: break-all; }
.inst-card .inst-status { flex-shrink: 0; }
.inst-meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 12.5px; line-height: 1.5; }
.inst-meta .k { color: var(--text-soft); }
.inst-meta .v { color: var(--text); word-break: break-all; }
.inst-meta .v code {
  background: var(--bg); padding: 1px 6px; border-radius: 4px;
  font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.inst-meta a { color: var(--primary); text-decoration: none; }
.inst-meta a:hover { text-decoration: underline; }
.inst-foot {
  display: flex; align-items: center; gap: 8px;
  padding-top: 10px; border-top: 1px solid var(--border);
  margin-top: auto; flex-wrap: wrap;
}
.inst-foot .btn { flex: 1 1 auto; min-width: 0; }
.inst-foot .menu-wrap { position: relative; flex: 0 0 auto; }
.menu-wrap .menu-btn {
  width: 36px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1; font-weight: 600;
}
.menu-pop {
  position: absolute; bottom: calc(100% + 6px); right: 0;
  min-width: 180px; max-width: 240px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 16px 40px -8px rgba(15,23,42,.22);
  padding: 6px; z-index: 50;
  display: none; flex-direction: column; gap: 2px;
}
.menu-pop.open { display: flex; }
.menu-pop button {
  text-align: left; padding: 8px 12px; font-size: 13px;
  background: none; border: 0; border-radius: 6px; color: var(--text);
  cursor: pointer; font-family: inherit; display: flex; align-items: center; gap: 8px;
  width: 100%;
}
.menu-pop button:hover { background: var(--bg); }
.menu-pop button.danger { color: var(--danger); }
.menu-pop button.danger:hover { background: #fef2f2; }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: 4px 2px; }

@media (max-width: 600px) {
  .inst-grid { grid-template-columns: 1fr; gap: 12px; }
  .inst-card { padding: 16px; }
  .inst-foot .btn { font-size: 12px; padding: 6px 10px; }
}

/* Free API banner */
.free-api-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px; margin: 12px 0 18px;
  background: linear-gradient(135deg, #eef2ff 0%, #ecfeff 100%);
  border: 1px solid #c7d2fe; border-radius: 10px;
}
.free-api-banner > div:first-child { flex: 1 1 240px; min-width: 0; }
.free-api-banner .fa-title { font-weight: 600; color: #1e3a8a; font-size: 15px; }
.free-api-banner .fa-sub { color: #475569; font-size: 12px; margin-top: 2px; }
@media (max-width: 600px) {
  .free-api-banner { padding: 12px; }
  .free-api-banner .select, .free-api-banner .btn { width: 100%; }
}

.theme-pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.theme-pack-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.theme-pack-option {
  display: flex;
  flex-direction: column;
  height: 100%;
  cursor: pointer;
}

.theme-pack-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #e5e7eb;
  border-bottom: 1px solid var(--border);
}

.theme-pack-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.theme-pack-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.theme-pack-meta {
  flex: 1;
  min-width: 0;
}

.theme-pack-title {
  font-weight: 600;
  color: var(--text);
}

.theme-pack-desc {
  color: var(--text-soft);
  font-size: 12px;
  margin-top: 4px;
  word-break: break-word;
}

.theme-pack-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  font-size: 12px;
}

.theme-asset-preview {
  margin-top: 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #f8fafc;
}

.theme-asset-preview img {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #e5e7eb;
}

.theme-asset-caption {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-soft);
}
