:root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #20242a;
    --muted: #6b7280;
    --line: #d9dee7;
    --primary: #136f63;
    --primary-dark: #0f5a51;
    --accent: #9a3412;
    --warning: #b45309;
    --danger: #b91c1c;
    --success: #15803d;
    --info: #1d4ed8;
    --shadow: 0 12px 28px rgba(20, 26, 35, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.45;
    letter-spacing: 0;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px clamp(16px, 4vw, 40px);
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 760;
    text-decoration: none;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    font-size: 0.9rem;
}

.brand-logo {
    display: block;
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 8px;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.main-nav a {
    color: #303740;
    padding: 8px 10px;
    border-radius: 8px;
    font-weight: 620;
}

.main-nav a:hover {
    background: #eef4f2;
    text-decoration: none;
}

.menu-toggle {
    display: none;
}

.page {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 44px;
}

.footer {
    display: flex;
    justify-content: flex-start;
    gap: 18px;
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto 24px;
    color: var(--muted);
    font-size: 0.9rem;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
    gap: 24px;
    align-items: stretch;
}

.hero-panel,
.panel,
.stat,
.table-shell {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.hero-panel {
    padding: clamp(24px, 5vw, 52px);
}

.hero-panel h1,
.page-head h1,
.panel h2 {
    margin: 0;
    line-height: 1.12;
    letter-spacing: 0;
}

.hero-panel h1 {
    max-width: 760px;
    font-size: clamp(2rem, 5vw, 4rem);
}

.lead {
    color: #48505b;
    font-size: 1.08rem;
    max-width: 760px;
}

.panel {
    padding: 22px;
}

.panel + .panel,
.table-shell + .panel {
    margin-top: 18px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.page-head p {
    margin: 6px 0 0;
    color: var(--muted);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat {
    padding: 16px;
}

.stat strong {
    display: block;
    font-size: 1.8rem;
    line-height: 1;
}

.stat span {
    color: var(--muted);
    font-size: 0.9rem;
}

.table-shell {
    overflow-x: auto;
}

.nested-table {
    margin-top: 16px;
    box-shadow: none;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    background: #f0f3f6;
    color: #3d4551;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

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

.compact th,
.compact td {
    padding: 9px 10px;
}

.form {
    display: grid;
    gap: 16px;
}

.field {
    display: grid;
    gap: 7px;
}

.field label {
    color: #313943;
    font-weight: 680;
}

.field small,
.muted {
    color: var(--muted);
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid #c9d1dc;
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    padding: 10px 12px;
    font: inherit;
}

input[type="checkbox"] {
    width: auto;
    min-height: auto;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(19, 111, 99, 0.18);
    border-color: var(--primary);
}

.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 14px;
    background: var(--primary);
    color: #ffffff;
    font: inherit;
    font-weight: 720;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.button:hover,
button:hover {
    background: var(--primary-dark);
    color: #ffffff;
    text-decoration: none;
}

.button.secondary {
    background: #ffffff;
    color: #26313d;
    border-color: var(--line);
}

.button.secondary:hover {
    background: #f3f6f8;
}

.button.warning {
    background: var(--warning);
}

.button.danger,
button.danger {
    background: var(--danger);
}

.button.ghost {
    background: transparent;
    color: var(--primary);
    border-color: transparent;
}

.button.ghost:hover {
    background: #eef4f2;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 760;
    white-space: nowrap;
}

.badge-muted {
    background: #edf0f3;
    color: #4b5563;
}

.badge-info {
    background: #e7efff;
    color: var(--info);
}

.badge-warning {
    background: #fff3df;
    color: var(--warning);
}

.badge-success {
    background: #e7f7ed;
    color: var(--success);
}

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.alert-success {
    border-color: #a8ddb8;
    background: #ecfdf3;
}

.alert-warning {
    border-color: #f3d29c;
    background: #fff7e8;
}

.alert-danger {
    border-color: #f1b1b1;
    background: #fff0f0;
}

.alert-info {
    border-color: #b8ccff;
    background: #eff5ff;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 18px;
}

.tabs a {
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: #2e3742;
    font-weight: 680;
}

.tabs a:hover {
    background: #eef4f2;
    text-decoration: none;
}

.timeline {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline li {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 99px;
    background: var(--line);
    flex: 0 0 12px;
}

.dot.active {
    background: var(--primary);
}

.public-link {
    display: flex;
    gap: 8px;
}

.public-link input {
    min-width: 0;
}

.actions-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    font-weight: 680;
}

.print-document {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: clamp(18px, 4vw, 42px);
    box-shadow: var(--shadow);
}

.signature-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 26px;
    margin-top: 34px;
}

.signature-box {
    min-height: 86px;
    border-top: 1px solid #404854;
    padding-top: 8px;
}

.empty-state {
    padding: 28px;
    color: var(--muted);
    text-align: center;
}

.danger-zone {
    border-color: #efb4b4;
    background: #fff7f7;
}

.logo-preview {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 78px;
    margin: 10px 0 16px;
}

.logo-preview img {
    max-width: 220px;
    max-height: 76px;
    object-fit: contain;
}

@media (max-width: 900px) {
    .hero,
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .page-head {
        display: grid;
    }

    .menu-toggle {
        display: inline-flex;
        background: #ffffff;
        color: var(--text);
        border-color: var(--line);
    }

    .main-nav[data-menu] {
        display: none;
        position: absolute;
        top: 64px;
        right: 16px;
        left: 16px;
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
        background: #ffffff;
        border: 1px solid var(--line);
        border-radius: 8px;
        box-shadow: var(--shadow);
    }

    .main-nav[data-menu].is-open {
        display: flex;
    }

    .main-nav a {
        width: 100%;
    }

    .footer {
        display: grid;
    }
}

@media (max-width: 620px) {
    .page {
        width: min(100% - 20px, 1180px);
        margin-top: 16px;
    }

    .panel,
    .hero-panel,
    .print-document {
        padding: 16px;
    }

    th,
    td {
        padding: 10px 9px;
    }

    .toolbar,
    .actions-inline,
    .public-link,
    .signature-row {
        display: grid;
        grid-template-columns: 1fr;
    }

    .button,
    button {
        width: 100%;
    }
}
