/* Prudle Labs Engine — dashboard design system */

:root {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #fafafe;
  --border: #e6e7f0;
  --text: #17182b;
  --text-dim: #6b6d85;
  --text-faint: #9496ab;

  /* Brand blue sampled directly from the Prudle Labs logo (#0B9BD7) */
  --primary: #0b9bd7;
  --primary-dark: #0880b0;
  --primary-tint: #e4f5fc;

  --red: #e5484d;
  --red-tint: #fde8e8;
  --amber: #b9770e;
  --amber-tint: #fdf3e0;
  --green: #1a9e6f;
  --green-tint: #e4f7f0;
  --blue: #2f6fed;
  --blue-tint: #e8f0fe;
  --purple: #8452e0;
  --purple-tint: #f1eafd;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 20, 43, 0.04), 0 8px 24px -12px rgba(20, 20, 43, 0.10);
  --shadow-sm: 0 1px 2px rgba(20, 20, 43, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }

a { color: inherit; text-decoration: none; }

/* --- Layout --- */

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

.sidebar {
  width: 248px;
  flex: 0 0 248px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
}

.logo {
  height: 34px;
  width: auto;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand h1 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
}

.brand p {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 1px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.3px;
  font-weight: 500;
  color: var(--text-dim);
  transition: background 0.12s ease, color 0.12s ease;
}

.nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav a.active {
  background: var(--primary-tint);
  color: var(--primary-dark);
}

.nav a .nav-icon {
  flex: 0 0 auto;
  color: var(--text-faint);
  transition: color 0.12s ease;
}

.nav a:hover .nav-icon {
  color: var(--text-dim);
}

.nav a.active .nav-icon {
  color: var(--primary);
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 28px;
}

.search {
  flex: 1 1 auto;
  max-width: 420px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 13px;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-tint);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

/* --- Profile dropdown (topbar, top-right) --- */

.user-menu {
  position: relative;
  flex: 0 0 auto;
}

.user-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
}

.user-trigger:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.user-trigger svg {
  color: var(--text-faint);
  flex: 0 0 auto;
}

.user-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
}

.user-name {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}

.user-email {
  font-size: 11px;
  color: var(--text-faint);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  z-index: 20;
}

.user-dropdown[hidden] {
  display: none;
}

.user-dropdown-company {
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.user-dropdown-company img {
  height: 26px;
  width: auto;
  object-fit: contain;
}

.user-dropdown-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}

.user-dropdown-info strong {
  font-size: 13.5px;
  color: var(--text);
}

.user-dropdown-info span {
  font-size: 12px;
  color: var(--text-faint);
  word-break: break-all;
}

.user-dropdown-logout {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--red-tint);
  color: #b0272c;
  border: none;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.user-dropdown-logout:hover {
  filter: brightness(0.96);
}

.content {
  padding: 26px 28px 60px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}

/* --- Page head --- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.kicker {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 4px;
}

.page-head h2 {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.lead {
  color: var(--text-dim);
  font-size: 13.5px;
  margin-top: 6px;
  max-width: 620px;
}

.btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  padding: 9px 15px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.12s ease, background 0.12s ease;
  white-space: nowrap;
}

button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

button.primary {
  background: var(--primary);
  color: #fff;
}
button.primary:hover:not(:disabled) { background: var(--primary-dark); }

button.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
button.secondary:hover:not(:disabled) { background: var(--surface-2); }

button.small { padding: 6px 11px; font-size: 12px; border-radius: 8px; }

/* --- Forms --- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 4px;
}

.form-grid.wide { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.form-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  margin-bottom: 5px;
}

.form-field input,
.form-field select {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.form-field input:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

/* --- AI banner --- */

.ai-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: linear-gradient(120deg, var(--primary-dark), var(--primary) 60%, #7d6bff);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.ai-banner h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.ai-banner p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.86);
  max-width: 640px;
}

.ai-score {
  flex: 0 0 auto;
  text-align: center;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 10px 22px;
}

.ai-score strong {
  display: block;
  font-size: 22px;
  font-weight: 800;
}

.ai-score span {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.78);
}

/* --- Grid & metrics --- */

.grid {
  display: grid;
  gap: 16px;
}

.grid.four { grid-template-columns: repeat(4, 1fr); }
.grid.two { grid-template-columns: 1.15fr 0.85fr; }

@media (max-width: 980px) {
  .grid.four { grid-template-columns: repeat(2, 1fr); }
  .grid.two { grid-template-columns: 1fr; }
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.metric .num {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.metric .label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
}

.metric .delta {
  font-size: 11.5px;
  font-weight: 600;
  margin-top: 9px;
  display: inline-block;
}

.metric .delta.up { color: var(--green); }
.metric .delta.warn { color: var(--amber); }
.metric .delta.down { color: var(--red); }

/* --- Card --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  box-shadow: var(--shadow-sm);
}

.card h3 {
  font-size: 14.5px;
  font-weight: 700;
}

.card .sub {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 3px;
  margin-bottom: 14px;
}

/* --- Row / list item --- */

.row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-top: 1px solid var(--border);
}

.row:first-of-type { border-top: none; padding-top: 4px; }

.row h4 {
  font-size: 13.5px;
  font-weight: 650;
  margin: 6px 0 4px;
}

.row p {
  font-size: 12.5px;
  color: var(--text-dim);
  max-width: 480px;
}

.row-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
}

.row-actions button { width: 128px; }

.empty-state {
  padding: 22px 4px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
}

.error-state {
  padding: 12px 14px;
  background: var(--red-tint);
  color: #a3282c;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}

/* --- Pills --- */

.pill {
  display: inline-block;
  font-size: 10.8px;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
}

.pill.red    { background: var(--red-tint);    color: #b0272c; }
.pill.amber  { background: var(--amber-tint);  color: #8a5c0a; }
.pill.green  { background: var(--green-tint);  color: #10714f; }
.pill.blue   { background: var(--blue-tint);   color: #1c4fb8; }
.pill.purple { background: var(--purple-tint); color: #6636c4; }

/* --- Timeline --- */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-left: 2px;
}

.timeline-item {
  display: flex;
  gap: 12px;
}

.timeline-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 5px;
  flex: 0 0 auto;
  position: relative;
}

.timeline-item:not(:last-child) .timeline-dot::after {
  content: "";
  position: absolute;
  top: 12px;
  left: 3.5px;
  width: 2px;
  height: 34px;
  background: var(--border);
}

.timeline-item h4 {
  font-size: 13px;
  font-weight: 650;
}

.timeline-item p {
  font-size: 12.3px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* --- Table --- */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.8px;
}

.table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  font-weight: 700;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); cursor: default; }
.table tbody tr.clickable:hover { cursor: pointer; background: var(--primary-tint); }

/* --- Progress bar --- */

.progress {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}

.bar {
  height: 100%;
  border-radius: 999px;
  background: var(--blue);
}

.bar.red { background: var(--red); }
.bar.amber { background: var(--amber); }
.bar.green { background: var(--green); }
.bar.purple { background: var(--purple); }

/* --- Highlight callout --- */

.highlight {
  background: var(--primary-tint);
  color: #3a2f88;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.6;
}

/* --- Draft textarea --- */

textarea.demo {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 12.8px;
  line-height: 1.6;
  padding: 12px 14px;
}

textarea.demo:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

/* --- Auth gate --- */

.auth-gate {
  position: fixed;
  inset: 0;
  background: rgba(23, 24, 43, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.auth-card {
  width: 320px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 24px;
}

.auth-card h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.auth-card p {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.auth-card input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  margin-bottom: 10px;
  font-family: inherit;
}

.auth-card input:focus { outline: none; border-color: var(--primary); }

.auth-card .auth-error {
  font-size: 12px;
  color: var(--red);
  margin-bottom: 8px;
  min-height: 14px;
}

/* --- Toast --- */

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--text);
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 12.8px;
  box-shadow: var(--shadow);
  z-index: 200;
  max-width: 340px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* --- Skeleton loading --- */

.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: skel-loading 1.4s ease infinite;
  border-radius: 6px;
  color: transparent !important;
}

@keyframes skel-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  .content { padding: 18px 16px 40px; }
  .row-actions { flex-direction: row; }
  .row-actions button { width: auto; flex: 1; }
}
