:root {
  --bg: #0f1420;
  --surface: #1a2133;
  --surface-2: #232c42;
  --border: #2d3752;
  --text: #e8ecf5;
  --text-dim: #9aa5c0;
  --accent: #5b8cff;
  --urgent: #ff5c5c;
  --warning: #ffb84d;
  --info: #5bc8af;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.topbar h1 { margin: 0; font-size: 1.4rem; }
.subtitle { color: var(--text-dim); font-size: 0.85rem; }

main { max-width: 960px; margin: 0 auto; padding: 24px; }

h2 { font-size: 1.05rem; margin: 0 0 12px; }

.alerts-bar { margin-bottom: 28px; }
.alerts-list { display: flex; flex-direction: column; gap: 8px; }

.alert-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: 4px solid var(--info);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.alert-item.urgent { border-right-color: var(--urgent); }
.alert-item.warning { border-right-color: var(--warning); }
.alert-item .meta { color: var(--text-dim); font-size: 0.8rem; white-space: nowrap; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
  text-align: right;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
.card .code { color: var(--accent); font-weight: 700; font-size: 0.85rem; }
.card h3 { margin: 6px 0; font-size: 1.05rem; }
.card .doctor { color: var(--text-dim); font-size: 0.85rem; }
.card .updated { margin-top: 10px; font-size: 0.75rem; color: var(--text-dim); }

.modal {
  position: fixed; inset: 0;
  background: rgba(5, 7, 14, 0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 560px; width: 100%;
  max-height: 85vh; overflow-y: auto;
  padding: 24px;
  position: relative;
}
.modal-content .doctor { color: var(--text-dim); margin-top: -8px; }
.modal-section { margin-top: 18px; }
.modal-section h3 { font-size: 0.95rem; margin: 0 0 8px; }
.modal-section ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.modal-section li {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.modal-section li a { color: var(--accent); }
.task-badge { font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; }
.task-badge.submitted { background: rgba(91, 200, 175, .2); color: var(--info); }
.task-badge.pending { background: rgba(255, 184, 77, .2); color: var(--warning); }
.empty-note { color: var(--text-dim); font-size: 0.85rem; }

.close-btn {
  position: absolute; top: 14px; left: 14px;
  background: none; border: none; color: var(--text-dim);
  font-size: 1.1rem; cursor: pointer;
}

.chat-toggle {
  position: fixed; bottom: 22px; left: 22px;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--accent); border: none; color: #fff;
  font-size: 1.4rem; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}

.chat-panel {
  position: fixed; bottom: 90px; left: 22px;
  width: min(360px, 90vw); height: min(480px, 70vh);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column;
  overflow: hidden; box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.chat-panel.hidden { display: none; }
.chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  position: relative;
}
.chat-header .close-btn { position: static; }
.chat-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { padding: 8px 12px; border-radius: 10px; font-size: 0.88rem; max-width: 90%; }
.chat-msg.user { background: var(--accent); color: #fff; align-self: flex-start; }
.chat-msg.bot { background: var(--surface-2); align-self: flex-end; }
.chat-form { display: flex; border-top: 1px solid var(--border); }
.chat-form input {
  flex: 1; border: none; background: transparent; color: var(--text);
  padding: 12px; outline: none; font-size: 0.9rem;
}
.chat-form button {
  background: var(--accent); color: #fff; border: none;
  padding: 0 16px; cursor: pointer; font-size: 0.85rem;
}

@media (max-width: 480px) {
  .chat-panel { left: 12px; right: 12px; width: auto; }
}
