:root {
    --green-900: #0d3b13;
    --green-700: #1b5e20;
    --green-600: #2e7d32;
    --green-100: #e6efe6;
    --bg: #f7f5ef;          /* warm off-white */
    --card: #ffffff;
    --ink: #1f2421;
    --ink-soft: #5b635d;
    --line: #e3e0d6;
    --amber: #e08a00;
    --amber-bg: #fff4dd;
    --red: #c0392b;
    --red-bg: #fbe7e4;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 14px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }

/* The hidden attribute must win over explicit display rules below. */
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.45;
}

button { font-family: inherit; cursor: pointer; }

/* Focus visibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.card:focus-visible {
    outline: 3px solid var(--green-600);
    outline-offset: 2px;
}

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: var(--green-700);
    color: #fff;
    box-shadow: var(--shadow);
}
.wordmark { font-size: 20px; font-weight: 700; letter-spacing: 0.2px; }
.wordmark-sub { font-weight: 400; opacity: 0.85; }
.flag { margin-right: 4px; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* Login screen */
.login-screen {
    position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
    background: var(--green-900); padding: 20px; z-index: 60;
}
.login-card {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
    width: 100%; max-width: 360px; padding: 28px 26px;
}
.login-brand { font-size: 22px; font-weight: 800; color: var(--green-700); }
.login-sub { color: var(--ink-soft); font-size: 14px; margin: 4px 0 20px; }
.login-error { color: var(--red); font-size: 13px; margin: 4px 0 0; }
.btn-block { width: 100%; margin-top: 8px; }

/* Top bar right / user menu */
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-menu { position: relative; }
.user-btn {
    border: 1px solid rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.12);
    color: #fff; padding: 8px 12px; border-radius: 8px; font-size: 14px; font-weight: 600;
}
.user-btn:hover { background: rgba(255, 255, 255, 0.2); }
.caret { font-size: 11px; opacity: 0.8; }
.user-dropdown {
    position: absolute; right: 0; top: calc(100% + 6px); background: #fff;
    border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
    min-width: 150px; overflow: hidden; z-index: 70;
}
.menu-item {
    display: block; width: 100%; text-align: left; border: none; background: #fff;
    padding: 10px 14px; font-size: 14px; color: var(--ink);
}
.menu-item:hover { background: #f1efe8; }

/* Team list */
.team-list { list-style: none; margin: 0 0 16px; padding: 0; }
.team-member {
    display: flex; justify-content: space-between; align-items: center;
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    padding: 10px 12px; margin-bottom: 8px;
}
.team-member .tm-name { font-weight: 600; font-size: 14px; }
.team-member .tm-email { font-size: 12px; color: var(--ink-soft); }
.team-member .tm-you { font-size: 11px; font-weight: 700; color: var(--green-700); }

/* Template list rows */
.template-row .tm-name { font-weight: 600; font-size: 14px; }
.template-row .tm-subject { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.template-actions { display: flex; gap: 4px; flex-shrink: 0; }
.template-actions .btn { padding: 5px 10px; font-size: 13px; }
.templates-empty { color: var(--ink-soft); font-style: italic; font-size: 14px; margin: 0 0 16px; }
/* Show the current template used on an email activity */
.a-template { color: var(--green-700); font-weight: 600; }

/* Buttons */
.btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
}
.btn:hover { background: #f1efe8; }
.btn-primary { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-600); }
.btn-danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.icon-btn {
    border: none; background: transparent; font-size: 18px; color: inherit;
    width: 34px; height: 34px; border-radius: 8px;
}
.icon-btn:hover { background: rgba(0, 0, 0, 0.08); }

/* Stats strip */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.stat {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .n { font-size: 26px; font-weight: 800; line-height: 1; }
.stat .l { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 6px; }
.stat.attention { background: var(--amber-bg); border-color: var(--amber); }
.stat.attention .n { color: var(--amber); }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
    padding: 5px 11px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.chip:hover { background: #f1efe8; }
.chip.active { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.search {
    flex: 1; min-width: 220px; max-width: 360px;
    border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; font-size: 14px; background: #fff;
}

/* Board */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow); cursor: pointer; display: flex; gap: 14px;
    transition: transform 0.06s ease, box-shadow 0.12s ease;
}
.card:hover { transform: translateY(-1px); box-shadow: 0 4px 18px rgba(0, 0, 0, 0.1); }
.card.high { border-left: 4px solid var(--amber); }
.card-main { flex: 1; min-width: 0; }
.card-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-title h3 { margin: 0; font-size: 16px; }
.type-tag {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
    background: var(--green-100); color: var(--green-700); padding: 2px 7px; border-radius: 6px; font-weight: 700;
}
.high-flag { font-size: 11px; font-weight: 800; color: var(--amber); }
.card-sub { font-size: 13px; color: var(--ink-soft); margin: 6px 0; }
.card-contact { font-size: 13px; }
.card-contact.none { color: var(--ink-soft); font-style: italic; }
.card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; text-align: right; white-space: nowrap; }

/* Status pills */
.pill {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
    padding: 3px 9px; border-radius: 999px; color: #fff;
}
.pill.researching { background: #8a8f87; }
.pill.sim_building { background: #6d4cb0; }
.pill.contacted   { background: #2f80ed; }
.pill.replied     { background: #1f9bd1; }
.pill.meeting     { background: #0b8f7a; }
.pill.demo        { background: #2e7d32; }
.pill.pilot       { background: #e08a00; }
.pill.live        { background: #1b5e20; }
.pill.passed      { background: #b94b3e; }

/* Sim dot */
.sim { font-size: 12px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.none { background: #c4c4c4; }
.dot.building { background: var(--amber); }
.dot.ready { background: var(--green-600); }

/* Owner attribution (subtle) */
.owner { font-size: 11px; color: var(--ink-soft); }

/* Follow-up */
.followup { font-size: 12px; color: var(--ink-soft); }
.followup.due { color: var(--red); font-weight: 700; }

/* Overlays */
.overlay {
    position: fixed; inset: 0; background: rgba(20, 28, 22, 0.45);
    display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.overlay-right { justify-content: flex-end; padding: 0; }

.modal {
    background: #fff; border-radius: var(--radius); width: 100%; max-width: 560px;
    max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.modal-narrow { max-width: 400px; }
.modal-head, .drawer-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h2, .drawer-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0 0 14px; }
legend { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--ink-soft); padding: 0 6px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 10px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input, select, textarea {
    width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line);
    border-radius: 8px; font-size: 14px; color: var(--ink); background: #fff; font-family: inherit;
}
textarea { resize: vertical; }
.req { color: var(--red); }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }

/* Drawer */
.drawer {
    background: var(--bg); width: 100%; max-width: 440px; height: 100vh;
    display: flex; flex-direction: column; overflow-y: auto; box-shadow: var(--shadow);
}
.drawer-meta { margin: 4px 0 0; font-size: 13px; color: var(--ink-soft); }
.drawer-actions { padding: 14px 20px 0; }
.drawer-block { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-block h3 { margin: 0 0 10px; font-size: 14px; }
.contact-line { font-size: 14px; margin: 2px 0; }
.contact-line.none { color: var(--ink-soft); font-style: italic; }
.activity-form .btn { margin-top: 4px; }
.activity-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-compose { background: #eef5ee; border-color: var(--green-600); color: var(--green-700); }
.btn-compose:hover { background: var(--green-100); }
.btn-compose:disabled { opacity: 0.5; cursor: not-allowed; }
.field-hint { font-size: 12px; color: var(--ink-soft); margin: 2px 0 10px; line-height: 1.7; }
.field-hint code {
    background: #eef0ea; border-radius: 4px; padding: 1px 5px; font-size: 11px; white-space: nowrap;
}

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-item {
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    padding: 10px 12px; margin-bottom: 8px; display: flex; gap: 10px; justify-content: space-between;
}
.activity-item .a-meta { font-size: 12px; color: var(--ink-soft); }
.activity-item .a-type {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
    color: var(--green-700);
}
.activity-item .a-summary { font-size: 14px; margin-top: 2px; white-space: pre-wrap; }
.activity-empty { color: var(--ink-soft); font-style: italic; font-size: 14px; }

.empty-state { text-align: center; color: var(--ink-soft); padding: 40px 0; font-style: italic; }

/* Toast */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--green-900); color: #fff; padding: 11px 18px; border-radius: 10px;
    font-size: 14px; font-weight: 600; box-shadow: var(--shadow); z-index: 100;
    animation: toast-in 0.18s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }

/* Responsive */
@media (max-width: 760px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .board { grid-template-columns: 1fr; }
    .container { padding: 16px; }
    .drawer { max-width: 100%; }
    .row { grid-template-columns: 1fr; }
    /* Stack the status/sim block under the card body so it doesn't clip. */
    .card { flex-direction: column; }
    .card-side { flex-direction: row; flex-wrap: wrap; align-items: center; text-align: left; }
}
