:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #66707d;
  --line: #e3e8ee;
  --accent: #2057d6;
  --accent-dark: #1746ae;
  --danger: #c0392b;
  --ok: #1e8449;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }

.topbar {
  background: linear-gradient(135deg, #16337e, #2057d6);
  color: #fff;
  padding: 28px 0 0;
}
.topbar h1 { margin: 0 0 4px; font-size: 26px; }
.topbar .subtitle { margin: 0 0 18px; opacity: 0.92; font-size: 15px; }

.tabs { display: flex; gap: 8px; }
.tab {
  border: none; background: rgba(255,255,255,0.14); color: #fff;
  padding: 11px 18px; font-size: 15px; cursor: pointer;
  border-radius: 8px 8px 0 0; transition: background .15s;
}
.tab:hover { background: rgba(255,255,255,0.24); }
.tab.active { background: var(--panel); color: var(--ink); font-weight: 600; }

main { padding: 22px 0 8px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 1px 3px rgba(16,24,40,.06);
}

h2 { margin: 0 0 16px; font-size: 20px; }

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  margin: 0 0 18px;
}
legend { font-weight: 600; padding: 0 8px; font-size: 15px; }

.row { margin-bottom: 12px; }
.row label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 5px; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 9px 11px;
  font-size: 15px;
  border: 1px solid #c6cfda;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(32,87,214,.15);
}

.hint { margin: 5px 0 0; font-size: 13px; color: var(--muted); }
.req { color: var(--danger); }
.badge {
  font-size: 11px; font-weight: 700; color: var(--accent-dark);
  background: #e7eefc; border-radius: 5px; padding: 2px 6px; margin-left: 4px;
}

.period { display: flex; gap: 22px; flex-wrap: wrap; }
.period-group { display: flex; align-items: center; gap: 7px; }
.period-label { font-weight: 600; }
.period-group input[type=number] { width: 70px; }
.period-group select { width: 130px; }
.period-group input[type=number]#date_start_year,
.period-group input[type=number]#date_end_year { width: 90px; }

.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }

.btn {
  border: none; border-radius: 8px; padding: 11px 18px;
  font-size: 15px; cursor: pointer; transition: background .15s, opacity .15s;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost { background: #eef1f5; color: var(--ink); }
.btn.ghost:hover { background: #e0e5ec; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.status { min-height: 22px; margin: 14px 0 0; font-size: 14px; }
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }

/* Заметки */
.notes-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.notes-head h2 { margin: 0; }

.admin-box {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 18px; background: #fafbfd;
}
.admin-box input[type=password] { width: auto; flex: 1; min-width: 200px; }
#admin-login { display: flex; gap: 10px; flex-wrap: wrap; }
.admin-hint { margin: 0 0 10px; color: var(--ok); font-weight: 600; }

.note-editor { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.note-editor textarea { resize: vertical; }
.pin { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.pin input { width: auto; }

.notes-list { display: flex; flex-direction: column; gap: 12px; }
.note {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; background: #fff;
}
.note.pinned { border-left: 4px solid var(--accent); }
.note-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.note-title { font-size: 16px; font-weight: 700; margin: 0; }
.note-date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.note-body { margin: 8px 0 0; white-space: pre-wrap; font-size: 15px; }
.note-actions { margin-top: 10px; display: flex; gap: 8px; }
.note-actions .btn { padding: 6px 12px; font-size: 13px; }
.pin-tag { font-size: 11px; color: var(--accent-dark); font-weight: 700; margin-left: 6px; }

.empty { color: var(--muted); font-size: 14px; }

.footer { padding: 18px 16px 30px; color: var(--muted); font-size: 13px; }

@media (max-width: 560px) {
  .actions { flex-direction: column; }
  .btn { width: 100%; }
}
