/* CRM - responsywny panel: uklad, formularze, tabele, menu i widok mobilny. */
:root {
    --accent: #2f6fed;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --text: #16202e;
    --muted: #64748b;
    --border: #e2e8f0;
    --ok: #157f4c;
    --warn: #b45309;
    --error: #c02626;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
}

[data-theme="dark"] {
    --bg: #0f1622;
    --surface: #17202f;
    --text: #e8edf5;
    --muted: #94a3b8;
    --border: #26334a;
    --shadow: none;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
code { background: rgba(100, 116, 139, .14); padding: .1em .35em; border-radius: 6px; font-size: .9em; }

.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .5rem 1rem; z-index: 50; }

.layout { display: flex; min-height: 100vh; }
.layout__main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.sidebar {
    width: 236px;
    flex: 0 0 236px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1rem .75rem;
}
.sidebar__brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; padding: .25rem .5rem 1rem; }
.sidebar__group { margin: 1rem .5rem .25rem; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sidebar__nav ul { list-style: none; margin: 0; padding: 0; }
.sidebar__link { display: block; padding: .5rem .65rem; border-radius: 9px; color: var(--text); }
.sidebar__link:hover { background: rgba(47, 111, 237, .08); text-decoration: none; }
.sidebar__link.is-active { background: var(--accent); color: #fff; }

.topbar {
    display: flex; align-items: center; gap: .75rem;
    padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
}
.topbar__title { font-size: 1.1rem; margin: 0; flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.topbar__user { font-weight: 600; }
.topbar__logout { margin: 0; }
.topbar__toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: .35rem .6rem; font-size: 1rem; }

.content { padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; flex: 1; }
.footer { display: flex; justify-content: space-between; padding: .75rem 1.25rem; color: var(--muted); font-size: .82rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); }
.card--warn { border-color: rgba(180, 83, 9, .45); }
.card__title { font-size: 1rem; margin-bottom: .75rem; }
.card__hint, .muted { color: var(--muted); }
.small { font-size: .82rem; }
.card__header { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card__actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.prose { margin: .5rem 0; white-space: normal; }

.grid { display: grid; gap: 1rem; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.card--full { grid-column: 1 / -1; }

.tiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.tile__label { color: var(--muted); font-size: .8rem; margin: 0 0 .35rem; }
.tile__value { font-size: 1.45rem; font-weight: 700; margin: 0; }
.tile__hint { color: var(--muted); font-size: .78rem; margin: .35rem 0 0; }

.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; }
.toolbar input, .toolbar select { min-width: 140px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: 9px; padding: .45rem .8rem; font: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--ghost { background: transparent; }
.btn--danger { border-color: var(--error); color: var(--error); }
.btn--small { padding: .3rem .55rem; font-size: .82rem; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: progress; }

.form { display: flex; flex-direction: column; gap: .75rem; }
.form--grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .85rem; }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .87rem; color: var(--muted); }
.field--full, .form__actions--full, .form__hint.field--full { grid-column: 1 / -1; }
.field--inline { flex-direction: row; align-items: center; gap: .5rem; }
.field__label { font-weight: 600; color: var(--text); }
.field input, .field select, .field textarea, .toolbar input, .toolbar select, .inline-form input, .table--form input, .table--form select, .table--form textarea {
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: 9px; padding: .5rem .6rem; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(47, 111, 237, .35); border-color: var(--accent); }
.checkbox { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
.checkbox input { width: auto; }
.form__actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.form__hint { color: var(--muted); font-size: .82rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin: .5rem 0; }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.table--compact th, .table--compact td { padding: .4rem .35rem; }
.table__actions { display: flex; gap: .3rem; flex-wrap: wrap; }
.table--form td { padding: .35rem .3rem; }
.table .right, .right { text-align: right; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list__item { display: flex; justify-content: space-between; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.list--plain .list__item { align-items: center; }
.list__actions { display: flex; gap: .3rem; }
.list__item p { margin: .15rem 0 0; }

.badge { display: inline-block; padding: .1rem .45rem; border-radius: 999px; border: 1px solid var(--border); font-size: .76rem; color: var(--muted); }
.badge--ok { color: var(--ok); border-color: rgba(21, 127, 76, .4); }
.badge--warn { color: var(--warn); border-color: rgba(180, 83, 9, .4); }
.badge--error { color: var(--error); border-color: rgba(192, 38, 38, .4); }
.badge--muted { color: var(--muted); }

.flash-stack { display: flex; flex-direction: column; gap: .5rem; }
.flash { padding: .6rem .8rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.flash--success { border-color: rgba(21, 127, 76, .45); color: var(--ok); }
.flash--error { border-color: rgba(192, 38, 38, .45); color: var(--error); }
.alert { border: 1px solid var(--border); border-radius: 10px; padding: .75rem .9rem; background: var(--surface); }
.alert--error { border-color: rgba(192, 38, 38, .45); }
.alert--warn { border-color: rgba(180, 83, 9, .45); }
.alert__title { margin: 0 0 .35rem; font-weight: 600; }
.alert ul { margin: 0; padding-left: 1.1rem; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .6rem; margin: 0; }
.summary dt { color: var(--muted); font-size: .78rem; }
.summary dd { margin: .1rem 0 0; }

.progress { height: 12px; background: rgba(100, 116, 139, .18); border-radius: 999px; overflow: hidden; margin: .5rem 0; }
.progress__bar { height: 100%; background: var(--accent); }
.progress--warn .progress__bar { background: var(--warn); }

.board { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem; }
.board__column { flex: 0 0 260px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; }
.board__title { font-size: .85rem; display: flex; justify-content: space-between; gap: .5rem; }
.board__card { border: 1px solid var(--border); border-radius: 10px; padding: .6rem; margin-bottom: .5rem; }
.board__move select { width: 100%; font-size: .8rem; padding: .3rem; }

.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.calendar__weekday { font-size: .74rem; color: var(--muted); text-align: center; text-transform: uppercase; }
.calendar__day { min-height: 92px; border: 1px solid var(--border); border-radius: 9px; padding: .3rem; display: flex; flex-direction: column; gap: .2rem; }
.calendar__day--empty { border-style: dashed; opacity: .4; }
.calendar__day.is-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.calendar__number { font-size: .78rem; color: var(--muted); }
.calendar__event { font-size: .72rem; padding: .15rem .3rem; border-radius: 6px; background: rgba(47, 111, 237, .12); color: var(--text); }
.calendar__event--payment { background: rgba(180, 83, 9, .15); }
.calendar__event--task { background: rgba(21, 127, 76, .14); }
.calendar__event--reminder { background: rgba(100, 116, 139, .18); }

.tabs { display: flex; gap: .35rem; flex-wrap: wrap; }
.tabs__link { padding: .4rem .75rem; border: 1px solid var(--border); border-radius: 999px; color: var(--text); background: var(--surface); }
.tabs__link.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

.pagination { display: flex; gap: .75rem; align-items: center; justify-content: center; padding-top: .75rem; color: var(--muted); font-size: .85rem; }
.empty { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; text-align: center; }
.checklist { margin: .5rem 0 1rem; padding-left: 1.1rem; }

@media (max-width: 860px) {
    .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow); }
    .topbar__toggle { display: inline-block; }
    .content { padding: .85rem; }
    .table { font-size: .84rem; }
    .topbar__actions .btn { display: none; }
    .topbar__actions .btn--primary, .topbar__logout .btn { display: inline-flex; }
}
