:root {
    --hth-red: #d71920;
    --hth-red-dark: #aa1117;
    --dark: #333333;
    --text: #222222;
    --muted: #666666;
    --border: #d7d7d7;
    --bg: #f4f4f4;
    --card: #ffffff;
    --actions-w: 105px;
    --property-w: 240px;
    --seller-w: 230px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--hth-red); }

.header {
    background: var(--dark);
    color: #fff;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header h1 {
    margin: 0;
    font-size: 26px;
    line-height: 1.15;
}

.header a {
    color: #fff;
    font-weight: 700;
    margin-left: 14px;
    text-decoration: none;
}

.container {
    max-width: 100%;
    padding: 20px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
    padding: 18px;
}

.spreadsheet-card { padding: 14px; }

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

.search-box {
    display: grid;
    grid-template-columns: minmax(220px, 420px) auto;
    gap: 8px;
    align-items: center;
}

input, textarea, select {
    width: 100%;
    border: 1px solid #cfcfcf;
    border-radius: 7px;
    padding: 9px 10px;
    font: inherit;
    background: #fff;
}

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

button, .btn {
    display: inline-block;
    background: var(--hth-red);
    color: #fff !important;
    border: 0;
    border-radius: 8px;
    padding: 9px 13px;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.15;
    text-decoration: none;
    cursor: pointer;
    text-align: center;
}

.btn.secondary, button.secondary { background: #555; }
.btn.light { background: #efefef; color: #222 !important; border: 1px solid #ccc; }
.btn.delete { background: #aa1117; }

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

.form-field label {
    display: block;
    font-weight: 700;
    margin-bottom: 5px;
    color: #333;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.login-box {
    max-width: 420px;
    margin: 80px auto;
}

.error, .success {
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 12px;
}
.error { background: #ffe7e7; border: 1px solid #ffb0b0; }
.success { background: #e8fff0; border: 1px solid #a7e0b6; }

.table-scroll-wrapper {
    position: relative;
    width: 100%;
}

.excel-table-wrap {
    width: 100%;
    max-width: 100%;
    height: calc(100vh - 185px);
    overflow: auto;
    position: relative;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.excel-table {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
    min-width: 2800px;
    width: max-content;
    font-size: 13px;
}

.excel-table th, .excel-table td {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 8px 9px;
    text-align: left;
    vertical-align: top;
    background: #fff;
    min-width: 180px;
    max-width: 260px;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.excel-table thead th {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--dark);
    color: #fff;
    font-weight: 800;
}

.excel-table thead th a {
    color: #fff !important;
    text-decoration: none;
}

.excel-table tbody tr:nth-child(even) td { background: #fafafa; }
.excel-table tbody tr:hover td { background: #fff8df; }

.excel-table .row-actions,
.excel-table .freeze-actions {
    position: sticky !important;
    left: 0 !important;
    z-index: 60 !important;
    width: var(--actions-w) !important;
    min-width: var(--actions-w) !important;
    max-width: var(--actions-w) !important;
    background: #fff !important;
    box-shadow: 2px 0 4px rgba(0,0,0,.12);
}

.excel-table thead .row-actions,
.excel-table thead .freeze-actions {
    z-index: 90 !important;
    background: var(--dark) !important;
    color: #fff !important;
}

.excel-table .freeze-property,
.excel-table .freeze-property-head {
    position: sticky !important;
    left: var(--actions-w) !important;
    z-index: 55 !important;
    width: var(--property-w) !important;
    min-width: var(--property-w) !important;
    max-width: var(--property-w) !important;
    background: #fff !important;
    box-shadow: 2px 0 4px rgba(0,0,0,.10);
}

.excel-table thead .freeze-property-head {
    z-index: 85 !important;
    background: var(--dark) !important;
    color: #fff !important;
}

.excel-table .freeze-seller,
.excel-table .freeze-seller-head {
    position: sticky !important;
    left: calc(var(--actions-w) + var(--property-w)) !important;
    z-index: 54 !important;
    width: var(--seller-w) !important;
    min-width: var(--seller-w) !important;
    max-width: var(--seller-w) !important;
    background: #fff !important;
    box-shadow: 2px 0 4px rgba(0,0,0,.10);
}

.excel-table thead .freeze-seller-head {
    z-index: 84 !important;
    background: var(--dark) !important;
    color: #fff !important;
}

.excel-table .row-actions .btn {
    display: block;
    width: 100%;
    font-size: 11px !important;
    padding: 6px 5px !important;
    margin: 0 0 6px 0 !important;
    border-radius: 7px !important;
}

.excel-table th:nth-child(4), .excel-table td:nth-child(4) { min-width: 120px; max-width: 160px; }
.excel-table th:nth-child(5), .excel-table td:nth-child(5) { min-width: 170px; max-width: 210px; }
.excel-table th:nth-child(n+6), .excel-table td:nth-child(n+6) { min-width: 190px; max-width: 250px; }

.scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 120;
    width: 34px;
    height: 54px;
    border-radius: 8px;
    padding: 0;
    background: rgba(51,51,51,.82);
    color: #fff;
    font-size: 22px;
}
.scroll-btn.left { left: 6px; }
.scroll-btn.right { right: 6px; }

.todo-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,.55);
    padding: 30px 16px;
    overflow: auto;
}

.todo-modal.show { display: block; }

.todo-modal-content {
    max-width: 650px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,.25);
    overflow: hidden;
}

.todo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--hth-red);
    color: #fff;
    padding: 14px 18px;
}

.todo-header h2 { margin: 0; font-size: 24px; }
.todo-close { background: #fff; color: var(--hth-red) !important; padding: 6px 10px; }
.todo-body { padding: 18px; }
.todo-record-title { font-weight: 800; font-size: 18px; margin-bottom: 14px; }
.todo-section-subtitle {
    font-size: 16px !important;
    font-weight: 800 !important;
    color: #fff !important;
    background-color: var(--hth-red-dark) !important;
    padding: 8px 10px !important;
    margin: 16px 0 8px !important;
    border-radius: 5px;
}
.todo-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 4px;
    border-bottom: 1px solid #eee;
    font-weight: 600;
}
.todo-item input { width: auto; transform: scale(1.15); }

@media print {
    @page { size: landscape; margin: .25in; }
    html, body { overflow: visible !important; background: #fff !important; }
    .header, .toolbar, .scroll-btn, .no-print, .actions, .todo-modal { display: none !important; }
    .container { max-width: none; margin: 0; padding: 0; }
    .card { border: 0; box-shadow: none; padding: 0; }
    .excel-table-wrap { height: auto; overflow: visible; border: 0; padding: 0; }
    .excel-table { font-size: 7px; width: 100%; min-width: 0; border-collapse: collapse; }
    .excel-table th, .excel-table td {
        position: static !important;
        left: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        white-space: normal !important;
        padding: 2px;
        overflow: visible !important;
        box-shadow: none !important;
    }
    .excel-table th { background: #ddd !important; color: #000 !important; }
    .excel-table th a { color: #000 !important; }
}

@media (max-width: 900px) {
    .header { display: block; padding: 16px 18px; }
    .header h1 { font-size: 22px; margin-bottom: 8px; }
    .container { padding: 14px; }
    .card { padding: 14px; }
    .form-grid { grid-template-columns: 1fr; }
    .search-box { grid-template-columns: 1fr; max-width: none; width: 100%; }
    .toolbar .btn, .toolbar button { width: 100%; text-align: center; }
    .excel-table-wrap { height: calc(100vh - 240px); }
}
