@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
  color-scheme: dark;
  --bg-main: #18181a;
  --bg-sidebar: #222224;
  --bg-panel: #27272a;
  --bg-input: #3f3f46;
  --bg-hover: #3f3f46;
  
  --ink: #e4e4e7;
  --muted: #a1a1aa;
  --line: #3f3f46;
  
  --accent: #d97757; /* Claude peach/orange accent */
  --accent-hover: #e88c6f;
  
  --font-serif: var(--font-sans);
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 14px/1.5 var(--font-sans);
  background: var(--bg-main);
  -webkit-font-smoothing: antialiased;
}

/* Base structural layout */
.shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 280px;
  width: 100%;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}

.rightbar {
  padding: 24px 16px;
  border-left: 1px solid var(--line);
  overflow: auto;
  background: var(--bg-main);
}

.workspace {
  min-width: 0;
  padding: 32px 48px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Typography & Brand */
.brand {
  font-family: var(--font-serif);
  font-size: 24px;
  color: var(--ink);
  margin-bottom: 32px;
  padding: 0 8px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

h1, h2, p { margin-top: 0; }
h1 { 
  font-family: var(--font-serif);
  font-size: 32px; 
  font-weight: 500;
  margin-bottom: 0; 
  letter-spacing: 0.5px;
}
h2 { 
  font-size: 16px; 
  font-weight: 600;
  margin-bottom: 4px; 
  color: var(--ink);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* Navigation */
nav { display: grid; gap: 4px; }

button, input, select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.nav:hover {
  background: var(--bg-hover);
  color: var(--ink);
}

.nav.active {
  color: var(--ink);
  background: var(--bg-hover);
  font-weight: 500;
}

.ghost {
  margin-top: auto;
  min-height: 38px;
  color: var(--muted);
  background: transparent;
  border-radius: 8px;
  padding: 0 12px;
  text-align: left;
  transition: all 0.2s ease;
}
.ghost:hover {
  background: var(--bg-hover);
  color: var(--ink);
}

/* Topbar and Controls */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
}

.filters, .toolbar, form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

input, select {
  min-height: 36px;
  border: 1px solid var(--line);
  padding: 0 14px;
  color: var(--ink);
  background: var(--bg-main);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, select:focus {
  border-color: var(--accent);
}

.primary {
  min-height: 36px;
  padding: 0 16px;
  color: #18181a;
  background: var(--ink);
  border-radius: 8px;
  font-weight: 500;
  transition: background-color 0.2s;
}
.primary:hover {
  background: #d4d4d8;
}

/* View switching */
.view { display: none; }
.view.active { display: block; }
.hidden { display: none !important; }

/* Dashboard Metrics & Panels */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric {
  padding: 20px;
  background: var(--bg-panel);
  border-radius: 12px;
  border: 1px solid var(--line);
}

.metric b {
  display: block;
  font-size: 28px;
  font-weight: 500;
  margin-bottom: 4px;
  font-family: var(--font-serif);
}

.metric span { color: var(--muted); font-size: 13px; }

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.panel {
  padding: 24px;
  background: var(--bg-panel);
  border-radius: 12px;
  border: 1px solid var(--line);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head span { color: var(--muted); font-size: 12px; }

/* Bars & Charts */
.bars { display: grid; gap: 12px; }
.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 48px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.bar-track {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

.funnel { display: grid; gap: 8px; }
.funnel-step {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-input);
  border-radius: 8px;
}

.kv {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.kv div {
  padding: 16px;
  background: var(--bg-input);
  border-radius: 8px;
}
.kv span { color: var(--muted); font-size: 13px; }

/* Tables */
.table-wrap {
  width: 100%;
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
th, td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}
th {
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}
tr.clickable { cursor: pointer; transition: background 0.15s; }
tr.clickable:hover { background: var(--bg-hover); }

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

/* Rightbar Cards & Feed */
.mini-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  margin-bottom: 16px;
  background: var(--bg-panel);
  border-radius: 12px;
  border: 1px solid var(--line);
}
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  color: var(--bg-main);
  background: var(--accent);
  font-weight: bold;
}
.mini-card p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.mini-card b { color: var(--ink); font-weight: 600; }

.feed { display: grid; gap: 8px; }
.feed-item {
  padding: 12px;
  background: var(--bg-panel);
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}
.feed-item:hover {
  border-color: var(--line);
}
.feed-item b { display: block; font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.feed-item span { color: var(--muted); font-size: 12px; }

/* Login */
.login-card {
  max-width: 400px;
  margin: 100px auto;
  padding: 32px;
  background: var(--bg-panel);
  border-radius: 16px;
  border: 1px solid var(--line);
}
.login-card form { display: grid; gap: 16px; margin-top: 24px; }
.error { color: #f87171; min-height: 20px; font-size: 13px; margin-top: 12px; }

.detail { margin-top: 24px; }
.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  color: #18181a;
  background: var(--ink);
  font-size: 11px;
  font-weight: 600;
  border-radius: 11px;
}

/* Button loading state */
@keyframes btnSpin {
  to { transform: rotate(360deg); }
}

.primary {
  position: relative;
}

.primary.loading {
  color: transparent;
  pointer-events: none;
}

.primary.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border: 2.5px solid #18181a33;
  border-top-color: #18181a;
  border-radius: 50%;
  animation: btnSpin 0.6s linear infinite;
}

.primary:disabled {
  opacity: 0.8;
  cursor: not-allowed;
}

/* Responsiveness */
@media (max-width: 1100px) {
  .shell { grid-template-columns: 240px minmax(0, 1fr); }
  .rightbar { display: none; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .shell {
    width: 100%;
    min-height: 100vh;
    grid-template-columns: 1fr;
  }
  .sidebar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .brand { margin-bottom: 0; font-size: 20px; }
  nav { display: flex; gap: 4px; }
  .ghost { margin-top: 0; margin-left: auto; }
  .workspace { padding: 16px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .grid.two, .metrics { grid-template-columns: 1fr; }
}
