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

:root {
  --bg: #faf8f5;
  --card: #ffffff;
  --accent: #c4884a;
  --accent-hover: #b37a3f;
  --text: #2c2c2c;
  --text-light: #6b6b6b;
  --border: #e5e1dc;
  --danger: #c0392b;
  --danger-hover: #a93226;
  --success: #27ae60;
  --diff-add: #eafbe7;
  --diff-remove: #fdeaea;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: Georgia, 'Times New Roman', serif; font-weight: 600; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
.header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-title {
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-right: 32px;
  white-space: nowrap;
}
.header-title span { color: var(--accent); }
.header-nav { display: flex; gap: 4px; flex: 1; }
.header-nav button {
  background: none;
  border: none;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-light);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}
.header-nav button:hover { background: var(--bg); color: var(--text); }
.header-nav button.active { background: var(--bg); color: var(--accent); font-weight: 500; }
.header-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-light);
}
.header-user img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}
.btn-logout {
  background: none;
  border: 1px solid var(--border);
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 20px;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.15s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ── Login ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  background: var(--card);
  padding: 48px 40px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-width: 400px;
  width: 100%;
  border: 1px solid var(--border);
}
.login-card h1 { font-size: 28px; margin-bottom: 8px; }
.login-card h1 span { color: var(--accent); }
.login-card .subtitle {
  font-style: italic;
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 32px;
}
.btn-discord {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 28px;
  font-size: 15px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  font-weight: 500;
}
.btn-discord:hover { background: var(--accent-hover); }

/* ── Layout ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}
.card h2 { font-size: 20px; margin-bottom: 16px; }
.card h3 { font-size: 16px; margin-bottom: 12px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: white; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11px;
  border-radius: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-light);
}
.badge-accent { background: #fdf0e2; border-color: #e8c89a; color: var(--accent); }

/* ── Forms ── */
input[type="text"], input[type="search"], textarea, select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 200px; font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace; font-size: 13px; }

label { font-size: 13px; font-weight: 500; display: block; margin-bottom: 4px; }
.form-row { margin-bottom: 16px; }
.form-inline { display: flex; gap: 8px; align-items: end; }
.form-inline .form-row { flex: 1; margin-bottom: 0; }

/* ── Table ── */
.env-table { width: 100%; border-collapse: collapse; }
.env-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
}
.env-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}
.env-table tr:hover { background: #fdfcfa; }
.env-table .key-cell {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.env-table .value-cell {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  word-break: break-all;
  max-width: 400px;
}
.env-table input[type="text"] {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  padding: 6px 8px;
}
.masked-value {
  color: var(--text-light);
  cursor: pointer;
  user-select: none;
}
.masked-value:hover { color: var(--accent); }

/* ── Projects list ── */
.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--card);
  cursor: pointer;
  transition: all 0.15s;
}
.project-item:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.project-name { font-weight: 600; font-size: 15px; }
.project-path { font-size: 12px; color: var(--text-light); font-family: monospace; margin-top: 2px; }
.project-tags { display: flex; gap: 4px; margin-top: 4px; }
.project-actions { display: flex; gap: 4px; }

/* ── Diff ── */
.diff-container { margin: 16px 0; }
.diff-row {
  display: flex;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  line-height: 1.6;
}
.diff-row.added { background: var(--diff-add); }
.diff-row.removed { background: var(--diff-remove); }
.diff-sign { width: 20px; text-align: center; flex-shrink: 0; font-weight: 700; }
.diff-content { padding: 2px 8px; flex: 1; }

/* ── Search results ── */
.search-result {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}
.search-result h4 { margin-bottom: 8px; }
.search-match {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  padding: 4px 0;
}
.search-match .key { font-weight: 600; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 28px;
  max-width: 560px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  border: 1px solid var(--border);
}
.modal h3 { font-size: 18px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Validation warnings ── */
.warning {
  background: #fef9e7;
  border: 1px solid #f0d78c;
  color: #8a6d0b;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ── Toggle ── */
.toggle-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.toggle-group button {
  border: none;
  background: var(--card);
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.15s;
}
.toggle-group button.active { background: var(--accent); color: white; }
.toggle-group button:not(:last-child) { border-right: 1px solid var(--border); }

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }

/* ── History ── */
.history-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.history-item:last-child { border-bottom: none; }
.history-action { font-weight: 600; }
.history-time { color: var(--text-light); font-size: 12px; }
.history-key { font-family: monospace; background: var(--bg); padding: 1px 6px; border-radius: 4px; }

/* ── Tabs (section) ── */
.section-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.section-tabs button {
  background: none;
  border: none;
  padding: 10px 18px;
  font-size: 14px;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.section-tabs button:hover { color: var(--text); }
.section-tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-light);
}
.empty-state h3 { margin-bottom: 8px; color: var(--text); }

/* ── Copy selector ── */
.copy-selector label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-family: monospace;
  font-size: 13px;
  cursor: pointer;
}
.copy-selector input[type="checkbox"] { accent-color: var(--accent); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .container { padding: 16px; }
  .header { padding: 0 12px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .form-inline { flex-direction: column; }
}
