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

:root {
  --bg:       #f7f6f3;
  --surface:  #ffffff;
  --border:   #e5e3dc;
  --ink:      #1c1c18;
  --muted:    #6a6a62;
  --hint:     #9a9a90;
  --sage:     #7a8c6e;
  --sage-bg:  #e8ede4;
  --danger:   #c4623a;
  --danger-bg:#faeee7;
  --sans:     'DM Sans', system-ui, sans-serif;
  --sidebar:  220px;
  --radius:   6px;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── LOGIN ── */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px; width: 360px;
}
.login-logo {
  font-size: 20px; letter-spacing: .1em; font-weight: 300;
  color: var(--ink); margin-bottom: 6px; display: block;
}
.login-logo span { color: var(--sage); }
.login-card h1 { font-size: 16px; font-weight: 500; margin-bottom: 24px; color: var(--muted); }

/* ── LAYOUT ── */
body:not(.login-page) { display: flex; }

.sidebar {
  width: var(--sidebar); flex-shrink: 0;
  background: var(--ink);
  height: 100vh; position: sticky; top: 0;
  display: flex; flex-direction: column;
  padding: 24px 0;
}
.sidebar-logo {
  font-size: 16px; letter-spacing: .1em; font-weight: 300;
  color: #fff; text-decoration: none;
  padding: 0 20px; margin-bottom: 28px; display: block;
}
.sidebar-logo span { color: var(--sage); }
.sidebar-nav {
  display: flex; flex-direction: column; flex: 1;
}
.sidebar-nav a {
  font-size: 13px; color: rgba(255,255,255,.5); text-decoration: none;
  padding: 10px 20px; transition: color .15s, background .15s;
  border-left: 2px solid transparent;
}
.sidebar-nav a:hover  { color: #fff; background: rgba(255,255,255,.05); }
.sidebar-nav a.active { color: #fff; border-left-color: var(--sage); background: rgba(255,255,255,.06); }
.sidebar-logout {
  font-size: 11px; color: rgba(255,255,255,.3); text-decoration: none;
  padding: 12px 20px; margin-top: 8px; transition: color .15s;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-logout:hover { color: rgba(255,255,255,.6); }

.admin-main {
  flex: 1; overflow-y: auto;
  padding: 32px 40px;
  max-width: calc(100vw - var(--sidebar));
}
.admin-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.admin-header h1 { font-size: 20px; font-weight: 500; }

/* ── STATS ── */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
}
.stat-num   { display: block; font-size: 28px; font-weight: 500; line-height: 1.1; }
.stat-label { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; letter-spacing: .05em; text-transform: uppercase; }

/* ── TABLE ── */
.articles-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.articles-table th {
  background: var(--bg); text-align: left;
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--hint); font-weight: 500;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.articles-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.articles-table tr:last-child td { border-bottom: none; }
.articles-table tr:hover td { background: #fbfaf8; }
.table-slug  { display: block; font-size: 11px; color: var(--hint); margin-top: 2px; }
.table-actions { display: flex; gap: 6px; align-items: center; }
.inline-form { display: inline; }

/* ── BADGES ── */
.badge {
  display: inline-block; font-size: 11px; font-weight: 500;
  padding: 2px 10px; border-radius: 20px; letter-spacing: .04em;
}
.badge-published { background: var(--sage-bg); color: var(--sage); }
.badge-draft     { background: #f0eeea; color: var(--hint); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--sans); font-size: 13px; font-weight: 400;
  padding: 8px 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover      { background: var(--bg); border-color: #ccc; }
.btn-primary    { background: var(--sage); border-color: var(--sage); color: #fff; }
.btn-primary:hover { background: #6a7a5f; border-color: #6a7a5f; }
.btn-danger     { background: transparent; border-color: var(--border); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-sm         { font-size: 12px; padding: 5px 12px; }
.btn-full       { width: 100%; justify-content: center; }

/* ── FORMS ── */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12px; font-weight: 500;
  letter-spacing: .04em; color: var(--muted);
  text-transform: uppercase; margin-bottom: 6px;
}
.required { color: var(--danger); }
.field input[type=text],
.field input[type=email],
.field input[type=password],
.field input[type=number],
.field select,
.field textarea {
  width: 100%;
  font-family: var(--sans); font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(122,140,110,.12);
}
.field textarea { resize: vertical; line-height: 1.6; }
.field-hint { font-size: 11px; color: var(--hint); margin-top: 4px; display: block; }

.slug-preview { display: flex; align-items: center; }
.slug-base {
  background: var(--bg); border: 1px solid var(--border);
  border-right: none; border-radius: var(--radius) 0 0 var(--radius);
  padding: 9px 10px; font-size: 13px; color: var(--hint);
  white-space: nowrap;
}
.slug-preview input {
  border-radius: 0 var(--radius) var(--radius) 0 !important;
}

/* ── ALERT ── */
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f5c4af; }

/* ── ARTICLE FORM LAYOUT ── */
.form-layout { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
.form-main   { display: flex; flex-direction: column; gap: 0; }

.form-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.form-panel h3 {
  font-size: 12px; font-weight: 500; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 16px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ── EDITOR TOOLBAR ── */
.editor-toolbar {
  display: flex; gap: 4px; align-items: center;
  background: var(--bg); border: 1px solid var(--border);
  border-bottom: none; border-radius: var(--radius) var(--radius) 0 0;
  padding: 6px 8px;
}
.editor-toolbar button {
  font-family: var(--sans); font-size: 12px; font-weight: 500;
  padding: 4px 10px; border-radius: 4px;
  border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer; transition: background .15s;
}
.editor-toolbar button:hover { background: var(--surface); border-color: var(--border); color: var(--ink); }
.editor-toolbar + textarea {
  border-radius: 0 0 var(--radius) var(--radius) !important;
  font-family: 'Menlo', 'Consolas', monospace !important;
  font-size: 13px !important;
}
.toolbar-hint { margin-left: auto; font-size: 11px; color: var(--hint); }

/* ── SERP PREVIEW ── */
.serp-preview {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-top: 12px;
}
.serp-title { font-size: 15px; color: #1a0dab; margin-bottom: 2px;
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.serp-url   { font-size: 12px; color: #006621; margin-bottom: 4px; }
.serp-desc  { font-size: 12px; color: #545454; line-height: 1.5;
              display: -webkit-box; -webkit-line-clamp: 2;
              -webkit-box-orient: vertical; overflow: hidden; }

/* ── EMPTY STATE ── */
.empty-state { padding: 48px 0; text-align: center; color: var(--hint); }
.empty-state a { color: var(--sage); text-decoration: none; }
