/* Cockpit POF — MVP styles, derived from Claude Design output + DS POF tokens.
   V1.1: switch to Tailwind + DS submodule. */

:root {
  --navy: #1C1F3B;
  --teal: #80C7C2;
  --teal-dark: #2BA595;
  --teal-deep: #3B6F77;
  --coral: #E8546C;
  --steel: #435D74;
  --steel-light: #5F7D95;
  --neutral-light: #F9FCFF;
  --neutral-mid: #CFD9E0;
  --gray-400: #A4B4C4;
  --gray-600: #6C757D;
  --body-text: #2C3543;
  --bg: #F7F5F2;
  --surface: #FFFFFF;
  --border: #E2DFD9;
  --success: #2E7D32;
  --warning: #E0A615;
  --error: #B43E2C;

  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(11, 37, 69, 0.06);
  --shadow-md: 0 4px 12px rgba(11, 37, 69, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--body-text);
  background: var(--bg);
}

a { color: var(--teal-deep); }
button { font-family: inherit; cursor: pointer; }

.view { display: none; }
.view.active { display: block; min-height: 100vh; }

/* ========== LOGIN ========== */

#view-login.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 32px;
}

.logo-block {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
}

.brand-logo {
  height: 56px !important;
  width: auto !important;
  max-width: 280px;
  display: block;
  flex-shrink: 0;
}

.topbar-logo {
  height: 32px !important;
  width: auto !important;
  max-width: 200px;
  display: block;
  flex-shrink: 0;
}

.topbar {
  overflow: hidden;
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.lang-switch button {
  padding: 4px 10px;
  background: transparent;
  border: 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--steel);
  letter-spacing: 0.04em;
  cursor: pointer;
}

.lang-switch button.active {
  background: var(--navy);
  color: var(--surface);
}

#view-login h1 {
  font-size: 22px;
  font-weight: 500;
  color: var(--navy);
  margin: 0 0 4px 0;
}

#view-login .subtitle {
  font-size: 13px;
  color: var(--steel);
  margin: 0 0 24px 0;
}

#form-password label {
  display: block;
  font-size: 12px;
  color: var(--steel);
  margin-bottom: 6px;
}

#form-password input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  margin-bottom: 16px;
  font-family: inherit;
}

#form-password input:focus {
  outline: none;
  border-color: var(--teal);
}

.btn-primary {
  width: 100%;
  padding: 10px 16px;
  background: var(--navy);
  color: var(--surface);
  border: none;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
}

.btn-primary:hover { background: var(--teal-deep); }

.btn-ghost {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 12px;
  color: var(--steel);
}

.btn-help {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--steel);
  font-weight: 500;
}

.error {
  color: var(--error);
  font-size: 13px;
  margin-top: 8px;
}

.hint {
  font-size: 12px;
  color: var(--steel);
  margin-top: 16px;
  text-align: center;
}

/* ========== TOPBAR ========== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand .name {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--steel);
  text-transform: uppercase;
}

.brand .product {
  font-size: 18px;
  font-weight: 500;
  color: var(--navy);
  margin-left: 12px;
}

.topbar nav {
  display: flex;
  gap: 4px;
}

.topbar nav a {
  padding: 8px 16px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--steel);
  font-size: 13px;
}

.topbar nav a.active {
  background: var(--navy);
  color: var(--surface);
}

.me {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--teal);
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}

.who {
  font-size: 12px;
  line-height: 1.3;
}

.who small {
  display: block;
  color: var(--gray-600);
  font-size: 10px;
}

/* ========== APP LAYOUT ========== */

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 64px);
}

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

.sb-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 12px;
  font-family: inherit;
  margin-bottom: 16px;
}

.sb-section {
  margin-bottom: 16px;
}

.sb-section .head {
  font-size: 11px;
  font-weight: 500;
  color: var(--steel);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  margin-bottom: 4px;
}

.sb-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--body-text);
  border-radius: var(--r-md);
  cursor: pointer;
}

.sb-item:hover { background: var(--neutral-light); }

.sb-item.active {
  background: rgba(128, 199, 194, 0.16);
  color: var(--navy);
  font-weight: 500;
}

.sb-foot {
  margin-top: auto;
}

.sb-foot .add {
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  color: var(--steel);
  font-size: 12px;
}

.sb-foot .add:hover {
  border-color: var(--teal);
  color: var(--teal-deep);
}

/* ========== CONTENT ========== */

.content {
  padding: 16px 24px 32px 24px;
}

.subheader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.crumb {
  font-size: 13px;
  color: var(--steel);
}

.filters {
  display: flex;
  gap: 8px;
}

.filter {
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--body-text);
}

.filter:hover { border-color: var(--teal); }

.filter.refresh {
  background: var(--navy);
  color: var(--surface);
  border-color: var(--navy);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filter.refresh svg {
  display: block;
}

.filter.refresh:hover {
  background: var(--teal-deep);
  border-color: var(--teal-deep);
}

/* ========== BRIEFING ========== */

.briefing {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.briefing .meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.source-tag {
  background: rgba(128, 199, 194, 0.12);
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--teal-deep);
}

.briefing p {
  margin: 0 0 12px 0;
  font-size: 14px;
}

.briefing .read {
  font-size: 12px;
  text-decoration: none;
}

/* ========== BLOCKS GRID ========== */

.blocks-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.col-3 { grid-column: span 3; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

.kpi, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.kpi .actions, .card .actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--steel);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.icon-btn:hover { border-color: var(--teal); color: var(--teal-deep); }

.kpi .k-top {
  font-size: 11px;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  padding-right: 80px;
}

.kpi .value {
  font-size: 28px;
  font-weight: 500;
  color: var(--navy);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.titles .eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-600);
  margin-bottom: 2px;
}

.titles h3 {
  font-size: 16px;
  font-weight: 500;
  color: var(--navy);
  margin: 0;
}

.chart-placeholder {
  background: var(--neutral-light);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  padding: 32px;
  text-align: center;
}

.chart-placeholder p { margin: 0; }
.chart-placeholder .muted { color: var(--gray-600); font-size: 12px; margin-top: 4px; }

.table-wrap { overflow-x: auto; }

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

th, td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--gray-600);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.kpi-sub {
  font-size: 11px;
  color: var(--gray-600);
  margin-top: 4px;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}

.donut-legend {
  flex: 1;
  font-size: 12px;
}

.lg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.lg-row:last-child { border-bottom: none; }

.lg-row .sw {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.lg-row .lg-val {
  margin-left: auto;
  font-weight: 500;
  color: var(--navy);
}

.funnel { padding: 8px 0; }

.funnel-row {
  display: grid;
  grid-template-columns: 120px 1fr 60px;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}

.funnel-label {
  font-size: 12px;
  color: var(--steel);
  text-align: right;
}

.funnel-bar {
  background: var(--neutral-light);
  height: 22px;
  border-radius: 4px;
  overflow: hidden;
}

.funnel-fill {
  background: var(--navy);
  height: 100%;
}

.funnel-val {
  font-size: 12px;
  font-weight: 500;
  color: var(--navy);
  text-align: right;
}

.empty, .loading, .error-state {
  padding: 64px 32px;
  text-align: center;
  color: var(--gray-600);
}

.error-state p { color: var(--error); }

.muted { color: var(--gray-600); }

/* ========== TOAST ========== */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--navy);
  color: var(--surface);
  padding: 12px 20px;
  border-radius: var(--r-md);
  font-size: 13px;
  max-width: 360px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ========== MODAL ========== */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(28, 31, 59, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal[hidden] { display: none; }

.modal-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 32px;
  max-width: 480px;
  box-shadow: var(--shadow-md);
}

.modal-card h2 {
  font-size: 18px;
  font-weight: 500;
  color: var(--navy);
  margin: 0 0 12px 0;
}

.modal-card ul {
  font-size: 13px;
  padding-left: 20px;
}
.modal-card li { margin-bottom: 6px; }
