:root {
    --ink: #171717;
    --muted: #66615c;
    --line: #e6dfd4;
    --paper: #fffaf0;
    --white: #fff;
    --yellow: #ffca0a;
    --orange: #f36c21;
    --red: #cf2c13;
    --green: #188f55;
    --shadow: 0 18px 40px rgba(31, 24, 16, .12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: #f7f2e9;
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.4;
}

a { color: inherit; text-decoration: none; }

button, .primary, .secondary {
    border: 1px solid var(--ink);
    background: var(--white);
    border-radius: 8px;
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    min-height: 42px;
    padding: 10px 14px;
}

.primary {
    background: var(--yellow);
    box-shadow: inset 0 -2px 0 rgba(0,0,0,.18);
    font-weight: 800;
}

.secondary { background: #fff4c2; font-weight: 700; }
.danger {
    background: #fff0ed;
    border-color: #c73a22;
    color: #a32716;
    font-weight: 800;
}
.small-btn {
    min-height: 34px;
    padding: 7px 10px;
}
.large { width: 100%; min-height: 58px; font-size: 1.2rem; }

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    color: var(--ink);
    font: inherit;
    margin-top: 6px;
    min-height: 44px;
    padding: 10px 12px;
}

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

label { display: block; font-weight: 700; }
label + label, form > label, .row { margin-top: 14px; }
textarea { resize: vertical; }

.topbar {
    align-items: center;
    background: var(--ink);
    color: var(--white);
    display: flex;
    gap: 18px;
    justify-content: space-between;
    padding: 10px clamp(16px, 4vw, 42px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    align-items: center;
    display: flex;
    gap: 12px;
    font-weight: 900;
}

.brand img { height: 52px; width: 52px; object-fit: contain; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.topbar nav a { border-radius: 8px; padding: 9px 10px; }
.topbar nav a:hover { background: rgba(255,255,255,.12); }

.shell {
    margin: 0 auto;
    max-width: 1180px;
    padding: 26px 18px 60px;
}

.hero {
    align-items: center;
    background: linear-gradient(135deg, #1b1b1b, #332017);
    border-radius: 8px;
    color: var(--white);
    display: flex;
    gap: 22px;
    justify-content: space-between;
    margin-bottom: 18px;
    padding: clamp(22px, 4vw, 38px);
}

.hero h1 { font-size: clamp(2rem, 5vw, 4rem); line-height: 1; margin: 0; max-width: 780px; }
.eyebrow { color: var(--yellow); font-weight: 900; letter-spacing: .08em; margin-top: 0; text-transform: uppercase; }

.panel, .login-card form {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: clamp(16px, 3vw, 26px);
}

.panel h2, .panel h3 { margin-top: 0; }

.compact { max-width: 480px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: minmax(280px, 420px) 1fr; align-items: start; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }

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

.stats article {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.stats span { display: block; font-size: 1.7rem; font-weight: 900; }
.stats small, .list-item small { color: var(--muted); display: block; }
.stats.slim { margin-top: 16px; }

.section-title, .toolbar, .filters {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 16px;
}

.filters { justify-content: flex-start; }
.filters label { min-width: 160px; }

.list { display: grid; gap: 10px; }
.list-item {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 12px;
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.actions form, .inline-form { margin: 0; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: middle; }
th { background: #fff4d0; font-size: .84rem; text-transform: uppercase; }
.signature-img { background: #fff; border: 1px solid var(--line); height: 58px; width: 140px; object-fit: contain; }
.selfie-img { border-radius: 8px; height: 58px; width: 58px; object-fit: cover; }
.paid { background: #dff7e8; border-color: var(--green); color: var(--green); }

.sectors-panel { margin-top: 18px; }
.sector-head, .sector-row {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: 80px minmax(220px, 1fr) 130px 110px 90px;
}
.sector-head {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 900;
    margin-bottom: 8px;
    text-transform: uppercase;
}
.sector-row {
    border-top: 1px solid var(--line);
    padding: 10px 0;
}
.sector-row input { margin-top: 0; }
.checkline {
    align-items: center;
    display: flex;
    gap: 8px;
    margin-top: 0;
}

.alert {
    background: #fff4c2;
    border: 1px solid #e5b900;
    border-radius: 8px;
    margin: 0 0 16px;
    padding: 12px 14px;
}
.alert.danger { background: #ffe5df; border-color: #e86b4d; }
.empty {
    background: rgba(255,255,255,.62);
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    padding: 24px;
    text-align: center;
}

.login-screen {
    min-height: 100vh;
    background: #111;
    display: grid;
    place-items: center;
}

.login-card { width: min(460px, calc(100vw - 28px)); }
.login-logo { display: block; margin: 0 auto 18px; max-height: 240px; max-width: 100%; object-fit: contain; }
.login-card h1 { margin-top: 0; }

.tablet-screen { background: #fbf5e8; }
.tablet {
    margin: 0 auto;
    max-width: 1160px;
    padding: 18px;
}
.tablet-head {
    align-items: center;
    background: var(--ink);
    border-radius: 8px;
    color: var(--white);
    display: flex;
    gap: 14px;
    margin-bottom: 16px;
    padding: 12px 16px;
}
.tablet-head img { height: 70px; width: 92px; object-fit: contain; }
.tablet-head h1, .tablet-head p { margin: 0; }
.tablet-grid { display: grid; gap: 16px; grid-template-columns: minmax(300px, 1fr) minmax(280px, 420px); align-items: start; }
.amount-display {
    background: #171717;
    border-radius: 8px;
    color: var(--white);
    font-size: 1.35rem;
    margin-top: 14px;
    padding: 14px;
}
.amount-display strong { color: var(--yellow); }
.declaration {
    background: #fff8df;
    border-left: 5px solid var(--orange);
    border-radius: 8px;
    font-weight: 700;
    padding: 12px;
}
.signature-box {
    border: 2px dashed #c9b994;
    border-radius: 8px;
    margin: 14px 0;
    min-height: 220px;
    position: relative;
}
.signature-box.small { min-height: 150px; }
.signature-box.small canvas { height: 150px; }
.signature-box canvas {
    display: block;
    height: 220px;
    touch-action: none;
    width: 100%;
}
.signature-box button {
    bottom: 10px;
    position: absolute;
    right: 10px;
}

.camera {
    background: #f7f2e9;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 14px 0;
    padding: 10px;
}
.camera video, .camera img {
    background: #111;
    border-radius: 8px;
    display: block;
    max-height: 220px;
    object-fit: cover;
    width: 100%;
}
.camera .actions { margin-top: 10px; justify-content: flex-start; }

.term-box {
    background: #fff8df;
    border: 1px solid #ead8a0;
    border-radius: 8px;
    margin: 14px 0;
    padding: 14px;
}
.term-box p {
    color: #3f3830;
    font-weight: 700;
    margin: 0 0 10px;
}
.term-preview {
    display: block;
    margin-top: 10px;
}

.terms-header { margin-bottom: 16px; }
.freelancer-cards {
    display: grid;
    gap: 12px;
}
.freelancer-card {
    align-items: center;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(31, 24, 16, .08);
    display: grid;
    gap: 14px;
    grid-template-columns: 86px 1fr auto;
    padding: 14px;
}
.freelancer-photo img, .avatar-placeholder {
    align-items: center;
    background: #f7f2e9;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    height: 86px;
    justify-content: center;
    object-fit: cover;
    text-align: center;
    width: 86px;
}
.freelancer-info h3 { margin: 0 0 4px; }
.freelancer-info p { color: var(--muted); margin: 2px 0; }
.status {
    border-radius: 999px;
    display: inline-flex;
    font-size: .78rem;
    font-weight: 900;
    margin-right: 6px;
    margin-top: 8px;
    padding: 5px 8px;
}
.status.ok { background: #dff7e8; color: var(--green); }
.status.off { background: #eee7df; color: #6f6258; }
.status.warn { background: #fff4c2; color: #8a6500; }
.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}
.term-print {
    background: #ece6dc;
    min-height: 100vh;
    padding: 18px;
}
.term-toolbar {
    margin: 0 auto 12px;
    max-width: 920px;
}
.term-document {
    background: #fff;
    border: 1px solid #d8d0c4;
    box-shadow: var(--shadow);
    margin: 0 auto;
    max-width: 920px;
    padding: 34px;
}
.term-brand {
    align-items: center;
    border-bottom: 2px solid var(--line);
    display: grid;
    gap: 16px;
    grid-template-columns: 110px 1fr 110px;
    margin-bottom: 18px;
    padding-bottom: 14px;
}
.term-brand img {
    max-height: 105px;
    max-width: 110px;
    object-fit: contain;
}
.term-brand h1 {
    font-size: 1.45rem;
    line-height: 1.15;
    margin: 0;
}
.term-document h2 {
    font-size: 1rem;
    margin: 18px 0 6px;
}
.term-document p {
    margin: 7px 0;
    text-align: justify;
}
.term-signatures {
    display: grid;
    gap: 32px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 44px;
}
.term-signatures > div {
    text-align: center;
}
.term-signatures img {
    border-bottom: 1px solid #222;
    height: 76px;
    object-fit: contain;
    width: 100%;
}
.signature-line {
    border-bottom: 1px solid #222;
    height: 76px;
    margin-bottom: 8px;
}
.term-signatures strong,
.term-signatures span {
    display: block;
    margin-top: 6px;
}

.report-head {
    align-items: center;
    display: flex;
    gap: 18px;
    margin-bottom: 16px;
}
.report-head img { height: 100px; width: 130px; object-fit: contain; }
.report-head h1, .report-head p { margin: 0; }
.totals {
    margin-left: auto;
    margin-top: 18px;
    max-width: 460px;
}
.totals p {
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    margin: 0;
    padding: 8px 0;
}
.totals .grand { font-size: 1.2rem; font-weight: 900; }
.print-only { display: none; }

@media (max-width: 820px) {
    .topbar, .hero, .list-item, .report-head { align-items: stretch; flex-direction: column; }
    .grid.two, .tablet-grid, .stats, .row, .freelancer-card, .term-brand, .term-signatures { grid-template-columns: 1fr; }
    .sector-head { display: none; }
    .sector-row { grid-template-columns: 1fr; }
    .card-actions { justify-content: flex-start; }
    .hero h1 { font-size: 2.25rem; }
    .topbar nav { justify-content: flex-start; }
}

@media print {
    body { background: #fff; }
    .topbar, .no-print, .toolbar, .filters, .alert, .print-report button { display: none !important; }
    .shell { max-width: none; padding: 0; }
    .panel { border: 0; box-shadow: none; padding: 0; }
    .term-print { background: #fff; padding: 0; }
    .term-document { border: 0; box-shadow: none; max-width: none; padding: 0; }
    .term-document p { font-size: 11px; }
    .term-document h2 { font-size: 12px; }
    .term-brand h1 { font-size: 16px; }
    .print-only { display: inline; }
    th, td { padding: 6px; }
    .signature-img { height: 44px; width: 110px; }
    .selfie-img { height: 44px; width: 44px; }
}
