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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
}

/* Header */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 20px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header h1 { font-size: 22px; font-weight: 600; }
.header .subtitle { font-size: 13px; opacity: 0.8; margin-top: 2px; }
.header-actions { display: flex; gap: 10px; align-items: center; }

/* Tabs */
.tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 0 20px;
  overflow-x: auto;
}
.tab {
  padding: 14px 20px;
  cursor: pointer;
  font-size: 14px;
  color: #666;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: all 0.2s;
}
.tab:hover { color: #667eea; }
.tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
  font-weight: 600;
}

/* Content */
.content { padding: 20px; max-width: 1100px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }

/* Cards */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card h2 { font-size: 16px; margin-bottom: 16px; color: #444; }
.card h3 { font-size: 14px; margin: 16px 0 10px; color: #555; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.badge-ok { background: #e6f7e6; color: #2e7d32; }
.badge-err { background: #fde8e8; color: #c62828; }
.badge-warn { background: #fff8e1; color: #f57f17; }

/* Status grid */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.status-item {
  background: #fafbfc;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 16px;
}
.status-item .label { font-size: 12px; color: #888; text-transform: uppercase; letter-spacing: 0.5px; }
.status-item .value { font-size: 18px; font-weight: 600; margin-top: 4px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 12px; font-size: 12px; color: #888; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid #eee; }
td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; font-size: 14px; }
tr:hover td { background: #fafbfc; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: #555; margin-bottom: 4px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: 12px; color: #999; margin-top: 2px; }

/* Buttons */
.btn {
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: #667eea; color: #fff; }
.btn-primary:hover { background: #5a6fd6; }
.btn-danger { background: #e53935; color: #fff; }
.btn-danger:hover { background: #c62828; }
.btn-secondary { background: #f0f0f0; color: #555; }
.btn-secondary:hover { background: #e0e0e0; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn + .btn { margin-left: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-group { margin-top: 16px; display: flex; gap: 8px; }

/* Binding visual */
.binding-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.binding-arrow { color: #999; font-size: 18px; }

/* Backup list */
.backup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.backup-info { font-size: 13px; }
.backup-info .name { font-weight: 500; }
.backup-info .meta { color: #888; font-size: 12px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  padding: 12px 24px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-ok { background: #2e7d32; }
.toast-err { background: #c62828; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  width: 90%;
  max-width: 550px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { margin-bottom: 18px; }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Workspace layout */
.ws-layout {
  display: flex;
  gap: 16px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  overflow: hidden;
  height: calc(100vh - 200px);
  min-height: 500px;
}
.ws-sidebar {
  width: 260px;
  min-width: 260px;
  border-right: 1px solid #eee;
  display: flex;
  flex-direction: column;
}
.ws-sidebar-header {
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #444;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ws-file-list {
  flex: 1;
  overflow-y: auto;
}
.ws-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
  transition: background 0.15s;
  gap: 6px;
}
.ws-file-item:hover { background: #f8f9fb; }
.ws-file-item.active { background: #eef1fd; border-left: 3px solid #667eea; }
.ws-file-info { flex: 1; min-width: 0; }
.ws-file-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ws-file-meta { font-size: 11px; color: #aaa; margin-top: 2px; }
.ws-file-actions { display: flex; gap: 4px; flex-shrink: 0; opacity: 0; transition: opacity 0.15s; }
.ws-file-item:hover .ws-file-actions { opacity: 1; }
.ws-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.ws-editor-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ws-editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.ws-editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #eee;
}
.ws-editor-area textarea {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 16px;
  font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  line-height: 1.7;
  color: #333;
}
.ws-editor-area textarea:focus {
  box-shadow: none;
}

/* Responsive */
@media (max-width: 640px) {
  .header { padding: 16px; }
  .header h1 { font-size: 18px; }
  .content { padding: 12px; }
  .form-row { grid-template-columns: 1fr; }
  .tab { padding: 12px 14px; font-size: 13px; }
  .ws-layout { flex-direction: column; height: auto; }
  .ws-sidebar { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid #eee; max-height: 200px; }
}
