:root {
    color-scheme: dark;

    --bg: #111b14;
    --panel: #213027;
    --panel-soft: #27382d;
    --border: #53665a;
    --text: #f4f6f2;
    --muted: #bdc7bf;
    --input: #18251d;
    --green: #62bd78;
    --yellow: #dfb64d;
    --blue: #71a9cf;
    --red: #d87770;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
}

body {
    background:
        radial-gradient(
            circle at top,
            #2a3d30 0,
            var(--bg) 55%
        );

    color: var(--text);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Helvetica Neue",
        sans-serif;
}

button,
input {
    font: inherit;
}

/* LOGIN */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(470px, 100%);
    padding: 48px 38px;

    background: rgba(33, 48, 39, 0.96);
    border: 1px solid var(--border);
    border-radius: 22px;

    box-shadow:
        0 25px 80px rgba(0, 0, 0, 0.38);
}

.brand,
.top-label,
.panel-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.24em;
}

.login-card h1 {
    margin: 15px 0 4px;
    text-align: center;
    font-family: Georgia, serif;
    font-size: clamp(42px, 11vw, 62px);
    font-weight: 400;
}

.brand,
.subtitle {
    text-align: center;
}

.subtitle {
    margin: 0 0 30px;
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 18px;
}

.login-form label {
    display: grid;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
}

.login-form input {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;

    background: var(--input);
    border: 1px solid var(--border);
    border-radius: 10px;

    color: var(--text);
    outline: none;
}

.login-form input:focus {
    border-color: #8ba091;
    box-shadow: 0 0 0 3px rgba(139, 160, 145, 0.14);
}

.login-form button,
.primary-button {
    min-height: 48px;
    padding: 0 20px;

    background: #aebbb0;
    border: 0;
    border-radius: 10px;

    color: #172119;
    font-weight: 800;
    cursor: pointer;
}

.alert {
    margin-bottom: 18px;
    padding: 12px 14px;

    background: rgba(216, 119, 112, 0.14);
    border: 1px solid rgba(216, 119, 112, 0.55);
    border-radius: 10px;

    color: #ffd8d5;
    font-size: 14px;
}

/* PANEL */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;

    max-width: 1500px;
    margin: 0 auto;
    padding: 28px 24px 14px;
}

.topbar h1 {
    margin: 7px 0 0;
    font-family: Georgia, serif;
    font-size: clamp(27px, 4vw, 43px);
    font-weight: 400;
}

.logout-button {
    min-height: 42px;
    padding: 0 16px;

    background: transparent;
    border: 1px solid var(--border);
    border-radius: 9px;

    color: var(--text);
    cursor: pointer;
}

.dashboard {
    max-width: 1500px;
    margin: 0 auto;
    padding: 18px 24px 45px;
}

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

.stat-card {
    position: relative;
    overflow: hidden;

    min-height: 126px;
    padding: 20px;

    background: rgba(33, 48, 39, 0.95);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.stat-card::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    content: "";
}

.stat-green::before {
    background: var(--green);
}

.stat-yellow::before {
    background: var(--yellow);
}

.stat-blue::before {
    background: var(--blue);
}

.stat-red::before {
    background: var(--red);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.stat-card strong {
    display: block;
    margin-top: 16px;
    font-size: clamp(25px, 4vw, 37px);
}

.panel-card {
    background: rgba(33, 48, 39, 0.96);
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;

    padding: 22px;
    border-bottom: 1px solid var(--border);
}

.panel-heading h2 {
    margin: 6px 0 0;
    font-size: 23px;
}

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

table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}

th,
td {
    padding: 15px 17px;
    text-align: left;
    white-space: nowrap;
}

th {
    background: #314439;
    color: var(--text);
    font-size: 13px;
}

td {
    border-top: 1px solid rgba(83, 102, 90, 0.36);
    color: #e7ece8;
    font-size: 14px;
}

tbody tr:hover {
    background: rgba(105, 128, 112, 0.09);
}

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

@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar,
    .panel-heading {
        align-items: flex-start;
    }
}

@media (max-width: 600px) {
    .topbar {
        padding-top: 22px;
    }

    .top-label {
        letter-spacing: 0.13em;
    }

    .dashboard {
        padding-inline: 14px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        min-height: 108px;
    }

    .panel-heading {
        flex-direction: column;
    }

    .primary-button {
        width: 100%;
    }

    .logout-button {
        font-size: 13px;
    }
}

/* =========================================================
   RÉPLICA VISUAL DE LA APP DE MAC
   ========================================================= */

.app-shell {
    min-height: 100vh;
    background:
        radial-gradient(
            circle at top,
            #35473a 0,
            #172119 48%,
            #111a14 100%
        );
}

.app-header {
    position: relative;

    display: flex;
    justify-content: center;
    align-items: center;

    min-height: 116px;
    padding: 20px 28px 12px;
}

.app-header form {
    position: absolute;
    top: 28px;
    right: 28px;
}

.app-title {
    text-align: center;
}

.app-title h1 {
    margin: 0;

    color: #f4f5f1;

    font-family:
        Georgia,
        "Times New Roman",
        serif;

    font-size: clamp(28px, 3.2vw, 48px);
    font-weight: 400;
    letter-spacing: 0.02em;
}

.app-subtitle {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;

    margin-top: 7px;

    color: #c4ccc5;

    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.26em;
}

.app-subtitle span {
    width: 74px;
    height: 1px;
    background: #66766a;
}

.contract-app {
    width: min(1760px, calc(100% - 32px));
    margin: 0 auto;
    padding-bottom: 24px;
}

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

.form-card {
    overflow: hidden;

    background: #2b3a30;
    border: 1px solid #5a6b5f;
    border-radius: 11px;

    box-shadow:
        0 10px 24px rgba(0, 0, 0, 0.16);
}

.form-card-title {
    display: flex;
    align-items: center;
    gap: 9px;

    min-height: 52px;
    padding: 0 18px;

    border-bottom: 1px solid #526257;

    color: #f2f4ef;
    font-size: 13px;
    font-weight: 800;
}

.card-icon {
    display: inline-grid;
    place-items: center;

    width: 24px;
    height: 24px;

    color: #dbe2db;
    font-size: 16px;
}

.form-card-body {
    display: grid;
    gap: 10px;
    padding: 15px 18px 17px;
}

.form-card label {
    display: grid;
    grid-template-columns: minmax(110px, 0.42fr) 1fr;
    align-items: center;
    gap: 12px;

    color: #eef1ec;
    font-size: 13px;
    font-weight: 600;
}

.form-card input,
.form-card select,
.search-bar input {
    width: 100%;
    height: 39px;
    padding: 0 12px;

    background: #1c2820;
    border: 1px solid #536359;
    border-radius: 7px;

    color: #eef1ec;
    outline: none;
}

.form-card input::placeholder,
.search-bar input::placeholder {
    color: #8f9a92;
}

.form-card input:disabled,
.form-card select:disabled,
.search-bar input:disabled {
    opacity: 1;
    cursor: default;
}

.generate-row {
    display: flex;
    justify-content: center;
    padding: 13px 0;
}

.generate-button {
    min-width: 420px;
    min-height: 50px;

    background: #aeb8ae;
    border: 0;
    border-radius: 9px;

    color: #1a241d;

    font-size: 16px;
    font-weight: 800;
}

.search-bar {
    display: grid;
    grid-template-columns: auto minmax(240px, 1fr) auto auto;
    align-items: center;
    gap: 10px;

    padding: 10px 14px;

    background: #26352b;
    border: 1px solid #56665b;
    border-radius: 10px;
}

.search-bar strong {
    color: #f0f2ee;
    font-size: 13px;
}

.search-bar button {
    height: 39px;
    padding: 0 18px;

    background: #34483a;
    border: 1px solid #607166;
    border-radius: 7px;

    color: #edf1ec;
    font-size: 12px;
    font-weight: 800;
}

.desktop-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;

    margin: 11px 0;
}

.desktop-stats article {
    display: flex;
    justify-content: space-between;
    align-items: center;

    min-height: 72px;
    padding: 12px 18px;

    background: #2c3c31;
    border: 1px solid #5a6a5f;
    border-radius: 10px;
}

.desktop-stats span {
    color: #c5cdc6;
    font-size: 13px;
    font-weight: 700;
}

.desktop-stats strong {
    color: #f4f6f2;
    font-size: clamp(20px, 2.2vw, 30px);
}

.contracts-table-card {
    overflow: hidden;

    background: #19231c;
    border: 1px solid #536359;
    border-radius: 10px;
}

.contracts-table-scroll {
    overflow: auto;
    max-height: 390px;
}

.contracts-table {
    min-width: 1000px;
}

.contracts-table th {
    position: sticky;
    top: 0;
    z-index: 2;

    padding: 13px 16px;

    background: #3a4a3e;
    color: #f0f3ee;

    font-size: 13px;
    font-weight: 800;
}

.contracts-table td {
    padding: 12px 16px;

    background: #1c271f;
    border-top: 1px solid #334139;

    color: #e7ece7;
    font-size: 13px;
}

.contracts-table tbody tr:nth-child(even) td {
    background: #202c23;
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 11px;

    border-radius: 999px;

    font-size: 11px;
    font-weight: 900;
}

.status.paid {
    background: rgba(75, 154, 93, 0.2);
    border: 1px solid rgba(93, 190, 115, 0.48);
    color: #8ce39f;
}

.status.pending {
    background: rgba(218, 170, 66, 0.16);
    border: 1px solid rgba(218, 170, 66, 0.45);
    color: #f2ca70;
}

.action-toolbar {
    display: grid;
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 8px;

    margin-top: 11px;
}

.action-toolbar button {
    min-height: 48px;
    padding: 0 10px;

    background: #27352b;
    border: 1px solid #56665b;
    border-radius: 8px;

    color: #f0f3ee;

    font-size: 12px;
    font-weight: 800;
}

.action-toolbar .whatsapp {
    background: #205c37;
    border-color: #367c4e;
}

.action-toolbar button:disabled {
    opacity: 1;
}

@media (max-width: 1100px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 760px) {
    .app-header {
        justify-content: flex-start;
        padding-right: 18px;
        padding-left: 18px;
    }

    .app-header form {
        position: static;
        margin-left: auto;
    }

    .app-title {
        text-align: left;
    }

    .app-title h1 {
        font-size: 23px;
    }

    .app-subtitle {
        justify-content: flex-start;
        font-size: 8px;
        letter-spacing: 0.15em;
    }

    .app-subtitle span {
        display: none;
    }

    .form-card label {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .generate-button {
        width: 100%;
        min-width: 0;
    }

    .search-bar {
        grid-template-columns: 1fr;
    }

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

    .desktop-stats article {
        display: block;
    }

    .desktop-stats strong {
        display: block;
        margin-top: 8px;
    }

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

.form-card textarea{width:100%;min-height:39px;padding:10px 12px;resize:vertical;background:#1c2820;border:1px solid #536359;border-radius:7px;color:#eef1ec;outline:none}
.form-card input:focus,.form-card select:focus,.form-card textarea:focus,.search-bar input:focus{border-color:#93a397;box-shadow:0 0 0 3px rgba(147,163,151,.12)}
.generate-button,.secondary-button,.search-bar button,.search-bar a,.action-toolbar button{cursor:pointer}
.secondary-button{margin-left:10px;min-height:50px;padding:0 25px;border:1px solid #657569;border-radius:9px;background:#26352b;color:#fff;font-weight:800}
.search-bar a{display:grid;place-items:center;height:39px;padding:0 18px;background:#34483a;border:1px solid #607166;border-radius:7px;color:#edf1ec;text-decoration:none;font-size:12px;font-weight:800}
.contract-row{cursor:pointer}.contract-row.selected td{background:#445647!important;outline:1px solid #718275}
.flash-stack{margin-bottom:10px}.alert{margin:0 0 8px}
.modal{position:fixed;inset:0;z-index:50;display:none;place-items:center;padding:20px;background:rgba(0,0,0,.72)}.modal.open{display:grid}
.modal-card{position:relative;width:min(620px,100%);max-height:90vh;overflow:auto;padding:28px;background:#26352b;border:1px solid #657569;border-radius:14px;color:#fff}.modal-card.wide{width:min(980px,100%)}
.modal-close{position:absolute;top:10px;right:12px;border:0;background:transparent;color:#fff;font-size:28px;cursor:pointer}
#detailsContent{line-height:1.7}.signature-actions{display:flex;justify-content:center;gap:10px;margin-top:12px}.signature-actions button{padding:11px 18px;border:1px solid #657569;border-radius:8px;background:#34483a;color:#fff}
#signatureCanvas{width:100%;height:320px;background:#fff;border-radius:8px;touch-action:none}
.payments-page{min-height:100vh;padding:30px;background:radial-gradient(circle at top,#35473a 0,#172119 48%,#111a14 100%)}.payments-card{max-width:1100px;margin:auto;padding:28px;background:#26352b;border:1px solid #5a6a5f;border-radius:14px}.back-link{color:#dce4dd}.payment-summary{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin:20px 0}.payment-summary span{padding:18px;background:#1c2820;border:1px solid #536359;border-radius:9px}.payment-summary strong{display:block;margin-top:8px;font-size:24px}.payment-form{display:grid;grid-template-columns:1fr 1fr auto;gap:12px;align-items:end;margin-bottom:24px}.payment-form label{display:grid;gap:7px}.payment-form input,.payment-form select{height:42px;padding:0 12px;background:#1c2820;border:1px solid #536359;border-radius:7px;color:#fff}.payment-form button{height:42px;padding:0 18px;border:0;border-radius:7px;background:#aeb8ae;color:#1a241d;font-weight:800}.payments-table a{color:#8ce39f}
@media(max-width:760px){.payment-summary,.payment-form{grid-template-columns:1fr}.app-header{gap:12px}.logout-button{padding:0 10px}.modal-card{padding:22px 16px}}

/* AJUSTES APROBADOS 2 */
.form-card textarea{
  width:100%!important;height:39px!important;min-height:39px!important;
  padding:9px 12px!important;resize:none!important;
  appearance:none!important;-webkit-appearance:none!important;
  background:#1c2820!important;border:1px solid #536359!important;
  border-radius:7px!important;color:#eef1ec!important;
  font:inherit!important;line-height:20px!important;
}
.selection-indicator{
  margin:0 0 9px;padding:10px 14px;background:#1c2820;
  border:1px dashed #657569;border-radius:8px;color:#aeb8b0;
  font-size:13px;text-align:center
}
.selection-indicator.active{
  background:rgba(68,108,78,.35);border-style:solid;border-color:#72b184;color:#e9f6ec
}
.delete-button{background:#4a2523!important;border-color:#8c4945!important}
.receipt-actions{display:flex;align-items:center;gap:8px}
.receipt-actions a,.receipt-actions button{
  min-height:36px;padding:0 12px;border:1px solid #607166;border-radius:7px;
  background:#34483a;color:#edf1ec;text-decoration:none;font-weight:800;font-size:12px;cursor:pointer
}
.receipt-actions button{background:#205c37;border-color:#367c4e}
.payments-header{display:flex;justify-content:space-between;align-items:flex-start;gap:20px}
.payments-header h1{margin:5px 0 0;font-family:Georgia,serif;font-size:36px;font-weight:400}
.payments-eyebrow{margin:0;color:#bdc7bf;font-size:11px;font-weight:800;letter-spacing:.22em}
.new-payment-card{margin:18px 0;padding:20px;background:#1c2820;border:1px solid #536359;border-radius:10px}
.new-payment-card h2{margin:0 0 16px}
.payments-table-wrap{overflow:auto;border:1px solid #536359;border-radius:10px}
.payments-table{min-width:850px}
.public-sign-page{min-height:100vh;display:grid;place-items:center;padding:20px;background:radial-gradient(circle at top,#35473a 0,#172119 48%,#111a14 100%)}
.public-sign-card{width:min(850px,100%);padding:30px;background:#26352b;border:1px solid #657569;border-radius:16px;text-align:center;box-shadow:0 24px 70px rgba(0,0,0,.35)}
.public-sign-card h1{margin:8px 0;font-family:Georgia,serif;font-size:38px;font-weight:400}
.sign-client{margin:15px 0 4px;font-size:22px;font-weight:800}.sign-event{margin:0 0 20px;color:#bdc7bf}
#publicSignature{display:block;width:100%;height:330px;background:#fff;border:2px solid #718275;border-radius:10px;touch-action:none}
.public-sign-actions{display:flex;justify-content:center;gap:10px;margin-top:16px}
.public-sign-actions button{min-height:48px;padding:0 20px;border:1px solid #657569;border-radius:8px;background:#34483a;color:#fff;font-weight:800}
.public-sign-actions #acceptSignature{background:#aeb8ae;color:#172119}
.signed-notice,.signed-success{margin:15px 0;padding:13px;border:1px solid #4d9962;border-radius:8px;background:rgba(56,133,77,.18);color:#9be3ac}
@media(max-width:760px){
  .payments-header{display:block}.payments-header .back-link{display:inline-block;margin-bottom:18px}
  .public-sign-card{padding:22px 14px}.public-sign-card h1{font-size:29px}
  #publicSignature{height:280px}.public-sign-actions{display:grid}
  .receipt-actions{align-items:stretch;flex-direction:column}
}

/* AJUSTES APROBADOS 3 */

.action-toolbar form {
    display: contents;
}

.contract-row.selected td {
    background: #445647 !important;
    outline: none !important;
    border-left: 0 !important;
    border-right: 0 !important;
    box-shadow: none !important;
}

.contract-row.selected td:first-child {
    border-radius: 0;
}

.contract-row.selected td:last-child {
    border-radius: 0;
}

.thanks-modal {
    position: fixed;
    inset: 0;
    z-index: 200;

    display: none;
    place-items: center;

    padding: 20px;

    background: rgba(7, 13, 9, 0.86);
    backdrop-filter: blur(8px);
}

.thanks-modal.open {
    display: grid;
}

.thanks-card {
    width: min(600px, 100%);
    padding: 38px 32px;

    background: #26352b;
    border: 1px solid #657569;
    border-radius: 18px;

    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.48);

    color: #eef2ed;
    text-align: center;
}

.thanks-check {
    display: grid;
    place-items: center;

    width: 68px;
    height: 68px;
    margin: 0 auto 18px;

    background: rgba(71, 159, 94, 0.2);
    border: 1px solid #58a86d;
    border-radius: 50%;

    color: #8ce39f;
    font-size: 36px;
    font-weight: 900;
}

.thanks-card h2 {
    margin: 0 0 16px;

    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(29px, 5vw, 42px);
    font-weight: 400;
}

.thanks-card p {
    margin: 12px 0;

    color: #d5ddd6;
    font-size: 16px;
    line-height: 1.65;
}

.thanks-signature {
    margin-top: 24px !important;

    color: #ffffff !important;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 21px !important;
}

#exitSigning {
    display: inline-grid;
    place-items: center;

    min-width: 150px;
    min-height: 48px;
    margin-top: 20px;
    padding: 0 22px;

    background: #aeb8ae;
    border-radius: 9px;

    color: #172119;
    text-decoration: none;
    font-weight: 900;
}

@media (max-width: 760px) {
    .thanks-card {
        padding: 30px 20px;
    }
}

/* AJUSTES APROBADOS 4 */
.contract-row.event-warning td {
  background: rgba(204, 150, 24, 0.20) !important;
}
.contract-row.event-warning:hover td {
  background: rgba(204, 150, 24, 0.28) !important;
}
.contract-row.event-urgent td {
  background: rgba(176, 54, 48, 0.24) !important;
}
.contract-row.event-urgent:hover td {
  background: rgba(176, 54, 48, 0.32) !important;
}
.contract-row.selected.event-warning td {
  background: rgba(204, 150, 24, 0.38) !important;
}
.contract-row.selected.event-urgent td {
  background: rgba(176, 54, 48, 0.42) !important;
}
.desktop-stats article.upcoming-alert {
  background: rgba(186, 105, 24, 0.32);
  border-color: #c77b28;
}
.desktop-stats article.upcoming-alert strong {
  color: #ffd08a;
}
.receipt-actions {
  justify-content: center;
}
.receipt-actions a,
.receipt-actions button {
  min-width: 94px;
  text-align: center;
}
