html, body { min-height: 100%; }

/* Settings pages (system/*) */
.sys__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; align-items: start; }
.sys__fields { display: grid; gap: 14px; margin-top: 14px; }
.sys__alert { margin-bottom: 16px; }
.sys__meta { margin: 12px 0 0; }
.sys__hint { margin: 0 0 12px; color: var(--panda-text-soft); }
.sys__form { margin: 0; }
.flash { margin-bottom: 16px; }

/* ---------------------------------------------------------------------------------------------------------------------
   Customer / licensing / task pages
   --------------------------------------------------------------------------------------------------------------------- */
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 0 0 16px; }
.filters .panda-field { margin: 0; min-width: 160px; }
.filters .panda-field--grow { flex: 1 1 240px; }
.filters__actions { display: flex; gap: 8px; }

.linktabs { display: flex; gap: 4px; padding: 4px; margin: 0 0 16px; background: var(--panda-surface-3); border-radius: var(--panda-radius-md); overflow-x: auto; scrollbar-width: none; }
.linktabs::-webkit-scrollbar { display: none; }
.linktabs a { flex: 0 0 auto; padding: 8px 14px; border-radius: var(--panda-radius-sm); color: var(--panda-text-muted); text-decoration: none; font-weight: var(--panda-weight-medium); font-size: var(--panda-font-sm); white-space: nowrap; }
.linktabs a:hover { color: var(--panda-text); }
.linktabs a[aria-current="page"] { background: var(--panda-surface); color: var(--panda-text); box-shadow: var(--panda-shadow-sm); }
.linktabs a .panda-badge { margin-left: 6px; }

.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 24px; margin: 0; }
.kv > div { min-width: 0; }
.kv dt { color: var(--panda-text-muted); font-size: var(--panda-font-xs); margin-bottom: 2px; }
.kv dd { margin: 0; font-weight: var(--panda-weight-medium); overflow-wrap: anywhere; }
.kv dd.mono, .mono { font-family: ui-monospace, Consolas, Menlo, monospace; font-size: .92em; }

.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cols--even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: grid; gap: 16px; }
.card-body { display: grid; gap: 14px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-form { display: inline; margin: 0; }
.muted { color: var(--panda-text-muted); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-link { color: inherit; text-decoration: none; font-weight: var(--panda-weight-medium); }
.cell-link:hover { color: var(--panda-primary); }
.cell-sub { display: block; color: var(--panda-text-muted); font-size: var(--panda-font-xs); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; color: var(--panda-text-muted); font-size: var(--panda-font-sm); }
.pager__links { display: flex; gap: 6px; }

.formsection { display: grid; gap: 14px; padding: 16px; border: 1px solid var(--panda-border); border-radius: var(--panda-radius-lg); background: var(--panda-surface-2); }
.formsection > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.formsection > header h3 { margin: 0; font-size: var(--panda-font-md); }
.formsection--nested { background: var(--panda-surface); }
.savebar { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; padding: 12px 16px; border: 1px solid var(--panda-border); border-radius: var(--panda-radius-lg); background: var(--panda-surface); box-shadow: var(--panda-shadow-md); }

.featuregrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.featurerow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--panda-border); border-radius: var(--panda-radius-md); background: var(--panda-surface); }
.featurerow > div:first-child { min-width: 0; }
.featurerow strong { display: block; font-weight: var(--panda-weight-medium); }
.featurerow small { display: block; color: var(--panda-text-muted); }
.featurerow__limit { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.featurerow__limit .panda-input { width: 84px; text-align: right; }

.timeline { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.timeline li { display: grid; gap: 2px; padding: 10px 0 10px 18px; border-left: 2px solid var(--panda-border); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--panda-primary); }
.timeline small { color: var(--panda-text-muted); }

.validation-message { color: var(--panda-danger); font-size: 12px; }
.validation-errors { margin: 0; padding-left: 18px; }

@media (max-width: 900px) {
    .cols, .cols--even { grid-template-columns: 1fr; }
    .filters .panda-field { flex: 1 1 100%; }
    .savebar { bottom: env(safe-area-inset-bottom, 0px); }
    .savebar .panda-button { flex: 1; }
}

/* Tasks */
.tasks__overdue { color: var(--panda-danger); font-weight: var(--panda-weight-medium); }
.tasks__people { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 6px; }
.taskdet__desc { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.taskdet__checklist { display: grid; gap: 6px; margin: 0; }
.taskdet__item { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 10px 12px; border: 1px solid var(--panda-border); border-radius: var(--panda-radius-md); background: var(--panda-surface); color: var(--panda-text); text-align: left; cursor: pointer; transition: background var(--panda-duration-fast), border-color var(--panda-duration-fast); }
.taskdet__item:hover:not(:disabled) { border-color: var(--panda-border-strong); background: var(--panda-surface-2); }
.taskdet__item:disabled { cursor: default; opacity: .8; }
.taskdet__item--done > span:last-child { color: var(--panda-text-muted); text-decoration: line-through; }
.taskdet__box { flex: 0 0 20px; width: 20px; height: 20px; display: grid; place-items: center; border: 2px solid var(--panda-border-strong); border-radius: 6px; font-size: 13px; font-weight: 700; line-height: 1; }
.taskdet__item--done .taskdet__box { border-color: var(--panda-success); background: var(--panda-success); color: #fff; }
.taskdet__add { display: flex; gap: 8px; margin-top: 6px; }
.taskdet__add .panda-input { flex: 1; }
.taskdet__comment { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--panda-border); }
.taskdet__comment:first-of-type { border-top: 0; }
.taskdet__comment p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.taskdet__kv { grid-template-columns: 1fr; }
.taskdet__kv .panda-chip { margin: 0 4px 4px 0; }

/* Customer / business detail */
.custdet__user { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--panda-border); }
.custdet__user:first-of-type { border-top: 0; }
.custdet__user .panda-person { min-width: 0; }
.custdet__user small { overflow-wrap: anywhere; }
.bizdet__licforms { display: grid; gap: 12px; margin: 0; }
.bizdet__inline { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.bizdet__inline .panda-field { margin: 0; width: 170px; }

@media (max-width: 600px) {
    .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
    .taskdet__kv { grid-template-columns: 1fr; }
}
