:root {
  color-scheme: light;
  --ink: #14231f;
  --forest: #123c31;
  --green: #1b5b48;
  --mint: #dff5d4;
  --lime: #c9ef7c;
  --paper: #fffdf8;
  --cream: #f4f1e7;
  --white: #fff;
  --line: #dfe5df;
  --muted: #66736d;
  --warning: #fff1c7;
  --danger: #ffe2dd;
  --shadow: 0 18px 45px rgba(20, 35, 31, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.loading-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}
.loading-screen img { width: min(360px, 75vw); }

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(380px, .95fr);
}
.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(40px, 8vw, 120px);
  background: var(--paper);
}
.login-logo { width: min(410px, 80vw); margin: 0 0 42px -14px; }
.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: .16em;
}
.eyebrow.light { color: var(--lime); }
.login-panel h1, .login-aside h2 {
  max-width: 740px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 5.4vw, 5.8rem);
  font-weight: 500;
  line-height: .97;
  letter-spacing: -.04em;
}
.login-panel .lede {
  max-width: 660px;
  margin: 28px 0;
  color: #53625c;
  font-size: clamp(1rem, 1.4vw, 1.22rem);
  line-height: 1.65;
}
.login-aside {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(40px, 7vw, 110px);
  overflow: hidden;
  background:
    radial-gradient(circle at 85% 15%, rgba(201, 239, 124, .26), transparent 30%),
    var(--forest);
  color: var(--white);
}
.login-aside h2 { font-size: clamp(2.4rem, 4vw, 4.7rem); }
.login-aside > p:last-child { max-width: 600px; color: #d5e4dd; font-size: 1.05rem; line-height: 1.65; }
.mini-flow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 48px 0 20px;
  flex-wrap: wrap;
}
.mini-flow span {
  padding: 13px 16px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 14px;
  background: rgba(255,255,255,.08);
}
.mini-flow b { color: var(--lime); }
.button {
  display: inline-flex;
  width: fit-content;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 999px;
  padding: 0 22px;
  background: var(--forest);
  color: var(--white);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}
.button:hover { background: var(--green); transform: translateY(-1px); }
.button.secondary { background: var(--cream); color: var(--ink); }
.button.outline { border: 1px solid var(--line); background: var(--white); color: var(--ink); }
.button.compact { min-height: 40px; padding: 0 17px; font-size: .86rem; }
.google-button { min-height: 56px; margin-top: 4px; }
.google-mark {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: var(--white);
  color: #4285f4;
}
.small-print { max-width: 520px; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.notice { padding: 12px 14px; border-radius: 12px; }
.notice.error { background: var(--danger); color: #8a2d20; }

.app-shell {
  min-height: 100vh;
  padding-left: 246px;
  background: #f8f7f1;
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: 246px;
  flex-direction: column;
  padding: 20px 14px;
  background: var(--forest);
  color: var(--white);
}
.brand { display: block; padding: 4px 7px 25px; }
.brand img {
  display: block;
  width: 205px;
  max-width: 100%;
  border-radius: 8px;
}
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a {
  display: flex;
  min-height: 45px;
  align-items: center;
  gap: 12px;
  border-radius: 12px;
  padding: 0 13px;
  color: #d8e6df;
  font-size: .93rem;
  font-weight: 700;
  text-decoration: none;
}
.sidebar nav a span { width: 20px; text-align: center; color: var(--lime); font-size: 1.05rem; }
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,.1); color: var(--white); }
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 10px 13px;
  color: #bed1c8;
  font-size: .78rem;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 5px rgba(201,239,124,.12);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 82px;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  padding: 14px clamp(20px, 3vw, 44px);
  background: rgba(255,253,248,.94);
  backdrop-filter: blur(16px);
}
.topbar h1 { margin: 0; font-size: 1.45rem; letter-spacing: -.03em; }
.topbar .eyebrow { margin: 0; font-size: .61rem; }
.top-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.client-picker { display: grid; gap: 2px; }
.client-picker span { color: var(--muted); font-size: .65rem; font-weight: 800; text-transform: uppercase; }
.client-picker select {
  width: 220px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 750;
}
.profile-button {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.profile-button > span:first-child {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border-radius: 12px;
  background: var(--forest);
  color: var(--lime);
  font-size: .8rem;
  font-weight: 900;
}
.profile-copy { display: grid; text-align: left; }
.profile-copy small { color: var(--muted); }
.profile-menu {
  position: fixed;
  z-index: 50;
  top: 72px;
  right: 24px;
  width: min(300px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: var(--white);
  box-shadow: var(--shadow);
}
.profile-menu p { overflow: hidden; margin: 0 0 10px; color: var(--muted); font-size: .82rem; text-overflow: ellipsis; }
.profile-menu button { width: 100%; border: 0; border-radius: 10px; padding: 10px; cursor: pointer; }
.menu-button { display: none; }
.icon-button { border: 0; background: transparent; cursor: pointer; font-size: 1.35rem; }
.safety-strip {
  padding: 9px clamp(20px, 3vw, 44px);
  background: #edf5df;
  color: #36533c;
  font-size: .78rem;
}
.content { max-width: 1520px; margin: 0 auto; padding: clamp(20px, 3vw, 44px); outline: none; }

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, .7fr);
  gap: 30px;
  border-radius: 24px;
  padding: clamp(24px, 4vw, 54px);
  background: var(--forest);
  color: var(--white);
}
.hero::after {
  position: absolute;
  right: -70px;
  bottom: -120px;
  width: 330px;
  height: 330px;
  border-radius: 50%;
  background: rgba(201,239,124,.12);
  content: "";
}
.hero h2 {
  max-width: 780px;
  margin: 0 0 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 4.6rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.04em;
}
.hero p { max-width: 690px; margin: 0; color: #d7e6df; line-height: 1.6; }
.hero-actions { display: flex; align-items: end; justify-content: end; gap: 10px; z-index: 1; }
.hero .button { background: var(--lime); color: var(--ink); }
.hero .button.secondary { background: rgba(255,255,255,.1); color: var(--white); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.metric, .card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
  box-shadow: 0 6px 22px rgba(20,35,31,.035);
}
.metric { padding: 20px; }
.metric span { color: var(--muted); font-size: .75rem; font-weight: 800; text-transform: uppercase; }
.metric strong { display: block; margin: 8px 0 2px; font-size: 2rem; letter-spacing: -.04em; }
.metric small { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.card { padding: 22px; }
.card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.card h2, .card h3 { margin: 0; letter-spacing: -.025em; }
.card h2 { font-size: 1.25rem; }
.card h3 { font-size: 1rem; }
.card-header p, .section-heading p { margin: 5px 0 0; color: var(--muted); font-size: .88rem; }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 4px 0 20px;
}
.section-heading h2 { margin: 0; font-family: Georgia, serif; font-size: clamp(2rem, 4vw, 3.5rem); font-weight: 500; }
.action-list, .timeline, .connection-grid, .resource-grid { display: grid; gap: 10px; }
.action-row, .timeline-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid #edf0ed;
  padding: 13px 0;
}
.action-row:first-child, .timeline-row:first-child { border-top: 0; padding-top: 0; }
.action-row > div, .timeline-row > div { min-width: 0; flex: 1; }
.action-row p, .timeline-row p { margin: 2px 0 0; color: var(--muted); font-size: .8rem; }
.action-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  background: var(--mint);
  color: var(--green);
  font-weight: 900;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--cream);
  color: #5b665f;
  font-size: .7rem;
  font-weight: 850;
  text-transform: capitalize;
}
.badge.connected, .badge.active, .badge.approved, .badge.live, .badge.ready_to_test, .badge.complete, .badge.verified { background: var(--mint); color: #27613b; }
.badge.attention, .badge.failed, .badge.rejected, .badge.suspended { background: var(--danger); color: #8a2d20; }
.badge.pending, .badge.waiting_for_client, .badge.payment_due, .badge.needs_input { background: var(--warning); color: #7c5d10; }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: var(--cream); }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 12px; color: var(--muted); font-size: .68rem; text-align: left; text-transform: uppercase; }
td { border-top: 1px solid #edf0ed; padding: 14px 12px; font-size: .86rem; vertical-align: top; }
tr[data-click] { cursor: pointer; }
tr[data-click]:hover { background: #fbfbf7; }
.muted { color: var(--muted); }
.empty {
  display: grid;
  min-height: 160px;
  place-items: center;
  border: 1px dashed #cad3cd;
  border-radius: 15px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}
.connection-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.connection-card {
  display: grid;
  min-height: 160px;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: var(--white);
}
.connection-card .connection-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: var(--cream);
  font-size: 1.1rem;
}
.connection-card h3, .connection-card p { margin: 0; }
.connection-card p { color: var(--muted); font-size: .8rem; line-height: 1.45; }
.connection-card button { align-self: end; justify-self: start; }
.resource-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.resource-card {
  display: flex;
  min-height: 150px;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: var(--white);
  color: var(--ink);
  text-decoration: none;
}
.resource-card:hover { border-color: #9eb7aa; transform: translateY(-2px); box-shadow: var(--shadow); }
.resource-card span { color: var(--green); font-size: .67rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.resource-card h3 { margin: 10px 0 7px; }
.resource-card p { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.resource-card b { margin-top: auto; padding-top: 12px; color: var(--green); }

form .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
label.field { display: grid; gap: 6px; color: #47534e; font-size: .78rem; font-weight: 760; }
label.field.wide { grid-column: 1 / -1; }
input, select, textarea {
  width: 100%;
  min-height: 43px;
  border: 1px solid #ccd5cf;
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--white);
  color: var(--ink);
}
textarea { min-height: 98px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--green); outline: 3px solid rgba(27,91,72,.12); }
.form-actions { display: flex; justify-content: end; gap: 10px; margin-top: 18px; }
.filters { display: flex; gap: 10px; align-items: center; }
.filters input { min-width: 240px; }

.toast {
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 32px));
  border-radius: 14px;
  padding: 14px 18px;
  background: var(--forest);
  color: var(--white);
  box-shadow: var(--shadow);
}
.toast.error { background: #8a2d20; }
dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: 88vh;
  overflow-y: auto;
  border: 0;
  border-radius: 22px;
  padding: 0;
  background: var(--white);
  box-shadow: 0 30px 90px rgba(12,25,20,.28);
}
dialog::backdrop { background: rgba(10,23,18,.58); backdrop-filter: blur(4px); }
#modal-form { position: relative; padding: clamp(22px, 4vw, 38px); }
.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--cream);
  cursor: pointer;
  font-size: 1.35rem;
}
.modal-heading { padding-right: 38px; margin-bottom: 22px; }
.modal-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 2rem; font-weight: 500; }
.modal-heading p { margin: 7px 0 0; color: var(--muted); }
.mobile-nav { display: none; }

@media (max-width: 1100px) {
  .app-shell { padding-left: 214px; }
  .sidebar { width: 214px; }
  .brand img { width: 180px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .connection-grid, .resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-add { display: none; }
}

@media (max-width: 820px) {
  .login-page { grid-template-columns: 1fr; }
  .login-panel { min-height: 100vh; padding: 30px 24px; }
  .login-logo { margin-bottom: 30px; }
  .login-aside { display: none; }
  .app-shell { padding: 0 0 78px; }
  .sidebar { display: none; }
  .sidebar.open { display: flex; width: min(300px, 84vw); box-shadow: 20px 0 60px rgba(0,0,0,.2); }
  .menu-button { display: block; }
  .topbar { min-height: 70px; gap: 12px; padding: 11px 16px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { font-size: 1.12rem; }
  .top-actions { gap: 7px; }
  .client-picker span { display: none; }
  .client-picker select { width: min(34vw, 160px); font-size: .8rem; }
  #quick-add, .profile-copy { display: none; }
  .profile-button { padding: 0; }
  .profile-menu { top: 62px; right: 12px; }
  .safety-strip { padding: 8px 16px; font-size: .7rem; }
  .content { padding: 18px 14px 10px; }
  .hero { grid-template-columns: 1fr; border-radius: 18px; padding: 24px 20px; }
  .hero h2 { font-size: 2.5rem; }
  .hero-actions { justify-content: start; flex-wrap: wrap; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .connection-grid, .resource-grid { grid-template-columns: 1fr; }
  .mobile-nav {
    position: fixed;
    z-index: 25;
    inset: auto 0 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    border-top: 1px solid var(--line);
    padding: 7px 4px max(7px, env(safe-area-inset-bottom));
    background: rgba(255,253,248,.97);
    backdrop-filter: blur(14px);
  }
  .mobile-nav a {
    display: grid;
    gap: 1px;
    place-items: center;
    color: var(--muted);
    font-size: .62rem;
    font-weight: 800;
    text-decoration: none;
  }
  .mobile-nav a span { font-size: 1.15rem; }
  .mobile-nav a.active { color: var(--green); }
  .section-heading { align-items: start; flex-direction: column; }
  .filters { width: 100%; }
  .filters input { min-width: 0; }
}

@media (max-width: 520px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .metric { padding: 15px; }
  .metric strong { font-size: 1.55rem; }
  .metric small { display: none; }
  .hero h2 { font-size: 2.15rem; }
  .hero p { font-size: .9rem; }
  .card { padding: 17px; border-radius: 15px; }
  .table-wrap table { min-width: 670px; }
  form .form-grid { grid-template-columns: 1fr; }
  label.field.wide { grid-column: auto; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .client-picker select { width: 112px; }
}

@media (prefers-reduced-motion: no-preference) {
  .button, .resource-card { transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease; }
  .content > * { animation: rise .3s ease both; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } }
}
