
:root{
  --bg:#f6f6f6;
  --card:#ffffff;
  --text:#222;
  --muted:#666;
  --border:#ddd;
  --primary:#1f2937;
  --danger:#b91c1c;
  --ok:#047857;
}
*{box-sizing:border-box}
body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;background:var(--bg);color:var(--text)}
.auth-container{max-width:520px}
.setup-container{max-width:720px}
.flash-spacer{height:12px}
a{color:var(--primary);text-decoration:none}
a:hover{text-decoration:underline}
.container{max-width:1100px;margin:0 auto;padding:24px}
.topbar{background:var(--card);border-bottom:1px solid var(--border)}
.topbar .container{display:flex;align-items:center;justify-content:space-between}
.brand{font-weight:700}
.nav a{margin-left:14px;color:var(--muted)}
.card{background:var(--card);border:1px solid var(--border);border-radius:12px;padding:18px}
.grid{display:grid;grid-template-columns:1fr;gap:16px}
@media(min-width:900px){.grid-2{grid-template-columns:1fr 1fr}}
h1{margin:0 0 12px}
h2{margin:0 0 10px}
label{display:block;font-size:0.92rem;color:var(--muted);margin:12px 0 6px}
input[type="text"],input[type="email"],input[type="password"],input[type="number"],input[type="datetime-local"],textarea,select{
  width:100%;padding:10px 12px;border:1px solid var(--border);border-radius:10px;font-size:1rem;background:#fff
}
textarea{min-height:130px;resize:vertical}
.row{display:flex;gap:12px;flex-wrap:wrap}
.row > div{flex:1;min-width:220px}
.btn{
  display:inline-block;padding:10px 14px;border-radius:10px;border:1px solid var(--border);background:#fff;cursor:pointer;
  font-size:0.95rem
}
.btn.primary{background:var(--primary);border-color:var(--primary);color:#fff}
.btn.danger{background:var(--danger);border-color:var(--danger);color:#fff}
.btn.ok{background:var(--ok);border-color:var(--ok);color:#fff}
.btn + .btn{margin-left:10px}
.table{width:100%;border-collapse:collapse}
.table th,.table td{padding:10px;border-bottom:1px solid var(--border);text-align:left;font-size:0.95rem;vertical-align:top}
.badge{display:inline-block;padding:2px 10px;border-radius:999px;border:1px solid var(--border);font-size:0.85rem;color:var(--muted)}
.flash{padding:12px 14px;border-radius:10px;border:1px solid var(--border);background:#fff;margin:0 0 14px;font-weight:600}
.flash.ok{border-color:#a7f3d0;background:#ecfdf5}
.flash.err{border-color:#ef4444;background:#fef2f2;color:#991b1b}
.small{font-size:0.9rem;color:var(--muted)}
.hr{height:1px;background:var(--border);margin:16px 0}

.cms-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #f8fafc;
  padding: 20px;
  margin: 18px 0;
}

.cms-panel h3 {
  margin: 0 0 14px;
  color: var(--dark);
}

.cms-input {
  min-height: 48px;
}

.cms-textarea {
  width: 100%;
  resize: vertical;
  line-height: 1.55;
}

.cms-textarea-short {
  min-height: 90px;
}

.cms-textarea-title {
  min-height: 120px;
  font-size: 20px;
  font-weight: 600;
}

.cms-textarea-medium {
  min-height: 150px;
}

.cms-textarea-large {
  min-height: 220px;
}

.editor-shell {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.editor-select {
  width: auto;
  min-width: 150px;
  min-height: 40px;
}

.editor-btn {
  min-height: 40px;
  padding: 8px 12px;
}

.post-editor {
  min-height: 520px;
  padding: 28px;
  font-size: 18px;
  line-height: 1.75;
  outline: none;
  background: #fff;
}

.post-editor:focus {
  box-shadow: inset 0 0 0 3px var(--primary-light);
}

.post-editor h2 {
  margin: 32px 0 12px;
  font-size: 32px;
}

.post-editor h3 {
  margin: 26px 0 10px;
  font-size: 24px;
}

.post-editor p {
  margin: 0 0 18px;
}

.post-editor blockquote {
  margin: 24px 0;
  padding: 16px 20px;
  border-left: 4px solid var(--primary);
  background: #eff6ff;
  color: var(--dark);
}

.post-editor img {
  max-width: 100%;
  height: auto;
  margin: 20px 0;
}

.post-editor ul,
.post-editor ol {
  margin: 18px 0;
  padding-left: 28px;
}

.editor-source {
  display: none;
  min-height: 520px;
  border: 0;
  border-radius: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.6;
}

.editor-source.is-visible {
  display: block;
}

.post-editor.is-hidden {
  display: none;
}


:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --dark: #1f2937;
  --text: #111827;
  --text-muted: #6b7280;
  --bg: #f9fafb;
  --card: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: all 0.2s;
}

a:hover {
  color: var(--primary-hover);
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* Topbar */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
}

.brand {
  font-weight: 700;
  font-size: 18px;
}

.brand a {
  color: var(--dark);
  text-decoration: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.nav a {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.nav a:hover {
  background: var(--bg);
  color: var(--primary);
  text-decoration: none;
}

/* Typography */
h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--dark);
}

h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--dark);
}

h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.small {
  font-size: 14px;
  color: var(--text-muted);
}

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

/* Grid */
.grid {
  display: grid;
  gap: 24px;
  margin-bottom: 24px;
}

.grid-2 {
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* Forms */
label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--dark);
  margin-bottom: 6px;
  margin-top: 16px;
}

label:first-child {
  margin-top: 0;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="search"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--card);
  transition: all 0.2s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea {
  min-height: 130px;
  resize: vertical;
}

.row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.row > div {
  flex: 1;
  min-width: 220px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  text-decoration: none;
}

.btn:hover {
  background: var(--bg);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.btn.danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.btn.ok {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.btn.ok:hover {
  background: #059669;
  border-color: #059669;
}

.btn + .btn {
  margin-left: 8px;
}

.btn svg {
  margin-right: 6px;
}

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead {
  background: var(--bg);
}

.table th {
  padding: 12px;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

.table td {
  padding: 12px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--bg);
}

/* Badge */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg);
}

/* Flash messages */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  font-size: 14px;
}

.flash.ok {
  background: var(--success-light);
  border-color: #6ee7b7;
  color: #065f46;
}

.flash.err {
  background: var(--danger-light);
  border-color: #fca5a5;
  color: #991b1b;
}

/* HR */
.hr {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
  border: none;
}

/* Dashboard specific */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-number {
  font-size: 36px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.stat-label {
  font-size: 14px;
  color: var(--text-muted);
}

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 20px;
}

.page-header h1 {
  margin-bottom: 4px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 16px;
  margin-bottom: 0;
}

.header-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Filter form */
.filter-form {
  padding: 0;
}

.filter-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-group select {
  min-width: 150px;
  width: auto;
}

.filter-group input[type="search"] {
  flex: 1;
  min-width: 250px;
}

/* Media gallery */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  background: var(--bg);
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-icon {
  color: var(--text-muted);
  margin-bottom: 16px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.media-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.2s;
  background: var(--card);
}

.media-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.media-preview {
  width: 100%;
  height: 160px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.media-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-info {
  padding: 12px;
}

.media-title {
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.media-actions {
  display: flex;
  gap: 4px;
  padding: 0 12px 12px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg);
  color: var(--dark);
}

.btn-icon.danger:hover {
  background: var(--danger-light);
  color: var(--danger);
}

/* Filter tabs */
.filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-tab {
  padding: 8px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.filter-tab:hover {
  background: var(--bg);
}

.filter-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state-large {
  text-align: center;
  padding: 60px 20px;
}

.empty-state-large svg {
  color: var(--text-muted);
  margin-bottom: 20px;
}

.empty-state-large h3 {
  margin-bottom: 8px;
}

.empty-state-large p {
  color: var(--text-muted);
}

/* Publication specific */
.pub-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.pub-authors {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 4px;
}

.pub-venue {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.year-badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  font-weight: 600;
  font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 16px;
  }
  
  .topbar .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .nav {
    width: 100%;
    justify-content: flex-start;
  }
  
  .page-header {
    flex-direction: column;
  }
  
  .filter-group {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-group input[type="search"],
  .filter-group select {
    width: 100%;
  }
  
  .row {
    flex-direction: column;
  }
  
  .row > div {
    min-width: 100%;
  }
  
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  
  .btn + .btn {
    margin-left: 0;
    margin-top: 8px;
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card,
.stat-card {
  animation: fadeIn 0.3s ease-out;
}

/* Login page specific */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

.login-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

/* Code/pre blocks */
code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
  font-size: 13px;
  color: var(--danger);
}
