* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Songti SC', 'Microsoft YaHei', sans-serif;
  color: #333;
  background: #f5f6f8;
  line-height: 1.5;
}

/* Header */
header {
  background: linear-gradient(135deg, #0f2540 0%, #1b3a57 100%);
  color: white;
  padding: 0 2rem;
  border-bottom: 3px solid #c19a3d;
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 72px;
  max-width: 1400px;
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.logo {
  font-size: 2rem;
  color: #e8ce80;
}
h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: white;
}
.subtitle {
  font-size: 0.75rem;
  color: #b0c4d8;
  margin-top: 2px;
}
.header-stats {
  font-size: 0.9rem;
  color: #b0c4d8;
}
.header-stats strong {
  color: #e8ce80;
  font-size: 1.15rem;
  margin: 0 0.2rem;
}
.user-info {
  color: #e8ce80;
  font-size: 0.85rem;
  margin-left: 1.2rem;
}
.user-info a {
  color: #b0c4d8;
  text-decoration: none;
}
.user-info a:hover { text-decoration: underline; }

/* Layout */
main {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.2rem;
  padding: 1.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* Sidebar */
.sidebar {
  background: white;
  border-radius: 6px;
  padding: 1.2rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  height: fit-content;
  position: sticky;
  top: 1rem;
}
.filter-group {
  margin-bottom: 1.1rem;
  border-bottom: 1px solid #eee;
  padding-bottom: 1rem;
}
.filter-group h3 {
  font-size: 0.85rem;
  color: #1b3a57;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.filter-group label {
  display: block;
  font-size: 0.87rem;
  padding: 3px 0;
  color: #555;
  cursor: pointer;
}
.filter-group label:hover { color: #1b3a57; }
.filter-group input[type="text"],
.filter-group input[type="date"],
.filter-group select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #dae0e6;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-top: 0.4rem;
}
.filter-group input[type="date"] { margin-top: 0.35rem; }
.checkbox { display: flex; align-items: center; gap: 0.4rem; }
.btn-primary, .btn-outline {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
}
.btn-primary {
  background: #1b3a57;
  color: white;
  margin-top: 0.5rem;
}
.btn-primary:hover { background: #2e6aa8; }
.btn-outline {
  background: transparent;
  color: #1b3a57;
  border: 1px solid #dae0e6;
  margin-top: 0.4rem;
}
.btn-outline:hover { background: #f0f4f8; }

/* Content */
.content {
  background: white;
  border-radius: 6px;
  padding: 1.2rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  min-height: 400px;
}
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.8rem;
  margin-bottom: 1rem;
}
#result-count {
  font-size: 0.9rem;
  color: #666;
}
#result-count strong { color: #1b3a57; }
.page-controls button {
  padding: 4px 12px;
  border: 1px solid #dae0e6;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  margin: 0 3px;
}
.page-controls button:disabled { color: #ccc; cursor: not-allowed; }
.page-controls button:not(:disabled):hover { border-color: #1b3a57; color: #1b3a57; }
#page-info { font-size: 0.85rem; color: #666; margin: 0 5px; }

/* Result list */
.doc {
  border-bottom: 1px solid #eee;
  padding: 1rem 0.4rem;
  cursor: pointer;
  transition: background 0.15s;
}
.doc:hover { background: #f8fafc; }
.doc-title {
  color: #1b3a57;
  font-weight: 600;
  font-size: 0.98rem;
  margin-bottom: 0.4rem;
  line-height: 1.4;
}
.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 0.5rem;
}
.doc-summary {
  color: #444;
  font-size: 0.87rem;
  line-height: 1.55;
  margin-bottom: 0.4rem;
}
.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 500;
  vertical-align: middle;
}
.badge-national { background: #e8eef6; color: #1b3a57; }
.badge-provincial { background: #fff0e0; color: #b57a1c; }
.badge-cat { background: #e8f5ee; color: #2e8b57; margin-left: 0.3rem; }
.badge-electric { background: #fff5e1; color: #c19a3d; }
.doc-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}
.key-tag {
  font-size: 0.75rem;
  background: #f0f4f8;
  color: #1b3a57;
  padding: 2px 8px;
  border-radius: 3px;
  border-left: 3px solid #c19a3d;
}
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: #999;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 2rem;
}
.modal.hidden { display: none; }
.modal-inner {
  background: white;
  border-radius: 8px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: #888;
  width: 32px;
  height: 32px;
  line-height: 32px;
}
.modal-close:hover { color: #1b3a57; }
.detail-title {
  font-size: 1.25rem;
  color: #1b3a57;
  font-weight: 700;
  margin-bottom: 0.6rem;
}
.detail-meta {
  color: #666;
  font-size: 0.85rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #eee;
  margin-bottom: 1rem;
}
.detail-meta > div { margin-bottom: 0.3rem; }
.detail-summary {
  background: #fff5e1;
  border-left: 4px solid #c19a3d;
  padding: 0.8rem 1rem;
  border-radius: 4px;
  font-size: 0.92rem;
  color: #333;
  margin: 1rem 0;
}
.detail-content {
  color: #333;
  font-size: 0.92rem;
  line-height: 1.7;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
  padding: 1rem;
  background: #fafbfc;
  border-radius: 4px;
}
.detail-key-data {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}
.detail-key-data .item {
  background: #f0f4f8;
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
  border-left: 3px solid #c19a3d;
}
.detail-key-data .item .name {
  font-size: 0.75rem;
  color: #666;
}
.detail-key-data .item .value {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1b3a57;
}

.attachments {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.att-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.8rem;
  background: #f0f4f8;
  border-radius: 4px;
  border-left: 3px solid #2e6aa8;
  text-decoration: none;
  color: #1b3a57;
  transition: background 0.15s;
}
.att-item:hover { background: #e8eef6; }
.att-icon { font-size: 1.15rem; }
.att-name { flex: 1; font-size: 0.9rem; word-break: break-all; }
.att-size { font-size: 0.78rem; color: #888; }
