/* Стили /app/: без внешних библиотек, под телефон и компьютер */
:root {
    --bg: #f5f5f7;
    --card: #fff;
    --text: #1d1d1f;
    --muted: #6e6e73;
    --line: #e2e2e7;
    --accent: #1d1d1f;
    --good: #1a7f37;
    --bad: #c62828;
}

* { box-sizing: border-box; }

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

a { color: inherit; }

.header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding: 12px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}

.header__brand { font-weight: 700; text-decoration: none; margin-right: auto; }
.header nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.header nav a { text-decoration: none; color: var(--muted); }
.header nav a.active { color: var(--text); font-weight: 600; }
.header form { margin: 0; }

.link-button {
    border: 0;
    background: none;
    padding: 0;
    font: inherit;
    color: var(--muted);
    cursor: pointer;
}

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

h1 { font-size: 24px; margin: 4px 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.card--narrow { max-width: 380px; margin: 40px auto; }

.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.nowrap { white-space: nowrap; }

.period-form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; }
.period-form label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }

input[type="date"], input[type="text"], input[type="password"] {
    font: inherit;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}

.button {
    font: inherit;
    padding: 8px 16px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
}

.quick-periods { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.quick-periods a {
    padding: 5px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    text-decoration: none;
    font-size: 14px;
}
.quick-periods a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.total { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.total__label { font-size: 13px; color: var(--muted); }
.total__value { font-size: 22px; font-weight: 600; white-space: nowrap; }
.total__note { font-size: 13px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.form-row input { width: 100%; }
.errors { color: var(--bad); margin: 0 0 12px; padding: 0; list-style: none; }

.message { padding: 10px 0; border-bottom: 1px solid var(--line); }
.message:last-child { border-bottom: 0; }
.message__meta { font-size: 13px; color: var(--muted); }
.message__text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.message--out .message__text { color: #0b4f9c; }

.pagination { display: flex; gap: 12px; justify-content: center; margin-top: 12px; }

@media (max-width: 600px) {
    main { padding: 12px; }
    h1 { font-size: 20px; }
    .total__value { font-size: 19px; }
    th, td { padding: 6px 8px; font-size: 14px; }
}
