/* Admin dashboard — a premium, minimal, modern SaaS-console visual language,
   deliberately distinct from the public site's dark marketing aesthetic
   (spec §46). Icons are inline SVG (see App\Support\Icons) — no emoji, no
   external icon font. */
:root {
  --a-bg: #f7f8f7; --a-panel: #ffffff; --a-line: #e8eae8; --a-line-soft: #f0f2f0;
  --a-fg: #141815; --a-mute: #6b756e; --a-mute-soft: #9aa39c;
  --a-acc: #16a34a; --a-acc-lit: #22c55e; --a-acc-soft: #ecfdf3; --a-acc-ring: rgba(22,163,74,0.18);
  --a-danger: #dc2626; --a-danger-soft: #fef2f2; --a-warn: #d97706;
  --a-sidebar: #0d1310; --a-sidebar-line: rgba(255,255,255,0.07); --a-sidebar-fg: #aab5ae; --a-sidebar-mute: #5c6961;
  --a-radius: 0.85rem; --a-radius-sm: 0.55rem;
  --a-shadow-sm: 0 1px 2px rgba(15,23,18,0.04);
  --a-shadow: 0 1px 3px rgba(15,23,18,0.06), 0 8px 24px -8px rgba(15,23,18,0.08);
  --a-sidebar-w: 248px;
}
* { box-sizing: border-box; }
body.admin {
  margin: 0; background: var(--a-bg); color: var(--a-fg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--a-acc); text-decoration: none; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.a-icon { display: inline-block; vertical-align: -3px; flex-shrink: 0; }

/* ── shell ───────────────────────────────────────────────────────────── */
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: var(--a-sidebar-w); flex: none; background: var(--a-sidebar); color: var(--a-sidebar-fg);
  padding: 1.1rem 0.85rem 1.5rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--a-sidebar-line);
}
.admin-sidebar__brand {
  display: flex; align-items: center; gap: 0.55rem; color: #fff; font-weight: 700; font-size: 1rem;
  padding: 0.5rem 0.6rem 1.3rem; letter-spacing: -0.01em;
}
.admin-sidebar__brand-mark {
  width: 1.6rem; height: 1.6rem; border-radius: 0.5rem; background: linear-gradient(145deg, var(--a-acc-lit), var(--a-acc));
  display: grid; place-items: center; color: #04140a; font-weight: 800; font-size: 0.82rem; flex-shrink: 0;
}
.admin-sidebar__group {
  font-size: 0.66rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--a-sidebar-mute); padding: 1.15rem 0.65rem 0.5rem;
}
.admin-sidebar a.nav-link {
  display: flex; align-items: center; gap: 0.65rem; padding: 0.52rem 0.65rem; border-radius: var(--a-radius-sm);
  color: var(--a-sidebar-fg); font-size: 0.86rem; font-weight: 500; margin-bottom: 0.1rem;
  transition: background .12s ease, color .12s ease;
}
.admin-sidebar a.nav-link .a-icon { opacity: 0.75; transition: opacity .12s ease; }
.admin-sidebar a.nav-link:hover { background: rgba(255,255,255,0.055); color: #fff; }
.admin-sidebar a.nav-link:hover .a-icon { opacity: 1; }
.admin-sidebar a.nav-link.is-active { background: var(--a-acc); color: #04140a; font-weight: 600; }
.admin-sidebar a.nav-link.is-active .a-icon { opacity: 1; }

.admin-main { flex: 1; min-width: 0; }
.admin-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem 1.6rem; background: rgba(255,255,255,0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--a-line); position: sticky; top: 0; z-index: 20;
}
.admin-topbar__title { font-size: 0.98rem; font-weight: 600; }
.admin-content { padding: 1.7rem 1.6rem 3.5rem; max-width: 1400px; }

.mobile-toggle-btn { display: none; }
.sidebar-scrim { display: none; }

/* ── stat cards ──────────────────────────────────────────────────────── */
.a-cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 1.8rem; }
.a-card {
  background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--a-radius);
  padding: 1.15rem 1.25rem; box-shadow: var(--a-shadow-sm); transition: box-shadow .15s ease, transform .15s ease;
}
.a-card:hover { box-shadow: var(--a-shadow); transform: translateY(-1px); }
.a-card__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.7rem; }
.a-card__icon { width: 2rem; height: 2rem; border-radius: 0.55rem; background: var(--a-acc-soft); color: var(--a-acc); display: grid; place-items: center; }
.a-card__label { font-size: 0.74rem; color: var(--a-mute); margin-bottom: 0.35rem; font-weight: 500; }
.a-card__value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.a-card__value.warn { color: var(--a-warn); }
.a-card__value.danger { color: var(--a-danger); }

/* ── panels ──────────────────────────────────────────────────────────── */
.a-panel { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--a-radius); padding: 1.4rem; margin-bottom: 1.4rem; box-shadow: var(--a-shadow-sm); }
.a-panel h2, .a-panel h3 { margin: 0 0 1rem; font-size: 1.02rem; }
.a-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.a-panel-head h1, .a-panel-head h2 { margin: 0; }

/* ── responsive layout primitives ───────────────────────────────────── */
.a-split { display: grid; gap: 1.4rem; grid-template-columns: 1fr 320px; align-items: start; }
.a-split--narrow { grid-template-columns: 1fr 300px; }
.a-split--wide { grid-template-columns: 1fr 340px; }
@media (max-width: 900px) { .a-split, .a-split--narrow, .a-split--wide { grid-template-columns: 1fr; } }

.a-grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .a-grid-2 { grid-template-columns: 1fr; } }

.a-table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── tables ──────────────────────────────────────────────────────────── */
table.a-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 560px; }
table.a-table th { text-align: left; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--a-mute); padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--a-line); white-space: nowrap; }
table.a-table td { padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--a-line-soft); vertical-align: middle; }
table.a-table tr:last-child td { border-bottom: none; }
table.a-table tr:hover td { background: #fafbfa; }

/* ── badges ──────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 0.24rem 0.65rem; border-radius: 999px; font-size: 0.71rem; font-weight: 600; white-space: nowrap; }
.badge-new { background: #dbeafe; color: #1d4ed8; }
.badge-contacted { background: #e0e7ff; color: #4338ca; }
.badge-follow_up { background: #fef3c7; color: #92400e; }
.badge-qualified { background: #ede9fe; color: #6d28d9; }
.badge-proposal_sent { background: #fce7f3; color: #be185d; }
.badge-negotiation { background: #ffedd5; color: #c2410c; }
.badge-won { background: #dcfce7; color: #15803d; }
.badge-lost { background: #fee2e2; color: #b91c1c; }
.badge-archived { background: #f3f4f6; color: #4b5563; }
.badge-low { background: #f3f4f6; color: #4b5563; }
.badge-medium { background: #dbeafe; color: #1d4ed8; }
.badge-high { background: #ffedd5; color: #c2410c; }
.badge-urgent { background: #fee2e2; color: #b91c1c; }

/* ── buttons ─────────────────────────────────────────────────────────── */
.a-btn {
  display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.58rem 1.15rem; border-radius: var(--a-radius-sm);
  background: var(--a-acc); color: #fff; border: 1px solid transparent; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: background .12s ease, box-shadow .12s ease, transform .1s ease; box-shadow: var(--a-shadow-sm);
}
.a-btn:hover { background: #128a3e; }
.a-btn:active { transform: translateY(1px); }
.a-btn.ghost { background: transparent; color: var(--a-fg); border-color: var(--a-line); box-shadow: none; }
.a-btn.ghost:hover { background: var(--a-line-soft); }
.a-btn.danger { background: var(--a-danger); }
.a-btn.danger:hover { background: #b91c1c; }
.a-btn.small { padding: 0.38rem 0.8rem; font-size: 0.78rem; }
.a-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.a-icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; padding: 0;
  border-radius: var(--a-radius-sm); background: transparent; border: 1px solid var(--a-line); color: var(--a-mute); cursor: pointer;
  transition: all .12s ease;
}
.a-icon-btn:hover { background: var(--a-line-soft); color: var(--a-fg); }
.a-icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.a-icon-btn.danger:hover { background: var(--a-danger-soft); color: var(--a-danger); border-color: #fecaca; }

/* ── forms ───────────────────────────────────────────────────────────── */
.a-field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1.05rem; }
.a-field label { font-size: 0.81rem; font-weight: 600; color: #374151; }
.a-field input, .a-field select, .a-field textarea {
  padding: 0.62rem 0.78rem; border: 1px solid var(--a-line); border-radius: var(--a-radius-sm);
  font-family: inherit; font-size: 0.87rem; color: var(--a-fg); background: #fff; transition: border-color .12s ease, box-shadow .12s ease;
  width: 100%;
}
.a-field input:focus, .a-field select:focus, .a-field textarea:focus { outline: none; border-color: var(--a-acc); box-shadow: 0 0 0 3px var(--a-acc-ring); }
.a-field input[type="file"] { padding: 0.4rem; border-style: dashed; }
.a-hint { font-size: 0.76rem; color: var(--a-mute); }
.a-error { font-size: 0.78rem; color: var(--a-danger); }

/* ── alerts ──────────────────────────────────────────────────────────── */
.a-alert { padding: 0.8rem 1.1rem; border-radius: var(--a-radius-sm); font-size: 0.85rem; margin-bottom: 1.2rem; border: 1px solid transparent; }
.a-alert.success { background: var(--a-acc-soft); color: #166534; border-color: #bbf7d0; }
.a-alert.error { background: var(--a-danger-soft); color: #991b1b; border-color: #fecaca; }

/* ── kanban ──────────────────────────────────────────────────────────── */
.kanban { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; -webkit-overflow-scrolling: touch; }
.kanban-col { flex: 0 0 260px; background: #eef1ef; border-radius: var(--a-radius); padding: 0.75rem; }
.kanban-col__head { display: flex; justify-content: space-between; font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--a-mute); padding: 0.3rem 0.4rem 0.7rem; }
.kanban-card { background: #fff; border: 1px solid var(--a-line); border-radius: 0.65rem; padding: 0.75rem 0.8rem; margin-bottom: 0.6rem; cursor: grab; font-size: 0.82rem; box-shadow: var(--a-shadow-sm); }
.kanban-card:active { cursor: grabbing; }
.kanban-card h4 { margin: 0 0 0.3rem; font-size: 0.87rem; font-weight: 600; }
.kanban-card .meta { color: var(--a-mute); font-size: 0.76rem; }
.kanban-col.drag-over { background: #dfe6e2; }

/* ── login ───────────────────────────────────────────────────────────── */
.login-shell { min-height: 100vh; display: grid; place-items: center; background: var(--a-sidebar); padding: 1.5rem; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 1.1rem; padding: 2.3rem; box-shadow: 0 20px 60px rgba(0,0,0,0.35); }
.login-card__brand { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1.6rem; }
.login-card h1 { font-size: 1.25rem; margin: 0 0 1.5rem; }

/* ── misc ────────────────────────────────────────────────────────────── */
.a-empty { text-align: center; color: var(--a-mute); padding: 2.5rem 1rem; font-size: 0.88rem; }
.a-divider { border: none; border-top: 1px solid var(--a-line); margin: 1.3rem 0; }
.a-list-row { display: flex; gap: 0.6rem; align-items: center; padding: 0.65rem 0; border-top: 1px solid var(--a-line-soft); }
.a-list-row:first-child { border-top: none; }
.a-chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.3rem 0.7rem; border-radius: 999px; border: 1px solid var(--a-line); font-size: 0.78rem; color: var(--a-mute); }

/* ── responsive ──────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .mobile-toggle-btn { display: inline-flex; }
  .admin-sidebar {
    position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: 0 0 0 100vmax rgba(0,0,0,0); width: 260px;
  }
  .admin-sidebar.is-open { transform: translateX(0); }
  .sidebar-scrim.is-open {
    display: block; position: fixed; inset: 0; background: rgba(10,15,12,0.45); z-index: 45;
  }
  .admin-content { padding: 1.3rem 1rem 3rem; }
  .admin-topbar { padding: 0.75rem 1rem; }
  .a-cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.7rem; }
}
@media (max-width: 480px) {
  .admin-topbar__user-text { display: none; }
}

/* ── Blog post WYSIWYG editor ─────────────────────────────────────────── */
.post-editor { border: 1px solid var(--a-line); border-radius: var(--a-radius); overflow: hidden; }
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 0.2rem; padding: 0.5rem; background: var(--a-bg);
  border-bottom: 1px solid var(--a-line);
}
.editor-toolbar button {
  background: transparent; border: 1px solid transparent; border-radius: 0.4rem; color: var(--a-fg);
  font-size: 0.8rem; font-weight: 600; padding: 0.35rem 0.6rem; cursor: pointer; line-height: 1;
}
.editor-toolbar button:hover { background: var(--a-line-soft); }
.editor-toolbar button.active { background: var(--a-acc-soft); color: var(--a-acc); border-color: var(--a-acc-ring); }
.editor-toolbar .sep { width: 1px; background: var(--a-line); margin: 0.2rem 0.3rem; }
.editor-canvas {
  min-height: 320px; padding: 1rem 1.2rem; font-size: 0.92rem; line-height: 1.65; outline: none;
}
.editor-canvas h2 { font-size: 1.3rem; margin: 1rem 0 0.5rem; }
.editor-canvas h3 { font-size: 1.1rem; margin: 0.9rem 0 0.4rem; }
.editor-canvas blockquote { border-left: 3px solid var(--a-acc); margin: 0.8rem 0; padding: 0.3rem 0 0.3rem 1rem; color: var(--a-mute); }
.editor-canvas img { max-width: 100%; border-radius: 0.4rem; }
.editor-canvas a { text-decoration: underline; }
.editor-source {
  display: none; width: 100%; min-height: 320px; border: none; padding: 1rem 1.2rem; font-size: 0.82rem;
  font-family: ui-monospace, monospace; resize: vertical; background: var(--a-panel); color: var(--a-fg);
}

/* ── Calendar / Notes ─────────────────────────────────────────────────── */
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.4rem; margin-bottom: 0.5rem;
}
.cal-weekdays span {
  text-align: center; font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--a-mute);
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.4rem; }
.cal-day {
  position: relative; aspect-ratio: 1; border: 1px solid var(--a-line); border-radius: 0.5rem;
  background: var(--a-panel); cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.15rem; font-size: 0.85rem; color: var(--a-fg);
  transition: background 0.15s, border-color 0.15s;
}
.cal-day:hover { background: var(--a-line-soft); border-color: var(--a-acc-ring); }
.cal-day--empty { visibility: hidden; cursor: default; border: none; }
.cal-day--today { border-color: var(--a-acc); font-weight: 700; }
.cal-day--has-notes { background: var(--a-acc-soft); }
.cal-day__dot {
  font-size: 0.62rem; font-weight: 700; color: #fff; background: var(--a-acc);
  border-radius: 999px; min-width: 1.1rem; height: 1.1rem; display: flex; align-items: center;
  justify-content: center; padding: 0 0.25rem;
}
.cal-dialog {
  border: 1px solid var(--a-line); border-radius: var(--a-radius); padding: 1.4rem;
  max-width: 420px; width: 90vw; box-shadow: var(--a-shadow-lg, 0 20px 40px rgba(0,0,0,0.2));
  background: var(--a-panel); color: var(--a-fg);
}
.cal-dialog::backdrop { background: rgba(10,15,12,0.5); }
.cal-dialog h3 { margin: 0 0 0.8rem; font-size: 1rem; }
.cal-dialog textarea {
  width: 100%; border: 1px solid var(--a-line); border-radius: 0.5rem; padding: 0.6rem;
  font-size: 0.85rem; font-family: inherit; resize: vertical; margin-top: 0.6rem;
}
.cal-dialog__actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.8rem; }
.cal-note-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.6rem;
  padding: 0.5rem 0; border-bottom: 1px solid var(--a-line-soft); font-size: 0.84rem;
}
.cal-note-row:last-child { border-bottom: none; }
.cal-note-row form { margin: 0; }
.cal-note-row button { background: none; border: none; color: var(--a-mute); cursor: pointer; }
.cal-note-row button:hover { color: #b91c1c; }

.quick-note {
  border: 1px solid var(--a-line); border-radius: 0.6rem; padding: 0.7rem 0.9rem; margin-bottom: 0.6rem;
}
.quick-note p { margin: 0 0 0.5rem; font-size: 0.86rem; white-space: pre-wrap; }
.quick-note__meta {
  display: flex; justify-content: space-between; align-items: center; font-size: 0.72rem; color: var(--a-mute);
}
.quick-note__meta form { margin: 0; }
