:root {
  --navy: #1c2733;
  --accent: #3a8ee6;
  --ok: #27ae60;
  --bad: #c0392b;
  --warn: #e67e22;
  --bg: #f4f6f8;
  --border: #dfe3e8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: #1a1a1a;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--navy);
  color: white;
  display: flex;
  flex-direction: column;
  padding: 24px 0;
}

.sidebar .brand {
  font-weight: 700;
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.sidebar .brand span {
  font-weight: 400;
  font-size: 12px;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.sidebar nav a {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  padding: 12px 24px;
  border-left: 3px solid transparent;
}

.sidebar nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
}

.sidebar nav a.active {
  background: rgba(255, 255, 255, 0.08);
  color: white;
  border-left-color: var(--accent);
  font-weight: 600;
}

.sidebar .logout {
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  padding: 12px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
}

.sidebar .logout:hover { color: white; }

.layout main { flex: 1; max-width: 960px; padding: 32px 40px; }

main.no-sidebar { max-width: 960px; margin: 32px auto; padding: 0 20px; }

h1 { margin-top: 0; }

.login-box {
  max-width: 420px;
  margin: 80px auto;
  text-align: center;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
}

.error { color: var(--bad); }

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

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 22px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card .label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: #6b7280; }
.card .value { font-size: 24px; font-weight: 700; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.data-table th, .data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th { background: var(--navy); color: white; }
.data-table td.ok { color: var(--ok); font-weight: 600; }
.data-table td.bad { color: var(--bad); font-weight: 600; }
.data-table td.warn { color: var(--warn); font-weight: 600; }

.bar {
  position: relative;
  background: var(--border);
  border-radius: 6px;
  height: 20px;
  min-width: 120px;
}

.bar::before {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--pct);
  background: var(--accent);
  border-radius: 6px;
}

.bar span {
  position: relative;
  z-index: 1;
  font-size: 12px;
  padding-left: 8px;
  line-height: 20px;
}

.hint { color: #6b7280; font-size: 13px; }
.success { color: var(--ok); }

h2 { margin-top: 32px; margin-bottom: 8px; font-size: 16px; }

.data-table td.col-action { text-align: right; }

.editor-form textarea {
  width: 100%;
  font-family: "Consolas", "Menlo", monospace;
  font-size: 13.5px;
  line-height: 1.5;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
}

.editor-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.editor-actions button {
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
}

.editor-actions button[value="save"] { background: var(--accent); color: white; }
.editor-actions button.secondary { background: white; border: 1px solid var(--border); color: #374151; }

.preview-box {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 22px;
  white-space: pre-wrap;
  line-height: 1.5;
}

.muted { color: #6b7280; font-weight: 400; font-size: 15px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-ok { background: rgba(39, 174, 96, 0.12); color: var(--ok); }
.badge-bad { background: rgba(192, 57, 43, 0.12); color: var(--bad); }

.search-form {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  max-width: 420px;
}

.search-form input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.search-form button, .editor-actions button, .inline-form button {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  background: var(--accent);
  color: white;
}

.actions-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}

.inline-form input[type="text"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  width: 140px;
}

.inline-form button.secondary { background: white; border: 1px solid var(--border); color: #374151; }
.inline-form button.danger { background: var(--bad); }

.button-link {
  display: inline-flex;
  align-items: center;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  color: #374151;
  text-decoration: none;
  font-size: 14px;
}

.button-link:hover { border-color: var(--accent); color: var(--accent); }
