/* Teliart CRM – halduspaneel */

.tcrm {
    --ink: #1c202c;
    --muted: #666e80;
    --line: #e3e6ea;
    --surface: #ffffff;
    --wash: #f6f7f7;
    --accent: #1f4e4a;
    --accent-ink: #ffffff;
    --accent-soft: #e4eeec;
    --warn: #b4541a;
    --warn-soft: #f8ebe2;
    --danger: #b42318;

    color: var(--ink);
    max-width: 1400px;
    font-size: 14px;
}

.tcrm *,
.tcrm *::before,
.tcrm *::after { box-sizing: border-box; }

.tcrm a { color: var(--accent); }
.tcrm a:focus-visible,
.tcrm button:focus-visible,
.tcrm input:focus-visible,
.tcrm select:focus-visible,
.tcrm textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    box-shadow: none;
}

/* ---------- Päis ---------- */

.tcrm-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin: 18px 0 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}
.tcrm-head h1 {
    margin: 0;
    padding: 0;
    font-size: 26px;
    line-height: 1.2;
    font-weight: 650;
    letter-spacing: -0.015em;
    color: var(--ink);
}
.tcrm-head p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}
.tcrm-head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.tcrm-export-label {
    color: var(--muted);
    margin-right: 2px;
}

/* ---------- Nupud ja lingid ---------- */

.tcrm-btn,
.tcrm .tcrm-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 16px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
}
.tcrm .tcrm-btn:hover { background: #173b38; border-color: #173b38; color: #fff; }
.tcrm .tcrm-btn.is-quiet {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line);
}
.tcrm .tcrm-btn.is-quiet:hover { border-color: var(--ink); color: var(--ink); background: var(--surface); }

.tcrm-link {
    font-weight: 600;
    text-decoration: none;
}
.tcrm-link:hover { text-decoration: underline; }
.tcrm .tcrm-link.is-danger { color: var(--danger); }
.tcrm-strong { font-weight: 600; color: var(--ink); }
.tcrm a.tcrm-strong { color: var(--ink); text-decoration: none; }
.tcrm a.tcrm-strong:hover { color: var(--accent); }
.tcrm-muted { color: var(--muted); }
.tcrm td small.tcrm-muted { display: block; margin-top: 2px; }

/* ---------- Numbririba ---------- */

.tcrm-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
}
.tcrm-stat {
    padding: 16px 20px 18px;
    border-left: 1px solid var(--line);
}
.tcrm-stat:first-child { border-left: 0; }
.tcrm-stat span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}
.tcrm-stat strong {
    display: block;
    margin-top: 6px;
    font-size: 28px;
    line-height: 1.1;
    font-weight: 650;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.tcrm-stat.is-accent strong { color: var(--accent); }

/* ---------- Paigutus ---------- */

.tcrm-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 20px;
    align-items: start;
}
.tcrm-split.is-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.tcrm-split-side .tcrm-panel { margin-bottom: 20px; }

.tcrm-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}
.tcrm-panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.tcrm-panel-head h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 650;
    color: var(--ink);
}
.tcrm-total {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.tcrm-empty {
    margin: 4px 0;
    padding: 18px;
    background: var(--wash);
    border-radius: 6px;
    color: var(--muted);
}
.tcrm-more { margin: 12px 0 0; }

/* ---------- Vormid ---------- */

.tcrm-fields {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px 16px;
}
.tcrm-field { display: flex; flex-direction: column; gap: 6px; }
.tcrm-field.is-half { grid-column: span 2; }
.tcrm-field.is-wide { grid-column: 1 / -1; }
.tcrm-field > span,
.tcrm-filters label > span {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}
.tcrm-field small { color: var(--muted); font-size: 12px; }

.tcrm input[type="text"],
.tcrm input[type="email"],
.tcrm input[type="tel"],
.tcrm input[type="date"],
.tcrm input[type="search"],
.tcrm input[type="password"],
.tcrm select,
.tcrm textarea {
    width: 100%;
    max-width: none;
    min-height: 38px;
    padding: 6px 10px;
    border: 1px solid #cfd4da;
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font-size: 14px;
    line-height: 1.4;
}
.tcrm textarea { resize: vertical; }
.tcrm input:focus,
.tcrm select:focus,
.tcrm textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); outline: 0; }

/* Kulunud aeg: tunnid ja minutid sammunuppudega */
.tcrm-dur {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.tcrm-step {
    display: inline-flex;
    align-items: stretch;
    height: 42px;
    border: 1px solid #cfd4da;
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
}
.tcrm-step:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tcrm .tcrm-step-btn {
    width: 40px;
    padding: 0;
    border: 0;
    background: var(--wash);
    color: var(--ink);
    font-size: 20px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}
.tcrm .tcrm-step-btn:hover { background: #eceff1; }
.tcrm .tcrm-step-btn.is-plus { background: var(--accent); color: #fff; }
.tcrm .tcrm-step-btn.is-plus:hover { background: #173b38; }
.tcrm .tcrm-step-btn:active { transform: scale(0.94); }
.tcrm .tcrm-step input[type="number"] {
    width: 48px;
    min-height: 0;
    padding: 0 2px 0 6px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    font-size: 18px;
    font-weight: 650;
    text-align: right;
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
    appearance: textfield;
}
.tcrm .tcrm-step input[type="number"]:focus { box-shadow: none; outline: 0; }
.tcrm .tcrm-step input::-webkit-outer-spin-button,
.tcrm .tcrm-step input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tcrm-unit {
    display: flex;
    align-items: center;
    padding: 0 10px 0 3px;
    color: var(--muted);
}
.tcrm-dur-error { display: none; color: var(--danger) !important; font-weight: 600; }
.tcrm-field.is-invalid .tcrm-dur-error { display: block; }
.tcrm-field.is-invalid .tcrm-step { border-color: var(--danger); }
@media (prefers-reduced-motion: reduce) {
    .tcrm .tcrm-step-btn:active { transform: none; }
}

.tcrm-form-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.tcrm-form-buttons { display: flex; align-items: center; gap: 16px; }
.tcrm-check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.tcrm-check input { margin: 0; }

/* Logimisvorm saab rohelise serva – see on paneeli kõige olulisem toiming */
.tcrm-log { border-top: 3px solid var(--accent); scroll-margin-top: 80px; }

.tcrm-copy-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin: -4px 0 16px;
    padding: 10px 12px;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}
.tcrm-copy-note[hidden] { display: none; }
.tcrm-log.is-flash { animation: tcrm-flash 1.2s ease-out; }
@keyframes tcrm-flash {
    0% { box-shadow: 0 0 0 4px rgba(31, 78, 74, 0.35); }
    100% { box-shadow: 0 0 0 0 rgba(31, 78, 74, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .tcrm-log.is-flash { animation: none; }
}

/* ---------- Taimer ---------- */

.tcrm-timer {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 4px 4px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--wash);
}
.tcrm-timer-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #b8bec7;
}
.tcrm-timer-display {
    min-width: 64px;
    font-size: 15px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}
.tcrm-timer-toggle {
    min-height: 30px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}
.tcrm-timer.is-running {
    background: var(--accent-soft);
    border-color: #bcd4d0;
}
.tcrm-timer.is-running .tcrm-timer-dot {
    background: var(--accent);
    animation: tcrm-pulse 1.6s ease-in-out infinite;
}
.tcrm-timer.is-running .tcrm-timer-display { color: var(--accent); }
.tcrm-timer.is-running .tcrm-timer-toggle { background: var(--accent); }

.tcrm-timer-hint {
    margin: -6px 0 14px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
}
.tcrm-timer-hint[hidden] { display: none; }
.tcrm-timer-hint.is-error { color: var(--danger); }
.tcrm .tcrm-timer-toggle:disabled { opacity: 0.7; cursor: wait; }

@keyframes tcrm-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}
@media (prefers-reduced-motion: reduce) {
    .tcrm-timer.is-running .tcrm-timer-dot { animation: none; }
}

/* ---------- Filtrid ---------- */

.tcrm-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 12px;
}
.tcrm-filters label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 150px;
}
.tcrm-filters label.is-grow { flex: 1 1 280px; }
.tcrm-filters .tcrm-btn { min-height: 38px; }

.tcrm-ranges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}
.tcrm-ranges a {
    padding: 5px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink);
    text-decoration: none;
    font-size: 13px;
}
.tcrm-ranges a:hover { border-color: var(--ink); }
.tcrm-ranges a.is-active {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}
.tcrm-panel > .tcrm-ranges:last-child { margin-bottom: 0; }

/* ---------- Tabelid ---------- */

.tcrm-table-wrap { overflow-x: auto; }
.tcrm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.tcrm-table th {
    padding: 8px 12px;
    border-bottom: 1px solid var(--ink);
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}
.tcrm-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
.tcrm-table tbody tr:hover td { background: var(--wash); }
.tcrm-table .num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.tcrm-table .nowrap { white-space: nowrap; }
.tcrm-table .act { text-align: right; white-space: nowrap; }
.tcrm-table .act .tcrm-link + .tcrm-link { margin-left: 12px; }
.tcrm-table .desc {
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #3d4352;
}
.tcrm-table .budget { min-width: 160px; }
.tcrm-table .budget small { display: block; margin-top: 4px; }

/* ---------- Staatused ---------- */

.tcrm-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.tcrm-badge.is-active { background: var(--accent-soft); color: var(--accent); }
.tcrm-badge.is-lead,
.tcrm-badge.is-paused { background: #fdf3d8; color: #8a5a00; }
.tcrm-badge.is-inactive { background: #eef0f2; color: var(--muted); }
.tcrm-badge.is-done { background: #e6edf8; color: #2c4f86; }

/* ---------- Tulbad ja eelarved ---------- */

.tcrm-bars,
.tcrm-budgets,
.tcrm-plist { margin: 0; padding: 0; list-style: none; }
.tcrm-bars li,
.tcrm-budgets li { margin: 0 0 14px; }
.tcrm-bars li:last-child,
.tcrm-budgets li:last-child { margin-bottom: 0; }
.tcrm-bars-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}
.tcrm-bars-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcrm-bars-row em { color: var(--muted); font-style: normal; }
.tcrm-bars-row strong { font-variant-numeric: tabular-nums; white-space: nowrap; }

.tcrm-bar {
    height: 6px;
    border-radius: 3px;
    background: #eceff1;
    overflow: hidden;
}
.tcrm-bar i {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
}
.tcrm-bar.is-thin { height: 3px; margin-top: 6px; max-width: 320px; }
.tcrm-bar.is-over i,
.tcrm-budgets .is-over .tcrm-bar i { background: var(--warn); }
.tcrm-budgets .is-over strong { color: var(--warn); }

.tcrm-plist li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.tcrm-plist li:last-child { border-bottom: 0; }
.tcrm-plist a { font-weight: 600; margin-right: auto; }

.tcrm-counts p { margin: 0 0 8px; color: var(--muted); }
.tcrm-counts p:last-child { margin: 0; }
.tcrm-counts strong {
    display: inline-block;
    min-width: 32px;
    color: var(--ink);
    font-size: 18px;
    font-variant-numeric: tabular-nums;
}

/* ---------- Kliendi kaart ---------- */

.tcrm-dl {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 8px 12px;
    margin: 0;
}
.tcrm-dl dt { color: var(--muted); }
.tcrm-dl dd { margin: 0; overflow-wrap: anywhere; }
.tcrm-notes {
    margin-top: 16px;
    padding: 12px 14px;
    background: var(--wash);
    border-left: 3px solid var(--line);
    white-space: normal;
    line-height: 1.5;
}

/* ---------- Projektid / haldusteenused ---------- */

.tcrm-tabs {
    display: flex;
    gap: 4px;
    margin: -4px 0 16px;
    border-bottom: 1px solid var(--line);
}
.tcrm .tcrm-tabs a {
    padding: 8px 14px;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
}
.tcrm .tcrm-tabs a:hover { color: var(--ink); }
.tcrm .tcrm-tabs a.is-active { color: var(--ink); border-bottom-color: var(--accent); }

.tcrm-type {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 18px;
    padding: 0;
    border: 0;
}
.tcrm-type legend { margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.tcrm-type-opt {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    color: var(--muted);
    line-height: 1.45;
}
.tcrm-type-opt input { margin-top: 3px; }
.tcrm-type-opt strong { display: block; color: var(--ink); }
.tcrm-type-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.tcrm-field[hidden] { display: none; }

.tcrm-over-note { color: var(--warn); font-weight: 600; }
.tcrm-budgets .tcrm-over-note { display: block; margin-top: 4px; font-size: 12px; }
.tcrm-total-row td { border-top: 1px solid var(--ink); border-bottom: 0; font-weight: 650; }

@media (max-width: 700px) {
    .tcrm-type { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Raporti saatmise dialoog ---------- */

.tcrm-dialog {
    width: min(640px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 24px 60px rgba(28, 32, 44, 0.25);
}
.tcrm-dialog::backdrop { background: rgba(28, 32, 44, 0.45); }
.tcrm-dialog > form { padding: 22px 24px 20px; }
.tcrm-dialog-close {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.tcrm-dialog-close:hover { background: var(--wash); color: var(--ink); }
.tcrm-dialog-note {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 6px;
    background: #fdf3d8;
    color: #6b4600;
}
.tcrm-fields.is-stack { grid-template-columns: minmax(0, 1fr); }
.tcrm-dialog-logo { margin-top: 14px; }
.tcrm-dialog-logo img {
    max-width: 110px;
    max-height: 28px;
    margin-left: 6px;
    object-fit: contain;
}
.tcrm-dialog-attach {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 0;
    padding: 10px 12px;
    border: 1px dashed #cfd4da;
    border-radius: 6px;
}
.tcrm-attach-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 40px;
    border-radius: 4px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    flex: none;
}
.tcrm-dialog .tcrm-form-foot small { flex: 1 1 260px; }
.tcrm .tcrm-link-btn {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font-size: 14px;
    cursor: pointer;
}

/* ---------- Kohanduv ---------- */

@media (max-width: 1200px) {
    .tcrm-split,
    .tcrm-split.is-even { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
    .tcrm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tcrm-stat:nth-child(3) { border-left: 0; }
    .tcrm-stat:nth-child(n+3) { border-top: 1px solid var(--line); }
    .tcrm-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
    .tcrm-fields { grid-template-columns: minmax(0, 1fr); }
    .tcrm-field.is-half { grid-column: auto; }
    .tcrm-filters label { min-width: 0; flex: 1 1 100%; }
    .tcrm-stat strong { font-size: 22px; }
    .tcrm-head h1 { font-size: 22px; }
}
