/* =========================================================
   Free tools — the shared look.

   Every free tool (bill maker, contract maker, deposit slip) loads this first and then its own
   small stylesheet. Every rule is scoped under .tbm, so a tool looks the same
   inside Laravel (Tailwind) as it does on a plain page, and cannot affect the
   site around it.

   The tokens copy the LIVE trackmyroom.com design system (public-*.css, read
   2026-09-22): brand = indigo scale, text = slate scale, cards rounded-2xl +
   shadow-line, inputs and buttons rounded-xl, the finished document as the
   highlighted card (border-brand-200 + shadow-raise), font Inter + Noto Sans
   Thai. If the site's brand changes, change these tokens and nothing else.
   ========================================================= */
.tbm {
    --tbm-brand-50: #eef2ff;
    --tbm-brand-200: #c7d2fe;
    --tbm-brand-500: #4f46e5;
    --tbm-brand-600: #4338ca;
    --tbm-brand-700: #3730a3;
    --tbm-brand-950: #1e1b4b;
    --tbm-slate-50: #f8fafc;
    --tbm-slate-200: #e2e8f0;
    --tbm-slate-400: #94a3b8;
    --tbm-slate-500: #64748b;
    --tbm-slate-700: #334155;
    --tbm-slate-900: #0f172a;
    --tbm-red-700: #b91c1c;
    --tbm-shadow-line: 0 1px 2px #0f172a0a;
    --tbm-shadow-raise: 0 18px 40px -24px #312e8173;

    color: var(--tbm-slate-700);
    font-family: "Inter", "Noto Sans Thai", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}
.tbm *, .tbm *::before, .tbm *::after { box-sizing: border-box; }

/* ---------- top bar (language switch) ---------- */
.tbm-top { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.tbm-top:empty { display: none; }
.tbm-lang { display: inline-flex; border: 1px solid var(--tbm-slate-200); border-radius: 9999px; padding: 4px; background: #fff; box-shadow: var(--tbm-shadow-line); }
.tbm-lang button {
    border: 0; background: none; font: inherit; font-size: 14px; font-weight: 600;
    padding: 6px 16px; border-radius: 9999px; color: var(--tbm-slate-500); cursor: pointer;
}
.tbm-lang button[aria-pressed="true"] { background: var(--tbm-brand-600); color: #fff; }
.tbm-lang button:focus-visible { outline: 2px solid var(--tbm-brand-500); outline-offset: 2px; }

/* ---------- layout: form | the document it makes ---------- */
.tbm-layout { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 992px) {
    .tbm-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
    .tbm-preview { position: sticky; top: 96px; }
}

/* ---------- form cards ---------- */
.tbm-section {
    border: 1px solid var(--tbm-slate-200); border-radius: 16px; background: #fff;
    box-shadow: var(--tbm-shadow-line); padding: 24px; margin: 0 0 16px; min-width: 0;
}
.tbm-section legend { float: left; width: 100%; color: var(--tbm-slate-900); font-weight: 700; font-size: 18px; margin: 0 0 16px; padding: 0; }
.tbm-section legend + * { clear: both; }
.tbm-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tbm-wide { grid-column: 1 / -1; }
@media (max-width: 480px) {
    .tbm-section { padding: 20px 16px; }
    .tbm-grid { grid-template-columns: minmax(0, 1fr); }
}

.tbm-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; }
.tbm-label { font-size: 14px; font-weight: 500; color: var(--tbm-slate-700); }
.tbm-label em { font-style: normal; font-weight: 400; color: var(--tbm-slate-500); }
.tbm-hint { font-size: 13px; color: var(--tbm-slate-500); }
.tbm-input {
    width: 100%; font: inherit; font-size: 14px; color: var(--tbm-slate-900); background: #fff;
    border: 1px solid var(--tbm-slate-200); border-radius: 12px; padding: 12px 16px; min-height: 46px;
    transition: border-color .15s, box-shadow .15s;
}
.tbm-input::placeholder { color: var(--tbm-slate-400); }
.tbm-input:focus { outline: none; border-color: var(--tbm-brand-500); box-shadow: 0 0 0 2px rgba(79, 70, 229, .2); }
textarea.tbm-input { min-height: 96px; resize: vertical; }

.tbm-toggle { display: inline-flex; flex-wrap: wrap; gap: 8px; align-self: end; }
.tbm-radio { display: inline-flex; margin: 0; cursor: pointer; }
.tbm-radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tbm-radio span {
    border: 1px solid var(--tbm-slate-200); border-radius: 9999px; padding: 8px 16px; font-size: 14px; font-weight: 600;
    color: var(--tbm-slate-500); background: #fff;
}
.tbm-radio input:checked + span { border-color: var(--tbm-brand-200); background: var(--tbm-brand-50); color: var(--tbm-brand-700); }
.tbm-radio input:focus-visible + span { outline: 2px solid var(--tbm-brand-500); outline-offset: 2px; }

.tbm-error { color: var(--tbm-red-700); font-size: 13px; margin: 8px 0 0; }
.tbm-error:empty { display: none; }
.tbm-note { color: var(--tbm-slate-500); font-size: 13px; margin: 0; }

/* Lines an owner adds and removes: charges, deductions, checklist items, own lease terms. */
.tbm-remove {
    height: 46px; border: 1px solid var(--tbm-slate-200); border-radius: 12px; background: #fff;
    font-size: 22px; line-height: 1; color: var(--tbm-slate-500); cursor: pointer;
}
.tbm-remove:hover { color: var(--tbm-red-700); border-color: var(--tbm-red-700); }
.tbm-add {
    border: 1px dashed var(--tbm-brand-200); background: var(--tbm-brand-50); color: var(--tbm-brand-700);
    font: inherit; font-size: 14px; font-weight: 600; border-radius: 12px; padding: 10px 16px; margin: 0 0 16px; cursor: pointer;
}
.tbm-add:hover { border-color: var(--tbm-brand-500); }
.tbm-add:focus-visible, .tbm-remove:focus-visible { outline: 2px solid var(--tbm-brand-500); outline-offset: 2px; }

/* ---------- the finished document ---------- */
.tbm-paper {
    background: #fff; border: 1px solid var(--tbm-brand-200); border-radius: 16px;
    padding: 24px; box-shadow: var(--tbm-shadow-raise);
}
@media (min-width: 640px) { .tbm-paper { padding: 32px; } }
@media (max-width: 480px) { .tbm-paper { padding: 20px 16px; } }
.tbm-empty { color: var(--tbm-slate-500); text-align: center; margin: 40px 0; }

/* ---------- actions under the document: the live site's buttons ---------- */
.tbm-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.tbm-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-size: 14px; font-weight: 600; border-radius: 12px; padding: 12px 20px; cursor: pointer;
    border: 1px solid var(--tbm-slate-200); background: #fff; color: var(--tbm-slate-700); box-shadow: var(--tbm-shadow-line);
    transition: background-color .2s, box-shadow .2s, border-color .2s;
}
.tbm-btn:hover { border-color: var(--tbm-brand-200); color: var(--tbm-brand-700); }
.tbm-btn-primary { flex: 1 1 100%; background: var(--tbm-brand-600); border-color: var(--tbm-brand-600); color: #fff; box-shadow: var(--tbm-shadow-raise); font-size: 16px; }
.tbm-btn-primary:hover { background: var(--tbm-brand-700); border-color: var(--tbm-brand-700); color: #fff; }
.tbm-btn:not(.tbm-btn-primary) { flex: 1 1 0; }
.tbm-btn:focus-visible { outline: 2px solid var(--tbm-brand-500); outline-offset: 2px; }
.tbm-btn:disabled { opacity: .6; cursor: not-allowed; }
.tbm-status { margin: 10px 0 0; font-size: 14px; color: var(--tbm-brand-700); text-align: center; }
.tbm-status:empty { display: none; }

/* ---------- print: the document alone, nothing of the page around it ----------
   A tool puts a copy of its document in .tbm-print-root (a direct child of <body>)
   on beforeprint and removes it on afterprint, so Ctrl+P works as well as the
   button. Everything else is display:none, not just invisible, so no blank pages
   follow. */
.tbm-print-root { display: none; }
@media print {
    @page { margin: 12mm; }
    html.tbm-printing body > *:not(.tbm-print-root) { display: none !important; }
    html.tbm-printing body { background: #fff !important; padding: 0 !important; margin: 0 !important; }
    .tbm-print-root { display: block; }
    .tbm-print-root .tbm-paper {
        border: 0; box-shadow: none; padding: 0;
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    .tbm-print-root .tbm-signatures { break-inside: avoid; page-break-inside: avoid; }
}

/* ---------- signature lines at the foot of a document (lease, deposit slip) ---------- */
.tbm-signatures { display: grid; gap: 28px 24px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 36px; }
@media (max-width: 480px) { .tbm-signatures { grid-template-columns: minmax(0, 1fr); } }
.tbm-sign { font-size: 13px; color: var(--tbm-slate-500); text-align: center; }
.tbm-sign-line { display: block; height: 40px; border-bottom: 1px solid var(--tbm-slate-400); margin-bottom: 6px; }
.tbm-sign-date { display: block; margin-top: 6px; font-size: 12px; }

/* A signature drawn on the screen (signature.js) sits on the line, like ink on paper. */
.tbm-sign-line.tbm-signed { height: 56px; display: flex; align-items: flex-end; justify-content: center; }
.tbm-sign-img { display: block; max-width: 100%; max-height: 54px; width: auto; height: auto; margin: 0 auto -6px; }

/* ---------- "sign on the screen" in the form (signature.js) ---------- */
.tbm-sign-hint { margin-bottom: 12px; }
.tbm-sign-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    padding: 12px 0; border-top: 1px solid var(--tbm-slate-200);
}
.tbm-sign-role { flex: 1 1 140px; min-width: 0; font-size: 14px; font-weight: 600; color: var(--tbm-slate-900); }
.tbm-sign-box { display: block; padding: 0; border: 0; background: none; cursor: pointer; font: inherit; border-radius: 8px; }
.tbm-sign-box:focus-visible { outline: 2px solid var(--tbm-brand-500); outline-offset: 2px; }
.tbm-sign-thumb, .tbm-sign-empty {
    display: flex; align-items: center; justify-content: center; width: 150px; height: 48px; object-fit: contain;
    border: 1px solid var(--tbm-slate-200); border-radius: 8px; background: #fff;
}
.tbm-sign-empty {
    border: 1px dashed var(--tbm-brand-200); background: var(--tbm-brand-50); color: var(--tbm-brand-700);
    font-size: 12px; line-height: 1.3; padding: 0 8px; text-align: center;
}
.tbm-sign-box:hover .tbm-sign-empty, .tbm-sign-box:hover .tbm-sign-thumb { border-color: var(--tbm-brand-500); }
.tbm-sign-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tbm-sign-btn {
    font: inherit; font-size: 14px; font-weight: 600; border-radius: 10px; padding: 8px 14px; min-height: 40px; cursor: pointer;
    border: 1px solid var(--tbm-brand-200); background: var(--tbm-brand-50); color: var(--tbm-brand-700);
}
.tbm-sign-btn:hover { border-color: var(--tbm-brand-500); }
.tbm-sign-remove { border-color: var(--tbm-slate-200); background: #fff; color: var(--tbm-slate-500); }
.tbm-sign-remove:hover { color: var(--tbm-red-700); border-color: var(--tbm-red-700); }
.tbm-sign-btn:focus-visible { outline: 2px solid var(--tbm-brand-500); outline-offset: 2px; }

/* The drawing pad: a box over the page. touch-action:none so a finger draws instead of scrolling. */
.tbm-sign-overlay {
    position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
    padding: 16px; background: rgba(15, 23, 42, .55);
}
.tbm-sign-dialog {
    width: 100%; max-width: 560px; background: #fff; border-radius: 16px; padding: 20px;
    box-shadow: var(--tbm-shadow-raise); max-height: 100%; overflow: auto;
}
.tbm-sign-title { margin: 0 0 4px; font-size: 16px; font-weight: 700; color: var(--tbm-slate-900); }
.tbm-sign-canvas {
    display: block; width: 100%; height: 220px; margin-top: 12px; background: #fff; cursor: crosshair;
    border: 1px solid var(--tbm-slate-400); border-radius: 12px;
    touch-action: none; -ms-touch-action: none; user-select: none; -webkit-user-select: none;
}
@media (max-height: 480px) { .tbm-sign-canvas { height: 150px; } }
.tbm-sign-dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tbm-sign-dialog-actions .tbm-btn { flex: 1 1 0; }
.tbm-sign-dialog-actions .tbm-btn-primary { flex: 2 1 100%; }
@media print { .tbm-sign-overlay { display: none !important; } }

/* ---------- "made with" line: travels with the image, the print and the text ---------- */
.tbm-made-with { margin: 16px 0 0; text-align: center; font-size: 11px; color: var(--tbm-slate-400); }

/* ---------- the invitation under the document ---------- */
.tbm-cta {
    margin-top: 20px; padding: 20px; border-radius: 16px;
    background: var(--tbm-brand-50); border: 1px solid var(--tbm-brand-200);
}
.tbm-cta[hidden] { display: none; }
.tbm-cta-title { margin: 0 0 6px; color: var(--tbm-slate-900); font-weight: 700; font-size: 16px; }
.tbm-cta-body { margin: 0 0 16px; font-size: 14px; color: var(--tbm-slate-700); }
.tbm-cta .tbm-btn-primary { width: 100%; text-decoration: none; }
.tbm-cta-note { margin: 8px 0 0; text-align: center; font-size: 12px; color: var(--tbm-slate-500); }

/* ---------- above every form: nothing typed is kept; signing up keeps it ---------- */
.tbm-save-note {
    margin: 0 0 16px; padding: 12px 16px; border-radius: 12px; font-size: 13px;
    background: var(--tbm-brand-50); border: 1px solid var(--tbm-brand-200); color: var(--tbm-slate-700);
}
.tbm-save-note a { color: var(--tbm-brand-700); font-weight: 600; }
.tbm-save-note a:focus-visible { outline: 2px solid var(--tbm-brand-500); outline-offset: 2px; }
