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

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

header {
  background: #1a1a2e;
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-shrink: 0;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
}

#project-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

#project-selector label {
  font-size: 14px;
  opacity: 0.8;
}

#project-select {
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid #444;
  background: #16213e;
  color: #fff;
  font-size: 14px;
  min-width: 250px;
}

#project-select option {
  background: #16213e;
}

#user-info {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.user-name {
  opacity: 0.9;
}

.logout-link {
  color: #aaa;
  text-decoration: none;
  font-size: 12px;
}

.logout-link:hover {
  color: #fff;
  text-decoration: underline;
}

main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#sidebar {
  width: 350px;
  background: #fff;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#breadcrumb {
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
  font-size: 13px;
  color: #666;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

#breadcrumb a {
  color: #0066cc;
  text-decoration: none;
  cursor: pointer;
}

#breadcrumb a:hover {
  text-decoration: underline;
}

#breadcrumb .separator {
  color: #999;
}

#upload-area {
  padding: 8px 16px;
  border-bottom: 1px solid #eee;
}

#upload-btn {
  width: 100%;
  padding: 8px;
  background: #0066cc;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

#upload-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

#upload-btn:not(:disabled):hover {
  background: #0052a3;
}

#document-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}

.doc-item:hover {
  background: #f0f6ff;
}

.doc-item.active {
  background: #e3effd;
}

.doc-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.doc-info {
  flex: 1;
  min-width: 0;
}

.doc-name {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-meta {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}

#detail-panel {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

#detail-empty {
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #999;
  font-size: 16px;
}

#detail-empty:not([hidden]) {
  display: flex;
}

#detail-content h2 {
  font-size: 20px;
  margin-bottom: 16px;
  word-break: break-word;
}

#detail-meta {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.8;
}

#detail-meta .label {
  color: #666;
  display: inline-block;
  width: 100px;
}

#detail-actions {
  margin-bottom: 24px;
}

#edit-btn {
  padding: 10px 24px;
  background: #0066cc;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: background 0.15s;
}

#edit-btn:hover {
  background: #0052a3;
}

#detail-revisions h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: #444;
}

#revision-list {
  list-style: none;
}

#revision-list li {
  padding: 10px 12px;
  border: 1px solid #eee;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  background: #fff;
}

.rev-version {
  font-weight: 600;
  color: #0066cc;
}

.rev-date {
  color: #888;
  margin-left: 8px;
}

.rev-comment {
  color: #666;
  margin-top: 4px;
  font-style: italic;
}

#loading {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#loading.active {
  display: flex;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #ddd;
  border-top-color: #0066cc;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  padding: 40px 16px;
  text-align: center;
  color: #999;
  font-size: 14px;
}
