/* fresh v2 */
/* ============================================================
   KEEFII DATACORE — Admin Styles
   Matches keefii-app-v2 admin CSS conventions
   ============================================================ */

/* --- Design Tokens --- */
:root, .dc-root {
  --bg-base: #f7f3ec;
  --bg-surface: #ffffff;
  --bg-elevated: #f1ece4;
  --bg-card: rgba(255,255,255,0.92);
  --accent-1: #1f8f5f;
  --accent-2: #38c793;
  --accent-tint-xs: rgba(31,143,95,0.05);
  --accent-tint-sm: rgba(31,143,95,0.08);
  --accent-tint-md: rgba(31,143,95,0.12);
  --accent-tint-lg: rgba(31,143,95,0.20);
  --text-strong: #1a1f27;
  --text-body: #48505d;
  --text-muted: #6b7482;
  --text-soft: #8e97a6;
  --border-subtle: rgba(25,31,42,0.10);
  --line-subtle: rgba(25,31,42,0.08);
  --r-xs: 12px;
  --r-sm: 18px;
  --r-md: 22px;
  --sidebar-bg: #071510;
  --sidebar-width: 220px;
  --topbar-height: 56px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, system-ui, sans-serif;
  background: var(--bg-base); color: var(--text-body); line-height: 1.5;
  overflow: hidden; height: 100vh;
}
a { color: var(--accent-1); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font: inherit; }
svg { display: block; }

/* --- Root Layout --- */
.dc-root {
  display: flex; flex-direction: column; height: 100vh;
  background: var(--sidebar-bg);
}

/* --- Topbar (mobile only) --- */
.dc-topbar {
  display: none; height: var(--topbar-height);
  background: var(--sidebar-bg); border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0 16px; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 100;
}
.dc-topbar__toggle {
  background: none; border: none; color: #8e97a6; padding: 4px;
  display: flex; align-items: center;
}
.dc-topbar__title { color: #e8e4dc; font-weight: 600; font-size: 0.9rem; flex: 1; }
.dc-topbar__badge {
  font-size: 0.68rem; color: var(--accent-2); text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 600;
}

/* --- Shell Layout --- */
.dc-shell { display: flex; flex: 1; overflow: hidden; }

/* --- Sidebar (desktop) --- */
.dc-sidebar {
  width: var(--sidebar-width); min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column; overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.04);
}
.dc-sidebar__brand {
  display: flex; align-items: center; gap: 8px;
  padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.dc-sidebar__logo { flex-shrink: 0; }
.dc-sidebar__wordmark {
  color: #e8e4dc; font-weight: 700; font-size: 1rem; letter-spacing: -0.02em;
}
.dc-sidebar__pill {
  font-size: 0.62rem; background: rgba(56,199,147,0.12); color: var(--accent-2);
  padding: 2px 7px; border-radius: 8px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; margin-left: auto;
}

/* --- Sidebar Nav --- */
.dc-sidebar__nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.dc-nav-section { margin-bottom: 4px; }
.dc-nav-section__title {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: rgba(255,255,255,0.25);
  padding: 12px 16px 6px;
}
.dc-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; color: rgba(255,255,255,0.55);
  font-size: 0.82rem; font-weight: 500; text-decoration: none;
  border-left: 3px solid transparent; transition: all 0.12s;
}
.dc-nav-item:hover { color: #e8e4dc; text-decoration: none; background: rgba(255,255,255,0.03); }
.dc-nav-item.is-active {
  color: #ffffff; background: rgba(56,199,147,0.08);
  border-left-color: var(--accent-2); font-weight: 600;
}
.dc-nav-item__icon { display: flex; opacity: 0.7; }
.dc-nav-item.is-active .dc-nav-item__icon { opacity: 1; }
.dc-nav-item__label { flex: 1; }

/* --- Sidebar Footer --- */
.dc-sidebar__footer {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.04);
}
.dc-sidebar-footer-link {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.78rem; color: rgba(255,255,255,0.4); text-decoration: none;
}
.dc-sidebar-footer-link:hover { color: #e8e4dc; text-decoration: none; }

/* --- Main Body --- */
.dc-body {
  flex: 1; overflow: hidden; background: var(--bg-base);
  display: flex; flex-direction: column;
}
.dc-main {
  flex: 1; overflow-y: auto; padding: 20px 24px;
}

/* --- Views --- */
.dc-view { display: block; }
.dc-view[hidden] { display: none; }

/* --- Loading --- */
.dc-loading {
  padding: 40px; text-align: center; color: var(--text-muted);
  font-size: 0.9rem;
}
.dc-loading::after { content: '...'; animation: dots 1.5s steps(4) infinite; }
@keyframes dots { 0%, 20% { content: '.'; } 40% { content: '..'; } 60% { content: '...'; } 100% { content: ''; } }

/* --- Error --- */
.dc-error {
  padding: 24px; background: rgba(239,68,68,0.06); border: 1px solid rgba(239,68,68,0.15);
  border-radius: var(--r-xs); color: #dc2626; font-size: 0.84rem;
}

/* --- Panel (Card) --- */
.dc-panel {
  background: var(--bg-surface); border-radius: var(--r-md);
  border: 1px solid var(--border-subtle); box-shadow: 0 10px 24px rgba(0,0,0,0.23);
  padding: 18px; margin-bottom: 16px;
}
.dc-panel__head { margin-bottom: 12px; }
.dc-panel__eyebrow {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--accent-1); margin-bottom: 2px;
  display: flex; align-items: center; gap: 8px;
}
.dc-panel__eyebrow::before {
  content: ''; width: 24px; height: 2px;
  background: linear-gradient(90deg, var(--accent-1), transparent);
  border-radius: 1px;
}
.dc-panel__title { font-size: 1rem; font-weight: 700; color: var(--text-strong); }

/* --- Stats Grid --- */
.dc-stats {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.dc-stat {
  background: var(--bg-surface); border-radius: var(--r-sm);
  border: 1px solid var(--border-subtle); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.dc-stat__value { font-size: 1.5rem; font-weight: 700; color: var(--text-strong); }
.dc-stat__label { font-size: 0.74rem; color: var(--text-muted); }
.dc-stat__sub {
  font-size: 0.78rem; color: var(--text-soft); margin-top: 2px;
}

/* --- Data Table Shell --- */
.dc-table-shell {
  overflow: auto; border-radius: var(--r-xs);
  border: 1px solid var(--border-subtle);
  background: rgba(255,255,255,0.7); margin-bottom: 12px;
}
.dc-table-shell--tall { max-height: 400px; }

.dc-table {
  width: 100%; min-width: 600px; border-collapse: collapse;
  font-size: 0.82rem;
}
.dc-table th {
  text-align: left; padding: 8px 12px;
  color: var(--text-muted); font-size: 0.68rem;
  font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  background: rgba(31,143,95,0.03);
  border-bottom: 1px solid var(--line-subtle); position: sticky; top: 0;
}
.dc-table td {
  padding: 8px 12px; border-bottom: 1px solid var(--line-subtle);
  color: var(--text-body); vertical-align: top;
}
.dc-table tr:hover td { background: var(--accent-tint-xs); }
.dc-table__mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.78rem; }
.dc-table__empty { text-align: center; padding: 24px !important; color: var(--text-soft); }

/* --- Pill Badges --- */
.dc-pill {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  padding: 2px 8px; border-radius: 10px; text-transform: capitalize;
  border: 1px solid var(--border-subtle); background: var(--accent-tint-xs);
  color: var(--text-body);
}
.dc-pill--ok { background: rgba(31,143,95,0.1); color: var(--accent-1); border-color: rgba(31,143,95,0.15); }
.dc-pill--error { background: rgba(239,68,68,0.08); color: #dc2626; border-color: rgba(239,68,68,0.15); }
.dc-pill--warning { background: rgba(245,158,11,0.08); color: #b45309; border-color: rgba(245,158,11,0.15); }
.dc-pill--muted { background: transparent; color: var(--text-soft); border-color: var(--border-subtle); }
.dc-pill--done { background: rgba(31,143,95,0.12); color: #166534; border-color: rgba(31,143,95,0.2); }
.dc-pill--bound { background: rgba(59,130,246,0.08); color: #1d4ed8; border-color: rgba(59,130,246,0.15); }
.dc-pill--syncing { background: rgba(245,158,11,0.1); color: #b45309; border-color: rgba(245,158,11,0.15); }

/* --- Filters Row --- */
.dc-filters {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 12px;
}
.dc-input {
  padding: 7px 12px; border: 1px solid var(--border-subtle);
  border-radius: 10px; font-size: 0.82rem; background: var(--bg-surface);
  color: var(--text-body); outline: none; flex: 1; min-width: 180px;
}
.dc-input:focus { border-color: var(--accent-1); box-shadow: 0 0 0 2px var(--accent-tint-md); }
.dc-input--sm { min-width: 100px; flex: 0 0 auto; }
.dc-select {
  padding: 7px 12px; border: 1px solid var(--border-subtle);
  border-radius: 10px; font-size: 0.82rem; background: var(--bg-surface);
  color: var(--text-body); outline: none; cursor: pointer;
}
.dc-select:focus { border-color: var(--accent-1); }

/* --- Buttons --- */
.dc-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border: 1px solid var(--border-subtle);
  border-radius: 10px; font-size: 0.82rem; font-weight: 600;
  background: var(--bg-surface); color: var(--text-body);
  transition: all 0.1s;
}
.dc-btn:hover { background: var(--accent-tint-sm); border-color: var(--accent-tint-lg); }
.dc-btn--primary { background: var(--accent-1); color: white; border-color: var(--accent-1); }
.dc-btn--primary:hover { background: #1a7a52; }
.dc-btn--sm { padding: 4px 10px; font-size: 0.76rem; }

/* --- Tabs --- */
.dc-tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--line-subtle);
  margin-bottom: 14px;
}
.dc-tab {
  padding: 8px 14px; font-size: 0.82rem; font-weight: 500;
  color: var(--text-muted); background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
}
.dc-tab:hover { color: var(--text-body); }
.dc-tab.is-active { color: var(--accent-1); border-bottom-color: var(--accent-1); font-weight: 600; }

/* --- Key-Value List --- */
.dc-kv { display: grid; gap: 6px; }
.dc-kv__row {
  display: grid; grid-template-columns: minmax(110px, 0.8fr) 1.2fr;
  gap: 8px; padding: 4px 0;
}
.dc-kv__row dt {
  color: var(--text-muted); font-size: 0.72rem;
  font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
}
.dc-kv__row dd { color: var(--text-body); font-size: 0.84rem; margin: 0; }

/* --- Refresh Button Area --- */
.dc-head-actions {
  display: flex; align-items: center; gap: 8px; margin-left: auto;
}

/* --- Pagination --- */
.dc-pager {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 0; font-size: 0.82rem; color: var(--text-muted);
}
.dc-pager button {
  padding: 4px 10px; border: 1px solid var(--border-subtle);
  border-radius: 8px; background: var(--bg-surface); cursor: pointer;
  font-size: 0.8rem; color: var(--text-body);
}
.dc-pager button:disabled { opacity: 0.4; cursor: default; }
.dc-pager button:hover:not(:disabled) { background: var(--accent-tint-sm); }
.dc-pager__info { font-size: 0.78rem; }

/* --- Detail Card --- */
.dc-detail-card {
  display: grid; gap: 10px; padding: 14px; border-radius: var(--r-sm);
  background: rgba(255,255,255,0.75); border: 1px solid var(--border-subtle);
  margin-bottom: 12px;
}
.dc-detail-card__title { font-size: 0.92rem; font-weight: 600; color: var(--text-strong); }
.dc-detail-card__body { font-size: 0.84rem; color: var(--text-body); }

/* --- JSON Block --- */
.dc-json {
  font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.76rem;
  white-space: pre-wrap; word-break: break-all;
  background: var(--accent-tint-xs); padding: 12px;
  border-radius: var(--r-xs); max-height: 360px; overflow: auto;
  border: 1px solid var(--border-subtle);
}

/* --- Toast --- */
.dc-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 10px 20px; border-radius: var(--r-xs);
  background: var(--text-strong); color: white; font-size: 0.84rem;
  z-index: 1000; opacity: 0; transition: opacity 0.2s;
  white-space: nowrap;
}
.dc-toast:not([hidden]) { opacity: 1; }

/* --- Search Results Inline (from hero) --- */
.dc-result-list {
  display: grid; gap: 6px; margin-bottom: 12px;
}
.dc-result-item {
  padding: 10px 14px; background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: var(--r-xs);
  cursor: pointer; transition: background 0.1s;
  display: flex; align-items: center; gap: 12px;
}
.dc-result-item:hover { background: var(--accent-tint-sm); }
.dc-result-item__name { font-weight: 600; color: var(--text-strong); font-size: 0.85rem; }
.dc-result-item__meta { color: var(--text-soft); font-size: 0.78rem; margin-left: auto; }

/* --- Responsive --- */
@media (max-width: 767px) {
  .dc-topbar { display: flex; }
  .dc-sidebar {
    position: fixed; top: var(--topbar-height); left: 0; bottom: 0;
    z-index: 200; transform: translateX(-100%); transition: transform 0.2s;
  }
  .dc-sidebar.is-open { transform: translateX(0); }
  .dc-main { padding: 14px; }
  .dc-stats { grid-template-columns: repeat(2, 1fr); }
}
