:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #1a2233; --muted: #6b7688;
  --line: #e3e8ef; --accent: #1f3864; --accent2: #2e75b6; --danger: #c00000;
}
* { box-sizing: border-box; margin: 0; }
body { font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
.hidden { display: none !important; }

/* Вход */
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(150deg, #1f3864, #2e75b6); }
#login-form { background: #fff; padding: 40px 36px; border-radius: 14px; width: 340px; box-shadow: 0 18px 60px rgba(0,0,0,.35); }
#login-form h1 { font-size: 30px; color: var(--accent); letter-spacing: 1px; }
#login-form h1 span { color: var(--accent2); font-weight: 300; }
#login-form .sub { color: var(--muted); margin: 4px 0 22px; font-size: 13px; }
#login-form input { width: 100%; padding: 11px 12px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
#login-form button { width: 100%; padding: 11px; background: var(--accent); color: #fff; border: 0; border-radius: 8px; font-size: 15px; cursor: pointer; }
.err { color: var(--danger); margin-top: 10px; font-size: 13px; min-height: 18px; }

/* Каркас */
header { display: flex; align-items: center; gap: 22px; background: var(--accent); color: #fff; padding: 0 18px; height: 52px; position: sticky; top: 0; z-index: 500; }
.logo { font-weight: 700; font-size: 18px; letter-spacing: 1px; }
.logo span { font-weight: 300; opacity: .85; }
nav#tabs { display: flex; gap: 4px; flex: 1; }
nav#tabs button { background: transparent; border: 0; color: #cdd8ea; padding: 16px 14px; cursor: pointer; font-size: 14px; border-bottom: 3px solid transparent; }
nav#tabs button.active { color: #fff; border-bottom-color: #7ea6d9; }
.badge { background: var(--danger); border-radius: 9px; padding: 1px 7px; font-size: 11px; color: #fff; }
.user-box { display: flex; gap: 14px; align-items: center; font-size: 13px; }
.user-box a { color: #9db4d4; text-decoration: none; }

#filters { display: flex; gap: 10px; padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
#filters select, #filters input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 13px; }
button.primary { background: var(--accent2); color: #fff; border: 0; border-radius: 8px; padding: 8px 16px; cursor: pointer; font-size: 13px; }
main { padding: 16px 18px; }

/* Канбан */
#view-board { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; min-height: 70vh; }
.col { background: #eceff4; border-radius: 12px; min-width: 250px; width: 250px; flex-shrink: 0; }
.col-head { padding: 10px 12px; font-weight: 600; font-size: 13px; border-bottom: 3px solid; display: flex; justify-content: space-between; border-radius: 12px 12px 0 0; }
.col-sum { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
.col-body { padding: 8px; min-height: 60px; max-height: calc(100vh - 240px); overflow-y: auto; }
.card { background: #fff; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; box-shadow: 0 1px 3px rgba(20,30,60,.09); border-left: 4px solid #ccc; }
.card:active { cursor: grabbing; }
.card .t { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.card .m { color: var(--muted); font-size: 12px; }
.card .warn { color: var(--danger); font-size: 12px; font-weight: 600; }
.col-body.dragover { outline: 2px dashed var(--accent2); border-radius: 8px; }

/* Карта */
#map { height: calc(100vh - 190px); border-radius: 12px; }
#map-legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 10px 4px; font-size: 12px; color: var(--muted); }
#map-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

/* Клиники / списки */
.toolbar { display: flex; gap: 10px; margin-bottom: 12px; }
.toolbar input { flex: 1; max-width: 420px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; }
table.grid { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(20,30,60,.08); }
table.grid th { text-align: left; font-size: 12px; color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--line); background: #fafbfd; }
table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
table.grid tr:hover td { background: #f4f8fe; cursor: pointer; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11.5px; color: #fff; white-space: nowrap; }

/* Модалка */
#modal-wrap { position: fixed; inset: 0; background: rgba(15,25,50,.45); z-index: 900; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 40px 16px; }
#modal { background: #fff; border-radius: 14px; width: 100%; max-width: 760px; padding: 24px 28px; box-shadow: 0 24px 80px rgba(0,0,0,.35); }
#modal h2 { font-size: 18px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
#modal h2 .x { cursor: pointer; color: var(--muted); font-size: 22px; font-weight: 400; }
.frow { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.frow label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.frow > div { flex: 1; min-width: 140px; }
.frow input, .frow select, .frow textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-family: inherit; }
.frow textarea { min-height: 60px; }
.hint { font-size: 12px; color: var(--accent2); margin: -4px 0 10px; min-height: 16px; }
.hint.bad { color: var(--danger); }
.acts { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; max-height: 300px; overflow-y: auto; }
.act { padding: 8px 10px; background: #f7f9fc; border-radius: 8px; margin-bottom: 6px; font-size: 12.5px; }
.act .who { color: var(--muted); font-size: 11px; margin-top: 3px; }
.btnrow { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }
button.ghost { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 16px; cursor: pointer; }

/* Напоминания */
.rem-item { background: #fff; border-left: 4px solid var(--danger); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(20,30,60,.08); cursor: pointer; }
.rem-item b { font-size: 14px; }
.rem-item .m { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

/* Дашборд */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.dash-card { background: #fff; border-radius: 12px; padding: 16px 18px; box-shadow: 0 1px 3px rgba(20,30,60,.08); }
.dash-card h3 { font-size: 14px; margin-bottom: 10px; color: var(--accent); }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12.5px; }
.bar-row .lbl { width: 165px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar { height: 14px; border-radius: 4px; min-width: 2px; }
.bar-row .val { color: var(--ink); font-size: 12px; white-space: nowrap; }
@media (max-width: 720px) {
  header { flex-wrap: wrap; height: auto; padding-bottom: 6px; }
  .col { min-width: 220px; width: 220px; }
}

/* MiniMap */
.mm { position: relative; overflow: hidden; background: #dce8f2; user-select: none; touch-action: none; cursor: grab; }
.mm:active { cursor: grabbing; }
.mm-tiles img { position: absolute; pointer-events: none; }
.mm-tiles img.mm-tile-fail { visibility: hidden; }
.mm.mm-offline { background:
  linear-gradient(#c9d9e8 1px, transparent 1px), linear-gradient(90deg, #c9d9e8 1px, transparent 1px), #dce8f2;
  background-size: 48px 48px; }
.mm-markers { position: absolute; inset: 0; }
.mm-marker { position: absolute; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); transform: translate(-50%, -50%); cursor: pointer; }
.mm-marker:hover { width: 19px; height: 19px; z-index: 5; }
.mm-popup { position: absolute; background: #fff; border-radius: 10px; padding: 10px 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.3); font-size: 12.5px; line-height: 1.5; z-index: 10; width: 230px; }
.mm-zoom { position: absolute; top: 12px; left: 12px; z-index: 20; display: flex; flex-direction: column; gap: 4px; }
.mm-zoom button { width: 32px; height: 32px; border: 0; border-radius: 8px; background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.3); font-size: 18px; cursor: pointer; }
.mm-attr { position: absolute; bottom: 4px; right: 8px; font-size: 10px; color: #667; z-index: 20; }
.mm-base { position: absolute; inset: 0; pointer-events: none; }
.mm-pop-title { font-weight: 700; font-size: 13.5px; margin-bottom: 2px; }
.mm-pop-sub { color: #6b7688; font-size: 11.5px; margin-bottom: 7px; }
.mm-pop-row { margin-bottom: 5px; }
.mm-btn { display: block; width: 100%; margin-top: 8px; padding: 7px 0; background: #2e75b6;
  color: #fff; border: 0; border-radius: 8px; font-size: 13px; cursor: pointer; }
.mm-btn:hover { background: #1f3864; }
