/* ==========================================================================
   TimeWorked — calculator tool pages
   ========================================================================== */

.tool-main {
    width: 100%;
    max-width: var(--prose-max);
    margin: 0 auto;
    padding: 2.5rem 1.5rem 0;
}

.tool-header {
    margin-bottom: 1.75rem;
}

.tool-header h1 {
    font-size: 2rem;
    line-height: 1.2;
    margin-bottom: 0.6rem;
}

.tool-header p {
    color: var(--text-secondary);
    font-size: 1.02rem;
    max-width: 62ch;
}

/* --------------------------------------------------------------- The card */

.calc {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.calc-body {
    padding: 1.25rem;
}

.calc-section + .calc-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.calc-section h2 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 0 0 0.85rem;
    font-weight: 600;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.9rem 1rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.field > label {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.field .field-input,
.field select {
    width: 100%;
    padding: 0.55rem 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    background: var(--bg-cell);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.field .field-input:focus,
.field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field .field-input.invalid {
    border-color: var(--danger);
    color: var(--danger);
}

.field .hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    min-height: 1rem;
}

.field .hint.error {
    color: var(--danger);
}

/* Repeatable shift rows */

.shift-row {
    display: grid;
    grid-template-columns: 72px 1fr 1fr;
    gap: 0.6rem;
    align-items: end;
    margin-bottom: 0.7rem;
}

.shift-row .shift-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding-bottom: 0.7rem;
}

.calc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

/* ------------------------------------------------------------- Result rail */

.result {
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
    padding: 1.25rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.result-figure {
    min-width: 0;
}

.result-figure dt {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.result-figure dd {
    font-family: var(--font-mono);
    font-size: 1.7rem;
    font-weight: 600;
    line-height: 1.25;
    margin: 0;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.result-figure.primary dd { color: var(--accent); }
.result-figure.money dd   { color: var(--success); }
.result-figure.warn dd    { color: var(--warning); }

.result-figure small {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 0.15rem;
}

/* Breakdown table inside the card */

.breakdown {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.breakdown th,
.breakdown td {
    padding: 0.45rem 0.5rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.breakdown th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.breakdown th:first-child,
.breakdown td:first-child {
    text-align: left;
    font-family: var(--font-sans);
    color: var(--text-secondary);
    white-space: normal;
}

.breakdown tr:last-child td {
    border-bottom: none;
    font-weight: 600;
    color: var(--text-primary);
}

/* ------------------------------------------------------------ Template list */

.template-list {
    display: grid;
    gap: 1rem;
    margin: 1.5rem 0;
}

.template {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}

.template-info {
    flex: 1 1 240px;
    min-width: 0;
}

.template-info h3 {
    font-size: 0.98rem;
    margin: 0 0 0.2rem;
}

.template-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

.template-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ------------------------------------------------------------ Printable sheet */

.printable {
    display: none;
}

@media print {
    body > *:not(.printable) { display: none !important; }

    .printable:empty { display: none !important; }

    .printable {
        display: block !important;
        color: #000;
        background: #fff;
    }

    .printable h1 {
        font-size: 1.2rem;
        margin-bottom: 0.5rem;
    }

    .printable table {
        width: 100%;
        border-collapse: collapse;
        font-size: 0.75rem;
    }

    .printable th,
    .printable td {
        border: 1px solid #000;
        padding: 0.4rem 0.3rem;
        text-align: center;
    }

    .printable th { background: #eee !important; }
    .printable td.wide { width: 22%; }

    .printable .meta {
        display: flex;
        gap: 2rem;
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
        flex-wrap: wrap;
    }

    .printable .meta span {
        display: inline-block;
        border-bottom: 1px solid #000;
        min-width: 180px;
        padding-bottom: 2px;
    }

    .printable .sign {
        display: flex;
        gap: 3rem;
        margin-top: 2.5rem;
        font-size: 0.8rem;
    }

    .printable .sign div {
        flex: 1;
        border-top: 1px solid #000;
        padding-top: 0.3rem;
    }
}

/* --------------------------------------------------------------- Responsive */

@media (max-width: 620px) {
    .tool-main {
        padding: 1.75rem 1rem 0;
    }

    .tool-header h1 {
        font-size: 1.55rem;
    }

    .shift-row {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .shift-row .shift-label {
        grid-column: 1 / -1;
        padding-bottom: 0;
        font-weight: 600;
        color: var(--text-secondary);
    }

    .result-figure dd {
        font-size: 1.4rem;
    }
}
