:root {
  --sidebar: #0f2922;
  --sidebar-text: #b8d4cb;
  --primary: #1b6b52;
  --primary-dark: #145a44;
  --danger: #dc2626;
  --bg: #f0f4f2;
  --surface: #fff;
  --border: #d8e4de;
  --text: #1a2e28;
  --muted: #5c6f68;
}

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

body {
  font-family: "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f2922, #1b6b52);
}

.login-card {
  background: var(--surface);
  padding: 40px;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-card h1 { font-size: 1.4rem; color: var(--primary-dark); }
.subtitle { color: var(--muted); margin-bottom: 24px; font-size: 0.9rem; }

.login-card label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }
.login-card input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  font: inherit;
}

.login-hint { font-size: 0.78rem; color: var(--muted); margin-top: 12px; }
.back-link { display: block; text-align: center; margin-top: 20px; font-size: 0.88rem; }

/* Layout */
.admin-app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand strong { color: #fff; display: block; font-size: 0.95rem; }
.stats-badge { font-size: 0.72rem; opacity: 0.7; margin-top: 6px; display: block; }

.sidebar-nav { flex: 1; padding: 12px 10px; }

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font: inherit;
  font-size: 0.88rem;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
}

.nav-item:hover { background: rgba(255,255,255,0.06); }
.nav-item.active { background: var(--primary); color: #fff; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.82rem;
}

.sidebar-footer a { color: #7dd3ac; }
.btn-text { background: none; border: none; color: var(--sidebar-text); cursor: pointer; margin-top: 8px; font-size: 0.82rem; }

.admin-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.admin-header {
  padding: 20px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-header h2 { font-size: 1.25rem; }

.tab-panel { padding: 24px 28px; overflow: auto; flex: 1; }

/* Dashboard */
.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.dash-card .num { font-size: 2rem; font-weight: 700; color: var(--primary); }
.dash-card .lbl { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }

.hint-block {
  margin-top: 20px;
  padding: 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #92400e;
}

/* Toolbar & Table */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input, .toolbar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  min-width: 160px;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th {
  background: #f4f9f7;
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tr:hover td { background: #fafcfb; }

.btn-row { display: flex; gap: 6px; }
.btn-sm {
  padding: 4px 10px;
  font-size: 0.78rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.btn-sm:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm.danger:hover { border-color: var(--danger); color: var(--danger); }

.btn {
  padding: 8px 16px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Data tab */
.data-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.action-card h3 { margin-bottom: 8px; font-size: 1rem; }
.action-card p { font-size: 0.85rem; color: var(--muted); margin-bottom: 14px; }
.action-card.danger { border-color: #fecaca; }
.action-card input[type=file] { margin-bottom: 10px; font-size: 0.85rem; }

.settings-form {
  max-width: 400px;
  background: var(--surface);
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.settings-form label { display: block; font-weight: 600; margin-bottom: 12px; }
.settings-form input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  font: inherit;
}

/* Modal */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.2);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 4px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 0.88rem;
}
.form-field textarea { min-height: 60px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

@media (max-width: 768px) {
  .admin-app { flex-direction: column; }
  .sidebar { width: 100%; }
}
