/* Merkio — Design System (Light, Monavio-inspired) */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
    --font-size-base: 14px;

    /* Light palette */
    --color-bg: #f5f6f8;
    --color-surface: #ffffff;
    --color-surface-2: #f0f1f4;
    --color-border: #e4e6ed;
    --color-border-subtle: #ecedf2;
    --color-text: #1a1d2b;
    --color-text-muted: #6b7280;
    --color-text-light: #9ca3b4;

    /* Accent — blue */
    --color-accent: #3b6df0;
    --color-accent-hover: #2d5ad4;
    --color-accent-subtle: rgba(59, 109, 240, 0.08);
    --color-accent-light: rgba(59, 109, 240, 0.14);

    /* Status */
    --color-green: #16a34a;
    --color-green-subtle: rgba(22, 163, 74, 0.08);
    --color-amber: #d97706;
    --color-amber-subtle: rgba(217, 119, 6, 0.08);
    --color-red: #dc2626;
    --color-red-subtle: rgba(220, 38, 38, 0.08);
    --color-blue: #2563eb;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --transition: 150ms ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: var(--font-size-base);
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Typography --- */
h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.02em; color: var(--color-text); }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1rem; font-weight: 500; }
h4 {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--color-accent-hover); }

/* --- Icons (inline SVG helper) --- */
.icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--color-text-muted);
    vertical-align: middle;
}
.icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-sm { width: 15px; height: 15px; }
.icon-xs { width: 13px; height: 13px; }

/* --- Cards --- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-xs);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.card-header h3 {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1.4;
    white-space: nowrap;
}

.btn-primary {
    background: var(--color-accent);
    color: #fff;
    box-shadow: var(--shadow-xs);
}
.btn-primary:hover {
    background: var(--color-accent-hover);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
}
.btn-secondary:hover {
    background: var(--color-surface-2);
    border-color: var(--color-text-light);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    padding: 5px 8px;
}
.btn-ghost:hover {
    color: var(--color-text);
    background: var(--color-surface-2);
    border-radius: var(--radius-sm);
}

.btn-danger {
    background: transparent;
    border: 1px solid var(--color-red);
    color: var(--color-red);
}
.btn-danger:hover {
    background: var(--color-red-subtle);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
}

/* --- Inputs --- */
input, textarea, select {
    font-family: inherit;
    font-size: 0.9rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    padding: 9px 12px;
    width: 100%;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

input::placeholder, textarea::placeholder {
    color: var(--color-text-light);
}

textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-group {
    margin-bottom: 14px;
}

/* --- Inline Editable --- */
.editable {
    cursor: text;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: all var(--transition);
    min-height: 1.5em;
}

.editable:hover {
    background: var(--color-surface-2);
}

.editable:focus {
    border-color: var(--color-accent);
    background: var(--color-surface);
    box-shadow: 0 0 0 3px var(--color-accent-subtle);
    outline: none;
}

.editable[data-placeholder]:empty::before {
    content: attr(data-placeholder);
    color: var(--color-text-light);
    font-style: italic;
}

/* --- Badges / Pills --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 99px;
    line-height: 1.6;
    letter-spacing: 0.01em;
}

.badge-green { background: var(--color-green-subtle); color: var(--color-green); }
.badge-amber { background: var(--color-amber-subtle); color: var(--color-amber); }
.badge-red { background: var(--color-red-subtle); color: var(--color-red); }
.badge-blue { background: rgba(37,99,235,0.08); color: var(--color-blue); }
.badge-accent { background: var(--color-accent-subtle); color: var(--color-accent); }
.badge-muted { background: var(--color-surface-2); color: var(--color-text-muted); }

/* --- Score Display --- */
.score-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.score-number {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

.score-number.green { color: var(--color-green); }
.score-number.amber { color: var(--color-amber); }
.score-number.red { color: var(--color-red); }

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 200ms;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 28px;
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.12);
    transform: translateY(8px);
    transition: transform 200ms;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}

.modal-header h2 {
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--color-text-light);
    cursor: pointer;
    font-size: 1.3rem;
    padding: 4px;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.modal-close:hover { color: var(--color-text); background: var(--color-surface-2); }

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 22px;
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    font-size: 0.85rem;
    color: var(--color-text);
    box-shadow: var(--shadow-md);
    animation: toast-in 200ms ease forwards;
    max-width: 320px;
}

.toast.success { border-left: 3px solid var(--color-green); }
.toast.error { border-left: 3px solid var(--color-red); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateY(-10px); }
}

/* --- Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 9px 12px;
    text-align: left;
    border-bottom: 1px solid var(--color-border-subtle);
    font-size: 0.9rem;
}

th {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

tr:last-child td { border-bottom: none; }

/* --- Checkbox --- */
.checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--color-accent);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-light);
}

/* --- Utility Classes --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Page Layout (inside iframe) --- */
.page {
    padding: 28px 32px;
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--color-bg);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.page-header h1 {
    font-size: 1.4rem;
}

.page-subtitle {
    font-size: 0.88rem;
    color: var(--color-text-muted);
    margin-bottom: 24px;
}

/* --- Two Column Layout --- */
.two-col {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    align-items: start;
}

.two-col > .col-main { min-width: 0; }
.two-col > .col-side { min-width: 0; }

/* --- Snapshot Bar (Deal Summary) --- */
.snapshot-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 16px 22px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-xs);
}

.snapshot-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.snapshot-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.snapshot-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.snapshot-divider {
    width: 1px;
    height: 36px;
    background: var(--color-border);
}

/* MEDDPICC letters */
.meddpicc-letters {
    display: flex;
    gap: 3px;
}

.meddpicc-letter {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    background: var(--color-surface-2);
    color: var(--color-text-light);
}

.meddpicc-letter.filled {
    background: var(--color-accent-light);
    color: var(--color-accent);
}

/* --- Accordion --- */
.accordion-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 8px;
    background: var(--color-surface);
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
}

.accordion-header:hover {
    background: var(--color-surface-2);
}

.accordion-content {
    padding: 0 18px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 300ms ease, padding 300ms ease;
}

.accordion-item.open .accordion-content {
    max-height: 500px;
    padding: 14px 18px 18px;
}

/* --- Signal Pills --- */
.signal-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 99px;
    font-size: 0.8rem;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border-subtle);
}

.signal-pill .signal-label {
    color: var(--color-text-muted);
    font-size: 0.72rem;
    font-weight: 500;
}

/* --- Loading --- */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-radius: var(--radius-lg);
    z-index: 10;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 36px 16px;
    color: var(--color-text-muted);
}

.empty-state h3 {
    color: var(--color-text);
    margin-bottom: 4px;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ── Rich text toolbar ── */
.rich-wrap { position:relative; }
.rich-toolbar { display:flex; gap:2px; padding:4px 6px; border:1px solid var(--color-border); border-bottom:none; border-radius:var(--radius-sm) var(--radius-sm) 0 0; background:var(--color-surface-2); }
.rich-toolbar button { background:none; border:none; cursor:pointer; padding:3px 6px; border-radius:3px; color:var(--color-text-muted); font-size:0.78rem; font-family:inherit; line-height:1; transition:all 0.15s; display:flex; align-items:center; justify-content:center; }
.rich-toolbar button:hover { background:var(--color-surface); color:var(--color-text); }
.rich-toolbar button svg { width:14px; height:14px; }
.rich-toolbar .tb-sep { width:1px; background:var(--color-border); margin:2px 4px; }
.rich-wrap textarea { border-top-left-radius:0 !important; border-top-right-radius:0 !important; }

/* Rich text display — rendered markdown-like content */
.rich-content { font-size:0.88rem; color:var(--color-text); line-height:1.45; word-wrap:break-word; }
.rich-content b, .rich-content strong { font-weight:600; color:var(--color-text); }
.rich-content i, .rich-content em { font-style:italic; }
.rich-content .rc-bullet { display:block; padding-left:16px; position:relative; margin:0; line-height:1.4; }
.rich-content .rc-bullet::before { content:"•"; position:absolute; left:4px; color:var(--color-accent); }

/* Section labels in cards — bold dark gray */
.section-label { font-size:0.72rem; font-weight:700; text-transform:uppercase; letter-spacing:0.05em; color:#374151; margin-bottom:4px; }
