:root {
  --teal-dark: #123B39;
  --teal: #0A6B63;
  --teal-light: #E8F2F0;
  --gold: #D5A547;
  --text: #263331;
  --muted: #667472;
  --bg: #F2F4F3;
  --warn: #F9EAD7;
  --risk: #FCEBE8;
  --line: #DCE3E1;
  --white: #fff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(18, 59, 57, .06), 0 8px 24px rgba(18, 59, 57, .06);
}

* { box-sizing: border-box; }

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

a { color: var(--teal); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; margin-top: 1.6rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }

/* ---------- Шапка ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.2rem;
  padding: .6rem 1.2rem;
  background: var(--teal-dark);
  color: #EAF3F1;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: inherit; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px; background: var(--teal);
  color: var(--gold); font-weight: 700; display: grid; place-items: center; font-size: .9rem;
}
.brand-text strong { display: block; font-size: .98rem; }
.brand-text small { color: #9FB8B4; font-size: .74rem; }
.nav { display: flex; gap: .2rem; flex: 1; flex-wrap: wrap; }
.nav-link {
  color: #C9DBD8; text-decoration: none; padding: .38rem .7rem; border-radius: 7px; font-size: .92rem;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.is-active { background: var(--teal); color: #fff; }
.userbox { display: flex; align-items: center; gap: .5rem; font-size: .84rem; color: #9FB8B4; }
.user-name { color: #EAF3F1; }
.linkish {
  background: none; border: 0; color: var(--gold); cursor: pointer; font: inherit; padding: 0;
  text-decoration: underline;
}

/* ---------- Каркас страницы ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 1.4rem 1.2rem 4rem; }
body.wide .page { max-width: 1500px; }

.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.card.tight { padding: .8rem .9rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: .5rem; }

/* ---------- Кнопки и формы ---------- */
.btn {
  display: inline-block; border: 1px solid var(--teal); background: var(--teal); color: #fff;
  border-radius: 8px; padding: .48rem .9rem; font: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #085A53; }
.btn.ghost { background: transparent; color: var(--teal); }
.btn.ghost:hover { background: var(--teal-light); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #3A2B08; }
.btn.gold:hover { background: #C4972F; }
.btn.danger { background: #B3382A; border-color: #B3382A; }
.btn.small { padding: .28rem .6rem; font-size: .84rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number],
select, textarea {
  width: 100%; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff; color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: -1px; }
.field { margin-bottom: .75rem; }
.check { display: flex; align-items: center; gap: .45rem; font-size: .9rem; color: var(--text); }
.check input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .8rem; margin: 0 0 1rem; }
legend { font-size: .85rem; color: var(--muted); padding: 0 .4rem; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: #FAFBFB; }

/* ---------- Значки ---------- */
.badge {
  display: inline-block; padding: .1rem .45rem; border-radius: 999px; font-size: .75rem;
  background: var(--teal-light); color: var(--teal-dark); white-space: nowrap;
}
.badge.p0 { background: #FCEBE8; color: #922718; }
.badge.p1 { background: #FDEEDD; color: #8A4A0B; }
.badge.p2 { background: #FBF1DA; color: #7A5A11; }
.badge.p3 { background: #ECEFEE; color: #4E5B59; }
.badge.gold { background: #FBF1DA; color: #7A5A11; }
.badge.ok { background: #E1F0E5; color: #1F6136; }
.badge.warn { background: var(--warn); color: #7A5A11; }
.badge.risk { background: var(--risk); color: #922718; }
.badge.grey { background: #ECEFEE; color: #4E5B59; }
.badge.overdue { background: #922718; color: #fff; }

.flash { padding: .6rem .9rem; border-radius: 8px; margin-bottom: 1rem; }
.flash.ok { background: #E1F0E5; color: #1F6136; }
.flash.err { background: var(--risk); color: #922718; }

/* ---------- Вкладки ---------- */
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tab {
  padding: .45rem .8rem; text-decoration: none; color: var(--muted); border-radius: 8px 8px 0 0;
  border: 1px solid transparent; border-bottom: none; font-size: .92rem;
}
.tab:hover { background: #fff; color: var(--text); }
.tab.is-active { background: #fff; color: var(--teal-dark); border-color: var(--line); font-weight: 600; }

/* ---------- Плитки ---------- */
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; }
.tile .n { font-size: 1.7rem; font-weight: 600; color: var(--teal-dark); line-height: 1.1; }
.tile .l { font-size: .82rem; color: var(--muted); }
.tile.alert .n { color: #922718; }

/* ---------- Задачи ---------- */
.task { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: .8rem .9rem; }
.task + .task { margin-top: .6rem; }
.task h3 { margin-bottom: .3rem; font-size: .98rem; }
.task .meta { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-bottom: .35rem; }
.task dl { display: grid; grid-template-columns: max-content 1fr; gap: .15rem .7rem; margin: .4rem 0 0; font-size: .87rem; }
.task dt { color: var(--muted); }
.task dd { margin: 0; }
.task.is-proposed { border-left: 3px solid var(--gold); }
.task.is-done { opacity: .65; }
.task.is-overdue { border-left: 3px solid #B3382A; }

/* ---------- Календарь ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal .dow { background: #EDF1F0; padding: .35rem .5rem; font-size: .76rem; color: var(--muted); text-transform: uppercase; }
.cal .day { background: #fff; min-height: 104px; padding: .35rem .4rem; min-width: 0; overflow: hidden; }
.cal .day.other { background: #F7F9F8; color: var(--muted); }
.cal .day.today { background: var(--teal-light); }
.cal .daynum { font-size: .78rem; color: var(--muted); }
.cal .ev {
  display: block; font-size: .76rem; margin-top: .2rem; padding: .12rem .3rem; border-radius: 5px;
  background: var(--teal-light); color: var(--teal-dark); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal .ev.p0 { background: #FCEBE8; color: #922718; }
.cal .ev.p1 { background: #FDEEDD; color: #8A4A0B; }
.cal .ev.done { text-decoration: line-through; opacity: .6; }
.cal .ev.meeting { background: #E9EDF7; color: #2B3E6B; }

/* ---------- Отчёт ---------- */
.report { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem 1.6rem; }
.report h1, .report h2, .report h3 { color: var(--teal-dark); }
.report h2 { border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
.report table { margin: .6rem 0 1rem; }
.report blockquote { border-left: 3px solid var(--gold); margin: 0 0 1rem; padding: .2rem 0 .2rem .8rem; color: var(--muted); }
.report code { background: #F2F4F3; padding: .1rem .3rem; border-radius: 4px; }

.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 1.6rem; text-align: center;
  color: var(--muted); background: #FBFCFC;
}
.dropzone.drag { border-color: var(--teal); background: var(--teal-light); color: var(--teal-dark); }

.progress { height: 8px; background: #E4EAE9; border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--teal); transition: width .4s; }

.timeline { list-style: none; padding: 0; margin: 0; font-size: .85rem; }
.timeline li { padding: .3rem 0; border-bottom: 1px dashed var(--line); }

details.section { margin-bottom: .6rem; }
details.section > summary { cursor: pointer; font-weight: 600; padding: .3rem 0; }

@media print {
  .topbar, .tabs, .no-print, .btn { display: none !important; }
  .page { max-width: none; padding: 0; }
  .card, .report { border: 0; box-shadow: none; padding: 0; }
  table { page-break-inside: auto; font-size: 10pt; }
  tr { page-break-inside: avoid; }
}

@media (max-width: 700px) {
  .topbar { gap: .6rem; }
  .brand-text small { display: none; }
  .task dl { grid-template-columns: 1fr; }
  .cal .day { min-height: 72px; }
}
