/* KlikNet home page with tiles (Components/Pages/Home, classes kh-*); colours only through --kui-* tokens. */

.kh-page { gap: 16px; }
.kh-hello { display: flex; flex-direction: column; gap: 2px; }
.kh-hello .kui-page-title { font-size: 22px; font-weight: 700; }
.kh-page .kui-btn i { font-size: 14px; }
.kh-edit-hint { margin: 0; padding: 8px 12px; border: 1px dashed var(--kui-border); border-radius: var(--kui-radius-m); color: var(--kui-muted); font-size: 13px; background: var(--kui-surface); }

.kh-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 160px; grid-auto-flow: dense; gap: 14px; }
.kh-w-2 { grid-column: span 2; }
.kh-w-3 { grid-column: span 3; }
.kh-w-4 { grid-column: span 4; }
.kh-h-2 { grid-row: span 2; }
.kh-h-3 { grid-row: span 3; }

.kh-tile { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 14px 16px; gap: 10px;
    background: var(--kui-surface); color: var(--kui-text); border: 1px solid var(--kui-border-soft); border-radius: var(--kui-radius-l);
    box-shadow: var(--kui-shadow-1); }
.kh-tile.is-editing { border-style: dashed; border-color: var(--kui-border); cursor: grab; }
.kh-tile.is-drop { outline: 2px solid var(--kui-accent); outline-offset: 2px; }
.kh-tile-head { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.kh-tile-icon { flex: none; width: 30px; height: 30px; border-radius: var(--kui-radius-m); display: inline-flex; align-items: center; justify-content: center;
    background: var(--kui-accent-soft); color: var(--kui-accent-ink); font-size: 15px; }
.kh-tile-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.kh-tile-title h2 { margin: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kh-tile-title span { font-size: 12px; color: var(--kui-muted); }
.kh-tile-open { flex: none; width: 28px; height: 28px; border-radius: var(--kui-radius); display: inline-flex; align-items: center; justify-content: center; color: var(--kui-muted); text-decoration: none; }
.kh-tile-open:hover { background: var(--kui-surface-2); color: var(--kui-accent-ink); }
.kh-tile-tools { display: flex; gap: 2px; flex: none; }
.kh-tile-tools .kui-btn { width: 28px; height: 28px; }
.kh-tile-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.kh-tile-msg { margin: auto 0; color: var(--kui-muted); font-size: 13px; }
.kh-tile-msg.is-error { color: var(--kui-danger); }
.kh-skeleton { flex: 1; border-radius: var(--kui-radius-m); background: linear-gradient(90deg, var(--kui-surface-2) 0%, var(--kui-line) 50%, var(--kui-surface-2) 100%);
    background-size: 200% 100%; animation: kh-shimmer 1.2s linear infinite; }
@keyframes kh-shimmer { from { background-position: 200% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .kh-skeleton { animation: none; } }

/* settings of one tile in edit mode */
/* over the tile content, so a chart does not shrink while the settings are open */
.kh-tile-settings { position: absolute; top: 52px; left: 10px; right: 10px; z-index: 3; display: flex; flex-direction: column; gap: 8px;
    padding: 10px; border: 1px solid var(--kui-border-soft); border-radius: var(--kui-radius-m); background: var(--kui-surface-2); font-size: 13px;
    box-shadow: var(--kui-shadow-pop); }
.kh-set-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.kh-set-row select { height: 30px; min-width: 140px; }

/* KPI */
.kh-kpi { display: flex; flex-direction: column; gap: 4px; margin-top: auto; min-width: 0; }
.kh-kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -.5px; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kh-kpi-value.is-alert { color: var(--kui-danger); }
.kh-kpi-sub { font-size: 12.5px; color: var(--kui-muted); }
.kh-delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--kui-muted); }
.kh-delta small { font-weight: 400; color: var(--kui-muted); }
.kh-delta.is-up { color: var(--kui-success); }
.kh-delta.is-down { color: var(--kui-danger); }

/* chart + table */
.kh-chart { flex: 1; min-height: 0; }
.kh-table-wrap { flex: 1; min-height: 0; overflow: auto; }
.kh-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kh-table th { position: sticky; top: 0; padding: 6px 8px; text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .03em; color: var(--kui-muted); background: var(--kui-surface); border-bottom: 1px solid var(--kui-border-soft); }
.kh-table td { padding: 7px 8px; border-bottom: 1px solid var(--kui-line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.kh-table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.kh-table tbody tr:hover td { background: var(--kui-row-hover); }

/* shortcuts */
.kh-shortcuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; overflow: auto; }
.kh-shortcut { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 10px; border: 1px solid var(--kui-border-soft);
    border-radius: var(--kui-radius-m); color: var(--kui-text); text-decoration: none; font-size: 13px; font-weight: 600; min-width: 0; }
.kh-shortcut i { color: var(--kui-accent-ink); font-size: 16px; }
.kh-shortcut span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kh-shortcut:hover { border-color: var(--kui-accent); background: var(--kui-accent-soft); color: var(--kui-text); }

.kh-empty { padding: 40px; text-align: center; color: var(--kui-muted); border: 1px dashed var(--kui-border); border-radius: var(--kui-radius-l); }

/* catalog window */
.kh-cat-group { margin: 12px 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--kui-muted); }
.kh-cat-group:first-child { margin-top: 0; }
.kh-cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.kh-cat-card { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--kui-border-soft); border-radius: var(--kui-radius-m); background: var(--kui-surface); }
.kh-cat-icon { flex: none; width: 32px; height: 32px; border-radius: var(--kui-radius-m); display: inline-flex; align-items: center; justify-content: center;
    background: var(--kui-accent-soft); color: var(--kui-accent-ink); }
.kh-cat-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.kh-cat-text span { color: var(--kui-text-2); }
.kh-cat-text small { color: var(--kui-muted); }

@media (max-width: 1100px) {
    .kh-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kh-w-3, .kh-w-4 { grid-column: span 2; }
}
@media (max-width: 700px) {
    .kh-grid { grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(150px, auto); }
    .kh-w-2, .kh-w-3, .kh-w-4 { grid-column: span 1; }
    .kh-h-2, .kh-h-3 { grid-row: span 1; min-height: 300px; }
}
