/* MeasureGate — modern visual layer (layout unchanged) */
:root {
  --mg-font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mg-text: #0f172a;
  --mg-text-muted: #64748b;
  --mg-bg: #f1f5f9;
  --mg-surface: #ffffff;
  --mg-border: #e2e8f0;
  --mg-border-strong: #cbd5e1;
  --mg-primary: #2563eb;
  --mg-primary-hover: #1d4ed8;
  --mg-primary-soft: #eff6ff;
  --mg-accent: #7c3aed;
  --mg-accent-dark: #5b21b6;
  --mg-success: #059669;
  --mg-danger: #dc2626;
  --mg-radius-sm: 6px;
  --mg-radius: 10px;
  --mg-radius-lg: 14px;
  --mg-radius-xl: 18px;
  --mg-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --mg-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.06);
  --mg-shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.1);
  --mg-transition: 0.15s ease;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

.bt-1.pt-3 { word-break: break-all; }
.modal-backdrop { z-index: 0 !important; }
.loggeddata { padding: 1rem !important; background-color: #ecfdf5; border-radius: var(--mg-radius); }

body {
  color: var(--mg-text);
  font-family: var(--mg-font);
  background-color: var(--mg-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container-xxl { background-color: transparent; }

.h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--mg-text);
}

.dropdown { border: 1px solid var(--mg-border) !important; border-radius: var(--mg-radius) !important; box-shadow: var(--mg-shadow); }
.dropdown-item { transition: background-color var(--mg-transition), color var(--mg-transition); }
.dropdown-item:hover { background-color: var(--mg-primary-soft); color: var(--mg-text); }

.display-6 { font-size: 2rem !important; font-weight: 600; letter-spacing: -0.02em; }

input[type=checkbox] {
  display: inline-block;
  width: 20px;
  height: 20px;
  -webkit-appearance: none;
  outline: 0;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: contain;
  margin-bottom: -4px;
  transition: transform var(--mg-transition);
}
input[type=checkbox]:active { transform: scale(0.96); }

.avatar { vertical-align: middle; width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255, 255, 255, 0.35); }
.avatar-large { vertical-align: middle; width: 90px; height: 90px; border-radius: 50%; box-shadow: var(--mg-shadow); object-fit: cover; }

.link { color: var(--mg-primary); text-decoration: none; cursor: pointer; font-weight: 500; }
.link:hover { color: var(--mg-primary-hover); text-decoration: underline; }

.ellipsis { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 300px; }
small { font-size: 0.75rem; color: var(--mg-text-muted); }
.w-74 { width: 73% !important; }

input[type=checkbox]:not(:checked) { background-image: url("/img/checkbox_empty.svg"); }
input[type=checkbox]:checked { background-image: url("/img/checkbox_checked.svg"); }
input[type=checkbox].big { width: 36px; height: 36px; }

label { display: inline; word-break: break-word; word-wrap: break-word; color: var(--mg-text); }
.checkarea { margin: 10px 0; }
.bb-1 { border-bottom: 1px solid var(--mg-border); }
.form-group { margin-top: 0.5rem !important; }

.form-control,
.form-select {
  outline: initial;
  border: 1px solid var(--mg-border-strong);
  border-radius: var(--mg-radius-sm);
  padding: 0.5rem 0.75rem;
  transition: border-color var(--mg-transition), box-shadow var(--mg-transition);
  background-color: var(--mg-surface);
}
.form-control:focus,
.form-select:focus {
  outline: initial;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  border-color: var(--mg-primary);
}

#padlock, #loginlogo { position: absolute; right: 0; top: 0; }
#loginlogo { left: 0; right: auto; }

.message.error {
  border: 1px solid #fecaca;
  background-color: #fef2f2;
  color: #991b1b;
  width: fit-content;
  padding: 0.5rem 1rem;
  border-radius: var(--mg-radius);
  font-size: 0.9rem;
}

button.close {
  box-sizing: content-box;
  width: 1em;
  height: 1em;
  padding: 0.25em;
  color: #fff;
  background: var(--mg-danger) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
  border: 0;
  border-radius: var(--mg-radius-sm);
  opacity: 0.9;
}

.bg-dark { -webkit-appearance: none !important; background-color: #1e293b !important; }

.message.error span {
  cursor: pointer;
  background-color: #fca5a5;
  color: #7f1d1d;
  margin-right: 0.5rem;
  padding: 2px 8px;
  margin-left: -1rem;
  border-radius: 4px;
}

.card {
  border-radius: var(--mg-radius-lg);
  border: 1px solid var(--mg-border);
  box-shadow: var(--mg-shadow-sm);
  background: var(--mg-surface);
}

.btn {
  border-radius: var(--mg-radius-sm);
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background-color var(--mg-transition), border-color var(--mg-transition), box-shadow var(--mg-transition), transform var(--mg-transition);
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background-color: var(--mg-primary);
  border-color: var(--mg-primary);
  background-image: none;
  box-shadow: var(--mg-shadow-sm);
}
.btn-primary:hover {
  background-color: var(--mg-primary-hover);
  border-color: var(--mg-primary-hover);
  background-image: none;
}
.btn-primary:focus,
.btn-primary:active {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
  background-color: var(--mg-primary-hover);
  border-color: var(--mg-primary-hover);
}

.btn-check:focus + .btn-primary,
.btn-primary:focus,
.btn-success:focus {
  background-color: var(--mg-primary-hover);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.btn-check:active + .btn-primary:focus,
.btn-check:checked + .btn-primary:focus,
.btn-primary.active:focus,
.btn-primary:active:focus,
.show > .btn-primary.dropdown-toggle:focus {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.btn-success {
  background-color: var(--mg-success);
  border-color: var(--mg-success);
}
.btn-success:hover {
  background-color: #047857;
  border-color: #047857;
}

.bg-full {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 45%, #2563eb 100%);
  height: calc(100vh - 55px);
}

.book { clip-path: polygon(10% 25%, 100% 40%, 101% 100%, 0% 100%); transition: clip-path 0.2s ease; }
.book:hover { clip-path: polygon(20% 10%, 100% 10%, 100% 100%, -1% 100%); }
.bookactive { filter: drop-shadow(0 4px 8px rgba(15, 23, 42, 0.12)); }
.bookactive .book { clip-path: polygon(20% 10%, 100% 10%, 100% 100%, -1% 100%); }

.black { background-color: #0f172a; }

.nav-item {
  width: 90px;
  text-align: center;
  padding: 1rem;
  border-radius: var(--mg-radius);
  box-shadow: var(--mg-shadow-sm);
  border: 1px solid var(--mg-border);
  background: var(--mg-surface);
  cursor: pointer;
  transition: box-shadow var(--mg-transition), border-color var(--mg-transition), transform var(--mg-transition);
}
.nav-item:hover {
  box-shadow: var(--mg-shadow);
  border-color: var(--mg-border-strong);
}
.nav-item.active {
  box-shadow: var(--mg-shadow);
  border-color: var(--mg-primary);
  background: var(--mg-primary-soft);
}

footer {
  background-color: #0f172a;
  text-align: center;
  color: #94a3b8;
  padding: 0.75rem;
  font-size: 0.875rem;
  letter-spacing: 0.02em;
}

#blank { height: 750px; display: block; }

.box {
  padding: 1.25rem 1.5rem;
  box-shadow: var(--mg-shadow);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-lg);
  margin-bottom: 1rem;
  background: var(--mg-surface);
}

/* Tables */
.table {
  --bs-table-bg: transparent;
  border-color: var(--mg-border);
}
.table thead th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mg-text-muted);
  border-bottom-width: 1px;
}
.table-hover tbody tr:hover {
  background-color: #f8fafc;
}

/* Calendar */
.week-days {
  color: var(--mg-text);
  display: flex;
  padding-inline-start: 0;
  padding-left: 5px;
  padding-right: 5px;
  justify-content: space-between;
  font-weight: 600;
  list-style: none;
  margin: 1rem 0;
}
#thiscalendar .week-days { padding-left: 0; padding-right: 0; }
.monthAndYear { color: var(--mg-accent-dark); font-size: 1.15rem; font-weight: 600; letter-spacing: -0.01em; }
.nextprev { color: var(--mg-accent-dark); }
.nextarrow, .prevarrow { cursor: pointer; transition: opacity var(--mg-transition); }
.nextarrow:hover, .prevarrow:hover { opacity: 0.7; }
.nextarrow { margin-left: 1rem; }
.weeks { color: var(--mg-accent-dark); display: flex; flex-direction: column; cursor: pointer; }
.weeks div { display: flex; font-weight: 400; justify-content: space-between; width: 100%; border-radius: var(--mg-radius-sm); transition: background-color var(--mg-transition), color var(--mg-transition); }
.weeks span { display: inline-block; font-family: var(--mg-font); font-weight: 500; padding: 7px; font-size: 12px; }
.weeks div:hover,
.weeks div.active { background-color: var(--mg-accent); color: #fff; }
.weeks span#active { background-color: #f59e0b; color: #1e293b; border-radius: var(--mg-radius-sm); }
#dateactive, .dateactive { background-color: #ede9fe; color: var(--mg-text); border-radius: var(--mg-radius-sm); }
.activeweek { background-color: #f8fafc; }
.inactivedate { color: #cbd5e1; }
.halfcol { flex: 0.44 0 2%; }
#modalhead { font-size: 1.15rem; margin-bottom: 0 !important; font-weight: 600; }
#weekcalendar { height: calc(95vh - 154px); overflow: auto; position: relative; }
.weekrow { background-color: var(--mg-surface); position: relative; user-select: none; border-bottom: 1px solid var(--mg-border); }
.weekday { width: 100%; position: relative; border-right: 1px solid #c4b5fd; }
.title { background: var(--mg-accent); text-align: center; color: #fff; position: sticky; top: 0; padding: 8px 0; font-weight: 500; }
#mg-calendar { box-shadow: var(--mg-shadow-lg); border-radius: var(--mg-radius-lg); border: 1px solid var(--mg-border); overflow: hidden; }
.days { background: #f8fafc; text-align: center; position: sticky; top: 1.5rem; display: flex; border-bottom: 1px solid var(--mg-border); }
.days div:first-child { border-right: 1px solid var(--mg-border); border-left: 1px solid var(--mg-border); }
.time { text-align: right; font-size: 13px; border-right: 1px solid var(--mg-border); position: relative; color: var(--mg-text-muted); padding-right: 5px; user-select: none; border-left: 1px solid var(--mg-border); min-width: 72px; padding-bottom: 9px; }
#current-time { border-top: 2px solid var(--mg-accent); position: absolute; z-index: 1; }
.circle { width: 10px; height: 10px; border-radius: 50%; background: var(--mg-accent); position: relative; top: -6px; z-index: 1; }
.current { font-weight: 600; }

.modal-content { border-radius: var(--mg-radius-lg) !important; border: 1px solid var(--mg-border); box-shadow: var(--mg-shadow-lg); overflow: hidden; }
.btn-close { background-color: transparent; opacity: 0.85; filter: invert(1); }
.modal-header {
  background: linear-gradient(135deg, var(--mg-accent) 0%, var(--mg-accent-dark) 100%);
  padding: 1rem 1.25rem;
  color: #ffffff;
  border-bottom: none;
}

.wd1 { flex: 1 0 0; }
.pr { position: relative; }
.wd0 { flex: 0.95 0 0; }
.selecteddiv { background-color: #ddd6fe; box-shadow: inset 3px 0 0 var(--mg-accent); }

.contactbox:nth-child(odd) { background: #f8fafc; }
.contactbox:nth-child(even) { background: var(--mg-surface); }
.contactbox p { margin: inherit; }
.contactbox { padding: 0.5rem 0.75rem; transition: background-color var(--mg-transition); }
#contactsList { border: 1px solid var(--mg-border); border-radius: var(--mg-radius); overflow: hidden; }

#mail-labels { max-height: 455px; overflow-y: auto; background-color: #f0f9ff; margin-bottom: 10px; border-radius: var(--mg-radius); border: 1px solid var(--mg-border); }
.activatebutton { margin-bottom: 20px; background-color: #e0f2fe; padding: 8px 12px; border-radius: var(--mg-radius-sm); cursor: pointer; transition: background-color var(--mg-transition); }
.activatebutton:hover { background-color: #bae6fd; }
#notif { right: 2rem; top: 7rem; width: 450px; position: fixed; border: 1px solid var(--mg-border); z-index: 999; border-radius: var(--mg-radius); box-shadow: var(--mg-shadow-lg); background: var(--mg-surface); overflow: hidden; }
#notif #bar { width: 1%; height: 4px; background-color: var(--mg-primary); }
#mail-labels .activatebutton { margin-bottom: 5px; }
.bb-grey { border-bottom: 1px solid var(--mg-border); }
.mailline:hover { background-color: #f8fafc; cursor: pointer; }
.calendarmove { position: absolute; right: 0; }
.pal { position: absolute; left: 0; }
.name { padding-left: 1rem; }

#uploadarea {
  width: 100%;
  height: 100px;
  border: 2px dashed var(--mg-border-strong);
  border-radius: var(--mg-radius);
  padding: 10px;
  margin: 10px 0;
  position: relative;
  background: #f8fafc;
  transition: border-color var(--mg-transition), background-color var(--mg-transition);
}
#uploadarea:hover { border-color: var(--mg-primary); background: var(--mg-primary-soft); }
#bannertext { position: absolute; top: 90px; left: 130px; color: var(--mg-text-muted); }
#dbi-upload-progress { position: absolute; top: 35%; left: 10%; width: 90%; pointer-events: none; }
.border-dark { border: 1px solid var(--mg-border-strong) !important; }
input[type=file]#dbi-file-upload { opacity: 0; width: 100%; height: 95%; }

.brand {
  color: white;
  background-color: var(--mg-primary);
  padding: 6px 12px;
  line-height: 1.5em;
  border-radius: var(--mg-radius-sm);
  font-weight: 500;
}
.brand:hover { color: #fff; background-color: var(--mg-primary-hover); }

.btn-check:focus + .btn,
.btn:focus { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2); }

.btn-mg {
  border: 1px solid #0891b2;
  color: #0e7490;
  background: #ecfeff;
}
.btn-mg:hover,
.btn-mg.active {
  color: #fff;
  background-color: #0891b2;
  border-color: #0891b2;
  box-shadow: var(--mg-shadow-sm);
}

.blueborder { border: 2px dashed #38bdf8 !important; background: #f0f9ff !important; }
.flashupdate { background-color: #bbf7d0 !important; }
.dropdown-toggle::after { position: absolute; right: 10px; bottom: 1.5rem; }

/* Projects folder list */
.project-list-page { padding: 0 0.25rem; }
.project-list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--mg-border);
}
.project-list-toolbar__search { flex: 1 1 220px; max-width: 360px; }
.project-list-toolbar__sort {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.project-list-toolbar__label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mg-text-muted);
  margin-right: 0.25rem;
}
.project-sort-btn.active {
  background-color: var(--mg-primary);
  border-color: var(--mg-primary);
  color: #fff;
}
.project-list-toolbar__add { margin-left: auto; }
.project-folder-list {
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
  overflow: hidden;
  background: var(--mg-surface);
}
.project-folder-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 48px;
  padding: 0.5rem 1rem 0.5rem 0;
  background: #fff;
  border-bottom: 1px solid var(--mg-border);
  cursor: pointer;
  transition: background-color var(--mg-transition);
}
.project-folder-row:last-child { border-bottom: none; }
.project-folder-row:hover { background: #f8fafc; }
.project-folder-row--locked {
  cursor: default;
  opacity: 0.85;
}
.project-folder-row--locked:hover { background: #fff; }
.project-folder-row__stripe {
  flex: 0 0 5px;
  align-self: stretch;
  min-height: 48px;
  border-radius: 0 2px 2px 0;
}
.project-folder-row__icon {
  flex: 0 0 auto;
  color: #64748b;
  display: flex;
  align-items: center;
}
.project-folder-row__name {
  flex: 1 1 auto;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--mg-text);
  text-decoration: none;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-folder-row__name:hover { color: var(--mg-primary); }
.project-folder-row__name--muted { color: var(--mg-text-muted); }
.project-star-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-sm);
  background: var(--mg-surface);
  color: var(--mg-text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--mg-transition), border-color var(--mg-transition), background-color var(--mg-transition);
}
.project-star-btn:hover {
  border-color: #eab308;
  color: #ca8a04;
  background: #fffbeb;
}
.project-star-btn.is-starred {
  border-color: #eab308;
  background: #fef9c3;
  color: #eab308;
}
.project-star-btn__icon {
  pointer-events: none;
}
.project-folder-row__star-btn {
  margin-left: auto;
}
.project-folder-row__settings {
  flex: 0 0 auto;
  margin-left: auto;
}
.project-folder-row__badge {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--mg-text-muted);
  background: #f1f5f9;
  padding: 0.2rem 0.5rem;
  border-radius: var(--mg-radius-sm);
}
.project-list-empty { margin-top: 1rem; text-align: center; }
.project-list-footer {
  margin-top: 1rem;
  text-align: right;
  font-size: 0.875rem;
}
.project-list-footer a { color: var(--mg-text-muted); }

/* Project workspace nav (list / board / files / notes) */
.project-workspace-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--mg-border);
}
.project-workspace-nav__lead {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1 1 auto;
  min-width: 0;
}
.project-workspace-nav__title {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-workspace-nav__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}
.project-workspace-nav__group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding-right: 0.75rem;
  margin-right: 0.5rem;
  border-right: 1px solid var(--mg-border);
}
.project-workspace-nav__group:last-child {
  border-right: none;
  padding-right: 0;
  margin-right: 0;
}
.project-workspace-nav .project-color-picker {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
.project-workspace-nav .project-color-picker__input,
.project-workspace-nav .project-color-picker input[type="color"] {
  width: 2rem;
  height: 2rem;
  padding: 0.1rem;
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-sm);
  cursor: pointer;
  vertical-align: middle;
}

/* Project todo list view (/projects/enter-project/:uuid/list) */
.project-todo-list-page {
  position: relative;
  padding-bottom: 2rem;
}
.project-todo-list-page .project-stage-board {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.project-todo-list-page .stagebox {
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-lg);
  box-shadow: var(--mg-shadow-sm);
  overflow: hidden;
  transition: border-color var(--mg-transition), box-shadow var(--mg-transition);
}
.project-todo-list-page .stagebox.over {
  border-color: var(--mg-primary);
  box-shadow: var(--mg-shadow);
}
.project-todo-list-page .stagebox[draggable="true"] {
  cursor: grab;
}
.project-todo-list-page .stagebox[draggable="true"]:active {
  cursor: grabbing;
}
.project-todo-list-page .project-stage-column__stripe {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  border-radius: var(--mg-radius-lg) 0 0 var(--mg-radius-lg);
  z-index: 1;
  pointer-events: none;
}
.project-todo-list-page .project-stage-column__stripe--right {
  left: auto;
  right: 0;
  border-radius: 0 var(--mg-radius-lg) var(--mg-radius-lg) 0;
}
.project-todo-list-page .project-stage-todos__stripe {
  display: block;
  flex-shrink: 0;
  width: 100%;
  height: 5px;
  pointer-events: none;
}
.project-todo-list-page .stage-body {
  display: flex;
  flex-direction: column;
}
.project-todo-list-page .stagehead {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem 0.85rem 1.15rem;
  border-bottom: 1px solid var(--mg-border);
  background: #f8fafc;
  z-index: 2;
}
.project-todo-list-page .stageheader {
  flex: 1 1 auto;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mg-text);
  min-width: 0;
}
.project-todo-list-page .stageboss {
  padding: 0.15rem 0.35rem;
  border-radius: var(--mg-radius-sm);
  outline: none;
}
.project-todo-list-page .stageboss:hover {
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--mg-border-strong);
  cursor: text;
}
.project-todo-list-page .pullup,
.project-todo-list-page .pulldown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-sm);
  background: var(--mg-surface);
  cursor: pointer;
  transition: background-color var(--mg-transition);
}
.project-todo-list-page .pullup:hover,
.project-todo-list-page .pulldown:hover {
  background: var(--mg-primary-soft);
}
.project-todo-list-page .dragger {
  position: static;
  opacity: 0.45;
  margin-left: auto;
}
.project-todo-list-page .todolist,
.project-todo-list-page .done-list {
  padding: 0.75rem 1rem 0.75rem 1.15rem;
  min-height: 48px;
}
.project-todo-list-page .done-list {
  border-top: 1px dashed var(--mg-border);
  background: #fafafa;
}
.project-todo-list-page .todonew {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem 1rem 1.15rem;
  border-top: 1px solid var(--mg-border);
  background: #f8fafc;
}
.project-todo-list-page .todonew .form-control {
  flex: 1 1 200px;
  min-width: 140px;
  max-width: none;
  width: auto !important;
}
.project-todo-list-page .todonew .btn {
  flex: 0 0 auto;
  width: auto !important;
  font-size: 0.8125rem;
}
.project-todo-list-page .todo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  max-height: none;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
  box-shadow: var(--mg-shadow-sm);
  cursor: pointer;
  transition: border-color var(--mg-transition), box-shadow var(--mg-transition), background-color var(--mg-transition);
}
.project-todo-list-page .todo:hover {
  border-color: #6ee7b7;
  background: #f0fdf4;
  box-shadow: var(--mg-shadow);
}
.project-todo-list-page .todo.done {
  background: #ecfdf5;
  border-color: #a7f3d0;
  opacity: 0.92;
}
.project-todo-list-page .todo .checkbox {
  flex: 0 0 auto;
}
.project-todo-list-page .todo .todotodo {
  font-size: 0.875rem;
  font-weight: 500;
  width: 65%;
}
.project-todo-list-page .todo .pr {
  flex: 0 0 auto;
}
.project-todo-list-page .todo .btn {
  width: auto !important;
  max-width: 100%;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}
.project-todo-list-page .loadmore {
  display: block;
  width: 100%;
  padding: 0.5rem;
  margin-top: 0.5rem;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, #0d9488 0%, #0f766e 100%);
  border: none;
  border-radius: var(--mg-radius-sm);
  cursor: pointer;
  transition: opacity var(--mg-transition);
}
.project-todo-list-page .loadmore:hover {
  opacity: 0.92;
  background: linear-gradient(180deg, #14b8a6 0%, #0d9488 100%);
}
.project-todo-list-page .placeholder {
  margin: 0;
  padding: 0.75rem;
  height: auto;
  min-height: 120px;
  border: 1px dashed var(--mg-border);
  border-radius: var(--mg-radius-sm);
  background: #f8fafc;
}
.project-todo-list-page .placeholder .line,
.project-todo-list-page .placeholder .fatline,
.project-todo-list-page .placeholder .checkbox,
.project-todo-list-page .placeholder .title {
  background: #e2e8f0;
  border-radius: var(--mg-radius-sm);
}
.project-todo-list-page .placeholder.pulse div {
  animation: crm-pulse 1s infinite ease-in-out;
}
.todo-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.todo-drawer-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
}
.todo-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(32rem, 100vw);
  height: 100vh;
  z-index: 1050;
  background: var(--mg-surface);
  box-shadow: -8px 0 40px rgba(15, 23, 42, 0.15);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow-x: hidden;
  overflow-y: auto;
}
.todo-drawer.is-open {
  transform: translateX(0);
}
.todo-drawer-panel {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 0;
}
.todo-drawer-panel__header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--mg-border);
  background: linear-gradient(180deg, #f8fafc 0%, var(--mg-surface) 100%);
  position: sticky;
  top: 0;
  z-index: 2;
}
.todo-drawer-panel__check {
  flex: 0 0 auto;
  padding-top: 0.35rem;
}
.todo-drawer-panel__title-wrap {
  flex: 1 1 auto;
  min-width: 0;
}
.todo-drawer-panel__title {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--mg-text);
  word-break: break-word;
}
.todo-drawer-panel__title[contenteditable="true"] {
  outline: none;
  box-shadow: inset 0 -2px 0 var(--mg-primary);
}
.todo-drawer-panel__hint {
  font-size: 0.7rem;
  color: var(--mg-text-muted);
  margin: 0.25rem 0 0;
}
.todo-drawer-panel__close {
  flex: 0 0 auto;
  margin-top: 0.15rem;
}
.todo-drawer-panel__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--mg-border);
  background: #f8fafc;
}
.todo-drawer-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.todo-drawer-panel__actions .btn {
  font-size: 0.8125rem;
}
.todo-drawer-panel__archive {
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0;
}
.todo-drawer-panel__archive:hover {
  text-decoration: underline;
}
.todo-drawer-panel__compose {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--mg-border);
}
.todo-drawer-panel__thread {
  padding: 1rem 1.25rem 2rem;
  flex: 1 1 auto;
}
.todo-drawer-panel__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mg-text-muted);
  margin-bottom: 0.65rem;
}
.todo-drawer-panel__compose .note-editor {
  border-radius: var(--mg-radius);
  border-color: var(--mg-border-strong);
}
.todo-drawer-panel__compose .note-toolbar {
  background: #f8fafc;
  border-bottom-color: var(--mg-border);
}
.todo-drawer-comment {
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
  background: #f8fafc;
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
}
.todo-drawer-comment__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.8125rem;
}
.todo-drawer-comment__meta strong {
  color: var(--mg-text);
}
.todo-drawer-comment__meta .timestamp {
  position: static;
  font-size: 0.7rem;
  color: var(--mg-text-muted);
}
.todo-drawer-comment__body {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--mg-text);
  word-break: break-word;
}
.todo-drawer-comment__body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--mg-radius-sm);
}
.project-todo-list-page #sesame .loggeddata {
  background: transparent;
  padding: 0;
}
.project-todo-list-page #todocommentsload {
  margin-top: 0;
  max-height: none;
  overflow: visible;
  border-top: none;
  padding-top: 0;
}
.project-todo-list-page #sesame .comment {
  border-top: none;
  padding: 0;
}
.project-todo-list-page .dropdown-aside,
.project-todo-list-page .dropdown-calendar,
.todo-drawer .dropdown-aside,
.todo-drawer .dropdown-calendar {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: auto;
  transform: translateX(-0.75rem);
  min-width: 270px;
  max-width: min(400px, calc(100vw - 2rem));
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
  padding: 0.65rem 0.75rem;
  z-index: 1100;
  box-shadow: var(--mg-shadow-lg);
  max-height: 320px;
  overflow-y: auto;
}
.project-todo-list-page .dropdown-aside .form-control,
.todo-drawer .dropdown-aside .form-control {
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}
.project-todo-list-page .dropdown-aside .checkcity,
.todo-drawer .dropdown-aside .checkcity {
  max-height: 220px;
  overflow-y: auto;
}
.project-todo-list-page .dropdown-aside .checkarea,
.todo-drawer .dropdown-aside .checkarea {
  display: block;
  padding: 0.4rem 0.35rem;
  margin: 0;
  border-radius: var(--mg-radius-sm);
  transition: background-color var(--mg-transition);
}
.project-todo-list-page .dropdown-aside .checkarea:hover,
.todo-drawer .dropdown-aside .checkarea:hover {
  background: var(--mg-primary-soft);
}
.project-todo-list-page .dropdown-aside .checkarea label,
.todo-drawer .dropdown-aside .checkarea label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  word-break: break-word;
}
.project-todo-list-page .todo .pr,
.todo-drawer-panel__actions .pr {
  position: relative;
}
.project-todo-list-page .closebox {
  width: 100%;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  background: var(--mg-text-muted);
  border-radius: var(--mg-radius-sm);
  padding: 0.35rem;
  cursor: pointer;
  margin-top: 0.35rem;
}
.project-todo-list-page .closebox:hover {
  background: var(--mg-text);
}
.project-todo-list-page #todocommentsload {
  margin-top: 1rem;
  max-height: 850px;
  overflow-y: auto;
  border-top: 1px solid var(--mg-border);
  padding-top: 1rem;
}
.project-todo-list-page .comment {
  border-top: 1px solid var(--mg-border);
  padding: 1rem 0;
}
.project-todo-list-page .timestamp {
  position: absolute;
  right: 0.5rem;
  bottom: 0.35rem;
  font-size: 0.7rem;
  color: var(--mg-text-muted);
}
.project-todo-list-page .disb {
  color: #fff;
  background-color: #94a3b8;
  border-color: #94a3b8;
}

/* Profile dropdown trigger */
#profileDropdown.dropdown-toggle {
  border-radius: 0 var(--mg-radius-sm) var(--mg-radius-sm) 0;
  transition: background-color var(--mg-transition);
}
#profileDropdown.dropdown-toggle:hover {
  background-color: #334155 !important;
}

/* Asset Management (/storages) */
.storage-page {
  padding: 0.25rem 0 2rem;
  width: 100%;
}
.storage-main { min-width: 0; }
.storage-sidebar { min-width: 0; }

.storage-breadcrumb {
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
  box-shadow: var(--mg-shadow-sm);
}
.storage-breadcrumb__track {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  font-size: 0.875rem;
}
.storage-breadcrumb__link {
  color: var(--mg-text-muted);
  text-decoration: none;
  font-weight: 500;
  padding: 0.2rem 0.35rem;
  border-radius: var(--mg-radius-sm);
  transition: color var(--mg-transition), background-color var(--mg-transition);
}
.storage-breadcrumb__link:hover {
  color: var(--mg-primary);
  background: var(--mg-primary-soft);
  text-decoration: none;
}
.storage-breadcrumb__link--root {
  color: var(--mg-text);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.storage-breadcrumb__sep {
  color: var(--mg-border-strong);
  user-select: none;
  font-weight: 300;
  line-height: 1;
}
.storage-breadcrumb__new {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.25rem;
  flex: 1 1 200px;
  min-width: 180px;
  max-width: 320px;
}
.storage-breadcrumb__folder-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: #d97706;
}
.storage-breadcrumb__folder-icon img,
.storage-breadcrumb__folder-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.storage-breadcrumb__new .form-control {
  border: 1px dashed var(--mg-border-strong);
  background: #f8fafc;
  font-size: 0.875rem;
  padding: 0.35rem 0.65rem;
}
.storage-breadcrumb__new .form-control:focus {
  border-style: solid;
  background: var(--mg-surface);
}

.storage-root-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 0.35rem);
  z-index: 100;
  min-width: 200px;
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
  box-shadow: var(--mg-shadow-lg);
  overflow: hidden;
}
.storage-root-menu a {
  display: block;
  padding: 0.55rem 1rem;
  color: var(--mg-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--mg-border);
  transition: background-color var(--mg-transition), color var(--mg-transition);
}
.storage-root-menu a:last-child { border-bottom: none; }
.storage-root-menu a:hover {
  background: var(--mg-primary-soft);
  color: var(--mg-primary);
  text-decoration: none;
}

.storage-folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--mg-border);
}
.storage-folder-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1rem 0.75rem 0.85rem;
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
  text-decoration: none;
  color: var(--mg-text);
  transition: border-color var(--mg-transition), box-shadow var(--mg-transition), transform var(--mg-transition);
}
.storage-folder-card:hover {
  border-color: #fcd34d;
  box-shadow: var(--mg-shadow);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--mg-text);
}
.storage-folder-card__icon {
  width: 56px;
  height: 48px;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  color: #f59e0b;
  filter: drop-shadow(0 2px 4px rgba(245, 158, 11, 0.25));
}
.storage-folder-card__icon img,
.storage-folder-card__icon svg {
  width: 48px;
  height: 42px;
}
.storage-folder-card__name {
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.3;
  word-break: break-word;
  max-width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.storage-upload-panel {
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-lg);
  padding: 1.25rem;
  box-shadow: var(--mg-shadow-sm);
  position: sticky;
  top: 1rem;
}
.storage-upload-panel__title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mg-text-muted);
  margin-bottom: 0.75rem;
}
.storage-upload-panel .form-group label {
  font-size: 0.875rem;
  color: var(--mg-text-muted);
}
.storage-upload-panel .form-group label mark {
  background: none;
  color: var(--mg-text);
  font-weight: 500;
  padding: 0;
}
.storage-upload-panel #dbi-file-upload-submit {
  width: 100%;
  margin-top: 0.5rem;
  font-weight: 600;
}

.storage-files-heading {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mg-text-muted);
  margin: 1.25rem 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--mg-border);
}
.storage-files-heading:first-child { margin-top: 0; }

.storage-file-card {
  height: 100%;
}
.storage-file-card .fileblock {
  border-radius: var(--mg-radius);
  overflow: hidden;
  border: 1px solid var(--mg-border);
  padding: 0;
  background: #f8fafc;
  transition: border-color var(--mg-transition), box-shadow var(--mg-transition);
}
.storage-file-card .fileblock:hover {
  border-color: var(--mg-primary);
  box-shadow: var(--mg-shadow);
  background: var(--mg-surface);
  cursor: pointer;
}
.storage-file-card .fileblock img {
  display: block;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.storage-file-card__meta {
  padding: 0.5rem 0 0.35rem;
  position: relative;
}
.storage-file-card__name {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--mg-text);
  line-height: 1.35;
  margin-bottom: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.storage-file-card__date {
  font-size: 0.7rem;
  color: var(--mg-text-muted);
}
.storage-file-card__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--mg-border);
}
.storage-file-card__actions .pvtfile {
  font-size: 0.75rem;
  color: var(--mg-text-muted);
  margin: 0;
  cursor: pointer;
}
.storage-file-card__action {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--mg-text-muted);
  padding: 0.2rem 0.45rem;
  border-radius: var(--mg-radius-sm);
  cursor: pointer;
  transition: background-color var(--mg-transition), color var(--mg-transition);
  text-decoration: none;
  border: none;
  background: transparent;
}
.storage-file-card__action:hover {
  background: var(--mg-primary-soft);
  color: var(--mg-primary);
}
.storage-file-card__action--danger:hover {
  background: #fef2f2;
  color: var(--mg-danger);
}
.storage-file-card__action img {
  width: 14px;
  height: 14px;
  opacity: 0.75;
}

.storage-page .filename {
  position: relative;
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-sm);
  margin: 4px 4px 4px 0;
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  background: var(--mg-surface);
}
.storage-page .removefromlist {
  color: var(--mg-danger);
  cursor: pointer;
  display: inline-block;
  font-weight: 600;
  margin-right: 6px;
  padding: 0 4px;
  border-right: 1px solid var(--mg-border);
  background: transparent;
}
.storage-page #filelist {
  max-height: 150px;
  overflow-y: auto;
  display: block;
  position: relative;
}
.storage-page .loadmore {
  display: inline-block;
  margin: 1rem auto;
  font-weight: 500;
  border-radius: var(--mg-radius);
}
.storage-page .disb {
  color: #fff;
  background-color: #94a3b8;
  border-color: #94a3b8;
}

/* CRM module — Contacts, Companies, Messages, Deals */
.crm-page {
  padding: 0.25rem 0 2rem;
  width: 100%;
}
.crm-page a:not(.btn):not(.crm-nav__item):not(.stretched-link):not(.page-link) {
  text-decoration: none;
}
.crm-main { min-width: 0; }
.crm-sidebar { min-width: 0; }
.crm-sidebar .box {
  position: sticky;
  top: 1rem;
  margin-bottom: 0;
}
.crm-sidebar .box > h5,
.crm-panel__title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mg-text-muted);
  margin-bottom: 1rem;
}

.crm-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  padding: 0.35rem;
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-lg);
  box-shadow: var(--mg-shadow-sm);
}
.crm-nav__item {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--mg-text-muted);
  text-decoration: none;
  border-radius: var(--mg-radius);
  transition: color var(--mg-transition), background-color var(--mg-transition), box-shadow var(--mg-transition);
}
.crm-nav__item:hover {
  color: var(--mg-accent-dark);
  background: #f5f3ff;
  text-decoration: none;
}
.crm-nav__item--active {
  color: #fff;
  background: linear-gradient(180deg, #7c3aed 0%, #5b21b6 100%);
  box-shadow: var(--mg-shadow-sm);
}
.crm-nav__item--active:hover {
  color: #fff;
  background: linear-gradient(180deg, #8b5cf6 0%, #6d28d9 100%);
}

.crm-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1rem;
}
.crm-toolbar .form-control,
.crm-toolbar .form-select {
  flex: 1 1 140px;
  min-width: 120px;
  font-size: 0.875rem;
}
.crm-toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-left: auto;
  font-size: 0.8125rem;
}
.crm-toolbar__actions .link-primary,
.crm-toolbar__actions .link-success {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 500;
  cursor: pointer;
}

.crm-table-wrap {
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
  overflow: hidden;
  background: var(--mg-surface);
  box-shadow: var(--mg-shadow-sm);
  margin-bottom: 1rem;
}
.crm-page .crm-table {
  table-layout: fixed;
  word-wrap: break-word;
  margin-bottom: 0;
}
.crm-page .crm-table thead {
  background: linear-gradient(180deg, #5b21b6 0%, #4c1d95 100%);
}
.crm-page .crm-table thead th {
  color: #fff;
  border-bottom: none;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.crm-page .crm-table thead th a {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}
.crm-page .crm-table thead th a:hover {
  color: #ede9fe;
  text-decoration: none;
}
.crm-page .crm-table tbody td {
  padding: 0.65rem 1rem;
  vertical-align: middle;
  border-color: var(--mg-border);
}
.crm-page .crm-table tbody tr {
  transition: background-color var(--mg-transition);
}
.crm-page .crm-table tbody tr:hover {
  background-color: #f8fafc;
}
.crm-page .crm-table .avatar {
  width: 36px;
  height: 36px;
  border: 2px solid var(--mg-border);
}
.crm-page .crm-table__name {
  font-weight: 500;
  color: var(--mg-text);
}
.crm-page .crm-table__meta {
  font-size: 0.8125rem;
  color: var(--mg-text-muted);
}
.crm-page .crm-table__subject {
  font-weight: 500;
  color: var(--mg-text);
}
.crm-page .crm-table__date {
  font-size: 0.8125rem;
  color: var(--mg-text-muted);
  white-space: nowrap;
}

.crm-pagination {
  margin-top: 0.5rem;
}
.crm-pagination .pagination {
  gap: 0.25rem;
}
.crm-pagination .page-link {
  border-radius: var(--mg-radius-sm);
  color: var(--mg-text);
  border-color: var(--mg-border);
}
.crm-pagination .page-item.active .page-link {
  background: var(--mg-accent);
  border-color: var(--mg-accent);
}

.crm-page .tag {
  display: inline-block;
  background: var(--mg-primary-soft);
  border: 1px solid #bfdbfe;
  border-radius: var(--mg-radius-sm);
  padding: 0.15rem 0.5rem;
  margin: 0.15rem 0.25rem 0.15rem 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--mg-text);
}
.crm-page .ct {
  font-style: normal;
  padding: 0 0.35rem;
  margin-left: 0.35rem;
  border-left: 1px solid var(--mg-border-strong);
  cursor: pointer;
  background: var(--mg-primary);
  color: #fff;
  border-radius: 0 var(--mg-radius-sm) var(--mg-radius-sm) 0;
  transition: background-color var(--mg-transition);
}
.crm-page .ct:hover {
  background: var(--mg-danger);
}

.crm-filter-tags {
  padding: 0.75rem 0;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--mg-border);
}
.crm-filter-tags p {
  font-size: 0.875rem;
  color: var(--mg-text-muted);
  margin-bottom: 0.35rem;
}

.crm-messages-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.crm-messages-toolbar .form-control {
  flex: 1 1 200px;
}
.crm-messages-aside {
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-lg);
  padding: 1rem;
  box-shadow: var(--mg-shadow-sm);
}
.crm-messages-aside label {
  font-size: 0.875rem;
  color: var(--mg-text-muted);
}
.crm-page #mcalendar {
  border-radius: var(--mg-radius);
  overflow: hidden;
}
.crm-page #loadmoremessages {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  font-weight: 500;
  color: var(--mg-primary);
  cursor: pointer;
  border-radius: var(--mg-radius);
  transition: background-color var(--mg-transition);
}
.crm-page #loadmoremessages:hover {
  background: var(--mg-primary-soft);
  text-decoration: none;
}
.crm-page .placeholder {
  margin: 15px;
  padding: 10px;
  height: 185px;
  border-radius: var(--mg-radius);
  border: 1px solid var(--mg-border);
  background: #f8fafc;
}
.crm-page .placeholder .line {
  height: 25px;
  margin: 10px 0 10px 10px;
  border-radius: var(--mg-radius-sm);
}
.crm-page .placeholder.pulse div {
  animation: crm-pulse 1s infinite ease-in-out;
}
@keyframes crm-pulse {
  0% { background-color: rgba(148, 163, 184, 0.15); }
  50% { background-color: rgba(148, 163, 184, 0.35); }
  100% { background-color: rgba(148, 163, 184, 0.15); }
}
.crm-page #shantadi {
  font-size: 0.875rem;
  color: var(--mg-text-muted);
}
.crm-page #shantadi a {
  font-weight: 500;
  color: var(--mg-primary);
}

.crm-deals-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}
.crm-deals-toolbar .form-select {
  max-width: 220px;
  font-size: 0.875rem;
}
.crm-deals-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.crm-deal-card {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem 1rem;
  padding: 1rem 1.25rem;
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
  box-shadow: var(--mg-shadow-sm);
  transition: border-color var(--mg-transition), box-shadow var(--mg-transition);
  position: relative;
}
.crm-deal-card:hover {
  border-color: #c4b5fd;
  box-shadow: var(--mg-shadow);
  cursor: pointer;
}
.crm-deal-card.pending { border-left: 4px solid #eab308; background: #fffbeb; }
.crm-deal-card.won { border-left: 4px solid var(--mg-success); background: #ecfdf5; }
.crm-deal-card.lost { border-left: 4px solid var(--mg-text-muted); background: #f8fafc; }
.crm-deal-card.follow-up { border-left: 4px solid var(--mg-accent); background: #f5f3ff; }
.crm-deal-card__price {
  flex: 0 0 100px;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--mg-text);
}
.crm-deal-card__body {
  flex: 1 1 200px;
  min-width: 0;
}
.crm-deal-card__body h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.crm-deal-card__status {
  flex: 0 0 auto;
  margin-left: auto;
  text-align: right;
}
.crm-deal-card .contactlink {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  margin-bottom: 0.5rem;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: var(--mg-radius-sm);
  font-size: 0.8125rem;
  position: relative;
}
.crm-deal-card .contactlink a {
  color: var(--mg-text);
  font-weight: 500;
}
.crm-deal-card .one5px {
  font-size: 0.75rem;
  color: var(--mg-primary);
  cursor: pointer;
}
.crm-deal-card .text-purple { color: var(--mg-accent-dark); }

.crm-modal-header {
  background: linear-gradient(180deg, #5b21b6 0%, #4c1d95 100%) !important;
  color: #fff;
}
.crm-modal-header .btn-close {
  filter: invert(1);
}

.crm-page .select2-container .select2-selection--single {
  height: 38px !important;
  border-color: var(--mg-border-strong) !important;
  border-radius: var(--mg-radius-sm) !important;
}
.crm-page .select2-container--default .select2-selection--single .select2-selection__arrow {
  top: 6px !important;
}
.crm-page .select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 37px !important;
  color: var(--mg-text-muted) !important;
}
.crm-page #printcontactlist { cursor: pointer; }
.crm-page .edt,
.crm-page .del { cursor: pointer; }

/* Contact detail (/view-contact) */
.contact-detail-page {
  padding: 0.25rem 0 2rem;
  width: 100%;
}
.contact-detail-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem 1.5rem;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-lg);
  box-shadow: var(--mg-shadow-sm);
}
.contact-detail-header__avatar {
  flex: 0 0 auto;
}
.contact-detail-header__avatar .avatar-large {
  width: 80px;
  height: 80px;
  border: 3px solid var(--mg-border);
}
.contact-detail-header__main {
  flex: 1 1 280px;
  min-width: 0;
}
.contact-detail-header__name {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}
.contact-detail-header__subtitle {
  font-size: 0.9375rem;
  color: var(--mg-text-muted);
  margin-bottom: 0.75rem;
}
.contact-detail-header__subtitle .contact-detail-manage-btn {
  vertical-align: middle;
  margin-left: 0.35rem;
}
.contact-detail-header__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.contact-detail-header__tags .tag {
  margin-left: 0;
  line-height: 1.5;
}
.contact-detail-header__contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  font-size: 0.875rem;
}
.contact-detail-header__contact-col {
  flex: 1 1 200px;
  min-width: 0;
  position: relative;
  padding-left: 2rem;
}
.contact-detail-header__contact-col .contact-detail-manage-btn {
  position: absolute;
  left: 0;
  top: 0;
}
.contact-detail-header__contact-item {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
  color: var(--mg-text);
}
.contact-detail-header__contact-item img {
  width: 16px;
  height: 16px;
  opacity: 0.65;
  margin-top: 0.15rem;
}
.contact-detail-header__social {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-top: 0.5rem;
}
.contact-detail-header__social a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  padding: 0.2rem 0.5rem;
  border-radius: var(--mg-radius-sm);
  transition: background-color var(--mg-transition);
}
.contact-detail-header__social a:hover {
  background: var(--mg-primary-soft);
}
.contact-detail-header__tag-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.contact-detail-header__tag-tools #tagselector {
  flex: 1 1 160px;
  max-width: 280px;
  width: auto;
}
.contact-detail-header__actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 200px;
}
.contact-detail-header__actions .btn {
  font-weight: 600;
  white-space: nowrap;
}
.contact-detail-header__meta {
  font-size: 0.8125rem;
  color: var(--mg-text-muted);
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.contact-detail-manage-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--mg-border-strong);
  border-radius: var(--mg-radius-sm);
  background: #f8fafc;
  cursor: pointer;
  transition: background-color var(--mg-transition), border-color var(--mg-transition), box-shadow var(--mg-transition);
}
.contact-detail-manage-btn:hover {
  background: var(--mg-primary-soft);
  border-color: var(--mg-primary);
  box-shadow: var(--mg-shadow-sm);
}
.contact-detail-manage-btn img {
  width: 16px;
  height: 16px;
}

.contact-detail-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  padding: 0.35rem;
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-lg);
  box-shadow: var(--mg-shadow-sm);
}
.contact-detail-tab {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  padding: 0.6rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--mg-text-muted);
  cursor: pointer;
  user-select: none;
  border-radius: var(--mg-radius);
  transition: color var(--mg-transition), background-color var(--mg-transition), box-shadow var(--mg-transition);
}
.contact-detail-tab:hover {
  color: var(--mg-accent-dark);
  background: #f5f3ff;
}
.contact-detail-tab.active {
  color: #fff;
  background: linear-gradient(180deg, #7c3aed 0%, #5b21b6 100%);
  box-shadow: var(--mg-shadow-sm);
}
.contact-detail-tab--wide {
  flex: 1.4 1 auto;
}

.contact-detail-work {
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
  padding: 1rem;
  min-height: 280px;
  box-shadow: var(--mg-shadow-sm);
}
.contact-detail-work #loadmessages,
.contact-detail-work #loaddeals,
.contact-detail-work #loadcases,
.contact-detail-work #loadnotes {
  background: #f8fafc;
  border-radius: var(--mg-radius-sm);
  padding: 0.5rem;
  margin-top: 0.75rem;
}
.contact-detail-work .placeholder {
  margin: 0;
  border: 1px dashed var(--mg-border);
  background: #f8fafc;
}
.contact-detail-work .placeholder .line,
.contact-detail-work .placeholder .fatline {
  background: #e2e8f0;
  border-radius: var(--mg-radius-sm);
}
.contact-detail-work .placeholder.pulse div {
  animation: crm-pulse 1s infinite ease-in-out;
}

.contact-message-item {
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color var(--mg-transition), box-shadow var(--mg-transition);
}
.contact-message-item:hover {
  border-color: #c4b5fd;
  box-shadow: var(--mg-shadow-sm);
}
.contact-message-item .subject {
  font-weight: 500;
  color: var(--mg-text);
  padding-right: 6rem;
}
.contact-message-item small {
  position: absolute;
  right: 0.75rem;
  bottom: 0.65rem;
  color: var(--mg-text-muted);
  font-size: 0.7rem;
}
.contact-message-item .hl {
  background: #fef08a;
  padding: 0 0.1em;
  border-radius: 2px;
}
.contact-detail-work #loadmoremessages {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-weight: 500;
  color: var(--mg-primary);
  cursor: pointer;
  border-radius: var(--mg-radius);
}
.contact-detail-work #loadmoremessages:hover {
  background: var(--mg-primary-soft);
}

.contact-detail-aside {
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-lg);
  padding: 1.25rem;
  box-shadow: var(--mg-shadow-sm);
}
.contact-detail-aside__section {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--mg-border);
}
.contact-detail-aside__section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.contact-detail-aside__heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mg-text-muted);
  margin-bottom: 0.5rem;
}
.contact-detail-aside address,
.contact-detail-aside p {
  font-size: 0.875rem;
  color: var(--mg-text);
  margin-bottom: 0.35rem;
}
.contact-detail-aside .setprim {
  cursor: pointer;
  color: var(--mg-primary);
  font-style: normal;
}
.contact-detail-aside .setprim:hover {
  text-decoration: underline;
}
.contact-detail-field {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-sm);
}
.contact-detail-merge {
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px solid #fecaca;
  border-radius: var(--mg-radius);
  background: #fffbeb;
}
.contact-detail-merge .alert {
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}
#contactpopulation {
  box-shadow: var(--mg-shadow-lg);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
  background: var(--mg-surface);
  z-index: 10;
  max-height: 240px;
  overflow-y: auto;
}
.contactpill {
  cursor: pointer;
  background: var(--mg-surface);
  border-bottom: 1px solid var(--mg-border);
  transition: background-color var(--mg-transition);
}
.contactpill:hover {
  background: var(--mg-primary-soft);
}
.contactpill p { margin-bottom: 0; }
.contact-detail-page .tag {
  background: var(--mg-primary-soft);
  border: 1px solid #bfdbfe;
}
.contact-detail-page .ct {
  background: var(--mg-primary);
}
.contact-detail-page .ct:hover {
  background: var(--mg-danger);
}
.contact-detail-page #adddeal {
  padding: 1rem;
  margin-bottom: 1rem;
  background: #f8fafc;
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
}
.contact-detail-page .fileblock {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-sm);
  margin-bottom: 0.5rem;
  background: var(--mg-surface);
  transition: border-color var(--mg-transition), background-color var(--mg-transition);
}
.contact-detail-page .fileblock:hover {
  border-color: var(--mg-primary);
  background: var(--mg-primary-soft);
}
.contact-detail-page .select2-container .select2-selection--single {
  height: 38px !important;
  border-color: var(--mg-border-strong) !important;
  border-radius: var(--mg-radius-sm) !important;
}
.contact-detail-page .select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 36px !important;
  color: var(--mg-text-muted) !important;
}
.contact-detail-page .select2-container--default .select2-selection--single .select2-selection__arrow {
  top: 6px !important;
}
.contact-note-card {
  padding: 0.85rem 1rem;
  margin-top: 0.5rem;
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
  box-shadow: var(--mg-shadow-sm);
}
.contact-note-card .mnotebody {
  font-size: 0.9375rem;
  line-height: 1.5;
  margin: 0.5rem 0;
}
.contact-note-card .one5px {
  height: 14px;
  width: auto;
}

/* Message view (/view-message) */
.message-view-page {
  padding: 0.5rem 0 2rem;
  max-width: 900px;
  margin: 0 auto;
}
.message-view-card {
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-lg);
  box-shadow: var(--mg-shadow);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.message-view-card__header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--mg-border);
  background: linear-gradient(180deg, #fafafa 0%, var(--mg-surface) 100%);
}
.message-view-card__contact {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.message-view-card__contact .avatar-large {
  width: 56px;
  height: 56px;
  border: 2px solid var(--mg-border);
}
.message-view-card__contact-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--mg-text);
  text-decoration: none;
}
.message-view-card__contact-name:hover {
  color: var(--mg-primary);
}
.message-view-card__email {
  font-size: 0.875rem;
  color: var(--mg-text-muted);
}
.message-view-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--mg-text-muted);
}
.message-view-card__subject {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 1rem 1.5rem 0;
  color: var(--mg-text);
  letter-spacing: -0.01em;
}
.message-view-card__body {
  padding: 1.25rem 1.5rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--mg-text);
  border-top: 1px solid var(--mg-border);
  word-break: break-word;
}
.message-view-card__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--mg-border);
  background: #f8fafc;
}
.message-view-attachments__title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mg-text-muted);
  margin-bottom: 0.5rem;
}
.message-view-attachment {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.5rem;
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-sm);
  font-size: 0.875rem;
  transition: border-color var(--mg-transition), background-color var(--mg-transition);
}
.message-view-attachment:hover {
  border-color: var(--mg-primary);
  background: var(--mg-primary-soft);
}
.message-view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}
.message-view-actions__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--mg-text);
  background: var(--mg-surface);
  border: 1px solid var(--mg-border-strong);
  border-radius: var(--mg-radius-sm);
  cursor: pointer;
  transition: background-color var(--mg-transition), border-color var(--mg-transition), color var(--mg-transition);
}
.message-view-actions__btn:hover {
  background: var(--mg-primary-soft);
  border-color: var(--mg-primary);
  color: var(--mg-primary);
}
.message-view-delete {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #fff;
  background: var(--mg-danger);
  border: none;
  border-radius: var(--mg-radius-sm);
  cursor: pointer;
  transition: opacity var(--mg-transition);
}
.message-view-delete:hover {
  opacity: 0.9;
}
.message-view-page #actionarea {
  background: var(--mg-surface);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius-lg);
  padding: 1.25rem;
  box-shadow: var(--mg-shadow-sm);
}
.message-view-page .downloadlink {
  cursor: pointer;
}
