* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f0f2f5;
  color: #333;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { text-decoration: none; color: inherit; }
.container {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
}

/* Navbar */
.navbar {
  background: #1a5f2a;
  color: #fff;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.nav-brand {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
}
.nav-links a {
  color: #fff;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.nav-links a:hover { opacity: 1; }
.nav-user {
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn-link {
  background: rgba(255,255,255,0.15);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
}
.btn-link:hover { background: rgba(255,255,255,0.25); }

/* Footer */
.footer {
  background: #1a5f2a;
  color: rgba(255,255,255,0.7);
  text-align: center;
  padding: 14px;
  font-size: 0.85rem;
  margin-top: auto;
}

/* Alert */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.95rem;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* Page title */
.page-title {
  font-size: 1.6rem;
  margin-bottom: 20px;
  color: #1a5f2a;
}

/* Card */
.card {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.card h2 { font-size: 1.2rem; margin-bottom: 16px; color: #333; }

/* Form */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 0.9rem;
  color: #555;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: #1a5f2a; }
.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.form-row .form-group { flex: 1; min-width: 150px; }

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table th,
.table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
}
.table th {
  background: #f8f9fa;
  font-weight: 700;
  color: #555;
}
.table tr:hover { background: #f9f9f9; }

/* Content tables (rendered from markdown/Excel/Word) */
.content-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.85rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.content-table th,
.content-table td {
  border: 1px solid #ddd;
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.content-table th {
  background: #e9ecef;
  font-weight: 600;
  color: #333;
}
.content-table tr:nth-child(even) {
  background: #f8f9fa;
}
.content-table tr:hover {
  background: #e9f5ff;
}
.content-table h4 {
  font-size: 0.9rem;
  margin: 16px 0 8px 0;
  color: #1a5f2a;
}

/* Large table specific styles */
.large-table {
  font-size: 0.8rem;
}
.large-table th,
.large-table td {
  padding: 6px 8px;
  word-break: break-word;
  max-width: 200px;
}

/* Content rendering */
.rule-content,
.prompt-content {
  font-size: 0.92rem;
  line-height: 1.7;
  color: #333;
}

.rule-content h1,
.rule-content h2,
.rule-content h3,
.rule-content h4 {
  color: #1a5f2a;
  margin: 24px 0 12px 0;
  font-weight: 600;
}
.rule-content h1 { font-size: 1.5rem; border-bottom: 2px solid #1a5f2a; padding-bottom: 8px; }
.rule-content h2 { font-size: 1.3rem; border-bottom: 1px solid #ddd; padding-bottom: 6px; }
.rule-content h3 { font-size: 1.15rem; }
.rule-content h4 { font-size: 1rem; color: #555; }

.rule-content p {
  margin: 12px 0;
}

.rule-content ul,
.rule-content ol {
  margin: 12px 0;
  padding-left: 24px;
}
.rule-content li {
  margin: 6px 0;
}

.rule-content hr {
  border: none;
  border-top: 1px solid #ddd;
  margin: 24px 0;
}

.rule-content strong {
  font-weight: 600;
  color: #000;
}

.rule-content em {
  font-style: italic;
  color: #555;
}

/* Docx content specific */
.docx-content {
  line-height: 1.8;
}
.docx-content p {
  margin: 10px 0;
}

/* Plain content fallback */
.plain-content {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8f9fa;
  padding: 16px;
  border-radius: 6px;
  overflow-x: auto;
}

/* Empty content message */
.empty-content {
  color: #888;
  font-style: italic;
  padding: 20px;
  text-align: center;
  background: #f8f9fa;
  border-radius: 6px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #1a5f2a; color: #fff; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-warning { background: #e67e22; color: #fff; }
.btn-danger { background: #c0392b; color: #fff; }
.btn-info { background: #2980b9; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; }
.btn-block { width: 100%; display: block; text-align: center; }

/* Badge */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-primary { background: #cce5ff; color: #004085; }
.badge-secondary { background: #e2e3e5; color: #383d41; }

/* Data Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
}
.data-table th {
  background: #f8f9fa;
  font-weight: 700;
  color: #555;
}
.data-table tr:hover { background: #f9f9f9; }

/* Edit form row */
.edit-form-row td { background: #f8f9fa; padding: 16px; }
.edit-form .form-row { gap: 10px; }

/* Rules page */
.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.rule-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rule-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rule-card-header h3 {
  font-size: 1.05rem;
  color: #1a5f2a;
}
.rule-card-meta {
  font-size: 0.82rem;
  color: #888;
}
.rule-card-desc {
  font-size: 0.9rem;
  color: #555;
  flex: 1;
  line-height: 1.5;
}
.rule-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* Prompts page - same grid/card style as rules */
.prompts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.prompt-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.prompt-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.prompt-card-header h3 {
  font-size: 1.05rem;
  color: #1a5f2a;
}
.prompt-card-desc {
  font-size: 0.9rem;
  color: #555;
  flex: 1;
  line-height: 1.5;
}
.prompt-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* View / Edit */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.page-subtitle {
  color: #888;
  font-size: 0.95rem;
  margin-top: 2px;
}
.page-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.rule-content {
  font-size: 0.92rem;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  color: #333;
}

.prompt-content {
  font-size: 0.92rem;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  color: #333;
}

.docx-content.pre-wrap,
.plain-content.pre-wrap {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.88rem;
  line-height: 1.6;
}
.code-textarea {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 500px;
}
.form-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
}
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a5f2a 0%, #27ae60 100%);
}
.login-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.login-box {
  background: #fff;
  padding: 40px 36px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 400px;
}
.login-title {
  font-size: 2rem;
  text-align: center;
  color: #1a5f2a;
  margin-bottom: 4px;
}
.login-subtitle {
  text-align: center;
  color: #888;
  margin-bottom: 24px;
  font-size: 0.95rem;
}
