*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #0EA5E9;
    --accent: #38BDF8;
    --bg: #0F172A;
    --surface: #1E293B;
    --surface2: #334155;
    --border: #334155;
    --text: #F1F5F9;
    --text-dim: #94A3B8;
    --font: 'Inter', system-ui, sans-serif;
    --proposal-primary: #0EA5E9;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    padding: .75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #060d1a 0%, var(--surface) 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .6rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: .55rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo h1 {
    font-size: .92rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo p {
    font-size: .6rem;
    color: var(--text-dim);
}

.header-actions {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
}

.btn {
    padding: .36rem .78rem;
    border-radius: 5px;
    border: none;
    font-family: var(--font);
    font-size: .7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .18s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent);
    color: #000;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #475569;
}

/* Layout */
.app-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    flex: 1;
    height: calc(100vh - 58px);
    overflow: hidden;
}

/* Form panel */
.form-panel {
    border-right: 1px solid var(--border);
    overflow-y: auto;
    background: var(--surface);
}

.form-section {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
}

.section-label {
    font-size: .65rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: .55rem;
}

.form-group {
    margin-bottom: .7rem;
}

.form-label {
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-dim);
    display: block;
    margin-bottom: .22rem;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    background: #0d1829;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    font-family: var(--font);
    font-size: .78rem;
    padding: .38rem .55rem;
    outline: none;
    transition: border-color .2s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    border-color: var(--primary);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
}

.form-row3 {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: .4rem;
}

.template-chips {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    margin-bottom: .6rem;
    padding: 0 1rem .6rem;
    border-bottom: 1px solid var(--border);
}

.template-chip {
    padding: .26rem .6rem;
    border-radius: 20px;
    font-size: .68rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid var(--border);
    background: var(--surface2);
    color: var(--text-dim);
    transition: all .15s;
}

.template-chip:hover {
    border-color: var(--primary);
    color: var(--accent);
}

/* Milestone rows */
.milestone-row {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-bottom: .35rem;
    animation: fadeIn .2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.milestone-name {
    flex: 2;
}

.milestone-dur {
    flex: 1;
}

.milestone-unit {
    flex: 1;
}

.milestone-amt {
    flex: 1;
}

.rm-btn {
    background: rgba(239, 68, 68, .15);
    border: none;
    color: #EF4444;
    cursor: pointer;
    border-radius: 4px;
    padding: .2rem .4rem;
    font-size: .75rem;
    flex-shrink: 0;
    transition: background .15s;
}

.rm-btn:hover {
    background: rgba(239, 68, 68, .3);
}

/* Pricing rows */
.pricing-row {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-bottom: .35rem;
}

.pricing-item {
    flex: 2;
}

.pricing-qty {
    flex: .8;
}

.pricing-rate {
    flex: 1;
}

.pricing-total {
    flex: 1;
    font-size: .72rem;
    color: var(--accent);
}

/* Theme selector */
.theme-row {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}

.theme-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color .15s;
}

.theme-dot.active {
    border-color: white;
}

/* Preview panel */
.preview-panel {
    overflow-y: auto;
    background: #e5e7eb;
    padding: 1.5rem;
    display: flex;
    justify-content: center;
}

/* Proposal document */
.proposal-doc {
    background: white;
    max-width: 680px;
    width: 100%;
    min-height: 900px;
    border-radius: 4px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .25);
    padding: 2.5rem;
    font-family: 'Inter', Georgia, serif;
    color: #1a1a1a;
}

.prop-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 3px solid;
}

.prop-company {
    font-size: 1.1rem;
    font-weight: 700;
}

.prop-contact {
    font-size: .72rem;
    color: #6b7280;
    line-height: 1.6;
}

.prop-title-block {
    text-align: right;
}

.prop-title-doc {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    margin-bottom: .25rem;
}

.prop-name {
    font-size: 1.2rem;
    font-weight: 700;
}

.prop-date {
    font-size: .7rem;
    color: #6b7280;
}

.prop-to {
    margin-bottom: 1.5rem;
    background: #f9fafb;
    border-radius: 6px;
    padding: .85rem 1rem;
}

.prop-to-label {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #6b7280;
    margin-bottom: .25rem;
}

.prop-to-name {
    font-size: 1rem;
    font-weight: 700;
}

.prop-to-company {
    font-size: .8rem;
    color: #6b7280;
}

.prop-section {
    margin-bottom: 1.5rem;
}

.prop-section-title {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: .25rem .5rem;
    border-radius: 3px;
    margin-bottom: .6rem;
    display: inline-block;
    color: white;
}

.prop-body {
    font-size: .82rem;
    line-height: 1.7;
    color: #374151;
    white-space: pre-wrap;
}

.prop-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .78rem;
}

.prop-table th {
    background: #f3f4f6;
    padding: .4rem .6rem;
    text-align: left;
    font-weight: 600;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6b7280;
}

.prop-table td {
    padding: .4rem .6rem;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
}

.prop-total-row td {
    font-weight: 700;
    border-top: 2px solid #e5e7eb;
}

.prop-terms {
    font-size: .75rem;
    color: #6b7280;
    line-height: 1.7;
    white-space: pre-wrap;
}

.prop-signature {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.sig-block .sig-line {
    border-bottom: 1px solid #9ca3af;
    margin-bottom: .3rem;
    height: 40px;
}

.sig-label {
    font-size: .68rem;
    color: #9ca3af;
}

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

::-webkit-scrollbar-track {
    background: var(--surface);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }

    .form-panel {
        max-height: 50vh;
    }

    .preview-panel {
        padding: .5rem;
    }
}