:root {
  --mint: #6ed9be;
  --mint-2: #4cc9aa;
  --mint-deep: #1f9d82;
  --ink: #1a1a1a;
  --muted: #5c6570;
  --paper: #ffffff;
  --wash: #f4faf7;
  --line: #e4eeea;
  --shadow: 0 12px 40px rgba(20, 40, 36, .08);
  --radius: 18px;
  --font: "Manrope", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  --tap: 48px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--wash);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; } /* stop iOS zoom */

/* —— Login —— */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: max(20px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  background:
    radial-gradient(520px 280px at 0% 0%, rgba(110,217,190,.28), transparent 70%),
    radial-gradient(520px 280px at 100% 100%, rgba(110,217,190,.18), transparent 70%),
    var(--paper);
}
.login-brand {
  display: flex; align-items: center; justify-content: center;
}
.login-brand img {
  height: 56px; width: auto; max-width: min(240px, 70vw);
}
.login-card {
  width: min(440px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 22px 24px;
}
.login-pick { width: min(860px, 100%); }
.login-card h1 {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(26px, 5vw, 34px);
  letter-spacing: -.02em;
  line-height: 1.15;
  margin-bottom: 6px;
}
.login-card .k {
  font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--mint-deep); margin-bottom: 8px;
}
.login-sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.login-card label {
  display: block; font-size: 12px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--mint-deep); margin: 4px 0 6px;
}
.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%; min-height: var(--tap);
  margin: 0 0 14px; padding: 12px 14px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
}
.login-card input:focus {
  outline: 2px solid var(--mint);
  border-color: var(--mint);
  background: #fff;
}
.login-card .btn { width: 100%; min-height: var(--tap); margin-top: 6px; }
.desk-pick { margin-top: 8px; max-width: 960px; }
.main .portal-card { background: #fff; }
.login-owner a { color: var(--mint-deep); font-weight: 700; }
.portal-grid { display: grid; gap: 12px; }
.portal-card {
  display: flex; flex-direction: column; justify-content: center;
  min-height: 92px; padding: 18px 18px;
  border: 1px solid var(--line);
  background: var(--wash);
  border-radius: 16px;
}
.portal-card b {
  font-family: var(--display); font-weight: 500; font-size: 22px; margin-bottom: 6px;
}
.portal-card span { color: var(--muted); font-size: 13px; }
.portal-card:hover, .portal-card:focus {
  border-color: var(--mint);
  background: #fff;
  box-shadow: 0 8px 24px rgba(31,157,130,.12);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 16px;
  border: 0; border-radius: 999px;
  background: var(--mint); color: #0c3a32;
  font-size: 13px; font-weight: 700; letter-spacing: .04em;
  cursor: pointer;
}
.btn:hover { background: var(--mint-2); }
.btn-ghost {
  background: #fff; color: var(--ink);
  border: 1px solid var(--line);
}
.btn-danger { background: #f4d6d2; color: #8a2b22; }
.btn-danger:hover { background: #ecc4bf; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.row-actions { display: flex; gap: 12px; white-space: nowrap; align-items: center; }
.row-actions a, .row-actions input, .row-actions button {
  color: var(--mint-deep); font-weight: 700; background: none; border: 0; cursor: pointer; padding: 0; font: inherit;
}
.row-actions .link-del { color: #8a2b22; }
.muted-meta { color: var(--muted); font-size: 13px; margin: 12px 0 4px; }
.pipe { grid-template-columns: repeat(7, minmax(0, 1fr)); }
a.card.pipe-card { display: block; transition: border-color .15s, box-shadow .15s; }
a.card.pipe-card:hover, a.card.pipe-card.on {
  border-color: var(--mint-2);
  box-shadow: 0 8px 24px rgba(31,157,130,.12);
}
.pipe-card b { font-size: 22px; }

.err, .errp { color: #c0392b; margin: 0 0 12px; font-size: 13px; }
.note { color: var(--mint-deep); margin: 10px 0; }

/* —— App shell —— */
.admin-bar {
  display: none;
  position: sticky; top: 0; z-index: 70;
  align-items: center; gap: 10px;
  min-height: 64px;
  padding: 8px 14px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--mint);
  border-bottom: 1px solid rgba(12,58,50,.08);
}
.admin-bar img { height: 40px; width: auto; max-width: 160px; filter: brightness(0); }
.admin-desk {
  margin-left: auto; font-size: 11px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: #0c3a32;
}
.admin-burger, .drawer-close {
  width: 44px; height: 44px; border: 0; border-radius: 12px;
  background: rgba(255,255,255,.55); color: var(--ink);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  cursor: pointer; flex-shrink: 0;
}
.admin-burger span { display: block; width: 18px; height: 2px; background: var(--ink); border-radius: 2px; }
.admin-veil {
  display: none; position: fixed; inset: 0; z-index: 75;
  background: rgba(18, 32, 28, .28);
}
.admin-veil.open { display: block; }

.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; min-height: 100dvh; }
.side {
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 22px 14px 28px;
}
.side-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.side-head .drawer-close { display: none; margin-left: auto; }
.side .brand img { height: 48px; width: auto; max-width: 180px; }
.side-role {
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--mint-deep); margin: 6px 8px 18px;
}
.side a {
  display: flex; align-items: center;
  min-height: 44px; padding: 8px 12px; margin-bottom: 4px;
  color: var(--muted); font-size: 14px; font-weight: 600;
  border-radius: 12px;
}
.side a:hover, .side a.on {
  color: var(--ink); background: var(--wash);
}
.side a.on { background: #e7f7f2; color: var(--mint-deep); }
.side .side-foot { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }

.main {
  padding: 24px 22px 72px;
  min-width: 0;
}
.top {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 22px;
}
h1 {
  font-family: var(--display); font-weight: 500;
  font-size: clamp(24px, 4vw, 32px);
  letter-spacing: -.02em;
}
.cards {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: 0 8px 24px rgba(20,40,36,.04);
}
.card b { display: block; font-family: var(--display); font-weight: 500; font-size: 28px; }
.card span { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--mint-deep); }

.table-scroll {
  width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: 14px; background: var(--paper);
  margin-bottom: 18px;
}
table { width: 100%; min-width: 640px; border-collapse: collapse; background: var(--paper); }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
th {
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--mint-deep); background: var(--wash); white-space: nowrap;
}
td a { color: var(--mint-deep); font-weight: 700; }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select, textarea, .field, select.field {
  padding: 12px 14px; min-height: 44px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; color: var(--ink);
}
.filters input, .filters select { flex: 1; min-width: min(220px, 100%); }
textarea, .field, select.field { width: 100%; }
textarea { min-height: 220px; }
select.field { background: var(--paper); }
.grid2 { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; }
label {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--mint-deep); margin: 12px 0 6px;
}

.v-h { font-family: var(--display); font-weight: 500; font-size: 22px; margin-bottom: 8px; }
.v-hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin-bottom: 12px; }
.v-row { display: flex; gap: 8px; align-items: stretch; }
.v-row .field { flex: 1; min-width: 0; }
.v-row .btn { flex-shrink: 0; }
.v-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.v-notes { min-height: 88px !important; }
.v-banner {
  margin: 10px 0 4px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid #d7efe7; background: #e7f7f2; color: #0c3a32; font-size: 13px;
}
.v-steps { margin: 14px 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.v-kpis .card:nth-child(1) { border-top: 3px solid #3db8c5; }
.v-kpis .card:nth-child(2) { border-top: 3px solid var(--mint-deep); }
.v-kpis .card:nth-child(3) { border-top: 3px solid #e0a35a; }
.v-kpis .card:nth-child(4) { border-top: 3px solid var(--mint); }
.badge-repeat, .badge-new {
  display: inline-block; padding: 4px 8px; font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; font-weight: 700; border-radius: 999px;
}
.badge-repeat { background: var(--mint); color: #0c3a32; }
.badge-new { background: #e7f7f2; color: var(--mint-deep); }
.filters label { color: var(--muted); letter-spacing: 0; text-transform: none; font-size: 13px; margin: 0; }
.note-item {
  margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; color: var(--muted);
}
.access-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px; margin-top: 8px;
}
.access-card .v-h { margin-bottom: 4px; }
.access-card .btn-row { margin-top: 16px; }

@media (min-width: 720px) {
  .login-card { padding: 36px 32px 28px; }
  .login-brand img { height: 64px; }
  .portal-grid { grid-template-columns: repeat(3, 1fr); }
  .login-pick .portal-grid { align-items: stretch; }
  .desk-pick { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
  .desk-pick { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1100px) {
  .admin-bar { display: flex; }
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(320px, 88vw);
    z-index: 80;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: none;
    padding-top: max(16px, env(safe-area-inset-top));
  }
  .side.open { transform: none; box-shadow: 16px 0 40px rgba(20,40,36,.16); }
  .side-head .drawer-close { display: inline-flex; }
  body.menu-on { overflow: hidden; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipe { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid2, .v-row2 { grid-template-columns: 1fr; }
  .main { padding: 18px 16px 100px; }
}

@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr; }
  .pipe { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .v-row { flex-direction: column; }
  .filters .btn, .filters .btn-ghost { width: 100%; }
  .top .btn { width: 100%; }
  .login-card { padding: 22px 16px 20px; }
}
