/* ===== Clean Clinic — дизайн-система админки ===== */
:root {
  --ink: #1b1620;
  --ink-2: #241a2e;
  --pink: #d61e93;
  --pink-soft: #fdf2f9;
  --pink-ink: #8f1460;
  --muted: #8a7a86;
  --line: #f0e4ec;
  --bg: #faf7f9;
  --green: #0d9463;
  --amber: #b07d00;
  --red: #b0435f;
  --blue: #1b5cb8;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(27,22,32,.07), 0 4px 16px rgba(27,22,32,.05);
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased;
}
h1,h2,h3 { font-family: 'Avenir Next', 'Segoe UI', system-ui, sans-serif; }
button { font-family: inherit; }
input, select, textarea {
  border: 1.5px solid #ead9e3; border-radius: 12px; padding: 11px 14px;
  font-size: 14px; outline: none; width: 100%; background: #fff; color: var(--ink);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--pink); }
textarea { resize: vertical; }

.btn {
  border: 0; border-radius: 12px; padding: 10px 18px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  cursor: pointer; transition: transform .12s, box-shadow .12s, opacity .12s;
}
.btn:active { transform: scale(.97); }
.btn-p { background: linear-gradient(135deg, #d61e93, #a3136e); color: #fff; box-shadow: 0 4px 14px rgba(214,30,147,.3); }
.btn-d { background: #f2e8ee; color: var(--ink); }
.btn-warn { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; border: 1.5px solid #ead9e3; color: var(--ink); }
.btn-lg { padding: 14px; font-size: 13px; width: 100%; }
.btn-xs { padding: 6px 12px; font-size: 10px; border-radius: 9px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.tag { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.t-pending { background: #fdf3e0; color: var(--amber); }
.t-confirmed { background: #e3f0fd; color: var(--blue); }
.t-done { background: #e2f7ee; color: var(--green); }
.t-cancelled { background: #f9e6ec; color: var(--red); }
.t-new { background: #f0eafe; color: #5b3fb8; }
.t-progress { background: #fdf3e0; color: var(--amber); }
.t-high { background: #f9e6ec; color: var(--red); }
.t-normal { background: #e3f0fd; color: var(--blue); }
.t-low { background: #eef0f2; color: var(--muted); }
.t-admin { background: #f9e6ec; color: var(--red); }
.t-doctor { background: #e3f0fd; color: var(--blue); }
.t-reception { background: #e2f7ee; color: var(--green); }

.muted { color: var(--muted); font-size: 12px; }
.card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.av {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-weight: 800; flex-shrink: 0;
  background: linear-gradient(135deg, #d61e93, #6d0d47);
}

/* ===== Вход ===== */
#authScreen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 700px at 80% -10%, #4a1240 0%, transparent 55%),
              radial-gradient(900px 600px at -10% 110%, #2c0f33 0%, transparent 55%),
              #170f1c;
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 400px; background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12); border-radius: 24px; padding: 36px 32px;
  backdrop-filter: blur(14px); color: #fff;
}
.auth-logo {
  width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #d61e93, #6d0d47); box-shadow: 0 8px 24px rgba(214,30,147,.4);
  color: #fff;
}
.auth-logo svg { width: 32px; height: 32px; }
.logo-bird { width: 22px; height: 22px; }
.auth-card h1 { margin-top: 16px; font-size: 24px; letter-spacing: .02em; }
.auth-sub { color: rgba(255,255,255,.55); font-size: 13px; margin: 4px 0 24px; }
.auth-card input { margin-bottom: 10px; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); color: #fff; }
.auth-card input::placeholder { color: rgba(255,255,255,.4); }
.auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: rgba(255,255,255,.55); }
.auth-switch a { color: #f06fc0; cursor: pointer; font-weight: 600; }
.auth-hint { margin-top: 18px; text-align: center; font-size: 11px; color: rgba(255,255,255,.4); line-height: 1.5; }

/* ===== Каркас ===== */
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex-shrink: 0; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #1b1620 0%, #241a2e 100%);
  color: #fff; position: sticky; top: 0; height: 100vh;
}
.side-logo { display: flex; align-items: center; gap: 10px; padding: 22px 20px; font-weight: 800; font-size: 15px; letter-spacing: .03em; }
.side-logo .logo-ic {
  width: 36px; height: 36px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #d61e93, #6d0d47); color: #fff; flex-shrink: 0;
}
.sidebar nav { flex: 1; padding: 6px 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 14px; margin-bottom: 3px; border: 0; border-radius: 12px;
  background: transparent; color: rgba(255,255,255,.6); font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: all .15s; text-align: left;
}
.nav-item svg { flex-shrink: 0; opacity: .8; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.on { background: linear-gradient(135deg, rgba(214,30,147,.9), rgba(163,19,110,.9)); color: #fff; box-shadow: 0 4px 14px rgba(214,30,147,.35); }
.nav-item.on svg { opacity: 1; }
.side-user {
  margin: 12px; padding: 14px; border-radius: 14px; background: rgba(255,255,255,.07);
  display: flex; align-items: center; gap: 10px;
}
.side-user .nm { font-size: 13px; font-weight: 700; line-height: 1.25; }
.side-user .rl { font-size: 10px; color: rgba(255,255,255,.5); text-transform: uppercase; letter-spacing: .06em; }
.side-user button { margin-left: auto; background: none; border: 0; color: rgba(255,255,255,.5); cursor: pointer; font-size: 15px; }
.side-user button:hover { color: #fff; }

.content { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 28px 14px;
}
.topbar h2 { font-size: 22px; }
.topbar-date { color: var(--muted); font-size: 13px; }
main { padding: 6px 28px 40px; }

/* ===== Дашборд ===== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat { background: #fff; border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat::after { content: ''; position: absolute; right: -18px; top: -18px; width: 70px; height: 70px; border-radius: 50%; background: var(--pink-soft); }
.stat .v { font-size: 26px; font-weight: 800; color: var(--pink-ink); position: relative; }
.stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 3px; position: relative; }
.section-h { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.section-h h3 { font-size: 16px; }

/* ===== Таблицы ===== */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--line); font-weight: 800; }
td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fdf8fb; }

/* ===== Канбан ===== */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .kanban { grid-template-columns: 1fr; } }
.kb-col { background: #f4edf1; border-radius: var(--radius); padding: 14px; min-height: 200px; }
.kb-col > h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 4px 6px 12px; display: flex; justify-content: space-between; }
.kb-card { background: #fff; border-radius: 13px; padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.kb-card .t { font-size: 13.5px; font-weight: 700; line-height: 1.35; }
.kb-card .d { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.kb-card .meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ===== Чат ===== */
.chat-wrap { display: grid; grid-template-columns: 1fr; gap: 0; height: calc(100vh - 220px); }
.chat-log { overflow-y: auto; padding: 6px 2px; flex: 1; }
.chat-msg { display: flex; gap: 10px; margin-bottom: 14px; align-items: flex-end; }
.chat-msg.me { flex-direction: row-reverse; }
.chat-bubble {
  max-width: 65%; padding: 11px 15px; border-radius: 16px; font-size: 13.5px; line-height: 1.45;
  background: #fff; box-shadow: var(--shadow);
}
.chat-msg.me .chat-bubble { background: linear-gradient(135deg, #d61e93, #a3136e); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg:not(.me) .chat-bubble { border-bottom-left-radius: 4px; }
.chat-meta { font-size: 10px; color: var(--muted); margin-top: 4px; }
.chat-msg.me .chat-meta { text-align: right; }
.chat-input { display: flex; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); align-items: center; }
.chat-input input { flex: 1; }
.chat-input .btn { min-width: 110px; }
.chat-attach {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: #fff;
  color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: .15s; flex-shrink: 0;
}
.chat-attach:hover { color: #d61e93; border-color: #d61e93; }
.chat-preview { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0 0; }
.chat-preview img { max-height: 90px; border-radius: 10px; box-shadow: var(--shadow); cursor: zoom-in; }
.chat-preview-x {
  width: 24px; height: 24px; border-radius: 50%; border: none; background: #2b2233; color: #fff;
  cursor: pointer; font-size: 12px; line-height: 1;
}
.chat-img {
  display: block; max-width: 260px; max-height: 260px; border-radius: 14px;
  box-shadow: var(--shadow); margin-bottom: 4px; cursor: zoom-in; object-fit: cover;
}
.chat-msg.me .chat-img { margin-left: auto; }
.chat-del {
  border: none; background: none; color: var(--muted); cursor: pointer; font-size: 11px;
  padding: 0 2px 0 6px; opacity: .55; transition: .15s;
}
.chat-del:hover { color: #d61e93; opacity: 1; }

/* ===== Сканер ===== */
.scanner { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
@media (max-width: 860px) { .scanner { grid-template-columns: 1fr; } }
.cam-box { position: relative; border-radius: var(--radius); overflow: hidden; background: #170f1c; aspect-ratio: 4/3; box-shadow: var(--shadow); }
.cam-box video { width: 100%; height: 100%; object-fit: cover; }
.cam-frame {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.cam-frame::before {
  content: ''; width: 210px; height: 210px; border-radius: 22px;
  border: 3px solid rgba(255,255,255,.9); box-shadow: 0 0 0 400px rgba(23,15,28,.45);
}
.cam-off { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; color: rgba(255,255,255,.7); }
.flash { animation: flash .5s; }
@keyframes flash { from { background: rgba(214,30,147,.35); } to { background: transparent; } }
.manual-qr { display: flex; gap: 10px; margin-top: 12px; }
.manual-qr input { flex: 1; }

/* ===== Дровер пациента ===== */
.drawer { position: fixed; inset: 0; background: rgba(23,15,28,.5); display: none; z-index: 60; backdrop-filter: blur(3px); }
.drawer.open { display: block; }
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: min(520px, 100%);
  background: var(--bg); overflow-y: auto; padding: 24px; animation: slideIn .22s ease-out;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.p-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.p-head h2 { font-size: 20px; }
.ledger-line { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.ledger-line:last-child { border-bottom: 0; }
.pos { color: var(--green); font-weight: 800; white-space: nowrap; }
.neg { color: var(--pink-ink); font-weight: 800; white-space: nowrap; }
.pill {
  background: var(--pink-soft); color: var(--pink-ink); border-radius: 10px;
  padding: 7px 11px; font-size: 12px; margin: 3px 6px 3px 0; display: inline-flex; gap: 7px; align-items: center; font-weight: 600;
}
.pill small { opacity: .55; text-transform: uppercase; font-size: 9px; font-weight: 800; letter-spacing: .05em; }
.pill.danger { background: #f9e6ec; color: var(--red); }
.p-sec { margin-top: 18px; }
.p-sec > b { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); display: block; margin-bottom: 8px; }

/* ===== Модалка ===== */
.modal { position: fixed; inset: 0; background: rgba(23,15,28,.5); display: none; z-index: 70; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(3px); }
.modal.open { display: flex; }
.modal-card { background: #fff; border-radius: 20px; padding: 26px; width: 100%; max-width: 440px; max-height: 85vh; overflow-y: auto; animation: popIn .18s ease-out; }
@keyframes popIn { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-card h3 { margin-bottom: 16px; font-size: 17px; }
.modal-card .field { margin-bottom: 12px; }
.modal-card .field > label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }

/* ===== Прочее ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 14px;
  font-size: 13px; display: none; z-index: 99; box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 34px 0; }
.stars { color: var(--pink); font-size: 15px; letter-spacing: 2px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #ddc9d5; border-radius: 8px; }
