:root {
  --ink: #15323a;
  --muted: #6d8388;
  --line: #d7e7e7;
  --mint: #e9f8f4;
  --teal: #07847d;
  --blue: #246b91;
  --green: #2faf72;
  --amber: #d89a24;
  --bg: #f5fbfa;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, "Source Sans 3", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 10%, #dff6f2 0, transparent 34%), var(--bg);
}
button, input, select { font: inherit; }
.hidden { display: none !important; }
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 48px;
  align-items: center;
  padding: 48px 8vw;
  position: relative;
  overflow: hidden;
}
.login-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(245,251,250,.92) 0%, rgba(245,251,250,.66) 42%, rgba(8,55,64,.42) 100%),
    linear-gradient(0deg, rgba(245,251,250,.30), rgba(245,251,250,.30)),
    url("/static/assets/login-banner.png");
  background-size: cover;
  background-position: center;
  z-index: 0;
}
.login-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(245,251,250,.20), rgba(7,132,125,.12), rgba(18,52,60,.24));
  backdrop-filter: saturate(1.05);
}
.heartbeat-layer {
  position: absolute;
  left: -8vw;
  top: 61%;
  width: 116vw;
  height: 180px;
  opacity: .92;
  z-index: 0;
  animation: fadeIn .7s ease .2s both;
}
.heartbeat-line,
.heartbeat-glow {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1420;
  stroke-dashoffset: 1420;
  animation: heartbeatDraw 3.6s linear infinite;
}
.heartbeat-line {
  stroke: rgba(7,132,125,.88);
  stroke-width: 5;
}
.heartbeat-glow {
  stroke: rgba(123,224,211,.34);
  stroke-width: 18;
  filter: blur(5px);
}
.login-hero, .login-card { position: relative; z-index: 1; opacity: 0; animation: fadeInUp .75s ease forwards; }
.login-card { animation-delay: .18s; }
.login-hero h1 { max-width: 760px; font-size: clamp(42px, 6vw, 76px); line-height: .96; margin: 10px 0 18px; letter-spacing: 0; }
.login-hero p { max-width: 600px; color: var(--muted); font-size: 20px; }
.eyebrow { margin: 0; color: var(--teal); text-transform: uppercase; font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.login-card {
  background: rgba(255,255,255,.88);
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(21,50,58,.12);
  border-radius: 8px;
  padding: 28px;
  transform: translateY(20%);
}
.login-logo {
  display: block;
  width: min(100%, 300px);
  margin: 0 auto 22px;
  border-radius: 8px;
  background: #000;
  box-shadow: 0 16px 42px rgba(18,52,60,.18);
}
.login-card h2 { margin-top: 0; }
label { display: grid; gap: 8px; margin: 16px 0; font-weight: 700; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fff;
}
button {
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}
.ms-login-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  border-radius: 8px;
  padding: 13px 16px;
  background: #fff;
  color: #1f2933;
  border: 1px solid #cfd8dc;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(21,50,58,.08);
}
.ms-login-button:hover {
  border-color: #9fb8be;
  box-shadow: 0 12px 32px rgba(21,50,58,.12);
}
.ms-mark {
  width: 20px;
  height: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  flex: 0 0 auto;
}
.ms-mark i:nth-child(1) { background: #f25022; }
.ms-mark i:nth-child(2) { background: #7fba00; }
.ms-mark i:nth-child(3) { background: #00a4ef; }
.ms-mark i:nth-child(4) { background: #ffb900; }
.ms-mark i {
  display: block;
  width: 100%;
  height: 100%;
}
.backdoor-link {
  position: absolute;
  right: 22px;
  bottom: 18px;
  z-index: 2;
  color: rgba(21,50,58,.24);
  font-size: 22px;
  font-weight: 800;
  text-decoration: none;
}
.backdoor-link:hover { color: rgba(7,132,125,.62); }
.error { color: #b42318; min-height: 20px; }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes heartbeatDraw {
  0% { stroke-dashoffset: 1420; opacity: .2; }
  12% { opacity: .95; }
  56% { stroke-dashoffset: 0; opacity: .95; }
  78% { stroke-dashoffset: -1420; opacity: .2; }
  100% { stroke-dashoffset: -1420; opacity: .2; }
}
.app { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); transition: grid-template-columns .22s ease; }
.app.sidebar-collapsed { grid-template-columns: 84px minmax(0, 1fr); }
.mobile-menu-toggle, .sidebar-backdrop { display: none; }
.sidebar {
  background: #12343c;
  color: white;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: width .22s ease;
}
.brand-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-width: 0; }
.brand-copy { min-width: 0; }
.sidebar-logo {
  display: block;
  width: 176px;
  max-width: 100%;
  height: auto;
  margin: 0 0 10px;
  object-fit: contain;
  border-radius: 6px;
  background: #000;
}
.sidebar span { display: block; color: #9fc7c9; margin-top: 4px; }
.sidebar-toggle {
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  background: #1e5b62;
  color: #e8fbfb;
  font-size: 24px;
  line-height: 1;
  flex: 0 0 auto;
}
.menu-section { display: grid; gap: 4px; margin-top: 16px; }
.menu-section > span { font-size: 12px; text-transform: uppercase; font-weight: 800; letter-spacing: .08em; }
.nav {
  text-align: left;
  background: transparent;
  color: #d8eeee;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.nav-icon {
  width: 34px;
  height: 34px;
  display: grid !important;
  place-items: center;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: #e8fbfb !important;
  margin: 0 !important;
  font-size: 12px;
  font-weight: 900;
  flex: 0 0 auto;
}
.nav-label { margin: 0 !important; color: inherit !important; white-space: normal; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.nav.active { background: #1e5b62; }
.nav.ghost { margin-top: auto; color: #b5d5d7; }
.app.sidebar-collapsed .sidebar { padding: 20px 14px; }
.app.sidebar-collapsed .brand-copy,
.app.sidebar-collapsed .menu-section > span,
.app.sidebar-collapsed .nav-label { display: none; }
.app.sidebar-collapsed .brand-row { justify-content: center; }
.app.sidebar-collapsed .sidebar-toggle { transform: rotate(180deg); }
.app.sidebar-collapsed .nav { justify-content: center; padding: 8px; }
.app.sidebar-collapsed .menu-section { margin-top: 8px; }
.workspace { padding: 28px; overflow: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.topbar h1 { margin: 4px 0 0; font-size: 34px; letter-spacing: 0; }
.user-badge { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; color: var(--muted); }
.filters { display: grid; grid-template-columns: repeat(4, minmax(150px,1fr)); gap: 12px; margin-bottom: 18px; }
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(140px,1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-grid.compact { grid-template-columns: repeat(4, minmax(140px,1fr)); }
.kpi {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 14px 40px rgba(21,50,58,.06);
}
.kpi span { color: var(--muted); font-weight: 700; font-size: 13px; }
.kpi strong { display: block; font-size: 32px; margin-top: 8px; }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
article {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}
article:first-child { grid-column: 1 / -1; }
article h3 { margin: 0 0 10px; font-size: 17px; }
.chart { height: 330px; width: 100%; }
.wide { height: 350px; }
.story-view {
  background: linear-gradient(135deg, rgba(255,255,255,.94), rgba(234,248,246,.94));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  min-height: calc(100vh - 148px);
  overflow: hidden;
}
.story-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.story-top h2 { margin: 4px 0 0; font-size: 30px; }
.story-controls { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 800; }
.story-frame { overflow: hidden; width: 100%; }
.story-track { display: flex; transition: transform .42s ease; }
.story-slide {
  flex: 0 0 100%;
  min-height: 540px;
  border: 0;
  box-shadow: none;
  background: transparent;
  padding: 16px 4px 4px;
  opacity: .55;
  transform: scale(.985);
  transition: opacity .35s ease, transform .35s ease;
}
.story-slide.active { opacity: 1; transform: scale(1); }
.story-slide h3 {
  max-width: 920px;
  font-size: clamp(28px, 4vw, 54px);
  line-height: 1.05;
  margin: 10px 0 28px;
  letter-spacing: 0;
}
.story-big-kpis { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 16px; }
.story-big-kpis.stacked { grid-template-columns: 1fr; }
.story-big-kpis .kpi { min-height: 150px; display: grid; align-content: center; }
.story-big-kpis .kpi strong { font-size: clamp(38px, 5vw, 68px); }
.story-pulse-grid { display: grid; grid-template-columns: minmax(360px, 1.3fr) minmax(260px, .7fr); gap: 18px; align-items: stretch; }
.story-hero-chart {
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: radial-gradient(circle at 50% 46%, #ffffff 0, #f1fbf9 58%, #e4f5f1 100%);
}
.story-chart { height: 360px; width: 100%; }
.story-company-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 340px;
  gap: 20px;
  align-items: stretch;
}
.story-company-grid .story-chart {
  height: 390px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  padding: 8px;
}
.company-callout {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #12343c;
  color: #e8fbfb;
  padding: 28px;
  display: grid;
  align-content: center;
  box-shadow: 0 18px 60px rgba(18,52,60,.16);
}
.company-callout span {
  display: block;
  color: #7be0d3;
  font-size: clamp(58px, 7vw, 96px);
  font-weight: 900;
  line-height: .95;
}
.company-callout strong { font-size: 22px; margin-top: 10px; }
.company-callout p { color: #b5d5d7; font-size: 17px; line-height: 1.45; margin: 18px 0 0; }
.story-dots { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.story-dot { width: 34px; height: 6px; border-radius: 999px; background: #c7dddd; border: 0; padding: 0; }
.story-dot.active { background: var(--teal); }
.construction-view {
  min-height: calc(100vh - 148px);
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.88);
  box-shadow: 0 18px 60px rgba(21,50,58,.07);
}
.construction-view h2 {
  margin: 8px 0 0;
  font-size: clamp(44px, 7vw, 88px);
  letter-spacing: 0;
}
.admin-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}
.capture-page, .category-page {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 14px 40px rgba(21,50,58,.06);
}
.category-head, .modal-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.category-head h2, .modal-head h2 { margin: 4px 0 0; font-size: 30px; }
.capture-form { display: grid; gap: 10px; }
.capture-form.large { grid-template-columns: repeat(2, minmax(180px,1fr)); }
.capture-form textarea {
  width: 100%;
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  resize: vertical;
}
.capture-form .full { grid-column: 1 / -1; }
.activity-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.activity-row {
  display: grid;
  grid-template-columns: 96px 110px 120px minmax(220px, 1fr) 140px 112px 178px;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.activity-row.header { background: var(--mint); font-weight: 800; color: var(--ink); }
.activity-row:last-child { border-bottom: 0; }
.activity-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px;
  gap: 12px;
  margin: 8px 0 14px;
}
.table-action {
  padding: 8px 10px;
  font-size: 13px;
  background: #e9f8f4;
  color: var(--teal);
}
.row-actions { display: flex; gap: 6px; }
.row-actions button { padding: 8px 9px; font-size: 13px; }
.edit-button { background: #eaf2fb; color: var(--blue); }
.delete-button, .danger-button { background: #b42318; color: #fff; }
.secondary-button { background: #e9f8f4; color: var(--ink); }
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
}
.pagination div { display: flex; align-items: center; gap: 10px; }
.pagination button:disabled { opacity: .45; cursor: not-allowed; }
.status-pill {
  display: inline-flex;
  width: max-content;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e9f8f4;
  color: var(--teal);
  font-weight: 800;
  font-size: 12px;
}
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18,52,60,.42);
  z-index: 20;
}
.modal-card {
  width: min(920px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 22px;
  box-shadow: 0 24px 90px rgba(18,52,60,.24);
}
.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 28px;
  line-height: 1;
  background: #e9f8f4;
  color: var(--ink);
}
.detail-card { width: min(760px, 100%); }
.delete-card { width: min(540px, 100%); }
.delete-copy { color: var(--muted); line-height: 1.5; margin-top: -4px; }
.delete-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.detail-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfefe;
}
.detail-item.full { grid-column: 1 / -1; }
.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.detail-item strong { white-space: pre-wrap; font-weight: 700; }
.panel-title h2 { margin: 0 0 4px; }
.panel-title p { margin: 0 0 18px; color: var(--muted); }
.admin-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  color: var(--muted);
}
.user-form { display: grid; grid-template-columns: repeat(6, minmax(120px,1fr)); gap: 10px; align-items: center; }
.users-table { margin-top: 18px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.row { display: grid; grid-template-columns: 1.3fr 1.7fr .8fr .8fr 160px; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: center; }
.row.header { background: var(--mint); font-weight: 800; }
.row:last-child { border-bottom: 0; }
.edit-user-form { grid-template-columns: repeat(2, minmax(180px,1fr)); }
.edit-user-form button { grid-column: 1 / -1; }
@media (max-width: 980px) {
  .login-shell, .app { grid-template-columns: 1fr; }
  .app.sidebar-collapsed { grid-template-columns: 1fr; }
  .mobile-menu-toggle {
    display: grid;
    place-items: center;
    position: fixed;
    left: 14px;
    top: 14px;
    z-index: 31;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 8px;
    background: #12343c;
    color: #fff;
    box-shadow: 0 12px 30px rgba(18,52,60,.20);
  }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 28;
    background: rgba(18,52,60,.38);
  }
  .app.mobile-menu-open .sidebar-backdrop { display: block; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(82vw, 300px);
    transform: translateX(-104%);
    transition: transform .24s ease;
    flex-direction: column;
    align-items: stretch;
    overflow-y: auto;
  }
  .app.mobile-menu-open .sidebar { transform: translateX(0); }
  .workspace { padding: 76px 16px 20px; }
  .brand-copy { display: block !important; }
  .menu-section > span, .nav-label { display: inline !important; }
  .sidebar-toggle { display: none; }
  .nav { justify-content: flex-start !important; }
  .nav.ghost { margin-top: 8px; margin-left: 0; }
  .filters, .kpi-grid, .chart-grid, .user-form, .capture-form.large, .activity-row, .table-tools, .detail-grid { grid-template-columns: 1fr; }
  .story-top, .story-controls { flex-direction: column; align-items: stretch; }
  .story-big-kpis, .story-pulse-grid, .story-company-grid { grid-template-columns: 1fr; }
  article:first-child { grid-column: auto; }
}
