/* Shortcut Finance — shared design system */
:root {
    --primary: #111111;
    --primary-light: #333333;
    --accent: #0f766e;
    --accent-hover: #115e59;
    --accent-light: #f0fdfa;
    --bg-app: #f0f0f0;
    --bg-card: #ffffff;
    --text-main: #111111;
    --text-muted: #555555;
    --border: #cccccc;
    --font-stack: 'Inter', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* Thai-readable type scale (เทียบมาตรฐานเว็บไทยทั่วไป ~14–16px) */
    --text-2xs: 12px;
    --text-xs: 13px;
    --text-sm: 14px;
    --text-base: 16px;
    --text-md: 17px;
    --text-lg: 18px;
    --line-height-thai: 1.6;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-stack);
    font-size: var(--text-base);
    line-height: var(--line-height-thai);
    background: var(--bg-app);
    color: var(--text-main);
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Site header ── */
.sf-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.sf-app .sf-header {
    position: sticky;
    top: 0;
    z-index: 100;
}

.sf-header-home {
    position: sticky;
    top: 0;
    z-index: 100;
}

.sf-header-brand {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-weight: 700;
    font-size: 16px;
    color: var(--primary);
}

.sf-header-brand a {
    color: inherit;
    text-decoration: none;
}

.sf-header-brand a:hover {
    color: var(--accent);
    text-decoration: none;
}

.sf-header-tagline {
    font-size: var(--text-2xs);
    font-weight: 400;
    color: var(--text-muted);
    flex: 1 1 100%;
}

@media (min-width: 641px) {
    .sf-header-tagline {
        flex: 0 1 auto;
    }
}

.sf-breadcrumb {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.sf-breadcrumb a {
    color: var(--accent);
}

.sf-breadcrumb strong {
    color: var(--primary);
    font-weight: 600;
}

/* ── Home page ── */
.sf-section-nav {
    display: flex;
    gap: 8px;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.sf-section-nav::-webkit-scrollbar {
    display: none;
}

.sf-section-nav a {
    flex-shrink: 0;
    padding: 7px 16px;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fafafa;
    transition: all 0.2s;
}

.sf-section-nav a:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-light);
    text-decoration: none;
}

.sf-home {
    max-width: 1080px;
    margin: 0 auto;
    padding: 40px 24px 64px;
}

.sf-hero {
    text-align: center;
    margin-bottom: 48px;
    padding: 32px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.sf-hero-eyebrow {
    font-size: var(--text-2xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin-bottom: 10px;
}

.sf-hero h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    line-height: 1.25;
}

.sf-hero p {
    font-size: var(--text-base);
    color: var(--text-muted);
    line-height: 1.55;
    max-width: 540px;
    margin: 0 auto 20px;
}

.sf-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.sf-hero-actions .btn-primary,
.sf-hero-actions .btn-secondary {
    text-decoration: none;
    display: inline-block;
}

.sf-section {
    margin-bottom: 44px;
    scroll-margin-top: 120px;
}

.sf-section-head {
    margin-bottom: 16px;
}

.sf-section-title {
    font-size: var(--text-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 4px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

.sf-section-desc {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: 6px;
}

.sf-tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}

a.sf-tool-card {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.sf-tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 18px 16px;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 140px;
}

.sf-tool-card:hover {
    border-color: var(--accent);
    box-shadow: 0 6px 20px rgba(15, 118, 110, 0.1);
    transform: translateY(-2px);
}

.sf-tool-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.sf-tool-badge {
    align-self: flex-start;
    font-size: var(--text-2xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 8px;
    border-radius: 4px;
    background: #f5f5f5;
    color: var(--text-muted);
}

.sf-tool-badge-calc {
    background: var(--accent-light);
    color: var(--accent);
}

.sf-tool-card h3 {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--primary);
    line-height: 1.35;
}

.sf-tool-card p {
    font-size: var(--text-sm);
    color: var(--text-muted);
    line-height: 1.5;
    flex: 1;
}

.sf-tool-meta {
    font-size: var(--text-xs);
    color: var(--accent);
    font-weight: 600;
    margin-top: auto;
    padding-top: 4px;
}

.sf-tool-meta::after {
    content: " →";
}

.sf-privacy-banner {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    font-size: var(--text-sm);
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 32px;
}

.sf-privacy-banner strong {
    color: var(--primary);
}

.sf-privacy-banner a {
    color: var(--accent);
}

.sf-footer {
    text-align: center;
    padding: 24px;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.sf-footer a {
    color: var(--accent);
}

.sf-footer-links {
    margin-top: 6px;
}

.sf-footer-note {
    margin-top: 10px;
    font-size: 11px;
    line-height: 1.5;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}

.sf-legal {
    max-width: 720px;
    margin: 0 auto;
    padding: 32px 24px 64px;
    line-height: 1.65;
    color: var(--text);
}

.sf-legal-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: 8px;
}

.sf-legal h1 {
    font-size: 1.75rem;
    margin-bottom: 12px;
}

.sf-legal-lead {
    color: var(--text-muted);
    margin-bottom: 28px;
}

.sf-legal section {
    margin-bottom: 28px;
}

.sf-legal h2 {
    font-size: var(--text-base);
    font-weight: 700;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.sf-legal h3 {
    font-size: var(--text-sm);
    font-weight: 600;
    margin: 14px 0 8px;
}

.sf-legal ul {
    margin: 8px 0 8px 1.25rem;
}

.sf-legal li {
    margin-bottom: 6px;
}

.sf-legal code {
    font-size: 0.9em;
    background: #f4f4f4;
    padding: 1px 5px;
    border-radius: 3px;
}

.sf-legal-quote {
    margin: 12px 0;
    padding: 12px 16px;
    background: #fafafa;
    border-left: 3px solid var(--accent);
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.sf-doc-disclaimer {
    font-size: 11px;
    color: var(--text-muted);
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    line-height: 1.5;
    margin-bottom: 12px;
}

.label-hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 11px;
}

.sf-consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    padding: 14px 20px;
}

.sf-consent-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.sf-consent-text {
    font-size: var(--text-sm);
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
    flex: 1;
    min-width: 240px;
}

.sf-consent-text a {
    color: var(--accent);
}

.sf-consent-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.sf-partner-contact {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
}

.sf-partner-contact li {
    margin-bottom: 6px;
}

@media (max-width: 600px) {
    .sf-consent-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .sf-consent-actions {
        justify-content: flex-end;
    }
}

/* ── Tool layout (form + preview) ── */
.sf-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.sf-app-body {
    display: flex;
    flex: 1;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

.sf-sidebar {
    width: 45%;
    min-width: 320px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    max-height: calc(100vh - 52px);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.02);
}

.sf-sidebar-top {
    padding: 20px 24px 12px;
    flex-shrink: 0;
}

.sf-sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px 16px;
}

.sf-sidebar-sticky {
    flex-shrink: 0;
    padding: 16px 24px 20px;
    background: linear-gradient(to top, var(--accent-light) 0%, #fff 50%);
    border-top: 1px solid var(--border);
}

.sf-preview {
    width: 55%;
    padding: 24px 32px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    max-height: calc(100vh - 52px);
    background: #e8e8e8;
    background-image: radial-gradient(circle at 1px 1px, #d0d0d0 1px, transparent 0);
    background-size: 16px 16px;
}

/* ── Typography & forms ── */
h1.sf-title {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
}

.sf-page-head {
    margin-bottom: 24px;
}

.sf-page-head h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.sf-page-head .privacy-note {
    margin-bottom: 0;
}

h2.sf-section-heading {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--primary-light);
    margin: 20px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 8px;
}

h2.sf-section-heading::before {
    content: "";
    display: block;
    width: 4px;
    height: 14px;
    background: var(--accent);
    border-radius: 2px;
    flex-shrink: 0;
}

.sf-sidebar-scroll > h2.sf-section-heading:first-of-type {
    margin-top: 0;
}

.privacy-note {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: var(--line-height-thai);
    margin-bottom: 12px;
}

.form-group {
    margin-bottom: 14px;
}

label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="number"],
input.sf-money-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: var(--text-base);
    font-family: inherit;
    color: var(--text-main);
    background: #fafafa;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input.sf-money-input {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: var(--text-base);
    font-family: inherit;
    color: var(--text-main);
    background: #fafafa;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

/* ── Buttons ── */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}

.btn-primary {
    padding: 10px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-secondary {
    padding: 9px 16px;
    background: #fff;
    color: var(--primary-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.btn-accent {
    padding: 10px 22px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.btn-accent:hover {
    background: var(--accent-hover);
}

.btn-remove {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
}

.btn-remove:hover {
    color: #111;
    border-color: #999;
}

.btn-add-line {
    width: 100%;
    margin-bottom: 8px;
}

/* ── Cards & toggles ── */
.checkbox-card,
.radio-card {
    display: block;
    position: relative;
    padding: 11px 12px 11px 38px;
    margin-bottom: 8px;
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: var(--text-sm);
    transition: all 0.2s;
}

.checkbox-card:hover,
.radio-card:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.checkbox-card:has(input:checked),
.radio-card:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-light);
}

.checkbox-card input,
.radio-card input {
    position: absolute;
    top: 12px;
    left: 12px;
}

.collapsible-panel {
    display: none;
    margin-top: 10px;
    padding: 12px;
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.collapsible-panel.is-open {
    display: block;
}

.line-item-card {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    background: #fafafa;
    margin-bottom: 10px;
}

.line-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
}

/* ── Summary rows ── */
.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-sm);
    color: var(--text-muted);
    padding: 4px 0;
}

.summary-row.grand {
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
}

.summary-row.grand span:last-child {
    color: var(--accent);
}

/* ── Preview area ── */
.preview-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 10px;
    align-self: flex-start;
    width: 100%;
    max-width: 210mm;
}

.preview-actions {
    margin-bottom: 14px;
    width: 100%;
    max-width: 210mm;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.print-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-right: auto;
    line-height: 1.4;
}

.preview-wrap {
    width: 100%;
    max-width: 210mm;
    overflow-x: auto;
}

/* ── A4 document sheet ── */
.a4-sheet,
.a4-sheet * {
    letter-spacing: -0.01em;
}

.a4-sheet {
    background: #fff;
    width: 100%;
    max-width: 210mm;
    min-height: auto;
    padding: 14mm 12mm 18mm;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    position: relative;
    color: #111;
    font-size: 11.5px;
    line-height: 1.5;
}

@media (min-width: 1025px) {
    .a4-sheet {
        min-height: 297mm;
    }
}

.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 12px;
    margin-bottom: 18px;
}

.company-block {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.company-block img {
    height: 40px;
    width: auto;
}

.company-block-text {
    font-size: 11px;
    color: #444;
    line-height: 1.4;
}

.company-block-text strong {
    font-size: 13px;
    color: var(--primary);
}

.doc-title-box {
    text-align: right;
}

.doc-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.info-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 20px;
    margin-bottom: 20px;
}

.info-block h3 {
    font-size: 11px;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
    margin-bottom: 8px;
    color: var(--primary);
}

.info-row {
    display: flex;
    margin-bottom: 4px;
    font-size: 11px;
}

.info-label {
    width: 100px;
    flex-shrink: 0;
    color: #555;
    font-weight: 500;
}

.info-value {
    flex: 1;
    color: #111;
}

.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.doc-table th {
    background: #f5f5f5;
    font-weight: 600;
    padding: 8px 10px;
    font-size: 11px;
    text-align: left;
    border-top: 1px solid #111;
    border-bottom: 1px solid #111;
}

.doc-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    font-size: 11px;
}

.doc-table tbody tr:last-child td {
    border-bottom: 1px solid #111;
}

.text-right { text-align: right; }
.text-center { text-align: center; }

.totals-box {
    width: 48%;
    margin-left: auto;
    margin-bottom: 20px;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 4px;
    font-size: 12px;
    color: #444;
}

.totals-row.grand {
    border-top: 2px solid #111;
    border-bottom: 2px solid #111;
    font-weight: 700;
    font-size: 14px;
    color: #111;
    padding: 8px 4px;
    margin-top: 4px;
}

.notes-block {
    font-size: 11px;
    color: #444;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    line-height: 1.5;
    white-space: pre-line;
}

.notes-block h4 {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 5px;
    color: #111;
}

.signature-row {
    display: flex;
    justify-content: space-between;
    margin-top: 36px;
    padding: 0 12px;
}

.sig-block {
    text-align: center;
    width: 200px;
}

.sig-line {
    border-bottom: 1px solid #999;
    height: 32px;
    margin-bottom: 6px;
}

.sig-label {
    font-size: 11px;
    font-weight: 500;
}

.pdf-footer {
    position: absolute;
    bottom: 8mm;
    left: 12mm;
    right: 12mm;
    text-align: center;
    font-size: 8pt;
    color: #888;
}

.a4-sheet a,
.a4-sheet a:link,
.a4-sheet a:visited {
    color: inherit !important;
    text-decoration: none !important;
    pointer-events: none;
}

.pdf-footer a,
.pdf-footer a:link,
.pdf-footer a:visited {
    color: #888 !important;
    text-decoration: underline !important;
    pointer-events: auto;
}

/* ── Calculator layout ── */
.sf-calc-layout {
    max-width: 720px;
    margin: 0 auto;
    padding: 28px 24px 64px;
    width: 100%;
}

.sf-calc-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 20px;
}

.sf-calc-card h2 {
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sf-calc-card h2::before {
    content: "";
    width: 4px;
    height: 14px;
    background: var(--accent);
    border-radius: 2px;
    flex-shrink: 0;
}

.sf-result-panel {
    background: var(--accent-light);
    border: 1px solid rgba(15, 118, 110, 0.2);
    border-radius: 8px;
    padding: 20px;
}

.sf-result-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: var(--text-base);
}

.sf-result-row.highlight {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    border-top: 1px solid rgba(15, 118, 110, 0.2);
    margin-top: 8px;
    padding-top: 12px;
}

.sf-disclaimer {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 16px;
    line-height: 1.45;
}

.sf-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    margin-top: 16px;
}

.sf-data-table th,
.sf-data-table td {
    padding: 8px 10px;
    border: 1px solid var(--border);
    text-align: right;
}

.sf-data-table th {
    background: #f5f5f5;
    font-weight: 600;
}

.sf-data-table th:first-child,
.sf-data-table td:first-child {
    text-align: center;
}

.sf-data-table tbody tr:nth-child(even) {
    background: #fafafa;
}

/* ── Receipt on behalf document ── */
.rob-sheet {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    line-height: 1.65;
}

.rob-sheet .rob-title {
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 18px;
    color: var(--primary);
}

.rob-company-line {
    text-align: center;
    margin-bottom: 14px;
    font-size: 14px;
    line-height: 2;
}

.rob-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 14px;
}

.rob-table th {
    background: #e8e8e8;
    border: 1px solid #999;
    padding: 9px 8px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.rob-table td {
    border: 1px solid #999;
    padding: 10px 8px;
    font-size: 12px;
    vertical-align: top;
    height: 34px;
}

.rob-table .col-date { width: 18%; }
.rob-table .col-desc { width: 38%; }
.rob-table .col-amt { width: 22%; text-align: right; }
.rob-table .col-note { width: 22%; }

.rob-total-row {
    display: flex;
    align-items: stretch;
    margin-bottom: 16px;
    gap: 12px;
}

.rob-amount-words {
    flex: 1;
    border: 1px solid #999;
    padding: 12px 14px;
    font-size: 13px;
    min-height: 52px;
    display: flex;
    align-items: center;
    line-height: 1.5;
}

.rob-total-box {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.rob-total-value {
    border-bottom: 1px solid #111;
    min-width: 130px;
    text-align: right;
    padding: 4px 8px;
    font-weight: 700;
    font-size: 14px;
}

/* ส่วนใต้ตาราง */
.rob-sheet-lower {
    padding-top: 10px;
}

.rob-cert {
    font-size: 14px;
    line-height: 2;
    text-align: left;
    width: 100%;
    margin-bottom: 28px;
}

.rob-cert-line {
    margin: 0 0 0.75em;
    text-indent: 0;
}

.rob-cert-line:last-child {
    margin-bottom: 0;
}

.rob-cert strong {
    font-weight: 700;
    color: #111;
}

.rob-sigs {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 28px;
    padding-right: 16px;
    margin-bottom: 8mm;
}

.rob-sig-line {
    width: 280px;
    max-width: 100%;
    font-size: 13px;
    line-height: 1.4;
}

.rob-sig-row {
    display: flex;
    align-items: baseline;
    gap: 4px;
    width: 100%;
}

.rob-sig-label,
.rob-sig-role {
    flex-shrink: 0;
    white-space: nowrap;
}

.rob-sig-dash {
    flex: 1;
    border-bottom: 1px solid #111;
    min-width: 80px;
    height: 1.15em;
    margin-bottom: 2px;
}

.rob-sig-name {
    text-align: center;
    margin-top: 6px;
    min-height: 1.3em;
    font-size: 13px;
}

.rob-disclaimer {
    font-size: 11px;
    color: var(--text-muted);
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    line-height: 1.5;
    margin-bottom: 12px;
}

@media print {
    .rob-table th {
        background: #e8e8e8 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .rob-sheet {
        font-size: 11pt !important;
        min-height: 0 !important;
    }

    .rob-sheet .rob-title {
        font-size: 16pt !important;
    }

    .rob-company-line {
        font-size: 11.5pt !important;
        line-height: 2 !important;
    }

    .rob-table th,
    .rob-table td {
        font-size: 10.5pt !important;
        padding: 7px 6px !important;
        height: auto !important;
    }

    .rob-amount-words {
        font-size: 11pt !important;
        min-height: 44px !important;
    }

    .rob-total-box,
    .rob-total-value {
        font-size: 11pt !important;
    }

    .rob-cert {
        font-size: 11.5pt !important;
        line-height: 2 !important;
        margin-bottom: 8mm !important;
    }

    .rob-sigs {
        margin-bottom: 12mm !important;
        gap: 10mm !important;
    }

    .rob-sig-line,
    .rob-sig-name {
        font-size: 11pt !important;
    }

    .rob-sig-line {
        width: 260px !important;
    }
}

/* ── Modals ── */
.sf-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.45);
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.sf-overlay.is-open {
    display: flex;
}

.sf-dialog {
    background: #fff;
    border-radius: 10px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

.sf-dialog h3 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 12px;
}

.sf-dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
    flex-wrap: wrap;
}

.sf-logo-preview {
    max-height: 48px;
    margin-top: 8px;
}

/* ── Mobile ── */
.mobile-bar {
    display: none;
}

@media screen and (max-width: 1024px) {
    .sf-app-body {
        flex-direction: column;
    }

    .sf-sidebar,
    .sf-preview {
        width: 100%;
        min-width: 0;
        max-height: none;
    }

    .sf-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .sf-preview {
        padding: 16px 12px 80px;
        align-items: stretch;
        background: var(--bg-app);
        background-image: none;
    }

    .preview-label,
    .preview-actions {
        max-width: none;
    }

    .a4-sheet {
        width: 100%;
        max-width: 100%;
        min-height: auto;
        font-size: 11px;
        padding: 16px 14px 40px;
    }

    .a4-sheet .info-grid {
        grid-template-columns: 1fr;
    }

    .a4-sheet .totals-box {
        width: 100%;
    }

    .mobile-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        padding: 12px 16px;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    .mobile-bar .mobile-total {
        font-size: 13px;
        color: var(--text-muted);
    }

    .mobile-bar .mobile-total strong {
        display: block;
        font-size: 17px;
        color: var(--accent);
        font-weight: 700;
    }

    .print-hint {
        display: none;
    }
}

@media screen and (max-width: 640px) {
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .sf-home {
        padding: 24px 16px 48px;
    }

    .sf-hero {
        padding: 24px 16px;
    }

    .sf-hero h1 {
        font-size: 22px;
    }

    .sf-section-nav {
        padding: 10px 16px;
    }

    .sf-header {
        padding: 12px 16px;
    }
}

/* ── Print ── */
@page {
    size: A4 portrait;
    margin: 8mm;
}

@media print {
    .sf-header,
    .sf-sidebar,
    .preview-label,
    .preview-actions,
    .mobile-bar,
    .sf-overlay {
        display: none !important;
    }

    html, body {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .sf-app-body,
    .sf-preview,
    .preview-wrap {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
        max-height: none !important;
    }

    .a4-sheet {
        box-shadow: none !important;
        width: 100% !important;
        max-width: 210mm !important;
        min-height: 0 !important;
        padding: 10mm 8mm 14mm !important;
        font-size: 9.5pt !important;
    }

    .pdf-footer {
        display: block !important;
        position: fixed;
        bottom: 5mm;
    }

    .a4-sheet .info-grid {
        grid-template-columns: 1.1fr 0.9fr !important;
    }

    .a4-sheet .totals-box {
        width: 48% !important;
    }

    .a4-sheet .signature-row {
        flex-direction: row !important;
        page-break-inside: avoid;
    }
}
