:root { --bg: #f5f6f8; --card: #fff; --line: #e3e6ea; --text: #1d2330; --muted: #6b7380; --accent: #7a3ff2; --red: #d93a3a; --green: #1f9d55; }
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
/* кнопки — как в CRM: белые с тонкой рамкой и тенью, главные — фиолетовый градиент, .ghost — светлая заливка */
button { border: 1px solid #e4e0ee; background: #fff; border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600; line-height: 1.25;
  white-space: nowrap; box-shadow: 0 1px 2px #1f23280d, 0 1px 1px #1f232808; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s, transform .08s; }
button.primary { background: linear-gradient(180deg, #8b5cf6, #7a3ff2); border-color: #6f32e3; color: #fff; box-shadow: 0 2px 8px #7a3ff238, inset 0 1px 0 #ffffff2e; }
button.danger { color: var(--red); }
button.ghost, a.ghost { background: #f3f0fa; border: 1px solid transparent; box-shadow: none; color: #4c4462; text-decoration: none; border-radius: 10px; padding: 6px 12px; font-weight: 600; }
@media (hover: hover) {
  button:hover { border-color: #cdbff5; background: #faf7ff; }
  button.primary:hover { background: linear-gradient(180deg, #7f4ff1, #6a28d6); border-color: #6224cc; }
  button.ghost:hover, a.ghost:hover { background: #ebe4fc; color: var(--accent); }
}
button:active { transform: scale(.97); }
button:focus-visible { outline: 2px solid #c4b0fa; outline-offset: 2px; }
button:disabled { opacity: .55; cursor: default; transform: none; }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; }
textarea { width: 100%; resize: vertical; }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.logo { font-size: 17px; }
#tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
#tabs button { border: none; background: none; padding: 7px 12px; white-space: nowrap; box-shadow: none; border-radius: 999px; font-weight: 500; }
#tabs button.on { background: #efe8fe; color: var(--accent); font-weight: 600; }
.who { color: var(--muted); font-size: 13px; }
body:not(.owner) .owner { display: none; }

main { max-width: 1100px; margin: 0 auto; padding: 12px; }
.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.bar input[type=search] { flex: 1; min-width: 200px; }
.sticky-bottom { position: sticky; bottom: 0; background: var(--bg); padding: 8px 0; }

.list { display: flex; flex-direction: column; gap: 6px; }
.row { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; cursor: pointer; display: grid; grid-template-columns: 120px 1fr auto; gap: 4px 12px; }
.row:hover { border-color: #c9b6fb; }
.row .d { font-weight: 600; }
.row .sub { color: var(--muted); font-size: 13px; grid-column: 2 / 4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sum { font-weight: 600; text-align: right; white-space: nowrap; }
.row.past { opacity: .8; }
.month { margin: 14px 0 4px; font-weight: 700; color: var(--muted); text-transform: uppercase; font-size: 12px; }
.tag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 10px; background: #eef0f3; margin-left: 4px; white-space: nowrap; }
.tag.red { background: #fde8e8; color: var(--red); }
.tag.green { background: #e3f6ea; color: var(--green); }
.tag.violet { background: #efe8fe; color: var(--accent); }

.overlay { position: fixed; inset: 0; background: rgba(20, 20, 30, .45); display: flex; align-items: flex-start; justify-content: center; padding: 20px 10px; overflow-y: auto; z-index: 10; }
.modal { background: var(--card); border-radius: 14px; padding: 18px; width: 100%; max-width: 720px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.grid label, .field { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.grid label input, .grid label select, .grid label textarea { color: var(--text); font-size: 15px; }
.grid .wide { grid-column: 1 / 3; }
.check { flex-direction: row !important; align-items: center; gap: 6px !important; color: var(--text) !important; font-size: 15px !important; }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.raw { white-space: pre-wrap; background: #f7f7f9; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 10px; }
.err { color: var(--red); }

.plan-item { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.plan-item.skip { opacity: .55; }
.plan-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.plan-item textarea { margin-top: 8px; font-size: 14px; }
.q-item { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; flex-wrap: wrap; }
.q-item .grow { flex: 1; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.card b { display: block; font-size: 22px; }
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; margin-bottom: 14px; font-size: 14px; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { background: #fafafb; font-weight: 600; }
td.n { text-align: right; white-space: nowrap; }
.bar-bg { background: #efe8fe; height: 8px; border-radius: 4px; }
.bar-fg { background: var(--accent); height: 8px; border-radius: 4px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: 90vw; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login { background: #fff; padding: 24px; border-radius: 14px; width: 320px; display: flex; flex-direction: column; gap: 10px; }
.login h1 { font-size: 20px; margin: 0; }

@media (max-width: 640px) {
  .row { grid-template-columns: 1fr auto; }
  .row .sub { grid-column: 1 / 3; }
  .row .d { grid-column: 1 / 3; }
  .grid { grid-template-columns: 1fr; }
  .grid .wide { grid-column: auto; }
  .who { display: none; }
}
#tabs button.on { background: linear-gradient(180deg, #8b5cf6, #7a3ff2); color: #fff; box-shadow: 0 2px 6px #7a3ff238; }
.modal-head button.ghost, button.ghost[onclick="closeModal()"] { background: transparent; border-radius: 50%; width: 34px; height: 34px; padding: 0; color: var(--muted); }
