* { box-sizing: border-box; }
body {
    margin: 0;
    background: #f4f6f8;
    color: #1f2933;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
}
a { color: #0f6f8f; text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
    background: #183642;
    color: #fff;
    padding: 18px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}
.brand { font-size: 18px; font-weight: bold; }
.nav a {
    color: #fff;
    margin-left: 16px;
    opacity: .9;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 26px; }
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}
h1 { margin: 0; font-size: 24px; }
h2 { margin: 0 0 16px; font-size: 18px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.panel {
    background: #fff;
    border: 1px solid #d8e0e6;
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.stat { font-size: 30px; font-weight: bold; margin-top: 8px; }
.muted { color: #657482; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
    display: inline-block;
    border: 0;
    background: #0f6f8f;
    color: #fff;
    padding: 11px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    line-height: 1.2;
    min-height: 42px;
}
.btn.secondary { background: #536471; }
.btn.light { background: #e9eef2; color: #1f2933; }
.btn.danger { background: #b42318; }
.btn:hover { text-decoration: none; filter: brightness(.96); }
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #d8e0e6;
    border-radius: 8px;
    overflow: hidden;
}
th, td { padding: 12px; border-bottom: 1px solid #e6ebef; text-align: left; vertical-align: top; }
th { background: #edf3f6; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.full { grid-column: 1 / -1; }
label { display: block; font-weight: bold; margin-bottom: 6px; }
input, select, textarea {
    width: 100%;
    border: 1px solid #c7d2da;
    border-radius: 6px;
    padding: 11px 10px;
    font: inherit;
    background: #fff;
    min-height: 42px;
}
textarea { min-height: 92px; resize: vertical; }
.notice {
    background: #fff7e6;
    border: 1px solid #ffd08a;
    color: #6b4100;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}
.success {
    background: #e8f7ee;
    border: 1px solid #96d5aa;
    color: #1e5e35;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}
.contract {
    background: #fff;
    border: 1px solid #d8e0e6;
    border-radius: 8px;
    padding: 34px;
    line-height: 1.55;
}
.contract h1 { text-align: center; margin-bottom: 22px; }
.contract-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.box { border: 1px solid #d8e0e6; padding: 14px; border-radius: 6px; }
.signatures { display: grid; grid-template-columns: repeat(2, 1fr); gap: 40px; margin-top: 46px; }
.signature-line { border-top: 1px solid #1f2933; padding-top: 8px; min-height: 70px; }
.service-fields { display: none; }
.service-fields.active { display: contents; }
@media (max-width: 780px) {
    body { font-size: 14px; }
    .topbar {
        display: block;
        padding: 16px;
    }
    .brand { line-height: 1.25; }
    .nav {
        margin-top: 14px;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .nav a {
        display: block;
        margin: 0;
        background: rgba(255,255,255,.1);
        border-radius: 6px;
        padding: 10px;
        text-align: center;
    }
    .page-head {
        display: block;
        margin-bottom: 14px;
    }
    .page-head h1, .page-head h2 { margin-bottom: 12px; }
    .grid, .form-grid, .contract-meta, .signatures { grid-template-columns: 1fr; }
    .wrap { padding: 14px; }
    .panel { padding: 14px; }
    .actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .btn {
        width: 100%;
        text-align: center;
        white-space: normal;
    }
    table {
        border: 0;
        background: transparent;
    }
    table tr {
        display: block;
        background: #fff;
        border: 1px solid #d8e0e6;
        border-radius: 8px;
        margin-bottom: 12px;
        overflow: hidden;
    }
    table th {
        display: none;
    }
    table td {
        display: grid;
        grid-template-columns: 118px 1fr;
        gap: 10px;
        border-bottom: 1px solid #e6ebef;
        padding: 11px 12px;
        word-break: break-word;
    }
    table td:before {
        content: attr(data-label);
        color: #657482;
        font-weight: bold;
    }
    table td:last-child { border-bottom: 0; }
    .contract {
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        margin-left: -14px;
        margin-right: -14px;
        padding: 18px 14px;
    }
    .contract h1 {
        font-size: 19px;
        line-height: 1.25;
    }
    .contract table th {
        display: none;
    }
    .contract table td {
        grid-template-columns: 120px 1fr;
    }
}
@media (max-width: 420px) {
    .nav { grid-template-columns: 1fr; }
    h1 { font-size: 21px; }
    h2 { font-size: 17px; }
    table td,
    .contract table td {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .box { padding: 12px; }
    .stat { font-size: 26px; }
}
@media print {
    body { background: #fff; }
    .topbar, .page-head .actions, .no-print { display: none !important; }
    .wrap { max-width: none; padding: 0; }
    .contract { border: 0; padding: 0; }
    table { border-collapse: collapse; background: #fff; }
    table tr { display: table-row; border: 0; margin: 0; }
    table th, table td { display: table-cell; }
    table td:before { display: none; }
}
