@font-face { font-family: Poppins; font-weight: 500; src: url(/fonts/Poppins-Medium.ttf); font-display: swap; }
@font-face { font-family: Poppins; font-weight: 600; src: url(/fonts/Poppins-SemiBold.ttf); font-display: swap; }
@font-face { font-family: Poppins; font-weight: 700; src: url(/fonts/Poppins-Bold.ttf); font-display: swap; }

:root {
  --teal: #009899; --teal-dark: #007677; --teal-50: #e6f5f5; --teal-100: #c8eaea;
  --ink: #2f3637; --muted: #6b7677; --line: #e3e8e8; --bg: #f4f7f7; --card: #fff;
  --green: #1f8a4c; --green-bg: #e4f4ea; --amber: #a86200; --amber-bg: #fff1d9;
  --red: #b42318; --red-bg: #fde8e6; --blue: #2459a8; --blue-bg: #e6eefb;
  --purple: #6b3fa0; --purple-bg: #f0e9f8; --grey-bg: #eef0f0;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,40,40,.06), 0 4px 14px rgba(16,40,40,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
h1, h2, h3, .brand, .kpi .n, button, .btn { font-family: Poppins, system-ui, sans-serif; }
h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
a { color: var(--teal-dark); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #fff; border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.side img { width: 170px; margin: 2px 8px 18px; }
.side a.nav { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--ink); text-decoration: none; font-weight: 500; font-family: Poppins, sans-serif; font-size: 14px; }
.side a.nav:hover { background: var(--teal-50); }
.side a.nav.on { background: var(--teal); color: #fff; }
.side a.nav .badge { margin-left: auto; background: var(--red); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; }
.side .who { margin-top: auto; font-size: 12px; color: var(--muted); padding: 10px 12px; border-top: 1px solid var(--line); }
.main { padding: 24px 32px 60px; max-width: 1240px; }
.demo-bar { background: #fff4d6; color: #6b4b00; border-bottom: 1px solid #f1d58a; padding: 8px 32px; font-size: 13px; display: flex; gap: 12px; align-items: center; }
.demo-bar button { margin-left: auto; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }

/* cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; border-top: 4px solid var(--teal); cursor: pointer; text-decoration: none; color: inherit; display: block; }
.kpi .n { font-size: 30px; font-weight: 600; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi.amber { border-color: #f0a400; } .kpi.blue { border-color: var(--blue); } .kpi.red { border-color: var(--red); } .kpi.purple { border-color: var(--purple); } .kpi.green { border-color: var(--green); }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; white-space: nowrap; font-family: Poppins, sans-serif; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.s-active { color: var(--green); background: var(--green-bg); }
.s-expiring { color: var(--amber); background: var(--amber-bg); }
.s-pending { color: var(--blue); background: var(--blue-bg); }
.s-grace { color: #b54708; background: #fdebd8; }
.s-lapsed, .s-failed { color: var(--red); background: var(--red-bg); }
.s-life, .s-legacy { color: var(--purple); background: var(--purple-bg); }
.s-cancelled, .s-renewed, .s-none { color: var(--muted); background: var(--grey-bg); }
.s-sent { color: var(--green); background: var(--green-bg); }
.s-queued { color: var(--blue); background: var(--blue-bg); }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--teal-50); color: var(--teal-dark); font-weight: 600; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--teal-50); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* forms and buttons */
button, .btn { white-space: nowrap; border: 0; border-radius: 9px; padding: 9px 16px; font-weight: 600; font-size: 14px; cursor: pointer; background: var(--teal); color: #fff; text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
button:hover { background: var(--teal-dark); }
button.ghost { background: #fff; color: var(--teal-dark); border: 1px solid var(--teal-100); }
button.ghost:hover { background: var(--teal-50); }
button.danger { background: #fff; color: var(--red); border: 1px solid #f3c3bd; }
button.danger:hover { background: var(--red-bg); }
button.sm { padding: 5px 11px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid #cfd8d8; border-radius: 9px; background: #fff; width: 100%; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal-100); border-color: var(--teal); }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; } .row > .auto { flex: 0 0 auto; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters button { background: #fff; color: var(--ink); border: 1px solid var(--line); font-weight: 500; padding: 6px 12px; }
.filters button.on { background: var(--teal); color: #fff; border-color: var(--teal); }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(20,40,40,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 520px; padding: 22px 24px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 760px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.confirm-box { background: var(--teal-50); border-left: 4px solid var(--teal); border-radius: 8px; padding: 12px 14px; margin-top: 8px; }
.confirm-box.warn { background: var(--red-bg); border-color: var(--red); }
.confirm-box ul { margin: 6px 0 0 18px; padding: 0; }
.err { color: var(--red); font-size: 13px; margin-top: 10px; }

/* member page */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.timeline { border-left: 3px solid var(--teal-100); margin-left: 6px; padding-left: 18px; }
.term { position: relative; margin-bottom: 16px; }
.term::before { content: ""; position: absolute; left: -26px; top: 6px; width: 13px; height: 13px; border-radius: 50%; background: var(--teal); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--teal-100); }
.bar-row { display: grid; grid-template-columns: 150px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; margin: 6px 0; }
.bar { height: 12px; border-radius: 6px; background: var(--teal); }
.spark { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.spark div { flex: 1; background: var(--teal-100); border-radius: 5px 5px 0 0; position: relative; min-height: 2px; }
.spark div.cur { background: var(--teal); }
.spark-l { display: flex; gap: 6px; font-size: 11px; color: var(--muted); } .spark-l span { flex: 1; text-align: center; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 99; font-size: 14px; box-shadow: var(--shadow); }
iframe.preview { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
@media (max-width: 900px) { .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; } .side img { width: 120px; margin: 0 8px; } .side .who { display: none; } .g2, .g3 { grid-template-columns: 1fr; } .main { padding: 16px; } }

/* icons */
.side a.nav .icon { width: 20px; height: 20px; }
.side a.nav .ext { width: 14px; height: 14px; margin-left: -4px; opacity: .7; }
button .icon { width: 17px; height: 17px; }
.tag { display: inline-flex; align-items: center; gap: 4px; } .tag .icon { width: 13px; height: 13px; }
.small.line .icon { color: var(--teal); margin-right: 4px; }
a.back { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.toast { display: flex; align-items: center; gap: 10px; }
.empty img { display: block; margin: 0 auto 8px; }
td .icon { color: var(--teal); }
button { transition: transform 100ms ease-out, background .15s; } button:active { transform: scale(.97); }
.kpi { transition: transform .15s, box-shadow .15s; } .kpi:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16,40,40,.10); }
.badge { animation: bhs-pulse-dot 2s ease-out infinite; }
@media (prefers-reduced-motion: reduce) { .badge { animation: none; } .kpi:hover { transform: none; } button:active { transform: none; } }

/* role-based visibility (the server checks every action too) */
.need-edit, .need-delete, .need-send, .need-users { display: none !important; }
body.can-edit .need-edit, body.can-delete .need-delete, body.can-send .need-send { display: inline-flex !important; }
body.can-users .need-users { display: flex !important; }
.role-pill { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--teal-50); color: var(--teal-dark); }
.linkbox { display: flex; gap: 8px; margin-top: 8px; } .linkbox input { font-size: 12px; }
