:root {
  --bg: #eef1f7;
  --panel: #ffffff;
  --ink: #1e2330;
  --muted: #6b7282;
  --accent: #1d718b;
  --accent-soft: #e4f2f6;
  --danger: #c0392b;
  --border: #e2e7f0;
  --shadow-lg: 0 18px 40px rgba(30, 35, 48, 0.12);
  --shadow-md: 0 12px 24px rgba(30, 35, 48, 0.08);
  --radius-lg: 22px;
  --radius-md: 14px;
  --font-display: "Merriweather", "Times New Roman", serif;
  --font-body: "IBM Plex Sans", "Helvetica", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: #f2f4f8;
  min-height: 100vh;
}

body::before {
  content: none;
}

#app {
  display: none;
  min-height: 100vh;
  padding: 0;
}

.shell {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  background: #fff;
  border-radius: 0;
  box-shadow: none;
  border: none;
  overflow: hidden;
  display: grid;
  grid-template-rows: 68px 1fr;
}

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: #fbfcff;
}

.app-version {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.4px;
}

.brand {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  height: 22px;
  width: auto;
  display: block;
}

.userbar {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 15% 30% 55%;
  gap: 0;
  padding: 0;
  min-height: 0;
}

.panel {
  background: #fff;
  border: none;
  padding: 0;
  min-height: 0;
  box-shadow: none;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.panel-left {
  background: #e8edf5;
}

.panel-center,
.panel-right {
  background: #fff;
}

.panel-center {
  background: #f2f5fa;
}

.panel-right {
  background: #ffffff;
  border-right: none;
}

.panel-title {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 1.2px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
  min-height: 44px;
  padding: 0 12px;
}

.panel-title.row {
  gap: 12px;
}

.panel-actions {
  display: inline-flex;
  gap: 8px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.list li {
  min-height: 52px;
  padding: 8px 12px;
  border: none;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: transparent;
  transition: background 0.15s ease;
  border-radius: 0;
  box-shadow: none;
}

.list li:hover {
  transform: none;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.45);
}

.list li.active {
  border-color: transparent;
  background: rgba(228, 242, 246, 0.85);
  box-shadow: inset 3px 0 0 rgba(12, 98, 124, 0.85);
}

.list button {
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  width: 100%;
}

.list-actions {
  display: inline-flex;
  gap: 6px;
}

.protocol-item {
  align-items: center;
}

.protocol-info {
  display: grid;
  gap: 2px;
  flex: 1;
}

.protocol-title {
  font-weight: 520;
  font-size: 14px;
  text-align: left;
}

.section-title {
  width: 100%;
  text-align: left;
  font-size: 14px;
  font-weight: 520;
}

.protocol-meta {
  font-size: 11px;
  color: var(--muted);
}

.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  border-radius: 6px;
  box-shadow: none;
}

.icon-btn.active {
  background: var(--accent-soft);
  border-color: rgba(12, 98, 124, 0.45);
  color: #0c627c;
}

.filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin-bottom: 0;
  background: transparent;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
}

.search-field i {
  color: var(--muted);
}

.search-field input {
  border: 1px solid var(--border);
  box-shadow: none;
  padding: 6px 10px;
  border-radius: 6px;
  background: #fff;
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  font-family: var(--font-body);
  background: #ffffff;
  color: var(--ink);
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px var(--border);
}

input:focus,
textarea:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(13, 114, 123, 0.35);
  outline-offset: 1px;
}

textarea {
  resize: vertical;
}

button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 10px;
  box-shadow: 0 14px 24px rgba(13, 98, 124, 0.2);
}

button.ghost {
  background: #ffffff;
  border: none;
  color: var(--ink);
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 10px;
  box-shadow: 0 10px 18px rgba(30, 35, 48, 0.1);
}

button.danger {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 10px;
}

.detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  overflow: auto;
}

.detail h3 {
  margin: 0;
  font-size: 22px;
}

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

.detail-body {
  display: grid;
  gap: 10px;
}

.detail-body p {
  margin: 0;
  line-height: 1.5;
}

.detail-body h1 {
  font-size: 20px;
  margin: 0;
}

.detail-body h2 {
  font-size: 18px;
  margin: 0;
}

.detail-body h3 {
  font-size: 16px;
  margin: 0;
}

.detail-body ul,
.detail-body ol {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
}

.detail-body li {
  margin-bottom: 4px;
}

.detail .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-actions {
  display: flex;
  justify-content: flex-start;
}

.detail-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.detail-time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.tag {
  background: var(--accent-soft);
  color: #0c627c;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 999px;
}

.attachment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px dashed var(--border);
  padding: 8px 10px;
  font-size: 14px;
}

.login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 31, 44, 0.4);
  backdrop-filter: blur(4px);
}

.login-card {
  background: var(--panel);
  padding: 24px;
  border: none;
  width: min(300px, 88vw);
  display: grid;
  gap: 12px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.login-logo {
  width: 90%;
  height: auto;
  justify-self: center;
}

.error {
  color: var(--danger);
  font-size: 14px;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.inline-form {
  border: 1px solid var(--border);
  padding: 14px;
  margin: 14px 0;
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.panel-right #protocolFormPanel {
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  padding: 16px;
  background: transparent;
  flex: 1;
  overflow: auto;
}

.panel-right #protocolFormPanel form {
  display: grid;
  gap: 10px;
}

.format-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0 10px;
}

.format-btn {
  border: none;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}

.format-h1 i {
  font-size: 14px;
}

.format-h2 i {
  font-size: 12px;
  opacity: 0.9;
}
.icon-only {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.format-underline {
  text-decoration: underline;
}

.hidden-field {
  display: none;
}

.editor {
  min-height: 240px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px var(--border);
  outline: none;
}

.editor:focus {
  outline: 2px solid rgba(13, 114, 123, 0.35);
  outline-offset: 1px;
}

.editor h1 {
  font-size: 20px;
  margin: 0 0 8px;
}

.editor h2 {
  font-size: 18px;
  margin: 0 0 8px;
}

.editor h3 {
  font-size: 16px;
  margin: 0 0 8px;
}

.editor p {
  margin: 0 0 8px;
  line-height: 1.5;
}

.editor ul,
.editor ol {
  margin: 0 0 8px;
  padding-left: 18px;
}

.editor li {
  margin-bottom: 4px;
}

.form-title {
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 11px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
}

.users-list {
  margin-bottom: 12px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.user-sections-wrap {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.hidden {
  display: none;
}


.history-item {
  border: 1px solid var(--border);
  padding: 10px;
  background: #fff;
  display: grid;
  gap: 6px;
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(30, 35, 48, 0.08);
}

.history-meta-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.history-badge {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #0c627c;
  font-weight: 600;
}

.history-badge.action-create {
  background: #e6f4ea;
  color: #1f7a4d;
}

.history-badge.action-update {
  background: #fff4e6;
  color: #b35b0f;
}

.history-badge.action-delete {
  background: #fdecea;
  color: #b23b2a;
}

.history-toggle {
  border: none;
  background: var(--accent-soft);
  color: var(--accent);
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-content {
  display: grid;
  gap: 6px;
}

.history-item.collapsed .history-content {
  display: none;
}

.history-title {
  font-weight: 600;
  font-size: 15px;
}

.history-meta {
  font-size: 12px;
  color: var(--muted);
}

.history-body {
  font-size: 13px;
  color: var(--ink);
  white-space: pre-line;
}

.history-body ul,
.history-body ol {
  margin: 6px 0 0;
  padding-left: 18px;
}

.history-body li {
  margin-bottom: 4px;
}

.history-attachments {
  display: grid;
  gap: 6px;
}

.history-attachment {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.history-panel {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .panel {
    border-right: none;
    border-bottom: 1px solid rgba(226, 231, 240, 0.8);
  }

  .panel-right {
    border-bottom: none;
  }

  .panel {
    min-height: unset;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .brand-logo {
    height: 18px;
  }

  .login-logo {
    width: 90%;
  }
}
