/* ==========================================================================
   Planara — time tracking, costs, budgets & cost reports
   Uses only design tokens from app.css so light and dark themes both work.
   ========================================================================== */

/* ---------- Filters ---------- */
.te-filters { padding: 12px 14px 10px; }
.te-filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; align-items: end; }
.te-filter-more { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.te-filter { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.te-filter-label { font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); }
.te-filter-range { grid-column: span 2; }
.te-filter-range .input { min-width: 0; }
.te-filter-actions { margin-top: 10px; }
.te-filter-actions .btn.active { background: var(--bg-active); color: var(--primary); }
.te-check { display: block; width: 100%; }
.te-check-btn { display: flex !important; align-items: center; justify-content: space-between; gap: 6px; text-align: left; cursor: pointer; }
.te-check-btn .icon { width: 13px; height: 13px; color: var(--text-faint); }
.te-check-btn.has-value { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.te-check-menu { min-width: 230px; max-height: 320px; }
.te-check-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap; }
.te-check-item:hover { background: var(--bg-hover); }
.te-check-item input { width: 15px; height: 15px; accent-color: var(--primary); margin: 0; }
.te-wp-input { position: relative; }
.te-wp-input .te-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.te-wp-input .input { padding-right: 30px; }

/* ---------- Stats ---------- */
.te-stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.te-stat { display: flex; flex-direction: column; padding: 10px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); min-width: 140px; box-shadow: var(--shadow-sm); }
.te-stat-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); font-weight: 600; }
.te-stat-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }
.te-stat-sub { font-size: .84rem; color: var(--text-muted); }

/* ---------- Tabs & tables ---------- */
.te-tabs { align-items: center; margin-bottom: 14px; }
.te-groupby { margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.te-table td { vertical-align: top; }
.te-wp { display: inline-flex; align-items: baseline; gap: 5px; color: var(--text); max-width: 340px; min-width: 0; }
.te-wp-cell .te-wp { display: flex; }
.te-wp:hover { text-decoration: none; }
.te-wp:hover .te-wp-subject { text-decoration: underline; color: var(--link); }
.te-wp-id { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.te-wp-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.te-wp .type-label { flex-shrink: 0; font-size: .72rem; }
.te-comment { color: var(--text-muted); max-width: 360px; word-break: break-word; }
.te-override { color: var(--warning); font-weight: 700; cursor: help; }
.te-summary .te-bar-col { width: 32%; }
.te-bar { display: block; height: 8px; border-radius: 4px; background: var(--bg-muted); overflow: hidden; }
.te-bar > span { display: block; height: 100%; background: var(--primary); border-radius: 4px; min-width: 2px; }
.table tfoot tr.sum-row td { border-top: 1px solid var(--border-strong); border-bottom: 0; }

/* ---------- Timer ---------- */
.te-timer {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 6px 0 12px; max-width: 420px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); border-radius: 17px; background: var(--danger-soft);
}
.te-timer-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); flex-shrink: 0; animation: te-pulse 1.4s ease-in-out infinite; }
@keyframes te-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.te-timer-clock { font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.te-timer-subject { color: var(--text); font-size: .9rem; min-width: 0; max-width: 220px; }
.te-timer .btn-xs { border-radius: 12px; }

/* ---------- Forms ---------- */
.te-form-card { max-width: 860px; }
.te-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
.form:not(.form-stacked) .te-form-grid .form-row { grid-template-columns: 200px minmax(0, 1fr); }
.form:not(.form-stacked) .te-form-grid { grid-template-columns: 1fr; }
.form-stacked .te-form-grid .form-row { margin-bottom: 10px; }
.te-hours-input { font-variant-numeric: tabular-nums; }
.te-costs-line { display: flex; align-items: baseline; gap: 10px; padding-top: 6px; flex-wrap: wrap; }
.te-costs-calc { font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.te-override-field { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.te-danger-zone { margin-top: 16px; }
.te-form-errors ul { margin: 0; padding-left: 18px; }
.modal .te-form { max-width: none; }
.modal .te-form .form-row { margin-bottom: 12px; }

/* ---------- My time ---------- */
.mt-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.mt-week-label { font-weight: 600; font-size: 1.05rem; padding: 0 6px; }
.mt-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.mt-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.mt-day { border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 320px; min-width: 0; }
.mt-day:first-child { border-left: 0; }
.mt-day.is-weekend { background: var(--bg-subtle); }
.mt-day.is-today .mt-day-head { background: var(--primary-soft); }
.mt-day.is-today .mt-day-num { background: var(--primary); color: var(--primary-text); }
.mt-day-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.mt-day-name { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); }
.mt-day-num { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 13px; font-weight: 700; padding: 0 4px; }
.mt-day-total { font-weight: 700; font-variant-numeric: tabular-nums; font-size: .92rem; }
.mt-day-total.is-zero { color: var(--text-faint); font-weight: 500; }
.mt-day-body { flex: 1; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.mt-entry {
  display: block; padding: 6px 8px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid hsl(var(--h, 210) 55% 50%); color: var(--text); font-size: .87rem; line-height: 1.35; box-shadow: var(--shadow-sm);
}
.mt-entry:hover { text-decoration: none; border-color: var(--border-strong); background: var(--bg-hover); color: var(--text); }
.mt-entry-hours { font-weight: 700; font-variant-numeric: tabular-nums; }
.mt-entry-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-entry-meta { display: block; color: var(--text-muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-add { margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 4px; height: 28px; border-radius: var(--radius); border: 1px dashed var(--border-strong); color: var(--text-muted); font-size: .85rem; opacity: .65; }
.mt-add:hover { opacity: 1; text-decoration: none; color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.mt-day-bar { height: 4px; background: var(--bg-muted); }
.mt-day-bar > span { display: block; height: 100%; background: var(--success); }
.mt-day-bar > span.is-over { background: var(--warning); }
.mt-weekfoot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 2px; flex-wrap: wrap; }
.mt-weektotal { font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.mt-side .card + .card { margin-top: 16px; }
.mt-recent { list-style: none; margin: 0; padding: 0; }
.mt-recent li { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-bottom: 1px solid var(--border); }
.mt-recent li:last-child { border-bottom: 0; }
.mt-recent .te-wp { display: flex; min-width: 0; max-width: 100%; font-size: .9rem; overflow: hidden; }
.mt-recent .mt-recent-actions { display: flex; gap: 2px; flex-shrink: 0; }
.mt-recent .mt-recent-project { display: block; font-size: .78rem; color: var(--text-muted); }
.mt-recent-main { flex: 1; min-width: 0; }

/* ---------- Unit costs ---------- */
.ce-units { display: flex; align-items: center; gap: 8px; }
.ce-units .input { max-width: 160px; }

/* ---------- Budgets ---------- */
.bg-list .bg-progress { min-width: 160px; }
.bg-meter { position: relative; height: 10px; border-radius: 5px; background: var(--bg-muted); overflow: hidden; }
.bg-meter > span { position: absolute; inset: 0 auto 0 0; background: var(--success); border-radius: 5px; }
.bg-meter.is-warn > span { background: var(--warning); }
.bg-meter.is-over > span { background: var(--danger); }
.bg-meter-lg { height: 14px; border-radius: 7px; }
.bg-figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.bg-figure { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.bg-figure .te-stat-value { font-size: 1.3rem; }
.bg-figure.is-over .te-stat-value { color: var(--danger); }
.bg-items .num { white-space: nowrap; }
.bg-items input.input-sm, .bg-items select.input-sm { min-width: 0; }
.bg-item-calc { display: block; font-size: .78rem; color: var(--text-faint); margin-top: 2px; white-space: nowrap; }
.bg-section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 8px; }
.bg-section-title h3 { margin: 0; font-size: 1.02rem; }
.bg-total-row td { font-weight: 700; background: var(--bg-subtle); }

/* ---------- Hourly rates ---------- */
.hr-source { font-size: .78rem; }
.hr-history-row td { padding-top: 6px; padding-bottom: 6px; }
.hr-rates-table .input { max-width: 160px; }

/* ---------- Cost reports ---------- */
.cr-setup { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.cr-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cr-chips { list-style: none; margin: 0 0 6px; padding: 0; display: flex; gap: 6px; flex-wrap: wrap; min-height: 30px; }
.cr-chip { display: inline-flex; align-items: center; gap: 2px; height: 28px; padding: 0 2px 0 10px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); font-size: .87rem; font-weight: 500; }
.cr-chip .btn { color: inherit; height: 22px; width: 22px; border-radius: 11px; }
.cr-units { display: flex; gap: 6px; flex-wrap: wrap; }
.cr-table-wrap { overflow: auto; max-height: 75vh; }
.cr-table th, .cr-table td { white-space: nowrap; }
.cr-table thead th { z-index: 2; }
.cr-table .cr-row-head { position: sticky; left: 0; background: var(--surface); z-index: 1; font-weight: 500; }
.cr-table thead .cr-row-head { background: var(--bg-subtle); z-index: 3; }
.cr-table tbody tr:hover .cr-row-head { background: var(--bg-hover); }
.cr-table .cr-total { font-weight: 700; background: var(--bg-subtle); }
.cr-table .cr-zero { color: var(--text-faint); }
.cr-table .cr-sub td { background: var(--bg-muted); font-weight: 600; }
.cr-table .cr-sub .cr-row-head { background: var(--bg-muted); }
.cr-table td.num a { color: inherit; }
.cr-heat { background: color-mix(in srgb, var(--primary) var(--a, 0%), transparent); }
.cr-presets { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cr-preset { display: inline-flex; align-items: center; gap: 2px; }

/* ---------- Admin cost types ---------- */
.ct-rates td .input { max-width: 180px; }
.ct-deleted td { opacity: .6; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .mt-layout { grid-template-columns: 1fr; }
  .bg-figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cr-setup { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .te-form-grid { grid-template-columns: 1fr; }
  .te-filter-range { grid-column: span 1; }
  .te-groupby { margin-left: 0; }
  .te-tabs { flex-wrap: wrap; }
  .mt-week { grid-template-columns: 1fr; }
  .mt-day { border-left: 0; border-top: 1px solid var(--border); min-height: 0; }
  .mt-day:first-child { border-top: 0; }
  .mt-add { margin-top: 4px; }
  .cr-groups { grid-template-columns: 1fr; }
  .te-timer-subject { max-width: 120px; }
}
@media (max-width: 560px) {
  .te-filter-grid { grid-template-columns: 1fr 1fr; }
  .te-stat { min-width: 0; flex: 1 1 40%; }
  .bg-figures { grid-template-columns: 1fr 1fr; }
  .te-comment { max-width: 200px; }
}
@media print {
  .te-filters, .te-timer, .mt-add, .te-tabs { display: none !important; }
}

/* small selects inside module filter bars (core select.input sets min-height 34px) */
.te-filters select.input-sm, .cr-setup select.input-sm, .te-groupby select.input-sm { min-height: 28px; padding-top: 3px; padding-bottom: 3px; }
.te-table td.te-project { white-space: nowrap; }
.te-form .form-hint:empty { display: none; }
.te-form input[type=date].input, .te-form input[type=time].input, .te-filters input[type=date].input { height: 34px; }
.te-filters input[type=date].input-sm { height: 28px; }
.bg-figure { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bg-items select.input-sm, .bg-items input.input-sm { min-height: 28px; }
.bg-items td { vertical-align: top; }
.bg-items td.num { text-align: right; }
.bg-items td.num .input { display: inline-block; }
.te-stat-value, .bg-figure .te-stat-value { word-break: break-word; }
.empty-state .btn .icon { width: 16px; height: 16px; margin: 0; color: inherit; stroke-width: 2; }
.mt-main, .mt-side { min-width: 0; }
.mt-day-body { min-width: 0; }
